All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Attributes | List of all members
sbnd::CRTBackTracker Class Reference

#include <CRTBackTracker.h>

Classes

struct  Config
 

Public Member Functions

 CRTBackTracker (const Config &config)
 
 CRTBackTracker (const fhicl::ParameterSet &pset)
 
 ~CRTBackTracker ()
 
void reconfigure (const Config &config)
 
void Initialize (const art::Event &event)
 
bool DataCompare (const sbnd::crt::CRTData &data1, const sbnd::crt::CRTData &data2)
 
bool HitCompare (const sbn::crt::CRTHit &hit1, const sbn::crt::CRTHit &hit2)
 
bool TrackCompare (const sbn::crt::CRTTrack &track1, const sbn::crt::CRTTrack &track2)
 
std::vector< int > AllTrueIds (const art::Event &event, const sbnd::crt::CRTData &data)
 
std::vector< int > AllTrueIds (const art::Event &event, const sbn::crt::CRTHit &hit)
 
std::vector< int > AllTrueIds (const art::Event &event, const sbn::crt::CRTTrack &track)
 
int TrueIdFromTotalEnergy (const art::Event &event, const sbnd::crt::CRTData &data)
 
int TrueIdFromDataId (const art::Event &event, int data_i)
 
int TrueIdFromTotalEnergy (const art::Event &event, const sbn::crt::CRTHit &hit)
 
int TrueIdFromHitId (const art::Event &event, int hit_i)
 
int TrueIdFromTotalEnergy (const art::Event &event, const sbn::crt::CRTTrack &track)
 
int TrueIdFromTrackId (const art::Event &event, int track_i)
 

Private Attributes

art::InputTag fCRTDataLabel
 
art::InputTag fCRTHitLabel
 
art::InputTag fCRTTrackLabel
 
bool fRollupUnsavedIds
 
std::map< int, std::map< int,
double > > 
fDataTrueIds
 
std::map< int, std::map< int,
double > > 
fHitTrueIds
 
std::map< int, std::map< int,
double > > 
fTrackTrueIds
 

Detailed Description

Definition at line 39 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.h.

Constructor & Destructor Documentation

sbnd::CRTBackTracker::CRTBackTracker ( const Config config)

Definition at line 5 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

5  {
6 
7  this->reconfigure(config);
8 
9 }
sbnd::CRTBackTracker::CRTBackTracker ( const fhicl::ParameterSet &  pset)
inline

Definition at line 63 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.h.

63  :
64  CRTBackTracker(fhicl::Table<Config>(pset, {})()) {}
sbnd::CRTBackTracker::~CRTBackTracker ( )

Definition at line 17 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

17  {
18 
19 }

Member Function Documentation

std::vector< int > sbnd::CRTBackTracker::AllTrueIds ( const art::Event &  event,
const sbnd::crt::CRTData data 
)

Definition at line 166 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

166  {
167 
168  std::vector<int> ids;
169 
170  // Get a handle to the CRT data in the event
171  auto crtDataHandle = event.getValidHandle<std::vector<sbnd::crt::CRTData>>(fCRTDataLabel);
172 
173  art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event, fCRTDataLabel);
174 
175  // Find which one matches the data passed to the function
176  int data_i = 0, index = 0;
177  for(auto const& crtData : (*crtDataHandle)){
178  if(DataCompare(crtData, data)) data_i = index;
179  index++;
180  }
181 
182  // Get all the true IDs from all the IDEs in the hit
183  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
184  for(size_t i = 0; i < ides.size(); i++){
185  int id = ides[i]->trackID;
186  if(fRollupUnsavedIds) id = std::abs(id);
187  ids.push_back(id);
188  }
189 
190  // Remove any repeated IDs
191  std::sort(ids.begin(), ids.end());
192  ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
193 
194  return ids;
195 
196 }
T abs(T value)
bool DataCompare(const sbnd::crt::CRTData &data1, const sbnd::crt::CRTData &data2)
std::vector< int > sbnd::CRTBackTracker::AllTrueIds ( const art::Event &  event,
const sbn::crt::CRTHit hit 
)

