From afd682cdf268c7a057e3831316a9e032b01a140a Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 20 Jul 2021 02:18:43 +0200 Subject: [PATCH 1/2] Make new style instantiation of SD's for many forward detectors --- SimG4CMS/Forward/interface/BHMSD.h | 1 - SimG4CMS/Forward/interface/Bcm1fSD.h | 1 - SimG4CMS/Forward/interface/BscSD.h | 6 +- SimG4CMS/Forward/interface/BscTest.h | 3 - SimG4CMS/Forward/interface/MtdSD.h | 1 - SimG4CMS/Forward/interface/PltSD.h | 1 - SimG4CMS/Forward/interface/TotemT2ScintSD.h | 1 - .../plugins/BCM1FSensitiveDetectorBuilder.cc | 34 +++++ .../plugins/BHMSensitiveDetectorBuilder.cc | 34 +++++ .../plugins/BSCSensitiveDetectorBuilder.cc | 34 +++++ .../plugins/MtdSensitiveDetectorBuilder.cc | 34 +++++ .../plugins/PLTSensitiveDetectorBuilder.cc | 35 +++++ .../TotemT2ScintSensitiveDetectorBuilder.cc | 34 +++++ SimG4CMS/Forward/plugins/module.cc | 21 --- SimG4CMS/Forward/src/BHMSD.cc | 6 +- SimG4CMS/Forward/src/Bcm1fSD.cc | 4 - SimG4CMS/Forward/src/BscSD.cc | 6 +- SimG4CMS/Forward/src/CastorNumberingScheme.cc | 10 +- SimG4CMS/Forward/src/CastorShowerLibrary.cc | 12 +- SimG4CMS/Forward/src/CastorTestAnalysis.cc | 120 ++++++++++-------- SimG4CMS/Forward/src/DoCastorAnalysis.cc | 75 ++++++----- SimG4CMS/Forward/src/MtdSD.cc | 13 +- SimG4CMS/Forward/src/PltSD.cc | 21 +-- SimG4CMS/Forward/src/TimingSD.cc | 25 ++-- SimG4CMS/Forward/src/TotemSD.cc | 2 - SimG4CMS/Forward/src/TotemT2ScintSD.cc | 3 +- SimG4CMS/Forward/src/ZdcSD.cc | 1 - 27 files changed, 352 insertions(+), 186 deletions(-) create mode 100644 SimG4CMS/Forward/plugins/BCM1FSensitiveDetectorBuilder.cc create mode 100644 SimG4CMS/Forward/plugins/BHMSensitiveDetectorBuilder.cc create mode 100644 SimG4CMS/Forward/plugins/BSCSensitiveDetectorBuilder.cc create mode 100644 SimG4CMS/Forward/plugins/MtdSensitiveDetectorBuilder.cc create mode 100644 SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc create mode 100644 SimG4CMS/Forward/plugins/TotemT2ScintSensitiveDetectorBuilder.cc diff --git a/SimG4CMS/Forward/interface/BHMSD.h b/SimG4CMS/Forward/interface/BHMSD.h index 80f0943c19a79..9339aba28cabe 100644 --- a/SimG4CMS/Forward/interface/BHMSD.h +++ b/SimG4CMS/Forward/interface/BHMSD.h @@ -16,7 +16,6 @@ class BHMNumberingScheme; class BHMSD : public TimingSD { public: BHMSD(const std::string &, - const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); diff --git a/SimG4CMS/Forward/interface/Bcm1fSD.h b/SimG4CMS/Forward/interface/Bcm1fSD.h index 4645ff72c19dc..338f78424f538 100644 --- a/SimG4CMS/Forward/interface/Bcm1fSD.h +++ b/SimG4CMS/Forward/interface/Bcm1fSD.h @@ -13,7 +13,6 @@ class G4Step; class Bcm1fSD : public TimingSD { public: Bcm1fSD(const std::string &, - const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); diff --git a/SimG4CMS/Forward/interface/BscSD.h b/SimG4CMS/Forward/interface/BscSD.h index 816dfb0ad3d8a..3ebf6e3856630 100644 --- a/SimG4CMS/Forward/interface/BscSD.h +++ b/SimG4CMS/Forward/interface/BscSD.h @@ -14,11 +14,7 @@ class BscNumberingScheme; class BscSD : public TimingSD { public: - BscSD(const std::string &, - const edm::EventSetup &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, - const SimTrackManager *); + BscSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); ~BscSD() override; diff --git a/SimG4CMS/Forward/interface/BscTest.h b/SimG4CMS/Forward/interface/BscTest.h index 308650f28a853..f03e010c77fa5 100644 --- a/SimG4CMS/Forward/interface/BscTest.h +++ b/SimG4CMS/Forward/interface/BscTest.h @@ -12,9 +12,6 @@ #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" -// necessary objects: -#include "FWCore/Framework/interface/ESHandle.h" - // // #include "SimG4Core/Notification/interface/Observer.h" diff --git a/SimG4CMS/Forward/interface/MtdSD.h b/SimG4CMS/Forward/interface/MtdSD.h index dedbad0987db9..59dc6be98c571 100644 --- a/SimG4CMS/Forward/interface/MtdSD.h +++ b/SimG4CMS/Forward/interface/MtdSD.h @@ -19,7 +19,6 @@ class SimTrackManager; class MtdSD : public TimingSD { public: MtdSD(const std::string &, - const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); diff --git a/SimG4CMS/Forward/interface/PltSD.h b/SimG4CMS/Forward/interface/PltSD.h index 11c0bbbfb65d7..ca2c155079ebf 100644 --- a/SimG4CMS/Forward/interface/PltSD.h +++ b/SimG4CMS/Forward/interface/PltSD.h @@ -13,7 +13,6 @@ class SimTrackManager; class PltSD : public TimingSD { public: PltSD(const std::string &, - const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); diff --git a/SimG4CMS/Forward/interface/TotemT2ScintSD.h b/SimG4CMS/Forward/interface/TotemT2ScintSD.h index 8c203c030c4d8..7755a5c821202 100644 --- a/SimG4CMS/Forward/interface/TotemT2ScintSD.h +++ b/SimG4CMS/Forward/interface/TotemT2ScintSD.h @@ -9,7 +9,6 @@ class TotemT2ScintSD : public CaloSD { public: TotemT2ScintSD(const std::string &, - const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); diff --git a/SimG4CMS/Forward/plugins/BCM1FSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/BCM1FSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..167ed4d7159da --- /dev/null +++ b/SimG4CMS/Forward/plugins/BCM1FSensitiveDetectorBuilder.cc @@ -0,0 +1,34 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/Bcm1fSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class BCM1FSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit BCM1FSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef Bcm1fSD BCM1FSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(BCM1FSensitiveDetectorBuilder, BCM1FSensitiveDetector); diff --git a/SimG4CMS/Forward/plugins/BHMSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/BHMSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..48c4cd4bdf979 --- /dev/null +++ b/SimG4CMS/Forward/plugins/BHMSensitiveDetectorBuilder.cc @@ -0,0 +1,34 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/BHMSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class BHMSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit BHMSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef BHMSD BHMSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(BHMSensitiveDetectorBuilder, BHMSensitiveDetector); diff --git a/SimG4CMS/Forward/plugins/BSCSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/BSCSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..74f4ce334c947 --- /dev/null +++ b/SimG4CMS/Forward/plugins/BSCSensitiveDetectorBuilder.cc @@ -0,0 +1,34 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/BscSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class BSCSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit BSCSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef BscSD BSCSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(BSCSensitiveDetectorBuilder, BSCSensitiveDetector); diff --git a/SimG4CMS/Forward/plugins/MtdSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/MtdSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..08ef70dfd0133 --- /dev/null +++ b/SimG4CMS/Forward/plugins/MtdSensitiveDetectorBuilder.cc @@ -0,0 +1,34 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/MtdSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class MtdSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit MtdSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef MtdSD MtdSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(MtdSensitiveDetectorBuilder, MtdSensitiveDetector); diff --git a/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..889bb99ab13ad --- /dev/null +++ b/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc @@ -0,0 +1,35 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/PltSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class PLTSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit PLTSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef PltSD PLTSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(PLTSensitiveDetectorBuilder, PLTSensitiveDetector); + diff --git a/SimG4CMS/Forward/plugins/TotemT2ScintSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/TotemT2ScintSensitiveDetectorBuilder.cc new file mode 100644 index 0000000000000..f43eb58af0729 --- /dev/null +++ b/SimG4CMS/Forward/plugins/TotemT2ScintSensitiveDetectorBuilder.cc @@ -0,0 +1,34 @@ +// system include files + +// user include files +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" +#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +#include "SimG4CMS/Forward/interface/TotemT2ScintSD.h" + +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class TotemT2ScintSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { +public: + explicit TotemT2ScintSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) {} + + void beginRun(const edm::EventSetup& es) final {} + + std::unique_ptr make(const std::string& iname, + const SensitiveDetectorCatalog& clg, + const edm::ParameterSet& p, + const SimTrackManager* man, + SimActivityRegistry& reg) const final { + auto sd = std::make_unique(iname, clg, p, man); + SimActivityRegistryEnroller::enroll(reg, sd.get()); + return sd; + } +}; + +typedef TotemT2ScintSD TotemT2ScintSensitiveDetector; +DEFINE_SENSITIVEDETECTORBUILDER(TotemT2ScintSensitiveDetectorBuilder, TotemT2ScintSensitiveDetector); diff --git a/SimG4CMS/Forward/plugins/module.cc b/SimG4CMS/Forward/plugins/module.cc index 08619c2e7e349..a4331dcdfbab3 100644 --- a/SimG4CMS/Forward/plugins/module.cc +++ b/SimG4CMS/Forward/plugins/module.cc @@ -2,33 +2,12 @@ #include "SimG4CMS/Forward/interface/CastorTestAnalysis.h" #include "SimG4CMS/Forward/interface/ZdcTestAnalysis.h" #include "SimG4CMS/Forward/interface/DoCastorAnalysis.h" -#include "SimG4CMS/Forward/interface/PltSD.h" -#include "SimG4CMS/Forward/interface/MtdSD.h" -#include "SimG4CMS/Forward/interface/TotemT2ScintSD.h" - #include "SimG4CMS/Forward/interface/BscTest.h" -#include "SimG4CMS/Forward/interface/BscSD.h" -#include "SimG4CMS/Forward/interface/BHMSD.h" -#include "SimG4CMS/Forward/interface/Bcm1fSD.h" - #include "SimG4CMS/Forward/plugins/SimG4FluxProducer.h" -#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" #include "SimG4Core/Watcher/interface/SimWatcherFactory.h" #include "FWCore/PluginManager/interface/ModuleDef.h" -typedef BscSD BSCSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(BSCSensitiveDetector); -typedef BHMSD BHMSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(BHMSensitiveDetector); -typedef MtdSD MtdSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(MtdSensitiveDetector); -typedef PltSD PLTSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(PLTSensitiveDetector); -typedef Bcm1fSD BCM1FSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(BCM1FSensitiveDetector); -typedef TotemT2ScintSD TotemT2ScintSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(TotemT2ScintSensitiveDetector); DEFINE_SIMWATCHER(CastorTestAnalysis); DEFINE_SIMWATCHER(ZdcTestAnalysis); DEFINE_SIMWATCHER(DoCastorAnalysis); diff --git a/SimG4CMS/Forward/src/BHMSD.cc b/SimG4CMS/Forward/src/BHMSD.cc index a3f4d1167544a..9054a6bc5006e 100644 --- a/SimG4CMS/Forward/src/BHMSD.cc +++ b/SimG4CMS/Forward/src/BHMSD.cc @@ -1,8 +1,6 @@ #include "SimG4CMS/Forward/interface/BHMSD.h" #include "SimG4CMS/Forward/interface/BHMNumberingScheme.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -10,10 +8,8 @@ #include -//#define debug //------------------------------------------------------------------- BHMSD::BHMSD(const std::string& name, - const edm::EventSetup& es, const SensitiveDetectorCatalog& clg, edm::ParameterSet const& p, const SimTrackManager* manager) @@ -25,7 +21,7 @@ BHMSD::BHMSD(const std::string& name, SetVerboseLevel(verbn); if (verbn > 0) { - edm::LogInfo("BHMSim") << "name = " << name << " and new BHMNumberingScheme"; + edm::LogVerbatim("BHMSim") << "name = " << name << " and new BHMNumberingScheme"; } numberingScheme = new BHMNumberingScheme(); } diff --git a/SimG4CMS/Forward/src/Bcm1fSD.cc b/SimG4CMS/Forward/src/Bcm1fSD.cc index 1e8d76d24a694..dec4c0fab0048 100644 --- a/SimG4CMS/Forward/src/Bcm1fSD.cc +++ b/SimG4CMS/Forward/src/Bcm1fSD.cc @@ -12,9 +12,6 @@ #include "SimG4Core/Notification/interface/TrackInformation.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -32,7 +29,6 @@ #include "CLHEP/Units/GlobalSystemOfUnits.h" Bcm1fSD::Bcm1fSD(const std::string& name, - const edm::EventSetup& es, const SensitiveDetectorCatalog& clg, edm::ParameterSet const& p, const SimTrackManager* manager) diff --git a/SimG4CMS/Forward/src/BscSD.cc b/SimG4CMS/Forward/src/BscSD.cc index 2ab2454f5392b..134cd63cbe050 100644 --- a/SimG4CMS/Forward/src/BscSD.cc +++ b/SimG4CMS/Forward/src/BscSD.cc @@ -10,8 +10,6 @@ #include "SimG4CMS/Forward/interface/BscG4HitCollection.h" #include "SimG4CMS/Forward/interface/BscNumberingScheme.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -19,10 +17,8 @@ #include -#define debug //------------------------------------------------------------------- BscSD::BscSD(const std::string& name, - const edm::EventSetup& es, const SensitiveDetectorCatalog& clg, edm::ParameterSet const& p, const SimTrackManager* manager) @@ -35,7 +31,7 @@ BscSD::BscSD(const std::string& name, if (name == "BSCHits") { if (verbn > 0) { - edm::LogInfo("BscSim") << "name = BSCHits and new BscNumberingSchem"; + edm::LogVerbatim("BscSim") << "name = BSCHits and new BscNumberingSchem"; } numberingScheme = new BscNumberingScheme(); } else { diff --git a/SimG4CMS/Forward/src/CastorNumberingScheme.cc b/SimG4CMS/Forward/src/CastorNumberingScheme.cc index 82b559ddd1944..f565556bfcf33 100644 --- a/SimG4CMS/Forward/src/CastorNumberingScheme.cc +++ b/SimG4CMS/Forward/src/CastorNumberingScheme.cc @@ -10,7 +10,7 @@ #include "G4LogicalVolumeStore.hh" #include -//#define castornumschemedebug +//#define EDM_ML_DEBUG CastorNumberingScheme::CastorNumberingScheme() : lvCASTFar(nullptr), @@ -62,7 +62,7 @@ CastorNumberingScheme::CastorNumberingScheme() if (strcmp(((*lvcite)->GetName()).c_str(), "C4HF") == 0) lvC4HF = (*lvcite); } -#ifdef castornumschemedebug +#ifdef EDM_ML_DEBUG edm::LogVerbatim("ForwardSim") << "Creating CastorNumberingScheme"; LogDebug("ForwardSim") << "CastorNumberingScheme:: LogicalVolume pointers\n" << lvCASTFar << " for CASTFar; " << lvCASTNear << " for CASTNear; " << lvCAST << " for CAST; " @@ -89,7 +89,7 @@ uint32_t CastorNumberingScheme::getUnitID(const G4Step* aStep) const { lvp lvs[20]; detectorLevel(aStep, level, copyno, lvs); -#ifdef castornumschemedebug +#ifdef EDM_ML_DEBUG LogDebug("ForwardSim") << "CastorNumberingScheme number of levels= " << level; #endif @@ -145,7 +145,7 @@ uint32_t CastorNumberingScheme::getUnitID(const G4Step* aStep) const { sector = sector * 2 - 1; } -#ifdef castornumschemedebug +#ifdef EDM_ML_DEBUG LogDebug("ForwardSim") << "CastorNumberingScheme " << "ich = " << ich << "copyno = " << copyno[ich] << "name = " << lvs[ich]->GetName(); #endif @@ -164,7 +164,7 @@ uint32_t CastorNumberingScheme::getUnitID(const G4Step* aStep) const { HcalCastorDetId castorId = HcalCastorDetId(true_for_positive_eta, sector, module); index = castorId.rawId(); -#ifdef castornumschemedebug +#ifdef EDM_ML_DEBUG uint32_t intindex = 0; intindex = packIndex(zside, sector, module); LogDebug("ForwardSim") << "CastorNumberingScheme: " diff --git a/SimG4CMS/Forward/src/CastorShowerLibrary.cc b/SimG4CMS/Forward/src/CastorShowerLibrary.cc index 27a6537f4b817..08d94635826ca 100644 --- a/SimG4CMS/Forward/src/CastorShowerLibrary.cc +++ b/SimG4CMS/Forward/src/CastorShowerLibrary.cc @@ -25,7 +25,7 @@ #include "TTree.h" #include "TBranch.h" -//#define DebugLog +//#define EDM_ML_DEBUG CastorShowerLibrary::CastorShowerLibrary(const std::string& name, edm::ParameterSet const& p) : hf(nullptr), @@ -238,7 +238,7 @@ CastorShowerEvent CastorShowerLibrary::getRecord(int type, int record) { // ////////////////////////////////////////////////////////////// -#ifdef DebugLog +#ifdef EDM_ML_DEBUG LogDebug("CastorShower") << "CastorShowerLibrary::getRecord: "; #endif int nrc = record; @@ -252,7 +252,7 @@ CastorShowerEvent CastorShowerLibrary::getRecord(int type, int record) { emBranch->GetEntry(nrc); } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG int nHit = showerEvent->getNhit(); LogDebug("CastorShower") << "CastorShowerLibrary::getRecord: Record " << record << " of type " << type << " with " << nHit << " CastorShowerHits"; @@ -286,7 +286,7 @@ CastorShowerEvent CastorShowerLibrary::select(int type, double pin, double etain int ienergy = FindEnergyBin(pin); int ieta = FindEtaBin(etain); -#ifdef DebugLog +#ifdef EDM_ML_DEBUG if (verbose) edm::LogVerbatim("CastorShower") << " ienergy = " << ienergy; if (verbose) @@ -305,7 +305,7 @@ CastorShowerEvent CastorShowerLibrary::select(int type, double pin, double etain phiin = phiMin + remainder; iphi = FindPhiBin(phiin); } -#ifdef DebugLog +#ifdef EDM_ML_DEBUG if (verbose) edm::LogVerbatim("CastorShower") << " iphi = " << iphi; #endif @@ -318,7 +318,7 @@ CastorShowerEvent CastorShowerLibrary::select(int type, double pin, double etain else irec = int(nEvtPerBinE * (ienergy + r)); -#ifdef DebugLog +#ifdef EDM_ML_DEBUG edm::LogVerbatim("CastorShower") << "CastorShowerLibrary:: Select record " << irec << " of type " << type; #endif diff --git a/SimG4CMS/Forward/src/CastorTestAnalysis.cc b/SimG4CMS/Forward/src/CastorTestAnalysis.cc index c5c1127db55aa..dfde77d41ba78 100644 --- a/SimG4CMS/Forward/src/CastorTestAnalysis.cc +++ b/SimG4CMS/Forward/src/CastorTestAnalysis.cc @@ -21,7 +21,7 @@ #include #include -#define debugLog +//#define EDM_ML_DEBUG enum ntcastors_elements { ntcastors_evt, @@ -63,19 +63,19 @@ CastorTestAnalysis::CastorTestAnalysis(const edm::ParameterSet& p) { eventNtFileName = m_Anal.getParameter("EventNtupleFileName"); if (verbosity > 0) { - std::cout << std::endl; - std::cout << "============================================================================" << std::endl; - std::cout << "CastorTestAnalysis:: Initialized as observer" << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl; + edm::LogVerbatim("ForwardSim") << "============================================================================"; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis:: Initialized as observer"; if (doNTcastorstep > 0) { - std::cout << " Step Ntuple will be created" << std::endl; - std::cout << " Step Ntuple file: " << stepNtFileName << std::endl; + edm::LogVerbatim("ForwardSim") << " Step Ntuple will be created"; + edm::LogVerbatim("ForwardSim") << " Step Ntuple file: " << stepNtFileName; } if (doNTcastorevent > 0) { - std::cout << " Event Ntuple will be created" << std::endl; - std::cout << " Step Ntuple file: " << stepNtFileName << std::endl; + edm::LogVerbatim("ForwardSim") << " Event Ntuple will be created"; + edm::LogVerbatim("ForwardSim") << " Step Ntuple file: " << stepNtFileName; } - std::cout << "============================================================================" << std::endl; - std::cout << std::endl; + edm::LogVerbatim("ForwardSim") << "============================================================================"; + edm::LogVerbatim("ForwardSim") << std::endl; } if (doNTcastorstep > 0) castorstepntuple = @@ -91,26 +91,26 @@ CastorTestAnalysis::~CastorTestAnalysis() { Finish(); if (verbosity > 0) { - std::cout << std::endl << "End of CastorTestAnalysis" << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl << "End of CastorTestAnalysis"; } - std::cout << "CastorTestAnalysis: End of process" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: End of process"; } //=================================================================== per EVENT -void CastorTestAnalysis::update(const BeginOfJob* job) { std::cout << " Starting new job " << std::endl; } +void CastorTestAnalysis::update(const BeginOfJob* job) { edm::LogVerbatim("ForwardSim") << " Starting new job "; } //==================================================================== per RUN void CastorTestAnalysis::update(const BeginOfRun* run) { - std::cout << std::endl << "CastorTestAnalysis: Starting Run" << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl << "CastorTestAnalysis: Starting Run"; if (doNTcastorstep) { - std::cout << "CastorTestAnalysis: output step root file created" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: output step root file created"; TString stepfilename = stepNtFileName; castorOutputStepFile = new TFile(stepfilename, "RECREATE"); } if (doNTcastorevent) { - std::cout << "CastorTestAnalysis: output event root file created" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: output event root file created"; TString stepfilename = eventNtFileName; castorOutputEventFile = new TFile(stepfilename, "RECREATE"); } @@ -119,7 +119,7 @@ void CastorTestAnalysis::update(const BeginOfRun* run) { } void CastorTestAnalysis::update(const BeginOfEvent* evt) { - std::cout << "CastorTestAnalysis: Processing Event Number: " << eventIndex << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Processing Event Number: " << eventIndex; eventIndex++; stepIndex = 0; } @@ -134,7 +134,7 @@ void CastorTestAnalysis::update(const G4Step* aStep) { G4double stepE = aStep->GetTotalEnergyDeposit(); if (verbosity >= 2) - std::cout << "Step " << stepL << ", " << stepE << std::endl; + edm::LogVerbatim("ForwardSim") << "Step " << stepL << ", " << stepE; G4Track* theTrack = aStep->GetTrack(); G4int theTrackID = theTrack->GetTrackID(); @@ -169,35 +169,35 @@ void CastorTestAnalysis::update(const G4Step* aStep) { castorsteparray[ntcastors_vpz] = vpz; /* - std::cout<<"TrackID: "<< theTrackID<GetCurrentStepNumber() <GetTrack()->GetParentID() <GetPosition().x() <<","<< theTrack->GetPosition().y() <<","<< theTrack->GetPosition().z() <GetKineticEnergy() <GetTotalEnergyDeposit() <GetStepLength() <GetTrackLength() <GetCurrentStepNumber(); + edm::LogVerbatim("ForwardSim") << " ParentID: " << aStep->GetTrack()->GetParentID(); + edm::LogVerbatim("ForwardSim") << " PDG: " << pdgcode; + edm::LogVerbatim("ForwardSim") << " X,Y,Z (mm): " << theTrack->GetPosition().x() << "," << theTrack->GetPosition().y() << "," << theTrack->GetPosition().z(); + edm::LogVerbatim("ForwardSim") << " KE (MeV): " << theTrack->GetKineticEnergy(); + edm::LogVerbatim("ForwardSim") << " Total EDep (MeV): " << aStep->GetTotalEnergyDeposit(); + edm::LogVerbatim("ForwardSim") << " StepLength (mm): " << aStep->GetStepLength(); + edm::LogVerbatim("ForwardSim") << " TrackLength (mm): " << theTrack->GetTrackLength(); if ( theTrack->GetNextVolume() != 0 ) - std::cout<<" NextVolume: "<< theTrack->GetNextVolume()->GetName() <GetNextVolume()->GetName(); else - std::cout<<" NextVolume: OutOfWorld"<GetPostStepPoint()->GetProcessDefinedStep() != NULL) - std::cout<<" ProcessName: "<< aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() <GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName(); else - std::cout<<" ProcessName: UserLimit"<GetNextVolume() != 0) - LogDebug("ForwardSim") << " NextVolume: " << theTrack->GetNextVolume()->GetName(); + edm::LogVerbatim("ForwardSim") << " NextVolume: " << theTrack->GetNextVolume()->GetName(); else - LogDebug("ForwardSim") << " NextVolume: OutOfWorld"; + edm::LogVerbatim("ForwardSim") << " NextVolume: OutOfWorld"; #endif //fill ntuple with step level information @@ -208,11 +208,11 @@ void CastorTestAnalysis::update(const G4Step* aStep) { //================= End of EVENT =============== void CastorTestAnalysis::update(const EndOfEvent* evt) { // Look for the Hit Collection - std::cout << std::endl << "CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID() << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl << "CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID(); // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); - std::cout << "update(*evt) --> accessed all HC"; + edm::LogVerbatim("ForwardSim") << "update(*evt) --> accessed all HC"; int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("CastorFI"); @@ -243,35 +243,39 @@ void CastorTestAnalysis::update(const EndOfEvent* evt) { // Find Primary info: int trackID = 0; +#ifdef EDM_ML_DEBUG int particleType = 0; +#endif G4PrimaryParticle* thePrim = nullptr; G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex(); - std::cout << "Event has " << nvertex << " vertex" << std::endl; + edm::LogVerbatim("ForwardSim") << "Event has " << nvertex << " vertex"; if (nvertex == 0) - std::cout << "CASTORTest End Of Event ERROR: no vertex" << std::endl; + edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERROR: no vertex"; for (int i = 0; i < nvertex; i++) { G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i); if (avertex == nullptr) - std::cout << "CASTORTest End Of Event ERR: pointer to vertex = 0" << std::endl; - std::cout << "Vertex number :" << i << std::endl; + edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERR: pointer to vertex = 0"; + edm::LogVerbatim("ForwardSim") << "Vertex number :" << i; int npart = avertex->GetNumberOfParticle(); if (npart == 0) - std::cout << "CASTORTest End Of Event ERR: no primary!" << std::endl; + edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERR: no primary!"; if (thePrim == nullptr) thePrim = avertex->GetPrimary(trackID); } double px = 0., py = 0., pz = 0., pInit = 0; +#ifdef EDM_ML_DEBUG double eta = 0., phi = 0.; - +#endif if (thePrim != nullptr) { px = thePrim->GetPx(); py = thePrim->GetPy(); pz = thePrim->GetPz(); pInit = sqrt(pow(px, 2.) + pow(py, 2.) + pow(pz, 2.)); if (pInit == 0) { - std::cout << "CASTORTest End Of Event ERR: primary has p=0 " << std::endl; + edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERR: primary has p=0 "; +#ifdef EDM_ML_DEBUG } else { float costheta = pz / pInit; float theta = acos(std::min(std::max(costheta, float(-1.)), float(1.))); @@ -279,26 +283,30 @@ void CastorTestAnalysis::update(const EndOfEvent* evt) { if (px != 0) phi = atan(py / px); +#endif } +#ifdef EDM_ML_DEBUG particleType = thePrim->GetPDGcode(); +#endif } else { - std::cout << "CASTORTest End Of Event ERR: could not find primary " << std::endl; + edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERR: could not find primary "; } - LogDebug("ForwardSim") << "CastorTestAnalysis: Particle Type " << particleType << " p/eta/phi " << pInit << ", " - << eta << ", " << phi; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Particle Type " << particleType << " p/eta/phi " << pInit << ", " << eta << ", " << phi; +#endif } int iEvt = (*evt)()->GetEventID(); if (iEvt < 10) - std::cout << " CastorTest Event " << iEvt << std::endl; + edm::LogVerbatim("ForwardSim") << " CastorTest Event " << iEvt; else if ((iEvt < 100) && (iEvt % 10 == 0)) - std::cout << " CastorTest Event " << iEvt << std::endl; + edm::LogVerbatim("ForwardSim") << " CastorTest Event " << iEvt; else if ((iEvt < 1000) && (iEvt % 100 == 0)) - std::cout << " CastorTest Event " << iEvt << std::endl; + edm::LogVerbatim("ForwardSim") << " CastorTest Event " << iEvt; else if ((iEvt < 10000) && (iEvt % 1000 == 0)) - std::cout << " CastorTest Event " << iEvt << std::endl; + edm::LogVerbatim("ForwardSim") << " CastorTest Event " << iEvt; - std::cout << std::endl << "===>>> Done writing user histograms " << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl << "===>>> Done writing user histograms "; } void CastorTestAnalysis::update(const EndOfRun* run) { ; } @@ -363,16 +371,16 @@ void CastorTestAnalysis::Finish() { if (doNTcastorstep) { castorOutputStepFile->cd(); castorstepntuple->Write(); - std::cout << "CastorTestAnalysis: Ntuple step written" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Ntuple step written"; castorOutputStepFile->Close(); - std::cout << "CastorTestAnalysis: Step file closed" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Step file closed"; } if (doNTcastorevent) { castorOutputEventFile->cd(); castoreventntuple->Write("", TObject::kOverwrite); - std::cout << "CastorTestAnalysis: Ntuple event written" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Ntuple event written"; castorOutputEventFile->Close(); - std::cout << "CastorTestAnalysis: Event file closed" << std::endl; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Event file closed"; } } diff --git a/SimG4CMS/Forward/src/DoCastorAnalysis.cc b/SimG4CMS/Forward/src/DoCastorAnalysis.cc index 1caa3f4d7bd3f..a488a4ece0ac9 100644 --- a/SimG4CMS/Forward/src/DoCastorAnalysis.cc +++ b/SimG4CMS/Forward/src/DoCastorAnalysis.cc @@ -9,6 +9,7 @@ // Original Author: P. Katsas // Created: 02/2007 // +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "SimG4CMS/Calo/interface/CaloG4Hit.h" #include "SimG4CMS/Calo/interface/CaloG4HitCollection.h" #include "DataFormats/Math/interface/Point3D.h" @@ -23,7 +24,7 @@ #include #include -#define debug 0 +//#define EDM_ML_DEBUG DoCastorAnalysis::DoCastorAnalysis(const edm::ParameterSet& p) { edm::ParameterSet m_Anal = p.getParameter("DoCastorAnalysis"); @@ -32,20 +33,20 @@ DoCastorAnalysis::DoCastorAnalysis(const edm::ParameterSet& p) { TreeFileName = m_Anal.getParameter("CastorTreeFileName"); if (verbosity > 0) { - std::cout << std::endl; - std::cout << "============================================================================" << std::endl; - std::cout << "DoCastorAnalysis:: Initialized as observer" << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl; + edm::LogVerbatim("ForwardSim") << "============================================================================"; + edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis:: Initialized as observer"; - std::cout << " Castor Tree will be created" << std::endl; - std::cout << " Castor Tree will be in file: " << TreeFileName << std::endl; - if (debug) - getchar(); - - std::cout << "============================================================================" << std::endl; - std::cout << std::endl; + edm::LogVerbatim("ForwardSim") << " Castor Tree will be created"; + edm::LogVerbatim("ForwardSim") << " Castor Tree will be in file: " << TreeFileName; +#ifdef EDM_ML_DEBUG + getchar(); +#endif + edm::LogVerbatim("ForwardSim") << "============================================================================"; + edm::LogVerbatim("ForwardSim") << std::endl; } - std::cout << "DoCastorAnalysis: output event root file created" << std::endl; + edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created"; TString treefilename = TreeFileName; CastorOutputEventFile = new TFile(treefilename, "RECREATE"); @@ -72,31 +73,34 @@ DoCastorAnalysis::~DoCastorAnalysis() { CastorOutputEventFile->cd(); //-- CastorOutputEventFile->Write(); CastorTree->Write("", TObject::kOverwrite); - std::cout << "DoCastorAnalysis: Ntuple event written" << std::endl; - if (debug) - getchar(); + edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Ntuple event written"; +#ifdef EDM_ML_DEBUG + getchar(); +#endif CastorOutputEventFile->Close(); - std::cout << "DoCastorAnalysis: Event file closed" << std::endl; - if (debug) - getchar(); + edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Event file closed"; +#ifdef EDM_ML_DEBUG + getchar(); +#endif if (verbosity > 0) { - std::cout << std::endl << "DoCastorAnalysis: end of process" << std::endl; - if (debug) - getchar(); + edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: end of process"; +#ifdef EDM_ML_DEBUG + getchar(); +#endif } } //=================================================================== per EVENT -void DoCastorAnalysis::update(const BeginOfJob* job) { std::cout << " Starting new job " << std::endl; } +void DoCastorAnalysis::update(const BeginOfJob* job) { edm::LogVerbatim("ForwardSim") << " Starting new job "; } //==================================================================== per RUN void DoCastorAnalysis::update(const BeginOfRun* run) { - std::cout << std::endl << "DoCastorAnalysis: Starting Run" << std::endl; + edm::LogVerbatim("ForwardSim") << std::endl << "DoCastorAnalysis: Starting Run"; - // std::cout << "DoCastorAnalysis: output event root file created"<< std::endl; + // edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: output event root file created"; // TString treefilename = TreeFileName; // CastorOutputEventFile = new TFile(treefilename,"RECREATE"); @@ -104,7 +108,7 @@ void DoCastorAnalysis::update(const BeginOfRun* run) { } void DoCastorAnalysis::update(const BeginOfEvent* evt) { - std::cout << "DoCastorAnalysis: Processing Event Number: " << eventIndex << std::endl; + edm::LogVerbatim("ForwardSim") << "DoCastorAnalysis: Processing Event Number: " << eventIndex; eventIndex++; } @@ -125,10 +129,10 @@ void DoCastorAnalysis::update(const EndOfEvent* evt) { // std::map > themap; int nentries = theCAFI->entries(); - if (debug) - std::cout << "nentries in CAFI: " << nentries << std::endl; - if (debug) - getchar(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("ForwardSim") << "nentries in CAFI: " << nentries; + getchar(); +#endif psimhit_x = &simhit_x; psimhit_x->clear(); @@ -200,14 +204,15 @@ void DoCastorAnalysis::update(const EndOfEvent* evt) { simhit_etot += energy; - if (debug) - std::cout << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit] << " , eta = " << (*psimhit_eta)[ihit] - << " , phi = " << (*psimhit_phi)[ihit] << " , energy = " << (*psimhit_energy)[ihit] << std::endl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("ForwardSim") << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit] << " , eta = " << (*psimhit_eta)[ihit] << " , phi = " << (*psimhit_phi)[ihit] << " , energy = " << (*psimhit_energy)[ihit]; +#endif } - //if(debug) std::cout<<" total energy = "<("TimeSliceUnit"); - edm::LogInfo("MtdSim") << "New time factor = " << newTimeFactor; + edm::LogVerbatim("MtdSim") << "New time factor = " << newTimeFactor; setTimeFactor(newTimeFactor); edm::LogVerbatim("MtdSim") << "MtdSD: Instantiation completed for " << name; @@ -60,7 +55,7 @@ uint32_t MtdSD::setDetUnitId(const G4Step* aStep) { } else { getBaseNumber(aStep); #ifdef EDM_ML_DEBUG - edm::LogInfo("MtdSim") << "DetId = " << numberingScheme->getUnitID(theBaseNumber); + edm::LogVerbatim("MtdSim") << "DetId = " << numberingScheme->getUnitID(theBaseNumber); #endif return numberingScheme->getUnitID(theBaseNumber); } @@ -68,7 +63,7 @@ uint32_t MtdSD::setDetUnitId(const G4Step* aStep) { void MtdSD::setNumberingScheme(MTDNumberingScheme* scheme) { if (scheme != nullptr) { - edm::LogInfo("MtdSim") << "MtdSD: updates numbering scheme for " << GetName(); + edm::LogVerbatim("MtdSim") << "MtdSD: updates numbering scheme for " << GetName(); if (numberingScheme) delete numberingScheme; numberingScheme = scheme; @@ -84,7 +79,7 @@ void MtdSD::getBaseNumber(const G4Step* aStep) { //Get name and copy numbers if (theSize > 1) { #ifdef EDM_ML_DEBUG - edm::LogInfo("MtdSim") << "Building MTD basenumber:"; + edm::LogVerbatim("MtdSim") << "Building MTD basenumber:"; #endif for (int ii = 0; ii < theSize; ii++) { theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(), touch->GetReplicaNumber(ii)); diff --git a/SimG4CMS/Forward/src/PltSD.cc b/SimG4CMS/Forward/src/PltSD.cc index 3254ad938f72f..a59a0c026fe9b 100644 --- a/SimG4CMS/Forward/src/PltSD.cc +++ b/SimG4CMS/Forward/src/PltSD.cc @@ -1,8 +1,5 @@ #include "SimG4CMS/Forward/interface/PltSD.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -16,8 +13,9 @@ #include +//#define EDM_ML_DEBUG + PltSD::PltSD(const std::string& name, - const edm::EventSetup& es, const SensitiveDetectorCatalog& clg, edm::ParameterSet const& p, const SimTrackManager* manager) @@ -36,8 +34,9 @@ PltSD::~PltSD() {} uint32_t PltSD::setDetUnitId(const G4Step* aStep) { unsigned int detId = 0; - LogDebug("PltSD") << " DetID = " << detId; - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("PltSD") << " DetID = " << detId; +#endif //Find number of levels const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); int level = 0; @@ -51,11 +50,11 @@ uint32_t PltSD::setDetUnitId(const G4Step* aStep) { G4String telName = touch->GetVolume(3)->GetName(); G4String volumeName = touch->GetVolume(4)->GetName(); if (sensorName != "PLTSensorPlane") - std::cout << " PltSD::setDetUnitId -w- Sensor name not PLTSensorPlane " << std::endl; + edm::LogVerbatim("PltSD") << " PltSD::setDetUnitId -w- Sensor name not PLTSensorPlane "; if (telName != "Telescope") - std::cout << " PltSD::setDetUnitId -w- Telescope name not Telescope " << std::endl; + edm::LogVerbatim("PltSD") << " PltSD::setDetUnitId -w- Telescope name not Telescope "; if (volumeName != "PLT") - std::cout << " PltSD::setDetUnitId -w- Volume name not PLT " << std::endl; + edm::LogVerbatim("PltSD") << " PltSD::setDetUnitId -w- Volume name not PLT "; //Get the information about which telescope, plane, row/column was hit int columnNum = touch->GetReplicaNumber(0); @@ -114,7 +113,9 @@ uint32_t PltSD::setDetUnitId(const G4Step* aStep) { //Define unique detId for each pixel. See https://twiki.cern.ch/twiki/bin/viewauth/CMS/PLTSimulationGuide for more information detId = 10000000 * pltNum + 1000000 * halfCarriageNum + 100000 * telNum + 10000 * sensorNum + 100 * rowNum + columnNum; - //std::cout << "Hit Recorded at " << "plt:" << pltNum << " hc:" << halfCarriageNum << " tel:" << telNum << " plane:" << sensorNum << std::endl; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("PltSD") << "Hit Recorded at " << "plt:" << pltNum << " hc:" << halfCarriageNum << " tel:" << telNum << " plane:" << sensorNum; +#endif } return detId; } diff --git a/SimG4CMS/Forward/src/TimingSD.cc b/SimG4CMS/Forward/src/TimingSD.cc index 940dcfed947b2..1436f5440277c 100644 --- a/SimG4CMS/Forward/src/TimingSD.cc +++ b/SimG4CMS/Forward/src/TimingSD.cc @@ -12,9 +12,6 @@ #include "SimG4Core/Physics/interface/G4ProcessTypeEnumerator.h" #include "SimDataFormats/SimHitMaker/interface/TrackingSlaveSD.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "G4Step.hh" @@ -30,7 +27,7 @@ #include #include -//#define debug +//#define EDM_ML_DEBUG static const float invgev = 1.0 / CLHEP::GeV; static const double invns = 1.0 / CLHEP::nanosecond; @@ -84,7 +81,7 @@ void TimingSD::setTimeFactor(double val) { return; } timeFactor = val; -#ifdef debug +#ifdef EDM_ML_DEBUG edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " time slice factor is set to " << timeFactor; #endif } @@ -96,7 +93,7 @@ void TimingSD::setCuts(double eCut, double historyCut) { if (historyCut > 0.) { energyHistoryCut = historyCut; } -#ifdef debug +#ifdef EDM_ML_DEBUG edm::LogVerbatim("TimingSim") << "TimingSD : for " << GetName() << " MC truth cuts in are " << energyCut / CLHEP::GeV << " GeV and " << energyHistoryCut / CLHEP::GeV << " GeV"; #endif @@ -132,7 +129,7 @@ void TimingSD::getStepInfo(const G4Step* aStep) { tof = (float)(preStepPoint->GetGlobalTime() * invns); } -#ifdef debug +#ifdef EDM_ML_DEBUG double distGlobal = std::sqrt(std::pow(hitPoint.x() - hitPointExit.x(), 2) + std::pow(hitPoint.y() - hitPointExit.y(), 2) + std::pow(hitPoint.z() - hitPointExit.z(), 2)); @@ -253,7 +250,7 @@ void TimingSD::storeHit(BscG4Hit* hit) { } void TimingSD::createNewHit(const G4Step* aStep) { -#ifdef debug +#ifdef EDM_ML_DEBUG const G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume(); edm::LogVerbatim("TimingSim") << "TimingSD CreateNewHit for " << GetName() << " PV " << currentPV->GetName() << " PVid = " << currentPV->GetCopyNo() << " Unit " << unitID << "\n primary " @@ -301,7 +298,7 @@ void TimingSD::createNewHit(const G4Step* aStep) { void TimingSD::updateHit() { currentHit->addEnergyDeposit(edepositEM, edepositHAD); -#ifdef debug +#ifdef EDM_ML_DEBUG edm::LogVerbatim("TimingSim") << "updateHit: " << GetName() << " add eloss(GeV) " << edeposit << "CurrentHit=" << currentHit << ", PostStepPoint= " << postStepPoint->GetPosition(); #endif @@ -328,7 +325,7 @@ void TimingSD::EndOfEvent(G4HCofThisEvent*) { Local3DPoint locEntryPoint = ConvertToLocal3DPoint(aHit->getEntryLocalP()); Local3DPoint locExitPoint = ConvertToLocal3DPoint(aHit->getExitLocalP()); -#ifdef debug +#ifdef EDM_ML_DEBUG edm::LogInfo("TimingSim") << "TimingSD: Hit for storage \n" << *aHit << "\n Entry point: " << locEntryPoint << "\n Exit point: " << locExitPoint << "\n"; @@ -349,7 +346,9 @@ void TimingSD::EndOfEvent(G4HCofThisEvent*) { } void TimingSD::PrintAll() { - LogDebug("TimingSim") << "TimingSD: Collection " << theHC->GetName() << "\n"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("TimingSim") << "TimingSD: Collection " << theHC->GetName(); +#endif theHC->PrintAllHits(); } @@ -360,7 +359,9 @@ void TimingSD::fillHits(edm::PSimHitContainer& cc, const std::string& hname) { } void TimingSD::update(const BeginOfEvent* i) { - LogDebug("TimingSim") << " Dispatched BeginOfEvent for " << GetName(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("TimingSim") << " Dispatched BeginOfEvent for " << GetName(); +#endif clearHits(); } diff --git a/SimG4CMS/Forward/src/TotemSD.cc b/SimG4CMS/Forward/src/TotemSD.cc index 317b19e3d1a9e..c32638c3e9003 100644 --- a/SimG4CMS/Forward/src/TotemSD.cc +++ b/SimG4CMS/Forward/src/TotemSD.cc @@ -13,8 +13,6 @@ // system include files // user include files -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/SimG4CMS/Forward/src/TotemT2ScintSD.cc b/SimG4CMS/Forward/src/TotemT2ScintSD.cc index f8574e237f1d7..914062786d242 100644 --- a/SimG4CMS/Forward/src/TotemT2ScintSD.cc +++ b/SimG4CMS/Forward/src/TotemT2ScintSD.cc @@ -18,7 +18,6 @@ //#define EDM_ML_DEBUG TotemT2ScintSD::TotemT2ScintSD(const std::string& name, - const edm::EventSetup& es, const SensitiveDetectorCatalog& clg, edm::ParameterSet const& p, const SimTrackManager* manager) @@ -30,7 +29,7 @@ TotemT2ScintSD::TotemT2ScintSD(const std::string& name, p.getParameter("TotemT2ScintSD").getParameter("IgnoreTrackID")) { edm::ParameterSet m_T2SD = p.getParameter("TotemT2ScintSD"); useBirk_ = m_T2SD.getParameter("UseBirkLaw"); - birk1_ = m_T2SD.getParameter("BirkC1") * (g / (MeV * cm2)); + birk1_ = m_T2SD.getParameter("BirkC1") * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2)); birk2_ = m_T2SD.getParameter("BirkC2"); birk3_ = m_T2SD.getParameter("BirkC3"); setNumberingScheme(new TotemT2ScintNumberingScheme()); diff --git a/SimG4CMS/Forward/src/ZdcSD.cc b/SimG4CMS/Forward/src/ZdcSD.cc index e030f0053ee97..e8d3052fa1b1b 100644 --- a/SimG4CMS/Forward/src/ZdcSD.cc +++ b/SimG4CMS/Forward/src/ZdcSD.cc @@ -8,7 +8,6 @@ #include "SimG4CMS/Forward/interface/ZdcSD.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "SimG4Core/Notification/interface/TrackInformation.h" From 49db86877122be10e634f13940d18bcdc361ae2c Mon Sep 17 00:00:00 2001 From: Sunanda Date: Tue, 20 Jul 2021 02:30:47 +0200 Subject: [PATCH 2/2] Code check --- SimG4CMS/Forward/interface/BHMSD.h | 5 +---- SimG4CMS/Forward/interface/Bcm1fSD.h | 5 +---- SimG4CMS/Forward/interface/MtdSD.h | 5 +---- SimG4CMS/Forward/interface/PltSD.h | 5 +---- SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc | 1 - SimG4CMS/Forward/src/CastorTestAnalysis.cc | 6 ++++-- SimG4CMS/Forward/src/DoCastorAnalysis.cc | 4 +++- SimG4CMS/Forward/src/PltSD.cc | 4 +++- 8 files changed, 14 insertions(+), 21 deletions(-) diff --git a/SimG4CMS/Forward/interface/BHMSD.h b/SimG4CMS/Forward/interface/BHMSD.h index 9339aba28cabe..08f803b57cf6b 100644 --- a/SimG4CMS/Forward/interface/BHMSD.h +++ b/SimG4CMS/Forward/interface/BHMSD.h @@ -15,10 +15,7 @@ class BHMNumberingScheme; class BHMSD : public TimingSD { public: - BHMSD(const std::string &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, - const SimTrackManager *); + BHMSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); ~BHMSD() override; diff --git a/SimG4CMS/Forward/interface/Bcm1fSD.h b/SimG4CMS/Forward/interface/Bcm1fSD.h index 338f78424f538..81978c017389b 100644 --- a/SimG4CMS/Forward/interface/Bcm1fSD.h +++ b/SimG4CMS/Forward/interface/Bcm1fSD.h @@ -12,10 +12,7 @@ class G4Step; class Bcm1fSD : public TimingSD { public: - Bcm1fSD(const std::string &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, - const SimTrackManager *); + Bcm1fSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); ~Bcm1fSD() override; uint32_t setDetUnitId(const G4Step *) override; diff --git a/SimG4CMS/Forward/interface/MtdSD.h b/SimG4CMS/Forward/interface/MtdSD.h index 59dc6be98c571..c6c5dbb26626b 100644 --- a/SimG4CMS/Forward/interface/MtdSD.h +++ b/SimG4CMS/Forward/interface/MtdSD.h @@ -18,10 +18,7 @@ class SimTrackManager; class MtdSD : public TimingSD { public: - MtdSD(const std::string &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, - const SimTrackManager *); + MtdSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); ~MtdSD() override; diff --git a/SimG4CMS/Forward/interface/PltSD.h b/SimG4CMS/Forward/interface/PltSD.h index ca2c155079ebf..aad91fd64e8fb 100644 --- a/SimG4CMS/Forward/interface/PltSD.h +++ b/SimG4CMS/Forward/interface/PltSD.h @@ -12,10 +12,7 @@ class SimTrackManager; class PltSD : public TimingSD { public: - PltSD(const std::string &, - const SensitiveDetectorCatalog &, - edm::ParameterSet const &, - const SimTrackManager *); + PltSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *); ~PltSD() override; uint32_t setDetUnitId(const G4Step *) override; diff --git a/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc b/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc index 889bb99ab13ad..891cd45f777eb 100644 --- a/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc +++ b/SimG4CMS/Forward/plugins/PLTSensitiveDetectorBuilder.cc @@ -32,4 +32,3 @@ class PLTSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { typedef PltSD PLTSensitiveDetector; DEFINE_SENSITIVEDETECTORBUILDER(PLTSensitiveDetectorBuilder, PLTSensitiveDetector); - diff --git a/SimG4CMS/Forward/src/CastorTestAnalysis.cc b/SimG4CMS/Forward/src/CastorTestAnalysis.cc index dfde77d41ba78..e7658357ea68d 100644 --- a/SimG4CMS/Forward/src/CastorTestAnalysis.cc +++ b/SimG4CMS/Forward/src/CastorTestAnalysis.cc @@ -208,7 +208,8 @@ void CastorTestAnalysis::update(const G4Step* aStep) { //================= End of EVENT =============== void CastorTestAnalysis::update(const EndOfEvent* evt) { // Look for the Hit Collection - edm::LogVerbatim("ForwardSim") << std::endl << "CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID(); + edm::LogVerbatim("ForwardSim") << std::endl + << "CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID(); // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); @@ -292,7 +293,8 @@ void CastorTestAnalysis::update(const EndOfEvent* evt) { edm::LogVerbatim("ForwardSim") << "CASTORTest End Of Event ERR: could not find primary "; } #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Particle Type " << particleType << " p/eta/phi " << pInit << ", " << eta << ", " << phi; + edm::LogVerbatim("ForwardSim") << "CastorTestAnalysis: Particle Type " << particleType << " p/eta/phi " << pInit + << ", " << eta << ", " << phi; #endif } diff --git a/SimG4CMS/Forward/src/DoCastorAnalysis.cc b/SimG4CMS/Forward/src/DoCastorAnalysis.cc index a488a4ece0ac9..77f642142a987 100644 --- a/SimG4CMS/Forward/src/DoCastorAnalysis.cc +++ b/SimG4CMS/Forward/src/DoCastorAnalysis.cc @@ -205,7 +205,9 @@ void DoCastorAnalysis::update(const EndOfEvent* evt) { simhit_etot += energy; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("ForwardSim") << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit] << " , eta = " << (*psimhit_eta)[ihit] << " , phi = " << (*psimhit_phi)[ihit] << " , energy = " << (*psimhit_energy)[ihit]; + edm::LogVerbatim("ForwardSim") << "hit " << ihit + 1 << " : x = " << (*psimhit_x)[ihit] + << " , eta = " << (*psimhit_eta)[ihit] << " , phi = " << (*psimhit_phi)[ihit] + << " , energy = " << (*psimhit_energy)[ihit]; #endif } diff --git a/SimG4CMS/Forward/src/PltSD.cc b/SimG4CMS/Forward/src/PltSD.cc index a59a0c026fe9b..30a54bb9267a3 100644 --- a/SimG4CMS/Forward/src/PltSD.cc +++ b/SimG4CMS/Forward/src/PltSD.cc @@ -114,7 +114,9 @@ uint32_t PltSD::setDetUnitId(const G4Step* aStep) { detId = 10000000 * pltNum + 1000000 * halfCarriageNum + 100000 * telNum + 10000 * sensorNum + 100 * rowNum + columnNum; #ifdef EDM_ML_DEBUG - edm::LogVerbatim("PltSD") << "Hit Recorded at " << "plt:" << pltNum << " hc:" << halfCarriageNum << " tel:" << telNum << " plane:" << sensorNum; + edm::LogVerbatim("PltSD") << "Hit Recorded at " + << "plt:" << pltNum << " hc:" << halfCarriageNum << " tel:" << telNum + << " plane:" << sensorNum; #endif } return detId;