7 #ifndef CRT_ONLINEPLOTTER_CPP 8 #define CRT_ONLINEPLOTTER_CPP 17 #include "TDirectory.h" 43 fTimestamps =
fFileService->template make<TH1D>(
"timestamps",
"Timestamps for All Modules;Timestamp;Triggers", 300, 6.592522e18, 6.592525e18);
45 "#Delta T[ns];Triggrs", 1000, -50, 100);
47 fTriggerTime =
fFileService->template make<TH1D>(
"triggerTime",
"Time of each Trigger in Run;Time [s];Triggers", 100, 0, 3);
49 fDeltaTSeconds =
fFileService->template make<TH1D>(
"deltaTSeconds",
"Difference in Elapsed Time Between Adjacent Triggers;#Delta T [s];" 50 "Triggers", 400, -0.3, 0.3);
52 fEventLength =
fFileService->template make<TH1D>(
"EventLength",
"Time Ticks Between Earliest and Latest Triggers;#DeltaT [ticks];Events",
62 const auto end = triggers.cend();
69 for(
const auto&
trigger: triggers)
81 std::map<CRT::FrameID, std::map<CRT::PlaneID, std::vector<uint64_t>>> moduleToOverlapTimes;
83 for(
auto iter = triggers.cbegin(); iter !=
end; ++iter)
94 const auto moduleID =
fGeom->ModuleID(
trigger.Channel());
95 std::cout <<
"Looking for plots for module " <<
trigger.Channel() <<
"\n";
99 std::cout <<
"Adding directory for module " <<
trigger.Channel() <<
"\n";
102 auto& module =
found->second;
105 moduleToOverlapTimes[moduleID][moduleID].push_back(
trigger.Timestamp());
118 module.fPrevSeconds = elapsed;
123 module.fTriggerDeltaT->Fill(
trigger.Timestamp()-module.fPrevTimestamp);
125 module.fPrevTimestamp =
trigger.Timestamp();
128 const auto& hits =
trigger.Hits();
129 module.fHitsPerTrigger->Fill(hits.size());
130 for(
const auto&
hit: hits)
135 const auto adcFound = module.fChannelToADC.find(
channel);
136 if(adcFound == module.fChannelToADC.end())
139 module.fChannelToADC[
channel] = module.fDir.template make<TH1D>(
name.c_str(), (
"Hits on Channel " 144 module.fChannelToADC[
channel]->Fill(
hit.ADC());
145 module.fAllADC->Fill(
hit.ADC());
150 if(triggers.size() > 1)
fEventLength->Fill(latest-earliest);
153 for(
const auto&
trigger: triggers)
155 const auto thisTime =
trigger.Timestamp();
161 auto& plots =
found->second;
163 const auto& frame = moduleToOverlapTimes[id];
164 const auto thisPlane = frame.find(
id);
165 for(
auto plane = frame.begin(); plane != frame.end(); ++plane)
167 if(plane != thisPlane)
171 for(
const auto&
time: plane->second) plots.fDeltaTOverlap->Fill(thisTime-
time);
182 template <
class DIRECTORY>
187 fHits =
fDir.template make<TH1D>(
"Hits",
"Hits for Each Channel;Channel;Hits", 65, 0, 64);
188 fTriggerDeltaT =
fDir.template make<TH1D>(
"TriggerDeltaT",
"Time Between Triggers;#Delta Timestamp [ticks];Pairs of Triggers",
190 fHitsPerTrigger =
fDir.template make<TH1D>(
"HitsPerTrigger",
"Hits in each Trigger;Hits;Triggers", 65, 0, 64);
192 fAllADC =
fDir.template make<TH1D>(
"AllADC",
"ADCs for All Channels in this Module;ADC;Hits", 1024, 0, 4096);
194 fDeltaTOverlap =
fDir.template make<TH1D>(
"DeltaTOverlap",
"Time Ticks Between Overlapping Modules' Triggers in an Event;" 195 "#DeltaT [ticks];Overlaps", 200, 0, 200);
223 std::unique_ptr<CRT::Geometry>
fGeom;
227 #endif //CRT_ONLINEPLOTTER_CPP
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
DQMPlotter(TFS &tfs, const double timeTickSize, std::unique_ptr< CRT::Geometry > &&geom)
virtual ~DQMPlotter()=default
void AnalyzeEvent(const std::vector< CRT::Trigger > &triggers)
unsigned long long fPrevTimestamp
std::map< CRT::ModuleID, ModulePlots< decltype(fFileService->mkdir("test"))> > fModules
std::unique_ptr< CRT::Geometry > fGeom
detail::Node< PlaneID, bool > ModuleID
ModulePlots(DIRECTORY &&dir)
static int max(int a, int b)
Detector simulation of raw signals on wires.
std::string to_string(ModuleType const mt)
std::map< size_t, TH1D * > fChannelToADC