Definition at line 199 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

199  {
200 
201  std::vector<int> ids;
202 
203  // Get a handle to the CRT hits in the event
204  auto crtHitHandle = event.getValidHandle<std::vector<sbn::crt::CRTHit>>(fCRTHitLabel);
205 
206  art::FindManyP<sbnd::crt::CRTData> findManyData(crtHitHandle, event, fCRTHitLabel);
207 
208  // Find which one matches the hit passed to the function
209  int hit_i = 0, index = 0;
210  for(auto const& crtHit : (*crtHitHandle)){
211  if(HitCompare(crtHit, hit)) hit_i = index;
212  index++;
213  }
214 
215  // Get the crt data associated to that hit and the IDEs associate to the data
216  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(hit_i);
217  art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event, fCRTDataLabel);
218 
219  // Get all the true IDs from all the IDEs in the hit
220  for(size_t i = 0; i < data.size(); i++){
221  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(i);
222  for(size_t j = 0; j < ides.size(); j++){
223  int id = ides[j]->trackID;
224  if(fRollupUnsavedIds) id = std::abs(id);
225  ids.push_back(id);
226  }
227  }
228 
229  // Remove any repeated IDs
230  std::sort(ids.begin(), ids.end());
231  ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
232 
233  return ids;
234 
235 }
T abs(T value)
bool HitCompare(const sbn::crt::CRTHit &hit1, const sbn::crt::CRTHit &hit2)
std::vector< int > sbnd::CRTBackTracker::AllTrueIds ( const art::Event &  event,
const sbn::crt::CRTTrack track 
)

Definition at line 238 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

238  {
239 
240  std::vector<int> ids;
241 
242  // Get a handle to the CRT tracks in the event
243  auto crtTrackHandle = event.getValidHandle<std::vector<sbn::crt::CRTTrack>>(fCRTTrackLabel);
244 
245  art::FindManyP<sbn::crt::CRTHit> findManyHits(crtTrackHandle, event, fCRTTrackLabel);
246 
247  // Find which one matches the track passed to the function
248  int track_i = 0, index = 0;
249  for(auto const& crtTrack : (*crtTrackHandle)){
250  if(TrackCompare(crtTrack, track)) track_i = index;
251  index++;
252  }
253 
254  // Get the crt hits associated to that hit and the data associate to the hits
255  std::vector<art::Ptr<sbn::crt::CRTHit>> hits = findManyHits.at(track_i);
256  art::FindManyP<sbnd::crt::CRTData> findManyData(hits, event, fCRTHitLabel);
257 
258  // Get all the true IDs from all the IDEs in the track
259  for(size_t i = 0; i < hits.size(); i++){
260  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(i);
261  art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event, fCRTDataLabel);
262  for(size_t j = 0; j < data.size(); j++){
263  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(j);
264  for(size_t k = 0; k < ides.size(); k++){
265  int id = ides[k]->trackID;
266  if(fRollupUnsavedIds) id = std::abs(id);
267  ids.push_back(id);
268  }
269  }
270  }
271 
272  // Remove any repeated IDs
273  std::sort(ids.begin(), ids.end());
274  ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
275 
276  return ids;
277 
278 }
bool TrackCompare(const sbn::crt::CRTTrack &track1, const sbn::crt::CRTTrack &track2)
T abs(T value)
pdgs k
Definition: selectors.fcl:22
bool sbnd::CRTBackTracker::DataCompare ( const sbnd::crt::CRTData data1,
const sbnd::crt::CRTData data2 
)

Definition at line 112 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

112  {
113 
114  if(data1.Channel() != data2.Channel()) return false;
115  if(data1.T0() != data2.T0()) return false;
116  if(data1.T1() != data2.T1()) return false;
117  if(data1.ADC() != data2.ADC()) return false;
118 
119  return true;
120 
121 }
uint32_t Channel() const
Definition: CRTData.cxx:20
uint32_t T0() const
Definition: CRTData.cxx:23
uint32_t ADC() const
Definition: CRTData.cxx:29
uint32_t T1() const
Definition: CRTData.cxx:26
bool sbnd::CRTBackTracker::HitCompare ( const sbn::crt::CRTHit hit1,
const sbn::crt::CRTHit hit2 
)

