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

Classes

struct  StripPlots
 

Public Member Functions

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

Private Types

using DIRECTORY = decltype(fFileService->mkdir("null"))
 

Private Attributes

TFS fFileService
 
std::map< CRT::StripID, StripPlotsfStrips
 
std::unique_ptr< CRT::GeometryfGeom
 
std::map< CRT::ModuleID, DIRECTORYfModuleToDir
 
std::map< CRT::StripID, size_t > fStripToChannel
 

Detailed Description

template<class TFS>
class CRT::ValidationPlotter< TFS >

Definition at line 36 of file ValidationPlotter.cpp.

Member Typedef Documentation

template<class TFS >
using CRT::ValidationPlotter< TFS >::DIRECTORY = decltype(fFileService->mkdir("null"))
private

Definition at line 155 of file ValidationPlotter.cpp.

Constructor & Destructor Documentation

template<class TFS >
CRT::ValidationPlotter< TFS >::ValidationPlotter ( TFS &  tfs,
std::unique_ptr< CRT::Geometry > &&  geom 
)
inline

Definition at line 40 of file ValidationPlotter.cpp.

40  : fFileService(tfs),
41  fGeom(std::move(geom))
42  {
43  }
def move(depos, offset)
Definition: depos.py:107
std::unique_ptr< CRT::Geometry > fGeom
template<class TFS >
virtual CRT::ValidationPlotter< TFS >::~ValidationPlotter ( )
virtualdefault

Member Function Documentation

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

Definition at line 49 of file ValidationPlotter.cpp.

50  {
51  std::cout << "New event\n";
52  //First, fill a nested map to ADC values to find overlaps.
53  CRT::geoMap<int16_t> stripToHits;
54 
55  for(const auto& trigger: triggers)
56  {
57  std::cout << "On module " << trigger.Channel() << ":\n";
58  const auto& hits = trigger.Hits();
59  for(const auto& hit: hits)
60  {
61  std::cout << "\tGot a hit on strip " << hit.Channel() << "\n";
62  const auto id = fGeom->StripID(trigger.Channel(), hit.Channel());
63 
64  //Create a place to put plots from this (strip, module) pair in case it will be needed later.
65  auto foundModule = fModuleToDir.find(id);
66  if(foundModule == fModuleToDir.end()) fModuleToDir.emplace(id, fFileService->mkdir("Module"+std::to_string(trigger.Channel())));
67 
68  auto foundStrip = fStripToChannel.find(id);
69  if(foundStrip == fStripToChannel.end()) fStripToChannel.emplace(id, hit.Channel());
70 
71  if(hit.ADC() > stripToHits[id]) stripToHits[id] = hit.ADC(); //TODO: Assuming for now that there is no more
72  // than 1 hit for each strip in an event.
73  // If there were more than one hit, I'd
74  // keep the largest here because I am
75  // looking for the largest ADC on each
76  // plane for matching later.
77  }
78  }
79 
80  //Next, find the highest ADC hit in each layer and look for an overlap with the other layer in its module.
81  //Fill a map with all such overlaps sorted by plane so that I can find 2D pixels made of pairs of highest-energy
82  //hits.
84  for(const auto& framePair: stripToHits)
85  {
86  //If there are 2 planes in this frame with hits, then
87  //there could be 2D overlaps in this frame.
88  if(framePair.second.size() > 1)
89  {
90  for(const auto& planePair: framePair.second)
91  {
92  for(const auto& modulePair: planePair.second)
93  {
94  //There have to be 2 layers with hits in this plane for overlaps to be possible.
95  if(modulePair.second.size() > 1)
96  {
97  auto layerPair = modulePair.second.begin();
98  auto& stripPairs = layerPair->second;
99  const auto firstMax = std::max_element(stripPairs.begin(), stripPairs.end(), [](const auto& first, const auto& second)
100  {
101  return first.second < second.second;
102  });
103 
104  ++layerPair; //Go to the other layer in this plane
105  auto& secondStripPairs = layerPair->second;
106  const auto secondMax = std::max_element(secondStripPairs.begin(), secondStripPairs.end(), [](const auto& first, const auto& second)
107  {
108  return first.second < second.second;
109  });
110 
111  if(firstMax->first.Overlaps(secondMax->first))
112  {
113  const auto& firstID = firstMax->first;
114  stripToOverlappingHits[firstID].push_back(*firstMax);
115 
116  const auto& secondID = secondMax->first;
117  stripToOverlappingHits[secondID].push_back(*secondMax);
118  } //If firstMax->first overlaps secondMax->first
119  } //If more than one layer has hits
120  } //For each module
121  } //For each plane in this frame
122  } //If more than one plane has hits
123  } //For each frame with hits
124 
125  //Finally, plot the ADCs of strips that are part of 2D pixels
126  for(const auto& framePair: stripToOverlappingHits)
127  {
128  if(framePair.second.size() > 1) //If there is more than one plane with overlapping hit pairs within a frame,
129  //that plane has 2D pixels.
130  {
131  for(const auto& planePair: framePair.second)
132  {
133  const std::vector<std::pair<CRT::StripID, int64_t>>& strips = planePair.second;
134  for(const auto& stripPair: strips) //TODO: Why doesn't planePair.second work here?!
135  {
136  //Look for plots for this StripID and create them if necessary. This way,
137  //I'll only get plots for modules that were part of overlapping pairs.
138  const auto& id = stripPair.first;
139  auto foundStrip = fStrips.find(stripPair.first);
140  if(foundStrip == fStrips.end())
141  {
142  foundStrip = fStrips.emplace(stripPair.first, StripPlots(fModuleToDir.at(id), fStripToChannel.at(id))).first;
143  }
144 
145  auto& strip = foundStrip->second;
146  strip.fOverlappingADCs->Fill(stripPair.second);
147  } //For each strip with an overlap in this plane
148  } //For each plane in this frame
149  } //If more than one plane
150  } //For each frame with pairs of overlapping strips
151  } //AnalyzeEvent()
std::map< CRT::ModuleID, DIRECTORY > fModuleToDir
detail::Node< void, uint8_t > FrameID
Definition: CRTID.h:120
std::map< CRT::StripID, StripPlots > fStrips
Detector simulation of raw signals on wires.
std::unique_ptr< CRT::Geometry > fGeom
std::map< CRT::StripID, size_t > fStripToChannel
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34

Member Data Documentation

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

Definition at line 154 of file ValidationPlotter.cpp.

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

Definition at line 174 of file ValidationPlotter.cpp.

template<class TFS >
std::map<CRT::ModuleID, DIRECTORY> CRT::ValidationPlotter< TFS >::fModuleToDir
private

Definition at line 177 of file ValidationPlotter.cpp.

template<class TFS >
std::map<CRT::StripID, StripPlots> CRT::ValidationPlotter< TFS >::fStrips
private

Definition at line 171 of file ValidationPlotter.cpp.

template<class TFS >
std::map<CRT::StripID, size_t> CRT::ValidationPlotter< TFS >::fStripToChannel
private

Definition at line 178 of file ValidationPlotter.cpp.


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