88 typedef long long int time;
129 produces<std::vector<CRT::Trigger>>();
130 produces<art::Assns<sim::AuxDetSimChannel, CRT::Trigger>>();
131 consumes<std::vector<sim::AuxDetSimChannel>>(
fSimLabel);
141 auto trigCol = std::make_unique<std::vector<CRT::Trigger>>();
142 auto simToTrigger = std::make_unique<art::Assns<sim::AuxDetSimChannel, CRT::Trigger>>();
154 std::map<uint32_t, art::PtrVector<sim::AuxDetSimChannel>> moduleToChannels;
155 for(
size_t channelPos = 0; channelPos <
channels->size(); ++channelPos)
157 const auto id = (*channels)[channelPos].AuxDetID();
158 const auto& det = geom->
AuxDet(
id);
159 if(det.Name().find(
"CRT") != std::string::npos)
161 moduleToChannels[id].push_back(makeSimPtr(channelPos));
165 MF_LOG_DEBUG(
"moduleToChannels") <<
"Got " << moduleToChannels.size() <<
" modules to process in detector simulation.\n";
168 for(
auto& pair: moduleToChannels)
170 auto& module = pair.second;
182 MF_LOG_DEBUG(
"moduleToChannels") <<
"Processing " << module.size() <<
" channels in module " << pair.first <<
"\n";
183 std::map<time, std::vector<std::pair<CRT::Hit, art::Ptr<sim::AuxDetSimChannel>>>>timeToHits;
184 for(
const auto&
channel: module)
187 const auto& ides =
channel->AuxDetIDEs();
188 for(
const auto& eDep: ides)
190 const size_t tAvg = (eDep.exitT+eDep.entryT)/2.;
196 std::stringstream ss;
197 auto lastTimeStamp=
time(0);
199 for(
auto window : timeToHits)
201 if (i!=0 && (
time(
fDeadtime)+lastTimeStamp)>window.first && lastTimeStamp<window.first)
continue;
203 const auto& hitsInWindow = window.second;
204 const auto aboveThresh = std::find_if(hitsInWindow.begin(), hitsInWindow.end(),
205 [
this](
const auto& hitPair) {
return hitPair.first.ADC() >
fDACThreshold; });
208 if(aboveThresh != hitsInWindow.end()){
210 std::vector<CRT::Hit> hits;
211 const time timestamp = window.first;
213 std::set<uint32_t> channelBusy;
215 for(
auto busyCheckWindow : timeToHits){
216 if (
time(busyCheckWindow.first)<timestamp ||
time(busyCheckWindow.first)>
end)
continue;
217 for(
const auto& hitPair: window.second)
219 const auto channel = hitPair.first.Channel();
221 if(channelBusy.insert(
channel).second)
223 hits.push_back(hitPair.first);
224 simToTrigger->addSingle(hitPair.second, makeTrigPtr(trigCol->size()-1));
229 lastTimeStamp=window.first;
231 MF_LOG_DEBUG(
"CreateTrigger") <<
"Creating CRT::Trigger...\n";
239 MF_LOG_DEBUG(
"CreateTrigger") <<
"Putting " << trigCol->size() <<
" CRT::Triggers into the event at the end of analyze().\n";
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
EDProducer(fhicl::ParameterSet const &pset)
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
size_t fReadoutWindowSize
void produce(art::Event &e) override
CRTSim & operator=(CRTSim const &)=delete
CRTSim(fhicl::ParameterSet const &p)