Definition at line 124 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

124  {
125 
126  if(hit1.ts1_ns != hit2.ts1_ns) return false;
127  if(hit1.plane != hit2.plane) return false;
128  if(hit1.x_pos != hit2.x_pos) return false;
129  if(hit1.y_pos != hit2.y_pos) return false;
130  if(hit1.z_pos != hit2.z_pos) return false;
131  if(hit1.x_err != hit2.x_err) return false;
132  if(hit1.y_err != hit2.y_err) return false;
133  if(hit1.z_err != hit2.z_err) return false;
134  if(hit1.tagger != hit2.tagger) return false;
135 
136  return true;
137 
138 }
float z_err
position uncertainty in z-direction (cm).
Definition: CRTHit.hh:43
float x_err
position uncertainty in x-direction (cm).
Definition: CRTHit.hh:39
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
Definition: CRTHit.hh:34
int plane
Name of the CRT wall (in the form of numbers).
Definition: CRTHit.hh:36
float y_err
position uncertainty in y-direction (cm).
Definition: CRTHit.hh:41
float z_pos
position in z-direction (cm).
Definition: CRTHit.hh:42
float y_pos
position in y-direction (cm).
Definition: CRTHit.hh:40
float x_pos
position in x-direction (cm).
Definition: CRTHit.hh:38
std::string tagger
Name of the CRT wall (in the form of strings).
Definition: CRTHit.hh:45
void sbnd::CRTBackTracker::Initialize ( const art::Event &  event)

Definition at line 33 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

33  {
34 
35  // Clear those data structures!
36  fDataTrueIds.clear();
37  fHitTrueIds.clear();
38  fTrackTrueIds.clear();
39 
40  // Get a handle to the CRT data in the event
41  art::Handle< std::vector<sbnd::crt::CRTData>> crtDataHandle;
42  std::vector<art::Ptr<sbnd::crt::CRTData> > crtDataList;
43  if (event.getByLabel(fCRTDataLabel, crtDataHandle))
44  art::fill_ptr_vector(crtDataList, crtDataHandle);
45 
46  art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event, fCRTDataLabel);
47 
48  std::map<art::Ptr<sbnd::crt::CRTData>, int> dataPtrMap;
49 
50  for(size_t data_i = 0; data_i < crtDataList.size(); data_i++){
51 
52  dataPtrMap[crtDataList[data_i]] = data_i;
53 
54  // Get all the true IDs from all the IDEs in the hit
55  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
56  for(size_t i = 0; i < ides.size(); i++){
57  int id = ides[i]->trackID;
58  if(fRollupUnsavedIds) id = std::abs(id);
59  fDataTrueIds[data_i][id] += ides[i]->energyDeposited;
60  }
61 
62  }
63 
64  art::Handle< std::vector<sbn::crt::CRTHit>> crtHitHandle;
65  std::vector<art::Ptr<sbn::crt::CRTHit> > crtHitList;
66  if (event.getByLabel(fCRTHitLabel, crtHitHandle))
67  art::fill_ptr_vector(crtHitList, crtHitHandle);
68 
69  art::FindManyP<sbnd::crt::CRTData> findManyData(crtHitHandle, event, fCRTHitLabel);
70 
71  std::map<art::Ptr<sbn::crt::CRTHit>, int> hitPtrMap;
72 
73  for(size_t hit_i = 0; hit_i < crtHitList.size(); hit_i++){
74 
75  hitPtrMap[crtHitList[hit_i]] = hit_i;
76 
77  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(hit_i);
78  for(size_t data_i = 0; data_i < data.size(); data_i++){
79 
80  int dataID = dataPtrMap[data[data_i]];
81 
82  for(auto const& di : fDataTrueIds[dataID]){
83  fHitTrueIds[hit_i][di.first] += di.second;
84  }
85 
86  }
87  }
88 
89  art::Handle< std::vector<sbn::crt::CRTTrack>> crtTrackHandle;
90  std::vector<art::Ptr<sbn::crt::CRTTrack> > crtTrackList;
91  if (event.getByLabel(fCRTTrackLabel, crtTrackHandle))
92  art::fill_ptr_vector(crtTrackList, crtTrackHandle);
93 
94  art::FindManyP<sbn::crt::CRTHit> findManyHits(crtTrackHandle, event, fCRTTrackLabel);
95 
96  for(size_t track_i = 0; track_i < crtTrackList.size(); track_i++){
97 
98  std::vector<art::Ptr<sbn::crt::CRTHit>> hits = findManyHits.at(track_i);
99  for(size_t hit_i = 0; hit_i < hits.size(); hit_i++){
100 
101  int hitID = hitPtrMap[hits[hit_i]];
102 
103  for(auto const& hi : fHitTrueIds[hitID]){
104  fTrackTrueIds[track_i][hi.first] += hi.second;
105  }
106 
107  }
108  }
109 }
T abs(T value)
std::map< int, std::map< int, double > > fTrackTrueIds
std::map< int, std::map< int, double > > fDataTrueIds
std::map< int, std::map< int, double > > fHitTrueIds
void sbnd::CRTBackTracker::reconfigure ( const Config config)

