Public Member Functions | Private Attributes | List of all members
calo::CaloChecker Class Reference
Inheritance diagram for calo::CaloChecker:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 CaloChecker (fhicl::ParameterSet const &config)
 
void analyze (const art::Event &evt) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::vector< std::stringfCaloLabels
 
std::string fTrackLabel
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 45 of file CaloChecker_module.cc.

Constructor & Destructor Documentation

calo::CaloChecker::CaloChecker ( fhicl::ParameterSet const &  config)
explicit

Definition at line 58 of file CaloChecker_module.cc.

58  :
60  fCaloLabels(config.get<std::vector<std::string>>("CaloLabels")),
61  fTrackLabel(config.get<std::string>("TrackLabel"))
62 {
63  assert(fCaloLabels.size() >= 2);
64 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::vector< std::string > fCaloLabels
static Config * config
Definition: config.cpp:1054

Member Function Documentation

void calo::CaloChecker::analyze ( const art::Event evt)
override

Definition at line 66 of file CaloChecker_module.cc.

66  {
68  std::vector<art::Ptr<recob::Track> > tracklist;
69  if (evt.getByLabel(fTrackLabel, trackListHandle)) {
70  art::fill_ptr_vector(tracklist, trackListHandle);
71  }
72 
73  std::vector<art::FindManyP<anab::Calorimetry>> calos;
74  for (const std::string &l: fCaloLabels) {
75  calos.emplace_back(tracklist, evt, l);
76  }
77 
78  float EPS = 1e-3;
79 
80  for (unsigned trk_i = 0; trk_i < tracklist.size(); trk_i++) {
81  std::vector<art::Ptr<anab::Calorimetry>> base = calos[0].at(trk_i);
82 
83  std::cout << "New Track!\n";
84  std::cout << "Base calo (" << fCaloLabels[0] << ") n calo: " << base.size() << std::endl;
85  for (unsigned plane = 0; plane < base.size(); plane++) {
86  std::cout << "N points on plane (" << plane << ") ID (" << base[plane]->PlaneID() << ") n points: " << base[plane]->dEdx().size() << std::endl;
87  }
88 
89  for (unsigned i = 1; i < fCaloLabels.size(); i++) {
90  bool equal = true;
91  std::vector<art::Ptr<anab::Calorimetry>> othr = calos[i].at(trk_i);
92  if (base.size() != othr.size()) {
93  equal = false;
94  std::cout << "Track: " << trk_i << " calo (" << fCaloLabels[0] << ") has (" << base.size() << "). Calo (" << fCaloLabels[i] << ") has size (" << othr.size() << ") mismatch." << std::endl;
95  }
96 
97  for (unsigned plane = 0; plane < base.size(); plane++) {
98  // check plane index
99  if (base[plane]->PlaneID() != othr[plane]->PlaneID()) {
100  equal = false;
101  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
102  std::cout << "Plane ID mismatch (" << base[plane]->PlaneID() << ") (" << othr[plane]->PlaneID() << ")" << std::endl;
103  }
104 
105  // check the range
106  if (abs(base[plane]->Range() - othr[plane]->Range()) > EPS) {
107  equal = false;
108  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
109  std::cout << "Range mismatch (" << base[plane]->Range() << ") (" << othr[plane]->Range() << ")" << std::endl;
110  }
111 
112  // check the kinetic energy
113  if (abs(base[plane]->KineticEnergy() - othr[plane]->KineticEnergy()) > EPS) {
114  equal = false;
115  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
116  std::cout << "KineticEnergy mismatch (" << base[plane]->KineticEnergy() << ") (" << othr[plane]->KineticEnergy() << ")" << std::endl;
117  }
118 
119  // check dE dx
120  const std::vector<float> &base_dedx = base[plane]->dEdx();
121  const std::vector<float> &othr_dedx = othr[plane]->dEdx();
122 
123  if (base_dedx.size() == othr_dedx.size()) {
124  for (unsigned i_dedx = 0; i_dedx < base_dedx.size(); i_dedx++) {
125  if (abs(base_dedx[i_dedx] - othr_dedx[i_dedx]) > EPS) {
126  equal = false;
127  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
128  std::cout << "dEdx mismatch at index: " << i_dedx << " (" << base_dedx[i_dedx] << ") (" << othr_dedx[i_dedx] << ")" << std::endl;
129  }
130  }
131  }
132  else {
133  equal = false;
134  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "dEdx size mismatch (" << base_dedx.size() << ") (" << othr_dedx.size() << ")" << std::endl;
135  }
136 
137  // check dQdx
138  const std::vector<float> &base_dqdx = base[plane]->dQdx();
139  const std::vector<float> &othr_dqdx = othr[plane]->dQdx();
140 
141  if (base_dqdx.size() == othr_dqdx.size()) {
142  for (unsigned i_dqdx = 0; i_dqdx < base_dqdx.size(); i_dqdx++) {
143  if (abs(base_dqdx[i_dqdx] - othr_dqdx[i_dqdx]) > EPS) {
144  equal = false;
145  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
146  std::cout << "dQdx mismatch at index: " << i_dqdx << " (" << base_dqdx[i_dqdx] << ") (" << othr_dqdx[i_dqdx] << ")" << std::endl;
147  }
148  }
149  }
150  else {
151  equal = false;
152  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "dQdx size mismatch (" << base_dqdx.size() << ") (" << othr_dqdx.size() << ")" << std::endl;
153  }
154 
155  // check Residual Range
156  const std::vector<float> &base_rr = base[plane]->ResidualRange();
157  const std::vector<float> &othr_rr = othr[plane]->ResidualRange();
158 
159  if (base_rr.size() == othr_rr.size()) {
160  for (unsigned i_rr = 0; i_rr < base_rr.size(); i_rr++) {
161  if (abs(base_rr[i_rr] - othr_rr[i_rr]) > EPS) {
162  equal = false;
163  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
164  std::cout << "ResidualRange mismatch at index: " << i_rr << " (" << base_rr[i_rr] << ") (" << othr_rr[i_rr] << ")" << std::endl;
165  }
166  }
167  }
168  else {
169  equal = false;
170  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "ResidualRange size mismatch (" << base_rr.size() << ") (" << othr_rr.size() << ")" << std::endl;
171  }
172 
173  // check DeadWireRC
174  const std::vector<float> &base_dwrr = base[plane]->DeadWireResRC();
175  const std::vector<float> &othr_dwrr = othr[plane]->DeadWireResRC();
176 
177  if (base_dwrr.size() == othr_dwrr.size()) {
178  for (unsigned i_dwrr = 0; i_dwrr < base_dwrr.size(); i_dwrr++) {
179  if (abs(base_dwrr[i_dwrr] - othr_dwrr[i_dwrr]) > EPS) {
180  equal = false;
181  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
182  std::cout << "DeadWireResRC mismatch at index: " << i_dwrr << " (" << base_dwrr[i_dwrr] << ") (" << othr_dwrr[i_dwrr] << ")" << std::endl;
183  }
184  }
185  }
186  else {
187  equal = false;
188  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "DeadWireResRC size mismatch (" << base_dwrr.size() << ") (" << othr_dwrr.size() << ")" << std::endl;
189  }
190 
191  // check Track Pitch
192  const std::vector<float> &base_tpv = base[plane]->TrkPitchVec();
193  const std::vector<float> &othr_tpv = othr[plane]->TrkPitchVec();
194 
195  if (base_tpv.size() == othr_tpv.size()) {
196  for (unsigned i_tpv = 0; i_tpv < base_tpv.size(); i_tpv++) {
197  if (abs(base_tpv[i_tpv] - othr_tpv[i_tpv]) > EPS) {
198  equal = false;
199  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
200  std::cout << "TrkPitchVec mismatch at index: " << i_tpv << " (" << base_tpv[i_tpv] << ") (" << othr_tpv[i_tpv] << ")" << std::endl;
201  }
202  }
203  }
204  else {
205  equal = false;
206  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "TrkPitchVec size mismatch (" << base_tpv.size() << ") (" << othr_tpv.size() << ")" << std::endl;
207  }
208 
209  // check TP Indices
210  const std::vector<size_t> &base_tpi = base[plane]->TpIndices();
211  const std::vector<size_t> &othr_tpi = othr[plane]->TpIndices();
212 
213  if (base_tpi.size() == othr_tpi.size()) {
214  for (unsigned i_tpi = 0; i_tpi < base_tpi.size(); i_tpi++) {
215  if (base_tpi[i_tpi] != othr_tpi[i_tpi]) {
216  equal = false;
217  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
218  std::cout << "TpIndices mismatch at index: " << i_tpi << " (" << base_tpi[i_tpi] << ") (" << othr_tpi[i_tpi] << ")" << std::endl;
219  }
220  }
221  }
222  else {
223  equal = false;
224  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "TpIndices size mismatch (" << base_tpi.size() << ") (" << othr_tpi.size() << ")" << std::endl;
225  }
226 
227  // check XYZ
228  const std::vector<geo::Point_t> &base_xyz = base[plane]->XYZ();
229  const std::vector<geo::Point_t> &othr_xyz = othr[plane]->XYZ();
230 
231  if (base_xyz.size() == othr_xyz.size()) {
232  for (unsigned i_xyz = 0; i_xyz < base_xyz.size(); i_xyz++) {
233  if (abs(base_xyz[i_xyz].X() - othr_xyz[i_xyz].X()) > EPS ||
234  abs(base_xyz[i_xyz].Y() - othr_xyz[i_xyz].Y()) > EPS ||
235  abs(base_xyz[i_xyz].Z() - othr_xyz[i_xyz].Z()) > EPS) {
236  equal = false;
237  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": ";
238  std::cout << "XYZ mismatch at index: " << i_xyz;
239  std::cout << "X (" << base_xyz[i_xyz].X() << ") (" << othr_xyz[i_xyz].X() << ") ";
240  std::cout << "Y (" << base_xyz[i_xyz].Y() << ") (" << othr_xyz[i_xyz].Y() << ") ";
241  std::cout << "Z (" << base_xyz[i_xyz].Z() << ") (" << othr_xyz[i_xyz].Z() << ") " << std::endl;
242  }
243  }
244  }
245  else {
246  equal = false;
247  std::cout << "Track: " << trk_i << " calos (" << fCaloLabels[0] << ") (" << fCaloLabels[i] << ") plane " << plane << ": " << "XYZ size mismatch (" << base_xyz.size() << ") (" << othr_xyz.size() << ")" << std::endl;
248  }
249 
250  }
251 
252  if (equal) {
253  std::cout << "Track: " << trk_i << " calo (" << fCaloLabels[0] << ") is equal to calo (" << fCaloLabels[i] << ")" << std::endl;
254  }
255 
256  }
257  }
258 
259 
260 }
std::string string
Definition: nybbler.cc:12
static QStrList * l
Definition: config.cpp:1044
T abs(T value)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
const double e
std::vector< std::string > fCaloLabels
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector<std::string> calo::CaloChecker::fCaloLabels
private

Definition at line 51 of file CaloChecker_module.cc.

std::string calo::CaloChecker::fTrackLabel
private

Definition at line 52 of file CaloChecker_module.cc.


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