Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34538 from bsunanda/Run3-gex83E
Run3-gex83E Update SD class initialization in SimG4CMS/CherenkovAnalysis
- Loading branch information
Showing
7 changed files
with
78 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
SimG4CMS/CherenkovAnalysis/plugins/DreamSensitiveDetectorBuilder.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// 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 "DetectorDescription/Core/interface/DDCompactView.h" | ||
#include "DetectorDescription/DDCMS/interface/DDCompactView.h" | ||
#include "Geometry/Records/interface/IdealGeometryRecord.h" | ||
#include "SimG4CMS/CherenkovAnalysis/interface/DreamSD.h" | ||
|
||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Utilities/interface/ESGetToken.h" | ||
#include "FWCore/PluginManager/interface/ModuleDef.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
class DreamSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { | ||
public: | ||
explicit DreamSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) { | ||
fromDD4Hep_ = p.getParameter<bool>("g4GeometryDD4hepSource"); | ||
if (fromDD4Hep_) | ||
cpvTokenDD4Hep_ = cc.esConsumes<edm::Transition::BeginRun>(); | ||
else | ||
cpvTokenDDD_ = cc.esConsumes<edm::Transition::BeginRun>(); | ||
} | ||
|
||
void beginRun(const edm::EventSetup& es) final { | ||
if (fromDD4Hep_) { | ||
cpvDD4Hep_ = &es.getData(cpvTokenDD4Hep_); | ||
} else { | ||
cpvDDD_ = &es.getData(cpvTokenDDD_); | ||
} | ||
} | ||
|
||
std::unique_ptr<SensitiveDetector> make(const std::string& iname, | ||
const SensitiveDetectorCatalog& clg, | ||
const edm::ParameterSet& p, | ||
const SimTrackManager* man, | ||
SimActivityRegistry& reg) const final { | ||
auto sd = std::make_unique<DreamSD>(iname, cpvDDD_, cpvDD4Hep_, clg, p, man); | ||
SimActivityRegistryEnroller::enroll(reg, sd.get()); | ||
return sd; | ||
} | ||
|
||
private: | ||
bool fromDD4Hep_; | ||
edm::ESGetToken<DDCompactView, IdealGeometryRecord> cpvTokenDDD_; | ||
edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> cpvTokenDD4Hep_; | ||
const DDCompactView* cpvDDD_; | ||
const cms::DDCompactView* cpvDD4Hep_; | ||
}; | ||
|
||
typedef DreamSD DreamSensitiveDetector; | ||
DEFINE_SENSITIVEDETECTORBUILDER(DreamSensitiveDetectorBuilder, DreamSensitiveDetector); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters