Classes | Public Member Functions | Private Attributes | List of all members
CRT::DQMPlotter< TFS > Class Template Reference

Classes

struct  ModulePlots
 

Public Member Functions

 DQMPlotter (TFS &tfs, const double timeTickSize, std::unique_ptr< CRT::Geometry > &&geom)
 
virtual ~DQMPlotter ()=default
 
void AnalyzeEvent (const std::vector< CRT::Trigger > &triggers)
 

Private Attributes

TFS fFileService
 
std::map< CRT::ModuleID, ModulePlots< decltype(fFileService->mkdir("test"))> > fModules
 
TH1D * fTimestamps
 
TH1D * fTriggerDeltaT
 
TH1D * fTriggerTime
 
TH1D * fDeltaTSeconds
 
TH1D * fEventLength
 
uint64_t fFirstTime
 
const double fTickSize
 
std::unique_ptr< CRT::GeometryfGeom
 

Detailed Description

template<class TFS>
class CRT::DQMPlotter< TFS >

Definition at line 35 of file DQMPlotter.cpp.

Constructor & Destructor Documentation

template<class TFS >
CRT::DQMPlotter< TFS >::DQMPlotter ( TFS &  tfs,
const double  timeTickSize,
std::unique_ptr< CRT::Geometry > &&  geom 
)
inline

Definition at line 39 of file DQMPlotter.cpp.

39  : fFileService(tfs),
41  fTickSize(timeTickSize), fGeom(std::move(geom))
42  {
43  fTimestamps = fFileService->template make<TH1D>("timestamps", "Timestamps for All Modules;Timestamp;Triggers", 300, 6.592522e18, 6.592525e18); //Trigger automatic binning?
44  fTriggerDeltaT = fFileService->template make<TH1D>("triggerDeltaT", "Time Difference Between Two Triggers on Any Channel;"
45  "#Delta T[ns];Triggrs", 1000, -50, 100);
46 
47  fTriggerTime = fFileService->template make<TH1D>("triggerTime", "Time of each Trigger in Run;Time [s];Triggers", 100, 0, 3);
48 
49  fDeltaTSeconds = fFileService->template make<TH1D>("deltaTSeconds", "Difference in Elapsed Time Between Adjacent Triggers;#Delta T [s];"
50  "Triggers", 400, -0.3, 0.3);
51 
52  fEventLength = fFileService->template make<TH1D>("EventLength", "Time Ticks Between Earliest and Latest Triggers;#DeltaT [ticks];Events",
53  100, 0, 100);
54  }
const double fTickSize
Definition: DQMPlotter.cpp:222
std::unique_ptr< CRT::Geometry > fGeom
Definition: DQMPlotter.cpp:223
uint64_t fFirstTime
Definition: DQMPlotter.cpp:221
TH1D * fDeltaTSeconds
Definition: DQMPlotter.cpp:217
def move(depos, offset)
Definition: depos.py:107
static int max(int a, int b)
TH1D * fTriggerDeltaT
Definition: DQMPlotter.cpp:215
template<class TFS >
virtual CRT::DQMPlotter< TFS >::~DQMPlotter ( )
virtualdefault

Member Function Documentation

template<class TFS >
void CRT::DQMPlotter< TFS >::AnalyzeEvent ( const std::vector< CRT::Trigger > &  triggers)
inline

Definition at line 60 of file DQMPlotter.cpp.

