28 bool findData =
false, findSimHit =
false;
37 art::Handle< std::vector<CRTHit>> crtTrueHitHandle;
38 std::vector<art::Ptr<CRTHit> > crtTrueHitList;
40 art::fill_ptr_vector(crtTrueHitList, crtTrueHitHandle);
42 art::FindManyP<sim::AuxDetIDE> findManyIdes(crtTrueHitHandle, event,
fCRTTrueHitLabel);
43 std::map<art::Ptr<CRTHit>,
int> trueHitPtrMap;
45 for(
size_t hit_i = 0; hit_i < crtTrueHitList.size(); hit_i++){
47 trueHitPtrMap[crtTrueHitList[hit_i]] = hit_i;
48 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(hit_i);
50 for(
size_t i = 0; i < ides.size(); i++){
52 int id = ides[i]->trackID;
59 mf::LogWarning(
"CRTBackTracker") <<
"no CRTTrueHit products found";
62 art::Handle< std::vector<CRTData>> crtDataHandle;
63 std::vector<art::Ptr<CRTData> > crtDataList;
64 std::map<art::Ptr<CRTData>,
int> dataPtrMap;
67 art::fill_ptr_vector(crtDataList, crtDataHandle);
68 art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event,
fCRTDataLabel);
70 for(
size_t data_i = 0; data_i < crtDataList.size(); data_i++){
72 dataPtrMap[crtDataList[data_i]] = data_i;
74 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
76 for(
size_t i = 0; i < ides.size(); i++){
78 int id = ides[i]->trackID;
86 mf::LogWarning(
"CRTBackTracker") <<
"no CRTData products found";
89 art::Handle< std::vector<CRTHit>> crtSimHitHandle;
90 std::vector<art::Ptr<CRTHit> > crtSimHitList;
91 std::map<art::Ptr<CRTHit>,
int> simHitPtrMap;
95 mf::LogError(
"CRTBackTracker")
96 <<
"no CRTData products found when some were expected (CRTSimHits found)";
98 art::fill_ptr_vector(crtSimHitList, crtSimHitHandle);
99 art::FindManyP<CRTData> findManyData(crtSimHitHandle, event,
fCRTSimHitLabel);
101 for(
size_t hit_i = 0; hit_i < crtSimHitList.size(); hit_i++){
103 simHitPtrMap[crtSimHitList[hit_i]] = hit_i;
104 std::vector<art::Ptr<CRTData>> data = findManyData.at(hit_i);
106 for(
size_t data_i = 0; data_i < data.size(); data_i++){
108 int dataID = dataPtrMap[data[data_i]];
118 mf::LogWarning(
"CRTBackTracker") <<
"no CRTSimHit products found";
121 art::Handle< std::vector<CRTTrack>> crtTrackHandle;
122 std::vector<art::Ptr<CRTTrack> > crtTrackList;
127 mf::LogError(
"CRTBackTracker")
128 <<
"no CRTSimHit products found when some were expected (CRTTracks found)";
130 art::fill_ptr_vector(crtTrackList, crtTrackHandle);
131 art::FindManyP<CRTHit> findManyHits(crtTrackHandle, event,
fCRTTrackLabel);
133 for(
size_t track_i = 0; track_i < crtTrackList.size(); track_i++){
135 std::vector<art::Ptr<CRTHit>> hits = findManyHits.at(track_i);
136 for(
size_t hit_i = 0; hit_i < hits.size(); hit_i++){
138 int hitID = simHitPtrMap[hits[hit_i]];
147 mf::LogWarning(
"CRTBackTracker") <<
"no CRTTrack products found";
156 if(data1.
fTs0 != data2.
fTs0)
return false;
157 if(data1.
fTs1 != data2.
fTs1)
return false;
159 for(
int ch=0; ch<64; ch++) {
160 if(data1.
fAdc[ch] != data2.
fAdc[ch])
return false;
210 std::vector<int> ids;
213 auto crtDataHandle =
event.getValidHandle<std::vector<CRTData>>(
fCRTDataLabel);
214 art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event,
fCRTDataLabel);
217 int data_i = 0, index = 0;
220 for(
auto const& crtData : (*crtDataHandle)){
230 mf::LogError(
"CRTBackTracker::AllTrueIds") <<
"no matches for provided CRTData product found!";
232 mf::LogError(
"CRTBackTracker::AllTrueIds") <<
"multiple matches for given CRTData product found!";
235 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
237 for(
size_t i = 0; i < ides.size(); i++){
239 int id = ides[i]->trackID;
247 std::sort(ids.begin(), ids.end());
248 ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
257 std::vector<int> ids;
260 art::Handle< std::vector<CRTHit> > crtSimHitHandle;
261 art::Handle< std::vector<CRTHit> > crtTrueHitHandle;
264 int hit_i = -1, tmp_hit_i = -1, index = 0;
265 bool sim=
false, findsim=
false, findtrue=
false;
271 for(
auto const& crtHit : (*crtSimHitHandle)){
273 if(
HitCompare(crtHit, hit)) tmp_hit_i = index;
289 for(
auto const& crtHit : (*crtTrueHitHandle)){
291 if(
HitCompare(crtHit, hit)) tmp_hit_i = index;
296 mf::LogError(
"CRTBackTracker::AllTrueIds") <<
"True/Sim CRTHit ID ambiguity!";
303 mf::LogError(
"CRTBackTracker::AllTrueIds") <<
"no match for passed CRTHit found!";
306 if(!findsim && !findtrue) {
307 mf::LogError(
"CRTBackTracker::AllTrueIds") <<
"no handle to CRTHits could be found!";
312 std::vector<art::Ptr<sim::AuxDetIDE>> ides;
316 art::FindManyP<CRTData> findManyData(crtSimHitHandle, event,
fCRTSimHitLabel);
317 std::vector<art::Ptr<CRTData>> data;
318 data = findManyData.at(hit_i);
319 art::FindManyP<sim::AuxDetIDE> findManySimIdes(data, event,
fCRTDataLabel);
320 for(
size_t i = 0; i < data.size(); i++){
322 ides = findManySimIdes.at(i);
323 for(
size_t j = 0; j < ides.size(); j++){
325 int id = ides[j]->trackID;
332 art::FindManyP<sim::AuxDetIDE> findManyTrueIdes(crtTrueHitHandle, event,
fCRTTrueHitLabel);
333 ides = findManyTrueIdes.at(hit_i);
334 for(
auto const& ide : ides) {
335 int id = ide->trackID;
342 std::sort(ids.begin(), ids.end());
343 ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
352 std::vector<int> ids;
354 auto crtTrackHandle =
event.getValidHandle<std::vector<CRTTrack>>(
fCRTTrackLabel);
355 art::FindManyP<CRTHit> findManyHits(crtTrackHandle, event,
fCRTTrackLabel);
357 int track_i = 0, index = 0;
359 for(
auto const& crtTrack : (*crtTrackHandle)){
366 std::vector<art::Ptr<CRTHit>> hits = findManyHits.at(track_i);
370 for(
size_t i = 0; i < hits.size(); i++){
372 std::vector<art::Ptr<CRTData>> data = findManyData.at(i);
373 art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event,
fCRTDataLabel);
374 for(
size_t j = 0; j < data.size(); j++){
376 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(j);
377 for(
size_t k = 0;
k < ides.size();
k++){
379 int id = ides[
k]->trackID;
388 std::sort(ids.begin(), ids.end());
389 ids.erase(std::unique(ids.begin(), ids.end()), ids.end());
398 std::map<int, double> ids;
401 auto crtDataHandle =
event.getValidHandle<std::vector<CRTData>>(
fCRTDataLabel);
402 art::FindManyP<sim::AuxDetIDE> findManyIdes(crtDataHandle, event,
fCRTDataLabel);
405 int data_i = 0, index = 0;
407 for(
auto const& crtData : (*crtDataHandle)){
414 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(data_i);
416 for(
size_t i = 0; i < ides.size(); i++){
418 int id = ides[i]->trackID;
420 ids[id] += ides[i]->energyDeposited;
424 double maxEnergy = -1;
429 if(
id.
second > maxEnergy){
431 maxEnergy =
id.second;
444 double maxEnergy = -1;
449 if(
id.
second > maxEnergy){
451 maxEnergy =
id.second;
466 std::map<int, double> ids;
469 auto crtHitHandle =
event.getValidHandle<std::vector<CRTHit>>(
fCRTSimHitLabel);
470 art::FindManyP<CRTData> findManyData(crtHitHandle, event,
fCRTSimHitLabel);
473 int hit_i = 0, index = 0;
475 for(
auto const& crtHit : (*crtHitHandle)){
482 std::vector<art::Ptr<CRTData>> data = findManyData.at(hit_i);
483 art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event,
fCRTDataLabel);
486 for(
size_t i = 0; i < data.size(); i++){
488 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(i);
490 for(
size_t j = 0; j < ides.size(); j++){
492 int id = ides[j]->trackID;
494 ids[id] += ides[j]->energyDeposited;
499 double maxEnergy = -1;
504 if(
id.
second > maxEnergy){
506 maxEnergy =
id.second;
521 double maxEnergy = -1;
526 if(
id.
second > maxEnergy){
528 maxEnergy =
id.second;
545 std::map<int, double> ids;
548 auto crtTrackHandle =
event.getValidHandle<std::vector<CRTTrack>>(
fCRTTrackLabel);
549 art::FindManyP<CRTHit> findManyHits(crtTrackHandle, event,
fCRTTrackLabel);
552 int track_i = 0, index = 0;
554 for(
auto const& crtTrack : (*crtTrackHandle)){
561 std::vector<art::Ptr<CRTHit>> hits = findManyHits.at(track_i);
565 for(
size_t i = 0; i < hits.size(); i++){
567 std::vector<art::Ptr<CRTData>> data = findManyData.at(i);
568 art::FindManyP<sim::AuxDetIDE> findManyIdes(data, event,
fCRTDataLabel);
570 for(
size_t j = 0; j < data.size(); j++){
572 std::vector<art::Ptr<sim::AuxDetIDE>> ides = findManyIdes.at(j);
574 for(
size_t k = 0;
k < ides.size();
k++){
576 int id = ides[
k]->trackID;
578 ids[id] += ides[
k]->energyDeposited;
585 double maxEnergy = -1;
590 if(
id.
second > maxEnergy){
592 maxEnergy =
id.second;
605 double maxEnergy = -1;
611 if(
id.
second > maxEnergy){
613 maxEnergy =
id.second;
uint8_t fMac5
FEB address following numbering convention common for both data and MC.
float z_err
position uncertainty in z-direction (cm).
bool HitCompare(const CRTHit &hit1, const CRTHit &hit2)
art::InputTag fCRTSimHitLabel
float x_err
position uncertainty in x-direction (cm).
std::map< int, std::map< int, double > > fTrueHitTrueIds
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
fhicl::Atom< art::InputTag > CRTSimHitLabel
int plane
Name of the CRT wall (in the form of numbers).
float y_err
position uncertainty in y-direction (cm).
void reconfigure(const Config &config)
std::map< int, std::map< int, double > > fDataTrueIds
art::InputTag fCRTTrackLabel
float x1_pos
X position of first CRTHit.
uint32_t fEntry
Hit index for given FEB in an event (starts from 0 for each event).
int TrueIdFromDataId(const art::Event &event, int data_i)
process_name use argoneut_mc_hitfinder track
int TrueIdFromTrackId(const art::Event &event, int track_i)
std::map< int, std::map< int, double > > fTrackTrueIds
bool DataCompare(const CRTData &data1, const CRTData &data2)
float y1_err
Y position error of first CRTHit.
art::InputTag fCRTTrueHitLabel
fhicl::Atom< art::InputTag > CRTTrueHitLabel
fhicl::Atom< bool > RollupUnsavedIds
float z_pos
position in z-direction (cm).
float z1_err
Z position error of first CRTHit.
float y2_err
Y position error of second CRTHit.
double ts1_ns
Average T1 (nanosecond) of the two hits making the track.
void Initialize(const art::Event &event)
Single hit (self trigger) of a CRT board.
art::InputTag fCRTDataLabel
fhicl::Atom< art::InputTag > CRTTrackLabel
float z1_pos
Z position of first CRTHit.
float y_pos
position in y-direction (cm).
bool TrackCompare(const CRTTrack &track1, const CRTTrack &track2)
uint16_t fAdc[64]
ADC readout for each channel. CAEN (Bern) CRT FEBs use only indices 0-31.
int TrueIdFromHitId(const art::Event &event, int hit_i)
int plane1
Plane ID of first CRTHit.
float z2_pos
Z position of second CRTHit.
float x_pos
position in x-direction (cm).
fhicl::Atom< art::InputTag > CRTDataLabel
float y2_pos
Y position of second CRTHit.
float y1_pos
Y position of first CRTHit.
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
CRTBackTracker(const Config &config)
float x2_pos
X position of second CRTHit.
int TrueIdFromTotalEnergy(const art::Event &event, const CRTData &data)
float x1_err
X position error of first CRTHit.
std::map< int, std::map< int, double > > fSimHitTrueIds
std::string tagger
Name of the CRT wall (in the form of strings).
int plane2
Plane ID of second CRTHit.
float z2_err
Z position error of second CRTHit.
float x2_err
X position error of second CRTHit.
uint64_t fTs0
Absolute hit timestamp [ns].
uint64_t fTs1
Trigger time, not well defined as of Apr 14, 2021.