-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run3-gex83C Convert one more SD (Hcal) to new format #34521
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
// system include files | ||
#include <string> | ||
#include <vector> | ||
|
||
// user include files | ||
#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h" | ||
#include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h" | ||
#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" | ||
|
||
#include "CondFormats/DataRecord/interface/HBHEDarkeningRecord.h" | ||
#include "CondFormats/HcalObjects/interface/HBHEDarkening.h" | ||
#include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h" | ||
#include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h" | ||
#include "Geometry/HcalCommonData/interface/HcalSimulationConstants.h" | ||
#include "Geometry/Records/interface/HcalSimNumberingRecord.h" | ||
#include "Geometry/Records/interface/HcalRecNumberingRecord.h" | ||
#include "SimG4CMS/Calo/interface/HCalSD.h" | ||
|
||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Utilities/interface/ESGetToken.h" | ||
#include "FWCore/PluginManager/interface/ModuleDef.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
class HcalSensitiveDetectorBuilder : public SensitiveDetectorMakerBase { | ||
public: | ||
explicit HcalSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc) | ||
: hdscToken_{cc.esConsumes<edm::Transition::BeginRun>()}, | ||
hdrcToken_{cc.esConsumes<edm::Transition::BeginRun>()}, | ||
hscsToken_{cc.esConsumes<edm::Transition::BeginRun>()}, | ||
hbdkToken_{ | ||
cc.esConsumes<HBHEDarkening, HBHEDarkeningRecord, edm::Transition::BeginRun>(edm::ESInputTag{"", "HB"})}, | ||
hedkToken_{ | ||
cc.esConsumes<HBHEDarkening, HBHEDarkeningRecord, edm::Transition::BeginRun>(edm::ESInputTag{"", "HE"})}, | ||
hcalDDSim_{nullptr}, | ||
hcalDDRec_{nullptr}, | ||
hcalSimConstants_{nullptr}, | ||
hbDarkening_{nullptr}, | ||
heDarkening_{nullptr} { | ||
edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("HCalSD"); | ||
agingFlagHB_ = m_HC.getParameter<bool>("HBDarkening"); | ||
agingFlagHE_ = m_HC.getParameter<bool>("HEDarkening"); | ||
forTBHC_ = m_HC.getUntrackedParameter<bool>("ForTBHCAL", false); | ||
forTBH2_ = m_HC.getUntrackedParameter<bool>("ForTBH2", false); | ||
} | ||
|
||
void beginRun(const edm::EventSetup& es) final { | ||
hcalDDSim_ = &es.getData(hdscToken_); | ||
if ((!forTBHC_) && (!forTBH2_)) | ||
hcalDDRec_ = &es.getData(hdrcToken_); | ||
edm::ESHandle<HcalSimulationConstants> hscs = es.getHandle(hscsToken_); | ||
if (hscs.isValid()) | ||
hcalSimConstants_ = hscs.product(); | ||
else | ||
edm::LogWarning("HcalSim") << "HcalSensitiveDetectorBuilder does not find record for HcalSimulationConstants"; | ||
if (agingFlagHB_) { | ||
edm::ESHandle<HBHEDarkening> hbdark = es.getHandle(hbdkToken_); | ||
if (hbdark.isValid()) | ||
hbDarkening_ = hbdark.product(); | ||
else | ||
edm::LogVerbatim("HcalSim") << "HcalSensitiveDetectorBuilder does not find record for HBDarkening"; | ||
} | ||
if (agingFlagHE_) { | ||
edm::ESHandle<HBHEDarkening> hedark = es.getHandle(hedkToken_); | ||
if (hedark.isValid()) | ||
heDarkening_ = hedark.product(); | ||
else | ||
edm::LogVerbatim("HcalSim") << "HcalSensitiveDetectorBuilder does not find record for HEDarkening"; | ||
} | ||
} | ||
|
||
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<HCalSD>( | ||
iname, hcalDDSim_, hcalDDRec_, hcalSimConstants_, hbDarkening_, heDarkening_, clg, p, man); | ||
SimActivityRegistryEnroller::enroll(reg, sd.get()); | ||
return sd; | ||
} | ||
|
||
private: | ||
const edm::ESGetToken<HcalDDDSimConstants, HcalSimNumberingRecord> hdscToken_; | ||
const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> hdrcToken_; | ||
const edm::ESGetToken<HcalSimulationConstants, HcalSimNumberingRecord> hscsToken_; | ||
const edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> hbdkToken_; | ||
const edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> hedkToken_; | ||
const HcalDDDSimConstants* hcalDDSim_; | ||
const HcalDDDRecConstants* hcalDDRec_; | ||
const HcalSimulationConstants* hcalSimConstants_; | ||
const HBHEDarkening* hbDarkening_; | ||
const HBHEDarkening* heDarkening_; | ||
bool agingFlagHB_, agingFlagHE_; | ||
bool forTBHC_, forTBH2_; | ||
}; | ||
|
||
typedef HCalSD HcalSensitiveDetector; | ||
DEFINE_SENSITIVEDETECTORBUILDER(HcalSensitiveDetectorBuilder, HcalSensitiveDetector); |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsunanda , where HCalSD is now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HcalSensitiveDetectorBuilder instantiates HCalSD as HcalSensitiveDetector by supplying all objects needed from EventSetup