Definition at line 21 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

21  {
22 
23  fCRTDataLabel = config.CRTDataLabel();
24  fCRTHitLabel = config.CRTHitLabel();
25  fCRTTrackLabel = config.CRTTrackLabel();
26 
27  fRollupUnsavedIds = config.RollupUnsavedIds();
28 
29  return;
30 
31 }
bool sbnd::CRTBackTracker::TrackCompare ( const sbn::crt::CRTTrack track1,
const sbn::crt::CRTTrack track2 
)

Definition at line 141 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

141  {
142 
143  if(track1.ts1_ns != track2.ts1_ns) return false;
144 
145  if(track1.plane1 != track2.plane1) return false;
146  if(track1.x1_pos != track2.x1_pos) return false;
147  if(track1.y1_pos != track2.y1_pos) return false;
148  if(track1.z1_pos != track2.z1_pos) return false;
149  if(track1.x1_err != track2.x1_err) return false;
150  if(track1.y1_err != track2.y1_err) return false;
151  if(track1.z1_err != track2.z1_err) return false;
152 
153  if(track1.plane2 != track2.plane2) return false;
154  if(track1.x2_pos != track2.x2_pos) return false;
155  if(track1.y2_pos != track2.y2_pos) return false;
156  if(track1.z2_pos != track2.z2_pos) return false;
157  if(track1.x2_err != track2.x2_err) return false;
158  if(track1.y2_err != track2.y2_err) return false;
159  if(track1.z2_err != track2.z2_err) return false;
160 
161  return true;
162 
163 }
float x1_pos
X position of first CRTHit.
Definition: CRTTrack.hh:33
float y1_err
Y position error of first CRTHit.
Definition: CRTTrack.hh:36
float z1_err
Z position error of first CRTHit.
Definition: CRTTrack.hh:38
float y2_err
Y position error of second CRTHit.
Definition: CRTTrack.hh:42
double ts1_ns
Average T1 (nanosecond) of the two hits making the track.
Definition: CRTTrack.hh:28
float z1_pos
Z position of first CRTHit.
Definition: CRTTrack.hh:37
int plane1
Plane ID of first CRTHit.
Definition: CRTTrack.hh:30
float z2_pos
Z position of second CRTHit.
Definition: CRTTrack.hh:43
float y2_pos
Y position of second CRTHit.
Definition: CRTTrack.hh:41
float y1_pos
Y position of first CRTHit.
Definition: CRTTrack.hh:35
float x2_pos
X position of second CRTHit.
Definition: CRTTrack.hh:39
float x1_err
X position error of first CRTHit.
Definition: CRTTrack.hh:34
int plane2
Plane ID of second CRTHit.
Definition: CRTTrack.hh:31
float z2_err
Z position error of second CRTHit.
Definition: CRTTrack.hh:44
float x2_err
X position error of second CRTHit.
Definition: CRTTrack.hh:40
int sbnd::CRTBackTracker::TrueIdFromDataId ( const art::Event &  event,
int  data_i 
)

