All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
sbnd::crt::CRTSlimmer Class Reference
Inheritance diagram for sbnd::crt::CRTSlimmer:

Public Member Functions

 CRTSlimmer (fhicl::ParameterSet const &p)
 
 CRTSlimmer (CRTSlimmer const &)=delete
 
 CRTSlimmer (CRTSlimmer &&)=delete
 
CRTSlimmeroperator= (CRTSlimmer const &)=delete
 
CRTSlimmeroperator= (CRTSlimmer &&)=delete
 
void produce (art::Event &e) override
 

Private Attributes

std::string _feb_data_producer
 
uint16_t _adc_threshold
 

Detailed Description

Definition at line 50 of file CRTSlimmer_module.cc.

Constructor & Destructor Documentation

sbnd::crt::CRTSlimmer::CRTSlimmer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 73 of file CRTSlimmer_module.cc.

74  : EDProducer{p}
75  , _feb_data_producer(p.get<std::string>("FEBDataProducer"))
76  , _adc_threshold(p.get<uint16_t>("ADCThreshold"))
77 {
78  produces<std::vector<sbnd::crt::CRTData>>();
79  produces<art::Assns<sbnd::crt::CRTData, sbnd::crt::FEBData>>();
80  produces<art::Assns<sbnd::crt::CRTData, sim::AuxDetIDE>>();
81 
82  consumes<std::vector<sbnd::crt::FEBData>>(_feb_data_producer);
83  consumes<art::Assns<sbnd::crt::FEBData, sim::AuxDetIDE, sbnd::crt::FEBTruthInfo>>(_feb_data_producer);
84 }
pdgs p
Definition: selectors.fcl:22
sbnd::crt::CRTSlimmer::CRTSlimmer ( CRTSlimmer const &  )
delete
sbnd::crt::CRTSlimmer::CRTSlimmer ( CRTSlimmer &&  )
delete

Member Function Documentation

CRTSlimmer& sbnd::crt::CRTSlimmer::operator= ( CRTSlimmer const &  )
delete
CRTSlimmer& sbnd::crt::CRTSlimmer::operator= ( CRTSlimmer &&  )
delete
void sbnd::crt::CRTSlimmer::produce ( art::Event &  e)
override

Definition at line 86 of file CRTSlimmer_module.cc.

87 {
88  // Implementation of required member function here.
89  std::unique_ptr<std::vector<sbnd::crt::CRTData>> crt_data_v(new std::vector<sbnd::crt::CRTData>);
90  std::unique_ptr<art::Assns<sbnd::crt::CRTData, sbnd::crt::FEBData>> crtdata_to_febdata_assns
91  (new art::Assns<sbnd::crt::CRTData, sbnd::crt::FEBData>);
92  std::unique_ptr<art::Assns<sbnd::crt::CRTData, sim::AuxDetIDE>> crtdata_to_ide_assns
93  (new art::Assns<sbnd::crt::CRTData, sim::AuxDetIDE>);
94 
95  art::Handle<std::vector<sbnd::crt::FEBData>> feb_data_h;
96  e.getByLabel(_feb_data_producer, feb_data_h);
97 
98  // make sure hits look good
99  if (!feb_data_h.isValid()) {
100  throw art::Exception(art::errors::Configuration) << "could not locate FEBData." << std::endl;;
101  }
102 
103  std::vector<art::Ptr<sbnd::crt::FEBData>> feb_data_v;
104  art::fill_ptr_vector(feb_data_v, feb_data_h);
105 
106  art::FindManyP<sim::AuxDetIDE, sbnd::crt::FEBTruthInfo> febdata_to_ides (feb_data_h, e, _feb_data_producer);
107 
108  art::PtrMaker<sbnd::crt::CRTData> makeDataPtr(e);
109 
110  for (size_t feb_i = 0; feb_i < feb_data_v.size(); feb_i++) {
111 
112  auto const feb_data = feb_data_v[feb_i];
113  mf::LogDebug("CRTSlimmer") << "FEB " << feb_i << " with mac " << feb_data->Mac5() << std::endl;
114 
115  auto ides = febdata_to_ides.at(feb_data.key());
116  mf::LogDebug("CRTSlimmer") << "We have " << ides.size() << " IDEs." << std::endl;
117 
118  // Construct a map to go from SiPM ID to the index of the IDE
119  // FEBTruthInfo stores, for each AuxDetIDE, a vector containing
120  // the SiPM IDs contributing to that energy deposit
121  std::map<int, std::vector<int>> sipm_to_ideids;
122  for (size_t j = 0; j < 32; j++) sipm_to_ideids[j] = std::vector<int>();
123  for (size_t ide_i = 0; ide_i < febdata_to_ides.data(feb_i).size(); ide_i++) {
124  const sbnd::crt::FEBTruthInfo *fti = febdata_to_ides.data(feb_i)[ide_i];
125  sipm_to_ideids[fti->GetChannel()].push_back(ide_i);
126  mf::LogDebug("CRTSlimmer") << "ide_i " << ide_i << " ene " << ides[ide_i]->energyDeposited << " fti->GetChannel() " << fti->GetChannel() << std::endl;
127  }
128 
129  auto adcs = feb_data->ADC();
130 
131  for (size_t i = 0; i < adcs.size(); i+=2) {
132 
133  // Both sipms need to be above threshold to save them
134  if (not (adcs[i] >= _adc_threshold and adcs[i+1] >= _adc_threshold)) {
135  continue;
136  }
137 
138  for (size_t sipm = 0; sipm < 2; sipm++) {
139  sbnd::crt::CRTData crt_data = sbnd::crt::CRTData(feb_data->Mac5() * 32 + i + sipm,
140  feb_data->Ts0(),
141  feb_data->Ts1(),
142  adcs[i+sipm]);
143 
144  mf::LogDebug("CRTSlimmer") << "Adding SiPM " << i + sipm << " with mac " << feb_data->Mac5()
145  << " mapped to channel " << crt_data.Channel() << std::endl;
146 
147  crt_data_v->emplace_back(std::move(crt_data));
148 
149  art::Ptr<sbnd::crt::CRTData> crt_data_p = makeDataPtr(crt_data_v->size() - 1);
150 
151  // Create the association between CRTData and FEBData
152  crtdata_to_febdata_assns->addSingle(crt_data_p, feb_data);
153 
154  // Create the association between CRTData and AuxDetIDEs
155  auto & ide_ids = sipm_to_ideids[i];
156  for (auto ide_id: ide_ids) {
157  auto ide = ides[ide_id];
158  mf::LogDebug("CRTSlimmer") << "Adding IDE with ID " << ide_id << std::endl;
159  crtdata_to_ide_assns->addSingle(crt_data_p, ide);
160  }
161  }
162  }
163  }
164 
165  mf::LogInfo("CRTSlimmer") << "Creating " << crt_data_v->size()
166  << " CRTData products." << std::endl;
167 
168  e.put(std::move(crt_data_v));
169  e.put(std::move(crtdata_to_febdata_assns));
170  e.put(std::move(crtdata_to_ide_assns));
171 }
uint32_t Channel() const
Definition: CRTData.cxx:20
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
do i e

Member Data Documentation

uint16_t sbnd::crt::CRTSlimmer::_adc_threshold
private

Definition at line 68 of file CRTSlimmer_module.cc.

std::string sbnd::crt::CRTSlimmer::_feb_data_producer
private

Definition at line 67 of file CRTSlimmer_module.cc.


The documentation for this class was generated from the following file: