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

#include <CRTTrueHitRecoAlg.h>

Classes

struct  Config
 

Public Types

using CRTHit = sbn::crt::CRTHit
 

Public Member Functions

 CRTTrueHitRecoAlg (const Config &config)
 
 CRTTrueHitRecoAlg (const fhicl::ParameterSet &pset)
 
 ~CRTTrueHitRecoAlg ()
 
void reconfigure (const Config &config)
 
vector< pair< CRTHit, vector
< sim::AuxDetIDE > > > 
CreateCRTHits (vector< art::Ptr< sim::AuxDetSimChannel >> adscList)
 
CRTHit FillCrtHit (vector< uint8_t > tfeb_id, map< uint8_t, vector< pair< int, float >>> tpesmap, float peshit, double time0, double time1, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
 

Private Attributes

geo::GeometryCore const * fGeometryService
 
CRTCommonUtilsfCrtutils
 
bool fUseReadoutWindow
 
double fEDepMin
 
bool fRollupUnusedIds
 
double fGlobalT0Offset
 

Detailed Description

Definition at line 48 of file CRTTrueHitRecoAlg.h.

Member Typedef Documentation

Definition at line 52 of file CRTTrueHitRecoAlg.h.

Constructor & Destructor Documentation

CRTTrueHitRecoAlg::CRTTrueHitRecoAlg ( const Config config)

Definition at line 10 of file CRTTrueHitRecoAlg.cc.

10  {
11  this->reconfigure(config);
12 
13  fGeometryService = lar::providerFrom<geo::Geometry>();
14  fCrtutils = new CRTCommonUtils();
15 }
void reconfigure(const Config &config)
geo::GeometryCore const * fGeometryService
icarus::crt::CRTTrueHitRecoAlg::CRTTrueHitRecoAlg ( const fhicl::ParameterSet &  pset)
inline

Definition at line 78 of file CRTTrueHitRecoAlg.h.

78  :
79  CRTTrueHitRecoAlg(fhicl::Table<Config>(pset, {})()) {}
CRTTrueHitRecoAlg(const Config &config)
CRTTrueHitRecoAlg::~CRTTrueHitRecoAlg ( )

Definition at line 24 of file CRTTrueHitRecoAlg.cc.

24 {}

Member Function Documentation

vector< pair< sbn::crt::CRTHit, vector< sim::AuxDetIDE > > > CRTTrueHitRecoAlg::CreateCRTHits ( vector< art::Ptr< sim::AuxDetSimChannel >>  adscList)

Definition at line 37 of file CRTTrueHitRecoAlg.cc.

39 {
40  vector<pair<CRTHit,vector<sim::AuxDetIDE>>> hitCol;
41  map<int,map<int,tagger>> trackTaggers; //trackID -> (moduleID -> tagger )
42 
43  //fill taggers
44  //loop over AuxDetSimChannels
45  for(auto const& adsc : adscList) {
46 
47  const int adID = adsc->AuxDetID();
48  const int layerID = fCrtutils->GetLayerID(adsc);
49  const char type = fCrtutils->GetAuxDetType(adID);
50  const string region = fCrtutils->GetAuxDetRegion(adID);
51  const int adsID = adsc->AuxDetSensitiveID();
52 
53  //loop over AuxDetIDEs
54  for(auto const& ide : adsc->AuxDetIDEs()) {
55 
56  //FIX ME: for now, ignoring negative IDs, impliment fRollupUnusedIds
57  if(/*ide.trackID>-1 &&*/ ide.energyDeposited*1000 < fEDepMin)
58  continue;
59  if(!fRollupUnusedIds && ide.trackID<0)
60  continue;
61  tagger& tag = (trackTaggers[ide.trackID])[adID];
62  tag.type = type;
63  tag.region = region;
64  tag.layerID.insert(layerID);
65  tag.stripLayer[adsID] = layerID;
66  tag.stripIDE[adsID] = ide;
67  }//AuxDetIDEs
68  }//AuxDetSimChannels
69 
70  int nmisscd=0, nmisspair=0;
71 
72  //apply logic to form hits
73  //loop over trackIDs
74  for (auto const& trk : trackTaggers) {
75 
76  map <int,tagger> mTaggers; //MINOS module ID -> tagger
77  // loop over taggers: modID->strip hit info
78  for (auto const& tag : trk.second) {
79 
80  vector<sim::AuxDetIDE> vide; //IDEs in hit
81  //XYZTVector
82  TLorentzVector rHit(0.,0.,0.,0.); //average hit position
83  vector<uint8_t> feb_id = {(fCrtutils->ADToMac( tag.first)).first};
84  map<uint8_t,vector< pair<int,float> > > pesmap;
85  float peshit = 0.;
86  double xerr=0., yerr=0., zerr = 0.;
87 
88  // if c or d type module
89  if (tag.second.type=='c' || tag.second.type=='d') {
90 
91  // if "X-Y" coincidence
92  if (tag.second.layerID.size()>1) {
93 
94  // loop over module strips map: stripID->pos 4-vec
95  for (auto const& ide : tag.second.stripIDE) {
96  rHit += fCrtutils->AvgIDEPoint(ide.second);
97  vide.push_back(ide.second);
98  peshit+=ide.second.energyDeposited*1000;
99  pesmap[feb_id[0]].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
100  }
101 
102  rHit*=1.0/tag.second.stripIDE.size();
103  rHit.SetT(rHit.T()+fGlobalT0Offset);
104 
105  //hit position RMS
106  for ( auto const& ide : tag.second.stripIDE) {
107  //XYZTVector
108  TLorentzVector point = fCrtutils->AvgIDEPoint(ide.second);
109  xerr += pow(point.X()-rHit.X(),2);
110  yerr += pow(point.Y()-rHit.Y(),2);
111  zerr += pow(point.Z()-rHit.Z(),2);
112  }
113  xerr = sqrt(xerr/(tag.second.stripIDE.size()-1));
114  yerr = sqrt(yerr/(tag.second.stripIDE.size()-1));
115  zerr = sqrt(zerr/(tag.second.stripIDE.size()-1));
116 
117  } //if coincidence
118  else{
119  nmisscd++;
120  continue;
121  }
122 
123  hitCol.push_back(std::make_pair(
124  FillCrtHit(feb_id, pesmap, peshit, rHit.T(), rHit.T(), 0, rHit.X(), xerr,
125  rHit.Y(), yerr, rHit.Z(), zerr, tag.second.region),
126  vide) );
127 
128  }//if c or d type
129 
130  if ( tag.second.type=='m' ) {
131  mTaggers[tag.first] = tag.second;
132  }
133 
134  } //loop over taggers
135 
136  set <int> mPairs; //keep track of used auxdetIDs
137  for (auto const& tag : mTaggers) {
138 
139  if (mPairs.find(tag.first) != mPairs.end()) continue; //don't double count
140 
141  vector<sim::AuxDetIDE> vide; //IDEs in hit
142  //XYZTVector
143  TLorentzVector rHit(0.,0.,0.,0.); //average hit position
144  auto macpair = fCrtutils->ADToMac(tag.first);
145  uint8_t mac1 = macpair.first;
146  uint8_t mac11 = macpair.second;
147  vector<uint8_t> feb_id = {mac1};
148  if(mac1!=mac11) feb_id.push_back(mac11);
149  map<uint8_t,vector< pair<int,float> > > pesmap;
150  float peshit = 0.;
151  bool pairFound = false;
152  double xerr=0., yerr=0., zerr = 0.;
153  set<int> layers;
154  layers.insert(*(tag.second.layerID.begin()));
155  mPairs.insert(tag.first);
156 
157  for (auto const& ide : tag.second.stripIDE) {
158  rHit += fCrtutils->AvgIDEPoint(ide.second);
159  vide.push_back(ide.second);
160  peshit+=ide.second.energyDeposited*1000;
161  pesmap[mac1].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
162  }
163 
164  //inner loop over mTaggers (try to find a coincidence match)
165  for (auto const& tag2 : mTaggers) {
166  if ( tag.first == tag2.first ) continue; //not the same module
167  if ( mPairs.find(tag2.first) != mPairs.end()) continue; //not aleady counted
168  if ( tag.second.region != tag2.second.region ) continue; //modules in same region
169 
170  layers.insert(*(tag2.second.layerID.begin()));
171 
172  //mark module as counted
173  mPairs.insert(tag2.first);
174 
175  //mac5's for 2nd module in pair
176  macpair = fCrtutils->ADToMac(tag2.first);
177  uint8_t mac2 = macpair.first;
178  uint8_t mac22 = macpair.second;
179  feb_id.push_back(mac2);
180  if(mac2!=mac22) feb_id.push_back(mac22);
181 
182  // loop over module strips map: stripID->pos 4-vec
183  for (auto const& ide : tag2.second.stripIDE) {
184  rHit += fCrtutils->AvgIDEPoint(ide.second);
185  vide.push_back(ide.second);
186  peshit+=ide.second.energyDeposited*1000;
187  pesmap[mac2].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
188  }//for xyzt in second tagger (module)
189 
190  if(layers.size()==2)
191  pairFound = true;
192  }//inner loop over taggers
193 
194  if (pairFound) {
195 
196  rHit*=1.0/vide.size();
197  rHit.SetT(rHit.T()+fGlobalT0Offset);
198 
199  //hit position RMS
200  for ( auto const& ide : vide) {
201  //XYZTVector
202  TLorentzVector point = fCrtutils->AvgIDEPoint(ide);
203  xerr += pow(point.X()-rHit.X(),2);
204  yerr += pow(point.Y()-rHit.Y(),2);
205  zerr += pow(point.Z()-rHit.Z(),2);
206  }
207 
208  xerr = sqrt(xerr/(vide.size()-1));
209  yerr = sqrt(yerr/(vide.size()-1));
210  zerr = sqrt(zerr/(vide.size()-1));
211 
212  hitCol.push_back(std::make_pair(
213  FillCrtHit(feb_id, pesmap, peshit, rHit.T(), rHit.T(), 0, rHit.X(), xerr,
214  rHit.Y(), yerr, rHit.Z(), zerr, tag.second.region),
215  vide) );
216 
217  }
218  else nmisspair++;
219 
220  } // outer loop over minos taggers
221  } //loop over trackTaggers
222 
223  std::cout << "CRTTrueHitRecoAlg: nmisscd=" << nmisscd << ", nmissm=" << nmisspair << std::endl;
224 
225  return hitCol;
226 }
map< int, int > stripLayer
string region
CRTHit FillCrtHit(vector< uint8_t > tfeb_id, map< uint8_t, vector< pair< int, float >>> tpesmap, float peshit, double time0, double time1, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
map< int, sim::AuxDetIDE > stripIDE
std::set< int > layerID
BEGIN_PROLOG could also be cout
sbn::crt::CRTHit CRTTrueHitRecoAlg::FillCrtHit ( vector< uint8_t >  tfeb_id,
map< uint8_t, vector< pair< int, float >>>  tpesmap,
float  peshit,
double  time0,
double  time1,
int  plane,
double  x,
double  ex,
double  y,
double  ey,
double  z,
double  ez,
std::string  tagger 
)

Definition at line 230 of file CRTTrueHitRecoAlg.cc.

232  {
233  CRTHit crtHit;
234  crtHit.feb_id = tfeb_id;
235  crtHit.pesmap = tpesmap;
236  crtHit.peshit = peshit;
237  crtHit.ts0_s_corr = time0*1e-9;
238  crtHit.ts0_ns = time0;
239  crtHit.ts0_ns_corr = time0;
240  crtHit.ts1_ns = time1;
241  crtHit.ts0_s = time0 * 1e-9;
242  crtHit.plane = plane;
243  crtHit.x_pos = x;
244  crtHit.x_err = ex;
245  crtHit.y_pos = y;
246  crtHit.y_err = ey;
247  crtHit.z_pos = z;
248  crtHit.z_err = ez;
249  crtHit.tagger = tagger;
250 
251  return crtHit;
252 
253 } //FillCrtHit()
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
std::map< uint8_t, std::vector< std::pair< int, float > > > pesmap
process_name opflash particleana ie ie y
do i e
std::vector< uint8_t > feb_id
void CRTTrueHitRecoAlg::reconfigure ( const Config config)

Definition at line 27 of file CRTTrueHitRecoAlg.cc.

27  {
28  fUseReadoutWindow = config.UseReadoutWindow();
29  fEDepMin = config.EDepMin();
30  fRollupUnusedIds = config.RollupUnusedIds();
31  fGlobalT0Offset = config.GlobalT0Offset();
32  return;
33 }

Member Data Documentation

CRTCommonUtils* icarus::crt::CRTTrueHitRecoAlg::fCrtutils
private

Definition at line 96 of file CRTTrueHitRecoAlg.h.

double icarus::crt::CRTTrueHitRecoAlg::fEDepMin
private

Definition at line 100 of file CRTTrueHitRecoAlg.h.

geo::GeometryCore const* icarus::crt::CRTTrueHitRecoAlg::fGeometryService
private

Definition at line 95 of file CRTTrueHitRecoAlg.h.

double icarus::crt::CRTTrueHitRecoAlg::fGlobalT0Offset
private

Definition at line 102 of file CRTTrueHitRecoAlg.h.

bool icarus::crt::CRTTrueHitRecoAlg::fRollupUnusedIds
private

Definition at line 101 of file CRTTrueHitRecoAlg.h.

bool icarus::crt::CRTTrueHitRecoAlg::fUseReadoutWindow
private

Definition at line 99 of file CRTTrueHitRecoAlg.h.


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