Definition at line 319 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

319  {
320 
321  if(fDataTrueIds.find(data_i) != fDataTrueIds.end()){
322  double maxEnergy = -1;
323  int trueId = -99999;
324  for(auto &id : fDataTrueIds[data_i]){
325  if(id.second > maxEnergy){
326  maxEnergy = id.second;
327  trueId = id.first;
328  }
329  }
330  return trueId;
331  }
332 
333  return -99999;
334 }
std::map< int, std::map< int, double > > fDataTrueIds
int sbnd::CRTBackTracker::TrueIdFromHitId ( const art::Event &  event,
int  hit_i 
)

Definition at line 382 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

382  {
383 
384  if(fHitTrueIds.find(hit_i) != fHitTrueIds.end()){
385  double maxEnergy = -1;
386  int trueId = -99999;
387  for(auto &id : fHitTrueIds[hit_i]){
388  if(id.second > maxEnergy){
389  maxEnergy = id.second;
390  trueId = id.first;
391  }
392  }
393  return trueId;
394  }
395 
396  return -99999;
397 }
std::map< int, std::map< int, double > > fHitTrueIds
int sbnd::CRTBackTracker::TrueIdFromTotalEnergy ( const art::Event &  event,
const sbnd::crt::CRTData data 
)

Definition at line 281 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

281  {
282 
283  std::map<int, double> ids;
284 
285  // Get a handle to the CRT data in the event
286  auto crtDataHandle = event.getValidHandle<std::vector<sbnd::crt::CRTData>>(fCRTDataLabel);
287 
288  art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event, fCRTDataLabel);
289 
290  // Find which one matches the data passed to the function
291  int data_i = 0, index = 0;
292  for(auto const& crtData : (*crtDataHandle)){
293  if(DataCompare(crtData, data)) data_i = index;
294  index++;
295  }
296 
297  // Get all the true IDs from all the IDEs in the hit
298  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
299  for(size_t i = 0; i < ides.size(); i++){
300  int id = ides[i]->trackID;
301  if(fRollupUnsavedIds) id = std::abs(id);
302  ids[id] += ides[i]->energyDeposited;
303  }
304 
305  // Find the true ID that contributed the most energy
306  double maxEnergy = -1;
307  int trueId = -99999;
308  for(auto &id : ids){
309  if(id.second > maxEnergy){
310  maxEnergy = id.second;
311  trueId = id.first;
312  }
313  }
314 
315  return trueId;
316 
317 }
T abs(T value)
bool DataCompare(const sbnd::crt::CRTData &data1, const sbnd::crt::CRTData &data2)
int sbnd::CRTBackTracker::TrueIdFromTotalEnergy ( const art::Event &  event,
const sbn::crt::CRTHit hit 
)

Definition at line 338 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

338  {
339 
340  std::map<int, double> ids;
341 
342  // Get a handle to the CRT hits in the event
343  auto crtHitHandle = event.getValidHandle<std::vector<sbn::crt::CRTHit>>(fCRTHitLabel);
344 
345  art::FindManyP<sbnd::crt::CRTData> findManyData(crtHitHandle, event, fCRTHitLabel);
346 
347  // Find which one matches the hit passed to the function
348  int hit_i = 0, index = 0;
349  for(auto const& crtHit : (*crtHitHandle)){
350  if(HitCompare(crtHit, hit)) hit_i = index;
351  index++;
352  }
353 
354  // Get the crt data associated to that hit and the IDEs associate to the data
355  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(hit_i);
356  art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event, fCRTDataLabel);
357 
358  // Get all the true IDs from all the IDEs in the hit
359  for(size_t i = 0; i < data.size(); i++){
360  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(i);
361  for(size_t j = 0; j < ides.size(); j++){
362  int id = ides[j]->trackID;
363  if(fRollupUnsavedIds) id = std::abs(id);
364  ids[id] += ides[j]->energyDeposited;
365  }
366  }
367 
368  // Find the true ID that contributed the most energy
369  double maxEnergy = -1;
370  int trueId = -99999;
371  for(auto &id : ids){
372  if(id.second > maxEnergy){
373  maxEnergy = id.second;
374  trueId = id.first;
375  }
376  }
377 
378  return trueId;
379 
380 }
T abs(T value)
bool HitCompare(const sbn::crt::CRTHit &hit1, const sbn::crt::CRTHit &hit2)
int sbnd::CRTBackTracker::TrueIdFromTotalEnergy ( const art::Event &  event,
const sbn::crt::CRTTrack track 
)

