diff --git a/DQM/python/dqm.py b/DQM/python/dqm.py index 3d66bc76d..bed4ccbed 100644 --- a/DQM/python/dqm.py +++ b/DQM/python/dqm.py @@ -391,23 +391,29 @@ def __init__(self, input_name) : class NtuplizeHgcrocDigiCollection(ldmxcfg.Analyzer) : def __init__(self,input_name, pedestal_table = None, input_pass = '', - using_eid = None, already_aligned = False, + using_eid = None, already_aligned = False, is_simulation = False, name = 'ntuplizehgcroc') : super().__init__(name,'dqm::NtuplizeHgcrocDigiCollection','DQM') self.input_name = input_name self.input_pass = input_pass - if using_eid is None : - # deduce if using eid based on presence of HcalDetectorMap in conditions system - from LDMX.Framework import ldmxcfg - from LDMX.Hcal.DetectorMap import HcalDetectorMap - using_eid = True - for cop in ldmxcfg.Process.lastProcess.conditionsObjectProviders : - if isinstance(cop,HcalDetectorMap) : - using_eid = False - break - self.using_eid = using_eid - self.already_aligned = already_aligned + self.is_simulation = is_simulation + + if is_simulation: + self.using_eid = False + self.already_aligned = True + else: + if using_eid is None : + # deduce if using eid based on presence of HcalDetectorMap in conditions system + from LDMX.Framework import ldmxcfg + from LDMX.Hcal.DetectorMap import HcalDetectorMap + using_eid = True + for cop in ldmxcfg.Process.lastProcess.conditionsObjectProviders : + if isinstance(cop,HcalDetectorMap) : + using_eid = False + break + self.using_eid = using_eid + self.already_aligned = already_aligned from LDMX.Conditions.SimpleCSVTableProvider import SimpleCSVIntegerTableProvider if pedestal_table is None : diff --git a/DQM/src/DQM/NtuplizeHgcrocDigiCollection.cxx b/DQM/src/DQM/NtuplizeHgcrocDigiCollection.cxx index 933860b4e..03e4bd096 100644 --- a/DQM/src/DQM/NtuplizeHgcrocDigiCollection.cxx +++ b/DQM/src/DQM/NtuplizeHgcrocDigiCollection.cxx @@ -15,7 +15,7 @@ class NtuplizeHgcrocDigiCollection : public framework::Analyzer { int fpga_, link_, channel_, index_; int section_, layer_, strip_, end_; bool tot_prog_, tot_comp_, aligned_; - bool using_eid_, already_aligned_; + bool using_eid_, already_aligned_, is_simulation_; bool good_link_; TTree* flat_tree_; @@ -30,6 +30,7 @@ class NtuplizeHgcrocDigiCollection : public framework::Analyzer { pedestal_table_ = ps.getParameter("pedestal_table"); using_eid_ = ps.getParameter("using_eid"); already_aligned_ = ps.getParameter("already_aligned"); + is_simulation_ = ps.getParameter("is_simulation"); } void onProcessStart() final override { @@ -45,7 +46,7 @@ class NtuplizeHgcrocDigiCollection : public framework::Analyzer { flat_tree_->Branch("raw_adc", &raw_adc_); flat_tree_->Branch("i_sample", &i_sample_); flat_tree_->Branch("ldmxsw_event", &ldmxsw_event_); - if (not already_aligned_) { + if (not already_aligned_ || is_simulation_ ) { flat_tree_->Branch("pf_event", &pf_event_); flat_tree_->Branch("pf_spill", &pf_spill_); flat_tree_->Branch("pf_ticks", &pf_ticks_); @@ -77,53 +78,91 @@ void NtuplizeHgcrocDigiCollection::analyze(const framework::Event& event) { hcal::HcalDetectorMap::CONDITIONS_OBJECT_NAME)}; ldmxsw_event_ = event.getEventNumber(); - if (already_aligned_) { - aligned_ = event.getObject(input_name_ + "Aligned", input_pass_); - } else { - aligned_ = false; - version_ = event.getObject(input_name_ + "Version", input_pass_); - pf_event_ = event.getObject(input_name_ + "Number", input_pass_); - pf_ticks_ = event.getObject(input_name_ + "Ticks", input_pass_); - pf_spill_ = event.getObject(input_name_ + "Spill", input_pass_); + if(not is_simulation_){ + if (already_aligned_) { + aligned_ = event.getObject(input_name_ + "Aligned", input_pass_); + } else { + aligned_ = false; + version_ = event.getObject(input_name_ + "Version", input_pass_); + pf_event_ = event.getObject(input_name_ + "Number", input_pass_); + pf_ticks_ = event.getObject(input_name_ + "Ticks", input_pass_); + pf_spill_ = event.getObject(input_name_ + "Spill", input_pass_); + } + } + else{ + aligned_ = true; + version_ = 0; + pf_event_ = ldmxsw_event_; + pf_ticks_ = 0; + pf_spill_ = 0; } - const auto& good_bxheader{ - event.getCollection(input_name_ + "GoodLinkHeader", input_pass_)}; - const auto& good_trailer{ - event.getCollection(input_name_ + "GoodLinkTrailer", input_pass_)}; + if(not is_simulation_){ + const auto& good_bxheader{ + event.getCollection(input_name_ + "GoodLinkHeader", input_pass_)}; + const auto& good_trailer{ + event.getCollection(input_name_ + "GoodLinkTrailer", input_pass_)}; - auto const& digis{ - event.getObject(input_name_, input_pass_)}; - for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) { - auto d{digis.getDigi(i_digi)}; - raw_id_ = static_cast(d.id()); - if (using_eid_) { - ldmx::HcalElectronicsID eid(d.id()); - fpga_ = eid.fiber(); - link_ = eid.elink(); - good_link_ = (good_bxheader.at(link_) and good_trailer.at(link_)); - channel_ = eid.channel(); - index_ = eid.index(); - } else { + auto const& digis{ + event.getObject(input_name_, input_pass_)}; + for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) { + auto d{digis.getDigi(i_digi)}; + raw_id_ = static_cast(d.id()); + if (using_eid_ ) { + ldmx::HcalElectronicsID eid(d.id()); + fpga_ = eid.fiber(); + link_ = eid.elink(); + good_link_ = (good_bxheader.at(link_) and good_trailer.at(link_)); + channel_ = eid.channel(); + index_ = eid.index(); + } else { + ldmx::HcalDigiID detid(d.id()); + ldmx::HcalElectronicsID eid = detmap.get(detid); + int link = eid.elink(); + good_link_ = (good_bxheader.at(link) and good_trailer.at(link)); + section_ = detid.section(); + layer_ = detid.layer(); + strip_ = detid.strip(); + end_ = detid.end(); + } + + for (i_sample_ = 0; i_sample_ < digis.getNumSamplesPerDigi(); i_sample_++) { + tot_prog_ = d.at(i_sample_).isTOTinProgress(); + tot_comp_ = d.at(i_sample_).isTOTComplete(); + tot_ = d.at(i_sample_).tot(); + toa_ = d.at(i_sample_).toa(); + int adc_t = d.at(i_sample_).adc_t(); + raw_adc_ = adc_t; + adc_ = adc_t - pedestal_table.get(d.id(), 0); + flat_tree_->Fill(); + } + } + } + //For simulated digis + else{ + auto const& digis{ + event.getObject(input_name_, input_pass_)}; + for (std::size_t i_digi{0}; i_digi < digis.size(); i_digi++) { + auto d{digis.getDigi(i_digi)}; + raw_id_ = static_cast(d.id()); ldmx::HcalDigiID detid(d.id()); ldmx::HcalElectronicsID eid = detmap.get(detid); - int link = eid.elink(); - good_link_ = (good_bxheader.at(link) and good_trailer.at(link)); + good_link_ = true; section_ = detid.section(); layer_ = detid.layer(); strip_ = detid.strip(); end_ = detid.end(); - } - for (i_sample_ = 0; i_sample_ < digis.getNumSamplesPerDigi(); i_sample_++) { - tot_prog_ = d.at(i_sample_).isTOTinProgress(); - tot_comp_ = d.at(i_sample_).isTOTComplete(); - tot_ = d.at(i_sample_).tot(); - toa_ = d.at(i_sample_).toa(); - int adc_t = d.at(i_sample_).adc_t(); - raw_adc_ = adc_t; - adc_ = adc_t - pedestal_table.get(d.id(), 0); - flat_tree_->Fill(); + for (i_sample_ = 0; i_sample_ < digis.getNumSamplesPerDigi(); i_sample_++) { + tot_prog_ = d.at(i_sample_).isTOTinProgress(); + tot_comp_ = d.at(i_sample_).isTOTComplete(); + tot_ = d.at(i_sample_).tot(); + toa_ = d.at(i_sample_).toa(); + int adc_t = d.at(i_sample_).adc_t(); + raw_adc_ = adc_t; + adc_ = adc_t - pedestal_table.get(d.id(), 0); + flat_tree_->Fill(); + } } } }