61  {
62  const auto end = triggers.cend();
63  auto prev = end;
64 
65  //If first timestamp hasn't been set to a suitable value yet, try to set it now to the
66  //earliest timestamp in this event.
68  {
69  for(const auto& trigger: triggers)
70  {
71  if(trigger.Timestamp() > 1e18 && trigger.Timestamp() < fFirstTime)
72  {
73  fFirstTime = trigger.Timestamp();
74  }
75  }
76  }
77 
78  //Map from Trigger to times in frame along each axis. First element is first 2 Triggers (alternates x and y), and second element is
79  //second 2 triggers (alternates y and x). What the "first" element means is different between frames, but it is consistent within a
80  //frame.
81  std::map<CRT::FrameID, std::map<CRT::PlaneID, std::vector<uint64_t>>> moduleToOverlapTimes;
82  uint64_t earliest = std::numeric_limits<uint64_t>::max(), latest = 1e16;
83  for(auto iter = triggers.cbegin(); iter != end; ++iter)
84  {
85  const auto& trigger = *iter;
86 
87  fTimestamps->Fill(trigger.Timestamp());
88  if(prev != end)
89  {
90  fTriggerDeltaT->Fill(trigger.Timestamp()-prev->Timestamp());
91  }
92 
93  //Find the plots for this Module
94  const auto moduleID = fGeom->ModuleID(trigger.Channel());
95  std::cout << "Looking for plots for module " << trigger.Channel() << "\n";
96  auto found = fModules.find(moduleID);
97  if(found == fModules.end())
98  {
99  std::cout << "Adding directory for module " << trigger.Channel() << "\n";
100  found = fModules.emplace(moduleID, ModulePlots<decltype(fFileService->mkdir("test"))>(fFileService->mkdir("module"+std::to_string(trigger.Channel())))).first;
101  }
102  auto& module = found->second;
103 
104  //Keep track of times of overlaps in this event
105  moduleToOverlapTimes[moduleID][moduleID].push_back(trigger.Timestamp());
106 
107  //Keep track of earliest and latest Trigger times in the event
108  if(trigger.Timestamp() > 1e16 && trigger.Timestamp() < earliest) earliest = trigger.Timestamp();
109  if(trigger.Timestamp() > latest) latest = trigger.Timestamp();
110 
111  if(trigger.Timestamp() > 1e16) //TODO: What do the very small timestamps represent? They have UNIX timestamp of 0
112  {
113  //Plot lower 32 timestamp bits versus time since beginning of event.
114  //To get time since beginning of event, I have to extract each part of the timestamp and convert the lower half to seconds.
115  const double elapsed = (trigger.Timestamp() - fFirstTime)*fTickSize; //In seconds.
116  fTriggerTime->Fill(elapsed);
117  fDeltaTSeconds->Fill(elapsed-module.fPrevSeconds);
118  module.fPrevSeconds = elapsed;
119 
120  if(module.fPrevTimestamp < std::numeric_limits<unsigned long long>::max()) //Don't fill fPrevTimestamp if there WAS no
121  //fPrevTimestamp
122  {
123  module.fTriggerDeltaT->Fill(trigger.Timestamp()-module.fPrevTimestamp);
124  }
125  module.fPrevTimestamp = trigger.Timestamp(); //This also sets the first fPrevTimestamp value
126  }
127 
128  const auto& hits = trigger.Hits();
129  module.fHitsPerTrigger->Fill(hits.size());
130  for(const auto& hit: hits)
131  {
132  const auto channel = hit.Channel();
133  module.fHits->Fill(channel);
134 
135  const auto adcFound = module.fChannelToADC.find(channel);
136  if(adcFound == module.fChannelToADC.end())
137  {
138  const auto name = "channel"+std::to_string(channel);
139  module.fChannelToADC[channel] = module.fDir.template make<TH1D>(name.c_str(), ("Hits on Channel "
140  +std::to_string(channel)).c_str(),
141  500, 0, 2000);
142  }
143 
144  module.fChannelToADC[channel]->Fill(hit.ADC());
145  module.fAllADC->Fill(hit.ADC());
146  } //For each Hit
147  prev = iter;
148  } //For each Trigger
149 
150  if(triggers.size() > 1) fEventLength->Fill(latest-earliest);
151 
152  //Fill overlap histograms
153  for(const auto& trigger: triggers)
154  {
155  const auto thisTime = trigger.Timestamp();
156  const auto& id = fGeom->ModuleID(trigger.Channel());
157 
158  //Find the plots for this module if any
159  auto found = fModules.find(id);
160  if(found == fModules.end()) continue;
161  auto& plots = found->second;
162 
163  const auto& frame = moduleToOverlapTimes[id];
164  const auto thisPlane = frame.find(id);
165  for(auto plane = frame.begin(); plane != frame.end(); ++plane)
166  {
167  if(plane != thisPlane) //TODO: I know that there will always be exactly 2 orientations for the CRT,
168  // so maybe I should use some dedicated keyed container with a complement()
169  // function here.
170  {
171  for(const auto& time: plane->second) plots.fDeltaTOverlap->Fill(thisTime-time);
172  } //If this is not the plane of the current Trigger
173  } //For each plane in this Trigger's frame
174  } //For each Trigger in this event
175  }
static QCString name
Definition: declinfo.cpp:673
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
const double fTickSize
Definition: DQMPlotter.cpp:222
std::map< CRT::ModuleID, ModulePlots< decltype(fFileService->mkdir("test"))> > fModules
Definition: DQMPlotter.cpp:213
uint8_t channel
Definition: CRTFragment.hh:201
std::unique_ptr< CRT::Geometry > fGeom
Definition: DQMPlotter.cpp:223
uint64_t fFirstTime
Definition: DQMPlotter.cpp:221
TH1D * fDeltaTSeconds
Definition: DQMPlotter.cpp:217
static int max(int a, int b)
Detector simulation of raw signals on wires.
TH1D * fTriggerDeltaT
Definition: DQMPlotter.cpp:215
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34

Member Data Documentation

template<class TFS >
TH1D* CRT::DQMPlotter< TFS >::fDeltaTSeconds
private

Definition at line 217 of file DQMPlotter.cpp.

template<class TFS >
TH1D* CRT::DQMPlotter< TFS >::fEventLength
private

Definition at line 218 of file DQMPlotter.cpp.

template<class TFS >
TFS CRT::DQMPlotter< TFS >::fFileService
private

Definition at line 178 of file DQMPlotter.cpp.

template<class TFS >
uint64_t CRT::DQMPlotter< TFS >::fFirstTime
private

Definition at line 221 of file DQMPlotter.cpp.

template<class TFS >
std::unique_ptr<CRT::Geometry> CRT::DQMPlotter< TFS >::fGeom
private

Definition at line 223 of file DQMPlotter.cpp.

template<class TFS >
std::map<CRT::ModuleID, ModulePlots<decltype(fFileService->mkdir("test"))> > CRT::DQMPlotter< TFS >::fModules
private

Definition at line 213 of file DQMPlotter.cpp.

template<class TFS >
const double CRT::DQMPlotter< TFS >::fTickSize
private

Definition at line 222 of file DQMPlotter.cpp.

template<class TFS >
TH1D* CRT::DQMPlotter< TFS >::fTimestamps
private

Definition at line 214 of file DQMPlotter.cpp.

template<class TFS >
TH1D* CRT::DQMPlotter< TFS >::fTriggerDeltaT
private

Definition at line 215 of file DQMPlotter.cpp.

template<class TFS >
TH1D* CRT::DQMPlotter< TFS >::fTriggerTime
private

Definition at line 216 of file DQMPlotter.cpp.


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