Definition at line 400 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

400  {
401 
402  std::map<int, double> ids;
403 
404  // Get a handle to the CRT tracks in the event
405  auto crtTrackHandle = event.getValidHandle<std::vector<sbn::crt::CRTTrack>>(fCRTTrackLabel);
406 
407  art::FindManyP<sbn::crt::CRTHit> findManyHits(crtTrackHandle, event, fCRTTrackLabel);
408 
409  // Find which one matches the track passed to the function
410  int track_i = 0, index = 0;
411  for(auto const& crtTrack : (*crtTrackHandle)){
412  if(TrackCompare(crtTrack, track)) track_i = index;
413  index++;
414  }
415 
416  // Get the crt hits associated to that hit and the data associate to the hits
417  std::vector<art::Ptr<sbn::crt::CRTHit>> hits = findManyHits.at(track_i);
418  art::FindManyP<sbnd::crt::CRTData> findManyData(hits, event, fCRTHitLabel);
419 
420  // Get all the true IDs from all the IDEs in the track
421  for(size_t i = 0; i < hits.size(); i++){
422  std::vector<art::Ptr<sbnd::crt::CRTData>> data = findManyData.at(i);
423  art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event, fCRTDataLabel);
424  for(size_t j = 0; j < data.size(); j++){
425  std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(j);
426  for(size_t k = 0; k < ides.size(); k++){
427  int id = ides[k]->trackID;
428  if(fRollupUnsavedIds) id = std::abs(id);
429  ids[id] += ides[k]->energyDeposited;
430  }
431  }
432  }
433 
434  // Find the true ID that contributed the most energy
435  double maxEnergy = -1;
436  int trueId = -99999;
437  for(auto &id : ids){
438  if(id.second > maxEnergy){
439  maxEnergy = id.second;
440  trueId = id.first;
441  }
442  }
443 
444  return trueId;
445 
446 }
bool TrackCompare(const sbn::crt::CRTTrack &track1, const sbn::crt::CRTTrack &track2)
T abs(T value)
pdgs k
Definition: selectors.fcl:22
int sbnd::CRTBackTracker::TrueIdFromTrackId ( const art::Event &  event,
int  track_i 
)

Definition at line 448 of file sbndcode/sbndcode/CRT/CRTUtils/CRTBackTracker.cc.

448  {
449 
450  if(fTrackTrueIds.find(track_i) != fTrackTrueIds.end()){
451  double maxEnergy = -1;
452  int trueId = -99999;
453  for(auto &id : fTrackTrueIds[track_i]){
454  if(id.second > maxEnergy){
455  maxEnergy = id.second;
456  trueId = id.first;
457  }
458  }
459 
460  return trueId;
461  }
462 
463  return -99999;
464 
465 }
std::map< int, std::map< int, double > > fTrackTrueIds

Member Data Documentation

art::InputTag sbnd::CRTBackTracker::fCRTDataLabel
private
art::InputTag sbnd::CRTBackTracker::fCRTHitLabel
private
art::InputTag sbnd::CRTBackTracker::fCRTTrackLabel
private
std::map<int, std::map<int, double> > sbnd::CRTBackTracker::fDataTrueIds
private
std::map<int, std::map<int, double> > sbnd::CRTBackTracker::fHitTrueIds
private
bool sbnd::CRTBackTracker::fRollupUnsavedIds
private
std::map<int, std::map<int, double> > sbnd::CRTBackTracker::fTrackTrueIds
private

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