1 #ifndef ICARUS_CRTTRUEHITRECOALG_CC
2 #define ICARUS_CRTTRUEHITRECOALG_CC
38 vector<art::Ptr<sim::AuxDetSimChannel>> adscList)
40 vector<pair<CRTHit,vector<sim::AuxDetIDE>>> hitCol;
41 map<int,map<int,tagger>> trackTaggers;
45 for(
auto const& adsc : adscList) {
47 const int adID = adsc->AuxDetID();
51 const int adsID = adsc->AuxDetSensitiveID();
54 for(
auto const& ide : adsc->AuxDetIDEs()) {
57 if( ide.energyDeposited*1000 <
fEDepMin)
61 tagger& tag = (trackTaggers[ide.trackID])[adID];
70 int nmisscd=0, nmisspair=0;
74 for (
auto const& trk : trackTaggers) {
76 map <int,tagger> mTaggers;
78 for (
auto const& tag : trk.second) {
80 vector<sim::AuxDetIDE> vide;
82 TLorentzVector rHit(0.,0.,0.,0.);
84 map<uint8_t,vector< pair<int,float> > > pesmap;
86 double xerr=0., yerr=0., zerr = 0.;
89 if (tag.second.type==
'c' || tag.second.type==
'd') {
92 if (tag.second.layerID.size()>1) {
95 for (
auto const& ide : tag.second.stripIDE) {
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));
102 rHit*=1.0/tag.second.stripIDE.size();
106 for (
auto const& ide : tag.second.stripIDE) {
109 xerr += pow(point.X()-rHit.X(),2);
110 yerr += pow(point.Y()-rHit.Y(),2);
111 zerr += pow(point.Z()-rHit.Z(),2);
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));
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),
130 if ( tag.second.type==
'm' ) {
131 mTaggers[tag.first] = tag.second;
137 for (
auto const& tag : mTaggers) {
139 if (mPairs.find(tag.first) != mPairs.end())
continue;
141 vector<sim::AuxDetIDE> vide;
143 TLorentzVector rHit(0.,0.,0.,0.);
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;
151 bool pairFound =
false;
152 double xerr=0., yerr=0., zerr = 0.;
154 layers.insert(*(tag.second.layerID.begin()));
155 mPairs.insert(tag.first);
157 for (
auto const& ide : tag.second.stripIDE) {
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));
165 for (
auto const& tag2 : mTaggers) {
166 if ( tag.first == tag2.first )
continue;
167 if ( mPairs.find(tag2.first) != mPairs.end())
continue;
168 if ( tag.second.region != tag2.second.region )
continue;
170 layers.insert(*(tag2.second.layerID.begin()));
173 mPairs.insert(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);
183 for (
auto const& ide : tag2.second.stripIDE) {
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));
196 rHit*=1.0/vide.size();
200 for (
auto const& ide : vide) {
203 xerr += pow(point.X()-rHit.X(),2);
204 yerr += pow(point.Y()-rHit.Y(),2);
205 zerr += pow(point.Z()-rHit.Z(),2);
208 xerr = sqrt(xerr/(vide.size()-1));
209 yerr = sqrt(yerr/(vide.size()-1));
210 zerr = sqrt(zerr/(vide.size()-1));
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),
223 std::cout <<
"CRTTrueHitRecoAlg: nmisscd=" << nmisscd <<
", nmissm=" << nmisspair << std::endl;
231 float peshit,
double time0,
double time1,
int plane,
232 double x,
double ex,
double y,
double ey,
double z,
double ez,
string tagger){
241 crtHit.
ts0_s = time0 * 1e-9;
242 crtHit.
plane = plane;
float z_err
position uncertainty in z-direction (cm).
process_name opflash particleana ie ie ie z
float x_err
position uncertainty in x-direction (cm).
std::map< uint8_t, std::vector< std::pair< int, float > > > pesmap
Saves signal hit information (FEB, local-channel and PE) .
map< int, int > stripLayer
Utilities related to art service access.
TLorentzVector AvgIDEPoint(sim::AuxDetIDE ide)
std::vector< uint8_t > feb_id
FEB address.
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
fhicl::Atom< double > EDepMin
process_name opflash particleana ie x
fhicl::Atom< bool > RollupUnusedIds
int plane
Name of the CRT wall (in the form of numbers).
float peshit
Total photo-electron (PE) in a crt hit.
void reconfigure(const Config &config)
float y_err
position uncertainty in y-direction (cm).
vector< pair< CRTHit, vector< sim::AuxDetIDE > > > CreateCRTHits(vector< art::Ptr< sim::AuxDetSimChannel >> adscList)
double ts0_ns_corr
[Honestly, not sure at this point, it was there since long time (BB)]
double ts0_s_corr
[Honestly, not sure at this point, it was there since long time (BB)]
uint64_t ts0_s
Second-only part of timestamp T0.
float z_pos
position in z-direction (cm).
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
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)
geo::GeometryCore const * fGeometryService
process_name opflash particleana ie ie y
map< int, sim::AuxDetIDE > stripIDE
CRTCommonUtils * fCrtutils
pair< uint8_t, uint8_t > ADToMac(size_t adid)
char GetAuxDetType(size_t adid)
float y_pos
position in y-direction (cm).
int GetLayerID(sim::AuxDetSimChannel const &adsc)
string GetAuxDetRegion(size_t adid)
float x_pos
position in x-direction (cm).
fhicl::Atom< double > GlobalT0Offset
std::string tagger
Name of the CRT wall (in the form of strings).
CRTTrueHitRecoAlg(const Config &config)
BEGIN_PROLOG could also be cout
fhicl::Atom< bool > UseReadoutWindow