diff --git a/include/Hcal/Event/HcalHit.h b/include/Hcal/Event/HcalHit.h index 2b5e167..cb80469 100644 --- a/include/Hcal/Event/HcalHit.h +++ b/include/Hcal/Event/HcalHit.h @@ -20,7 +20,7 @@ namespace ldmx { * from the HCAL, providing particular information for the HCAL, * above and beyond what is available in the CalorimeterHit. */ -class HcalHit : public CalorimeterHit { +class HcalHit : public ldmx::CalorimeterHit { public: /** * Class constructor. @@ -84,7 +84,6 @@ class HcalHit : public CalorimeterHit { */ ClassDef(HcalHit, 2); }; - } // namespace ldmx #endif /* HCAL_EVENT_HCALHIT_H_ */ diff --git a/include/Hcal/Event/HcalVetoResult.h b/include/Hcal/Event/HcalVetoResult.h index bf42f40..922887d 100644 --- a/include/Hcal/Event/HcalVetoResult.h +++ b/include/Hcal/Event/HcalVetoResult.h @@ -38,7 +38,7 @@ class HcalVetoResult { bool passesVeto() const { return passesVeto_; }; /** @return The maximum PE HcalHit. */ - inline HcalHit getMaxPEHit() const { return maxPEHit_; } + inline ldmx::HcalHit getMaxPEHit() const { return maxPEHit_; } /** * Sets whether the Hcal veto was passed or not. @@ -54,11 +54,13 @@ class HcalVetoResult { * * @param maxPEHit The maximum PE HcalHit */ - inline void setMaxPEHit(const HcalHit maxPEHit) { maxPEHit_ = maxPEHit; } + inline void setMaxPEHit(const ldmx::HcalHit maxPEHit) { + maxPEHit_ = maxPEHit; + } private: /** Reference to max PE hit. */ - HcalHit maxPEHit_; + ldmx::HcalHit maxPEHit_; /** Flag indicating whether the event passes the Hcal veto. */ bool passesVeto_{false}; diff --git a/include/Hcal/HcalDigiProducer.h b/include/Hcal/HcalDigiProducer.h index f2fbf35..2cacbcf 100644 --- a/include/Hcal/HcalDigiProducer.h +++ b/include/Hcal/HcalDigiProducer.h @@ -19,15 +19,15 @@ #include "Framework/EventProcessor.h" #include "Tools/NoiseGenerator.h" -namespace ldmx { +namespace hcal { /** * @class HcalDigiProducer * @brief Performs digitization of simulated HCal data */ -class HcalDigiProducer : public Producer { +class HcalDigiProducer : public framework::Producer { public: - HcalDigiProducer(const std::string& name, Process& process); + HcalDigiProducer(const std::string& name, framework::Process& process); virtual ~HcalDigiProducer() { ; } @@ -36,19 +36,19 @@ class HcalDigiProducer : public Producer { * * @param parameters Set of parameters used to configure this processor. */ - void configure(Parameters& parameters) final override; + void configure(framework::config::Parameters& parameters) final override; - virtual void produce(Event& event); + virtual void produce(framework::Event& event); - HcalID generateRandomID(HcalID::HcalSection sec); - void constructNoiseHit(std::vector&, HcalID::HcalSection, double, - double, const std::map&, + ldmx::HcalID generateRandomID(ldmx::HcalID::HcalSection sec); + void constructNoiseHit(std::vector&, ldmx::HcalID::HcalSection, + double, double, const std::map&, std::unordered_set&); private: bool verbose_{false}; std::unique_ptr random_{nullptr}; - std::unique_ptr noiseGenerator_{nullptr}; + std::unique_ptr noiseGenerator_{nullptr}; double meanNoise_{0}; int nProcessed_{0}; @@ -67,6 +67,6 @@ class HcalDigiProducer : public Producer { int SUPER_STRIP_SIZE_{1}; }; -} // namespace ldmx +} // namespace hcal #endif diff --git a/include/Hcal/HcalVetoProcessor.h b/include/Hcal/HcalVetoProcessor.h index 1f5870a..7762a43 100644 --- a/include/Hcal/HcalVetoProcessor.h +++ b/include/Hcal/HcalVetoProcessor.h @@ -20,12 +20,12 @@ #include "Framework/Configure/Parameters.h" #include "Framework/EventProcessor.h" -namespace ldmx { +namespace hcal { -class HcalVetoProcessor : public Producer { +class HcalVetoProcessor : public framework::Producer { public: /** Constructor */ - HcalVetoProcessor(const std::string &name, Process &process); + HcalVetoProcessor(const std::string &name, framework::Process &process); /** Destructor */ ~HcalVetoProcessor(); @@ -35,7 +35,7 @@ class HcalVetoProcessor : public Producer { * * @param parameters Set of parameters used to configure this processor. */ - void configure(Parameters ¶meters) final override; + void configure(framework::config::Parameters ¶meters) final override; /** * Run the processor and create a collection of results which @@ -43,7 +43,7 @@ class HcalVetoProcessor : public Producer { * * @param event The event to process. */ - void produce(Event &event); + void produce(framework::Event &event); private: /** Total PE threshold. */ @@ -59,6 +59,6 @@ class HcalVetoProcessor : public Producer { float minPE_{1}; }; // HcalVetoProcessor -} // namespace ldmx +} // namespace hcal #endif // HCAL_HCALVETOPROCESSOR_H_ diff --git a/python/hcal.py b/python/hcal.py index 5556775..a146cad 100644 --- a/python/hcal.py +++ b/python/hcal.py @@ -14,7 +14,7 @@ class HcalDigiProducer(ldmxcfg.Producer) : """ def __init__(self,name = 'hcalDigis') : - super().__init__(name,'ldmx::HcalDigiProducer','Hcal') + super().__init__(name,'hcal::HcalDigiProducer','Hcal') self.meanNoise = 0.02 self.readoutThreshold= 1 @@ -43,7 +43,7 @@ class HcalVetoProcessor(ldmxcfg.Producer) : """ def __init__(self,name = 'hcalVeto') : - super().__init__(name,'ldmx::HcalVetoProcessor','Hcal') + super().__init__(name,'hcal::HcalVetoProcessor','Hcal') self.pe_threshold = 5.0 self.max_time = 50.0 diff --git a/src/Hcal/Event/HcalHit.cxx b/src/Hcal/Event/HcalHit.cxx index 0d1620e..6411d76 100644 --- a/src/Hcal/Event/HcalHit.cxx +++ b/src/Hcal/Event/HcalHit.cxx @@ -7,7 +7,7 @@ ClassImp(ldmx::HcalHit) namespace ldmx { void HcalHit::Clear() { - CalorimeterHit::Clear(); + ldmx::CalorimeterHit::Clear(); pe_ = 0; minpe_ = -99; } @@ -19,4 +19,4 @@ ClassImp(ldmx::HcalHit) << "ns, amplitude: " << getAmplitude() << ", pe: " << getPE() << "}" << std::endl; } -} +} // namespace ldmx diff --git a/src/Hcal/Event/HcalVetoResult.cxx b/src/Hcal/Event/HcalVetoResult.cxx index 56a737a..32a5652 100644 --- a/src/Hcal/Event/HcalVetoResult.cxx +++ b/src/Hcal/Event/HcalVetoResult.cxx @@ -1,10 +1,3 @@ -/** - * @file HcalVetoResult.h - * @brief Class used to encapsulate the results obtained from - * HcalVetoProcessor. - * @author Omar Moreno, SLAC National Accelerator Laboratory - */ - #include "Hcal/Event/HcalVetoResult.h" //----------------// @@ -31,4 +24,4 @@ ClassImp(ldmx::HcalVetoResult) << " Passes veto: " << passesVeto_ << std::endl; maxPEHit_.Print(); } -} +} // namespace ldmx diff --git a/src/Hcal/HcalDigiProducer.cxx b/src/Hcal/HcalDigiProducer.cxx index d836cbd..682bbc9 100644 --- a/src/Hcal/HcalDigiProducer.cxx +++ b/src/Hcal/HcalDigiProducer.cxx @@ -9,12 +9,13 @@ #include #include -namespace ldmx { +namespace hcal { -HcalDigiProducer::HcalDigiProducer(const std::string& name, Process& process) +HcalDigiProducer::HcalDigiProducer(const std::string& name, + framework::Process& process) : Producer(name, process) {} -void HcalDigiProducer::configure(Parameters& parameters) { +void HcalDigiProducer::configure(framework::config::Parameters& parameters) { STRIPS_BACK_PER_LAYER_ = parameters.getParameter("strips_back_per_layer"); NUM_BACK_HCAL_LAYERS_ = parameters.getParameter("num_back_hcal_layers"); @@ -37,39 +38,39 @@ void HcalDigiProducer::configure(Parameters& parameters) { parameters.getParameter("strip_position_resolution"); sim_hit_pass_name_ = parameters.getParameter("sim_hit_pass_name"); - noiseGenerator_ = std::make_unique(meanNoise_, false); + noiseGenerator_ = std::make_unique(meanNoise_, false); noiseGenerator_->setNoiseThreshold( 1); // hard-code this number, create noise hits for non-zero PEs! } -HcalID HcalDigiProducer::generateRandomID(HcalID::HcalSection sec) { +ldmx::HcalID HcalDigiProducer::generateRandomID(ldmx::HcalID::HcalSection sec) { int layer, strip; - HcalID::HcalSection section = sec; - if (sec == HcalID::BACK) { + ldmx::HcalID::HcalSection section = sec; + if (sec == ldmx::HcalID::BACK) { layer = random_->Integer(NUM_BACK_HCAL_LAYERS_); strip = random_->Integer(STRIPS_BACK_PER_LAYER_ / SUPER_STRIP_SIZE_); - } else if (sec == HcalID::TOP || sec == HcalID::BOTTOM) { + } else if (sec == ldmx::HcalID::TOP || sec == ldmx::HcalID::BOTTOM) { layer = random_->Integer(NUM_SIDE_TB_HCAL_LAYERS_); - section = HcalID::HcalSection(random_->Integer(2) + 1); + section = ldmx::HcalID::HcalSection(random_->Integer(2) + 1); strip = random_->Integer(STRIPS_SIDE_TB_PER_LAYER_); - } else if (sec == HcalID::LEFT || sec == HcalID::RIGHT) { + } else if (sec == ldmx::HcalID::LEFT || sec == ldmx::HcalID::RIGHT) { layer = random_->Integer(NUM_SIDE_LR_HCAL_LAYERS_); - section = HcalID::HcalSection(random_->Integer(2) + 3); + section = ldmx::HcalID::HcalSection(random_->Integer(2) + 3); strip = random_->Integer(STRIPS_SIDE_LR_PER_LAYER_); } else std::cout << "WARNING [HcalDigiProducer::generateRandomID]: HcalSection is " "not known" << std::endl; - return HcalID(section, layer, strip); + return ldmx::HcalID(section, layer, strip); } void HcalDigiProducer::constructNoiseHit( - std::vector& hcalRecHits, HcalID::HcalSection section, + std::vector& hcalRecHits, ldmx::HcalID::HcalSection section, double total_noise, double min_noise, const std::map& hcaldetIDEdep, std::unordered_set& noiseHitIDs) { - HcalHit noiseHit; + ldmx::HcalHit noiseHit; noiseHit.setPE(total_noise); noiseHit.setMinPE(min_noise); noiseHit.setAmplitude(total_noise); @@ -92,19 +93,19 @@ void HcalDigiProducer::constructNoiseHit( hcalRecHits.push_back(noiseHit); } -void HcalDigiProducer::produce(Event& event) { +void HcalDigiProducer::produce(framework::Event& event) { // Need to handle seeding on the first event if (!noiseGenerator_->hasSeed()) { - const RandomNumberSeedService& rseed = - getCondition( - RandomNumberSeedService::CONDITIONS_OBJECT_NAME); + const framework::RandomNumberSeedService& rseed = + getCondition( + framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME); noiseGenerator_->seedGenerator( rseed.getSeed("HcalDigiProducer::NoiseGenerator")); } if (random_.get() == nullptr) { - const RandomNumberSeedService& rseed = - getCondition( - RandomNumberSeedService::CONDITIONS_OBJECT_NAME); + const framework::RandomNumberSeedService& rseed = + getCondition( + framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME); random_ = std::make_unique(rseed.getSeed("HcalDigiProducer")); } @@ -132,12 +133,12 @@ void HcalDigiProducer::produce(Event& event) { } // looper over sim hits and aggregate energy depositions for each detID - auto hcalHits{event.getCollection( - EventConstants::HCAL_SIM_HITS, sim_hit_pass_name_)}; + auto hcalHits{event.getCollection( + ldmx::EventConstants::HCAL_SIM_HITS, sim_hit_pass_name_)}; - for (const SimCalorimeterHit& simHit : hcalHits) { + for (const ldmx::SimCalorimeterHit& simHit : hcalHits) { int detIDraw = simHit.getID(); - HcalID detID(detIDraw); + ldmx::HcalID detID(detIDraw); int layer = detID.layer(); int subsection = detID.section(); int strip = detID.strip(); @@ -151,7 +152,7 @@ void HcalDigiProducer::produce(Event& event) { // Hcal if (SUPER_STRIP_SIZE_ != 1 && subsection == 0) { int newstrip = strip / SUPER_STRIP_SIZE_; - detID = HcalID(detID.section(), detID.layer(), newstrip); + detID = ldmx::HcalID(detID.section(), detID.layer(), newstrip); detIDraw = detID.raw(); } @@ -176,7 +177,7 @@ void HcalDigiProducer::produce(Event& event) { } // loop over detIDs and simulate number of PEs - std::vector hcalRecHits; + std::vector hcalRecHits; for (std::map::iterator it = hcaldetIDEdep.begin(); it != hcaldetIDEdep.end(); ++it) { int detIDraw = it->first; @@ -187,19 +188,19 @@ void HcalDigiProducer::produce(Event& event) { hcalZpos[detIDraw] = hcalZpos[detIDraw] / hcaldetIDEdep[detIDraw]; double meanPE = depEnergy / mev_per_mip_ * pe_per_mip_; - HcalID curDetId(detIDraw); + ldmx::HcalID curDetId(detIDraw); int cur_subsection = curDetId.section(); int cur_layer = curDetId.layer(); int cur_strip = curDetId.strip(); - if (curDetId.getSection() == HcalID::BACK) + if (curDetId.getSection() == ldmx::HcalID::BACK) numSigHits_back++; - else if (curDetId.getSection() == HcalID::TOP || - curDetId.getSection() == HcalID::BOTTOM) + else if (curDetId.getSection() == ldmx::HcalID::TOP || + curDetId.getSection() == ldmx::HcalID::BOTTOM) numSigHits_side_tb++; - else if (curDetId.getSection() == HcalID::LEFT || - curDetId.getSection() == HcalID::RIGHT) + else if (curDetId.getSection() == ldmx::HcalID::LEFT || + curDetId.getSection() == ldmx::HcalID::RIGHT) numSigHits_side_lr++; else std::cout @@ -271,12 +272,13 @@ void HcalDigiProducer::produce(Event& event) { // This is the quantized position along the length of the bar - LEFT/RIGHT // is for fixed HCAL geometry // float ecal_width_(525); - // if (cur_subsection == HcalID::TOP) cur_xpos = half_total_width/2.0 - // - ecal_width/4.0; if (cur_subsection == HcalID::BOTTOM) cur_xpos = - // -half_total_width/2.0 + ecal_width/4.0; if (cur_subsection == - // HcalID::LEFT) cur_ypos = half_total_width/2.0 - ecal_width/4.0; if - // (cur_subsection == HcalID::RIGHT) cur_ypos = -half_total_width/2.0 + - // ecal_width/4.0; + // if (cur_subsection == ldmx::HcalID::TOP) cur_xpos = + // half_total_width/2.0 + // - ecal_width/4.0; if (cur_subsection == ldmx::HcalID::BOTTOM) cur_xpos + // = -half_total_width/2.0 + ecal_width/4.0; if (cur_subsection == + // ldmx::HcalID::LEFT) cur_ypos = half_total_width/2.0 - + // ecal_width/4.0; if (cur_subsection == ldmx::HcalID::RIGHT) cur_ypos = + // -half_total_width/2.0 + ecal_width/4.0; // This would be the quantized z position. The side_hcal_z0 value must be // derived fromn the geometry! float side_hcal_z0(215.5); cur_zpos = @@ -284,18 +286,18 @@ void HcalDigiProducer::produce(Event& event) { // This is the quantized position along the thickness of the bar - check // RIGHT / LEFT float back_hcal_layer_thickness(39); float - // side_hcal_xy_offset(294); if (cur_subsection == HcalID::TOP) cur_ypos - // = side_hcal_xy_offset+(cur_layer-1)*back_hcal_layer_thickness; if - // (cur_subsection == HcalID::BOTTOM) cur_ypos = + // side_hcal_xy_offset(294); if (cur_subsection == ldmx::HcalID::TOP) + // cur_ypos = side_hcal_xy_offset+(cur_layer-1)*back_hcal_layer_thickness; + // if (cur_subsection == ldmx::HcalID::BOTTOM) cur_ypos = // -side_hcal_xy_offset-(cur_layer-1)*back_hcal_layer_thickness; if - // (cur_subsection == HcalID::LEFT) cur_xpos = + // (cur_subsection == ldmx::HcalID::LEFT) cur_xpos = // -side_hcal_xy_offset-(cur_layer-1)*back_hcal_layer_thickness; if - // (cur_subsection == HcalID::RIGHT) cur_xpos = + // (cur_subsection == ldmx::HcalID::RIGHT) cur_xpos = // side_hcal_xy_offset+(cur_layer-1)*back_hcal_layer_thickness; } if (hcalLayerPEs[detIDraw] >= readoutThreshold_) { - HcalHit hit; + ldmx::HcalHit hit; hit.setID(detIDraw); hit.setPE(hcalLayerPEs[detIDraw]); hit.setMinPE(hcalLayerMinPEs[detIDraw]); @@ -311,7 +313,7 @@ void HcalDigiProducer::produce(Event& event) { } if (verbose_) { - HcalID detID(detIDraw); + ldmx::HcalID detID(detIDraw); int layer = detID.layer(); int subsection = detID.section(); @@ -353,7 +355,7 @@ void HcalDigiProducer::produce(Event& event) { if (total_noise < readoutThreshold_) continue; double min_noise = std::min(cur_noise_pe_1, cur_noise_pe_2); - constructNoiseHit(hcalRecHits, HcalID::BACK, total_noise, min_noise, + constructNoiseHit(hcalRecHits, ldmx::HcalID::BACK, total_noise, min_noise, hcaldetIDEdep, noiseHitIDs); ctr_back_noise++; } @@ -366,10 +368,10 @@ void HcalDigiProducer::produce(Event& event) { (STRIPS_SIDE_TB_PER_LAYER_ * NUM_SIDE_TB_HCAL_LAYERS_) * 2 - numSigHits_side_tb); for (auto noise : noiseHits_PE) { - constructNoiseHit(hcalRecHits, HcalID::TOP, noise, noise, hcaldetIDEdep, - noiseHitIDs); - constructNoiseHit(hcalRecHits, HcalID::BOTTOM, noise, noise, hcaldetIDEdep, - noiseHitIDs); + constructNoiseHit(hcalRecHits, ldmx::HcalID::TOP, noise, noise, + hcaldetIDEdep, noiseHitIDs); + constructNoiseHit(hcalRecHits, ldmx::HcalID::BOTTOM, noise, noise, + hcaldetIDEdep, noiseHitIDs); } // simulate noise hits in side, left / right hcal @@ -377,15 +379,15 @@ void HcalDigiProducer::produce(Event& event) { (STRIPS_SIDE_LR_PER_LAYER_ * NUM_SIDE_LR_HCAL_LAYERS_) * 2 - numSigHits_side_lr); for (auto noise : noiseHits_PE) { - constructNoiseHit(hcalRecHits, HcalID::LEFT, noise, noise, hcaldetIDEdep, - noiseHitIDs); - constructNoiseHit(hcalRecHits, HcalID::RIGHT, noise, noise, hcaldetIDEdep, - noiseHitIDs); + constructNoiseHit(hcalRecHits, ldmx::HcalID::LEFT, noise, noise, + hcaldetIDEdep, noiseHitIDs); + constructNoiseHit(hcalRecHits, ldmx::HcalID::RIGHT, noise, noise, + hcaldetIDEdep, noiseHitIDs); } event.add("HcalRecHits", hcalRecHits); } -} // namespace ldmx +} // namespace hcal -DECLARE_PRODUCER_NS(ldmx, HcalDigiProducer); +DECLARE_PRODUCER_NS(hcal, HcalDigiProducer); diff --git a/src/Hcal/HcalVetoProcessor.cxx b/src/Hcal/HcalVetoProcessor.cxx index 96f8bf0..b6c5db0 100644 --- a/src/Hcal/HcalVetoProcessor.cxx +++ b/src/Hcal/HcalVetoProcessor.cxx @@ -11,31 +11,32 @@ //-------------// #include "DetDescr/HcalID.h" -namespace ldmx { +namespace hcal { -HcalVetoProcessor::HcalVetoProcessor(const std::string &name, Process &process) +HcalVetoProcessor::HcalVetoProcessor(const std::string &name, + framework::Process &process) : Producer(name, process) {} HcalVetoProcessor::~HcalVetoProcessor() {} -void HcalVetoProcessor::configure(Parameters ¶meters) { +void HcalVetoProcessor::configure(framework::config::Parameters ¶meters) { totalPEThreshold_ = parameters.getParameter("pe_threshold"); maxTime_ = parameters.getParameter("max_time"); maxDepth_ = parameters.getParameter("max_depth"); minPE_ = parameters.getParameter("back_min_pe"); } -void HcalVetoProcessor::produce(Event &event) { +void HcalVetoProcessor::produce(framework::Event &event) { // Get the collection of sim particles from the event - const std::vector hcalRecHits = - event.getCollection("HcalRecHits"); + const std::vector hcalRecHits = + event.getCollection("HcalRecHits"); // Loop over all of the Hcal hits and calculate to total photoelectrons // in the event. float totalPe{0}; float maxPE{-1000}; - const HcalHit *maxPEHit; - for (const HcalHit &hcalHit : hcalRecHits) { + const ldmx::HcalHit *maxPEHit; + for (const ldmx::HcalHit &hcalHit : hcalRecHits) { // If the hit time is outside the readout window, don't consider it. if (hcalHit.getTime() >= maxTime_) continue; @@ -52,8 +53,8 @@ void HcalVetoProcessor::produce(Event &event) { // If not, don't consider the hit. Double sided readout is only // being used for the back HCal bars. For the side HCal, just // use the maximum PE as before. - HcalID id(hcalHit.getID()); - if ((id.section() == HcalID::BACK) && (hcalHit.getMinPE() < minPE_)) + ldmx::HcalID id(hcalHit.getID()); + if ((id.section() == ldmx::HcalID::BACK) && (hcalHit.getMinPE() < minPE_)) continue; // Find the maximum PE in the list @@ -66,18 +67,18 @@ void HcalVetoProcessor::produce(Event &event) { // If the maximum PE found is below threshold, it passes the veto. bool passesVeto = (maxPE < totalPEThreshold_); - HcalVetoResult result; + ldmx::HcalVetoResult result; result.setVetoResult(passesVeto); result.setMaxPEHit(*maxPEHit); if (passesVeto) { - setStorageHint(hint_shouldKeep); + setStorageHint(framework::hint_shouldKeep); } else { - setStorageHint(hint_shouldDrop); + setStorageHint(framework::hint_shouldDrop); } event.add("HcalVeto", result); } -} // namespace ldmx +} // namespace hcal -DECLARE_PRODUCER_NS(ldmx, HcalVetoProcessor); +DECLARE_PRODUCER_NS(hcal, HcalVetoProcessor);