52 std::map<std::pair<std::string, unsigned>, std::vector<CRTStrip>> taggerStrips;
54 for (
size_t i = 0; i < crtList.size(); i+=2){
61 if(!(t1 >= -driftTimeMuS && t1 <= readoutWindowMuS))
continue;
66 taggerStrips[strip.
tagger].push_back(strip);
83 uint32_t channel = sipm1->Channel();
99 double time = (t1 + t2)/2.;
101 CRTStrip stripHit = {time, channel, sipmDist.first, sipmDist.second, npe1+npe2, tagger, ind};
108 uint32_t channel = sipm1->Channel();
110 if (stripName.empty()) {
111 throw cet::exception(
"CRTHitRecoAlg")
112 <<
"Cannot find strip name for channel " << channel << std::endl;
122 double x = (width/2.)*atan(log(1.*npe2/npe1)) + (width/2.);
125 double normx = x + 0.344677*x - 1.92045;
126 double ex = 1.92380e+00+1.47186e-02*normx-5.29446e-03*normx*normx;
128 return std::make_pair(x, ex);
133 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>>
CRTHitRecoAlg::CreateCRTHits(std::map<std::pair<std::string, unsigned>, std::vector<CRTStrip>> taggerStrips){
135 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>> returnHits;
137 std::vector<uint8_t> tfeb_id = {0};
138 std::map<uint8_t, std::vector<std::pair<int,float>>> tpesmap;
139 tpesmap[0] = {std::make_pair(0,0)};
142 for(
auto &tagStrip : taggerStrips){
143 std::sort(tagStrip.second.begin(), tagStrip.second.end(),
145 return (a.
t0 < b.t0) ||
146 ((a.
t0 == b.t0) && (a.
channel < b.channel));
149 tagStrip.second.erase(std::unique(tagStrip.second.begin(), tagStrip.second.end(),
151 return a.
t0 == b.t0 && a.
channel == b.channel;
152 }), tagStrip.second.end());
155 std::vector<std::string> usedTaggers;
157 for (
auto &tagStrip : taggerStrips){
158 if (std::find(usedTaggers.begin(),usedTaggers.end(),tagStrip.first.first)!=usedTaggers.end())
continue;
159 usedTaggers.push_back(tagStrip.first.first);
160 unsigned planeID = 0;
161 if(tagStrip.first.second==0) planeID = 1;
162 std::pair<std::string,unsigned> otherPlane = std::make_pair(tagStrip.first.first, planeID);
164 for (
size_t hit_i = 0; hit_i < tagStrip.second.size(); hit_i++){
172 for (
size_t hit_j = 0; hit_j < taggerStrips[otherPlane].size(); hit_j++){
174 std::vector<double> limits2 =
ChannelToLimits(taggerStrips[otherPlane][hit_j]);
178 double t0_1 = tagStrip.second[hit_i].t0;
179 double t0_2 = taggerStrips[otherPlane][hit_j].t0;
182 TVector3
mean((overlap[0] + overlap[1])/2.,
183 (overlap[2] + overlap[3])/2.,
184 (overlap[4] + overlap[5])/2.);
186 std::abs((overlap[3] - overlap[2])/2.),
187 std::abs((overlap[5] - overlap[4])/2.));
192 double pes =
CorrectNpe(tagStrip.second[hit_i], taggerStrips[otherPlane][hit_j], mean);
197 mean.Y(), error.Y(), mean.Z(), error.Z(), tagStrip.first.first);
198 std::vector<int> dataIds;
199 dataIds.push_back(tagStrip.second[hit_i].dataID);
200 dataIds.push_back(tagStrip.second[hit_i].dataID+1);
201 dataIds.push_back(taggerStrips[otherPlane][hit_j].dataID);
202 dataIds.push_back(taggerStrips[otherPlane][hit_j].dataID+1);
203 returnHits.push_back(std::make_pair(crtHit, dataIds));
211 TVector3
mean((limits1[0] + limits1[1])/2.,
212 (limits1[2] + limits1[3])/2.,
213 (limits1[4] + limits1[5])/2.);
215 std::abs((limits1[3] - limits1[2])/2.),
216 std::abs((limits1[5] - limits1[4])/2.));
218 double time = tagStrip.second[hit_i].t0 -
fTimeOffset;
219 double pes = tagStrip.second[hit_i].pes;
224 mean.Y(), error.Y(), mean.Z(), error.Z(), tagStrip.first.first);
225 std::vector<int> dataIds;
226 dataIds.push_back(tagStrip.second[hit_i].dataID);
227 dataIds.push_back(tagStrip.second[hit_i].dataID+1);
228 returnHits.push_back(std::make_pair(crtHit, dataIds));
233 for (
size_t hit_j = 0; hit_j < taggerStrips[otherPlane].size(); hit_j++){
235 std::vector<double> limits1 =
ChannelToLimits(taggerStrips[otherPlane][hit_j]);
239 TVector3
mean((limits1[0] + limits1[1])/2.,
240 (limits1[2] + limits1[3])/2.,
241 (limits1[4] + limits1[5])/2.);
243 std::abs((limits1[3] - limits1[2])/2.),
244 std::abs((limits1[5] - limits1[4])/2.));
246 double time = taggerStrips[otherPlane][hit_j].t0 -
fTimeOffset;
247 double pes = taggerStrips[otherPlane][hit_j].pes;
252 mean.Y(), error.Y(), mean.Z(), error.Z(), otherPlane.first);
253 std::vector<int> dataIds;
254 dataIds.push_back(taggerStrips[otherPlane][hit_j].dataID);
255 dataIds.push_back(taggerStrips[otherPlane][hit_j].dataID+1);
256 returnHits.push_back(std::make_pair(crtHit, dataIds));
281 double minX = std::max(strip1[0], strip2[0]);
282 double maxX = std::min(strip1[1], strip2[1]);
283 double minY = std::max(strip1[2], strip2[2]);
284 double maxY = std::min(strip1[3], strip2[3]);
285 double minZ = std::max(strip1[4], strip2[4]);
286 double maxZ = std::min(strip1[5], strip2[5]);
288 std::vector<double> null = {-99999, -99999, -99999, -99999, -99999, -99999};
289 std::vector<double>
overlap = {minX, maxX, minY, maxY, minZ, maxZ};
292 if ((minX<maxX && minY<maxY) || (minX<maxX && minZ<maxZ) || (minY<maxY && minZ<maxZ))
return overlap;
306 std::pair<std::string, unsigned>
output = std::make_pair(tagName, planeID);
324 std::vector<std::pair<int,float>>> tpesmap,
float peshit,
double time,
int plane,
325 double x,
double ex,
double y,
double ey,
double z,
double ez, std::string
tagger){
333 crtHit.
ts0_ns = time * 1e3;
335 crtHit.
ts1_ns = time * 1e3;
336 crtHit.
ts0_s = time * 1
e-6;
337 crtHit.
plane = plane;
346 mf::LogInfo(
"CRTHitRecoAlg") <<
"Filling hit with time " << time <<
", fTimeOffset " <<
fTimeOffset <<
'\n'
347 <<
"\t and is in fact " << crtHit.
ts0_ns <<
" " << crtHit.
ts0_s <<
" " <<crtHit.
ts1_ns << std::endl;
356 geo::Point_t pos {position.X(), position.Y(), position.Z()};
371 return pesCorr1 + pesCorr2;
375 geo::Point_t pos {position.X(), position.Y(), position.Z()};
386 double timeCorr1 = strip1.
t0 - stripDist1 *
fPropDelay * 1
e-3;
387 double timeCorr2 = strip2.
t0 - stripDist2 *
fPropDelay * 1e-3;
398 return (timeCorr1 + timeCorr2) / 2.;
float z_err
position uncertainty in z-direction (cm).
process_name opflash particleana ie ie ie z
fhicl::Atom< double > NpeScaleShift
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) .
fhicl::Atom< double > TDelayShift
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 ...
process_name opflash particleana ie x
int plane
Name of the CRT wall (in the form of numbers).
float peshit
Total photo-electron (PE) in a crt hit.
fhicl::Atom< double > PropDelay
float y_err
position uncertainty in y-direction (cm).
fhicl::Atom< double > TDelayNorm
double TPCTick2Time(double const tick) const
Given TPC time-tick (waveform index), returns electronics clock [us].
unsigned int ReadOutWindowSize() const
CRTStrip CreateCRTStrip(art::Ptr< sbnd::crt::CRTData > sipm1, art::Ptr< sbnd::crt::CRTData > sipm2, size_t ind)
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)]
CRTModuleGeo GetModule(std::string moduleName) const
uint64_t ts0_s
Second-only part of timestamp T0.
fhicl::Atom< double > TDelayOffset
std::pair< std::string, unsigned > tagger
std::pair< double, double > DistanceBetweenSipms(art::Ptr< sbnd::crt::CRTData > sipm1, art::Ptr< sbnd::crt::CRTData > sipm2)
bool CheckModuleOverlap(uint32_t channel)
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...
process_name opflash particleana ie ie y
fhicl::Atom< double > QPed
void reconfigure(const Config &config)
std::string ChannelToStripName(size_t channel) const
enum::sbnd::CRTPlane GetPlaneIndex(std::string tagger)
std::map< std::pair< std::string, unsigned >, std::vector< CRTStrip > > CreateTaggerStrips(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< sbnd::crt::CRTData >> data)
fhicl::Atom< double > TimeOffset
fhicl::Atom< double > ClockSpeedCRT
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
double CorrectNpe(CRTStrip strip1, CRTStrip strip2, TVector3 position)
CRTStripGeo GetStrip(std::string stripName) const
std::vector< std::pair< sbn::crt::CRTHit, std::vector< int > > > CreateCRTHits(std::map< std::pair< std::string, unsigned >, std::vector< CRTStrip >> taggerStrips)
fhicl::Atom< bool > UseReadoutWindow
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
std::pair< std::string, unsigned > ChannelToTagger(uint32_t channel)
fhicl::Atom< double > TimeCoincidenceLimit
std::vector< double > StripLimitsWithChargeSharing(std::string stripName, double x, double ex)
float y_pos
position in y-direction (cm).
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
fhicl::Atom< double > QSlope
sbn::crt::CRTHit FillCrtHit(std::vector< uint8_t > tfeb_id, std::map< uint8_t, std::vector< std::pair< int, float >>> tpesmap, float peshit, double time, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
Contains all timing reference information for the detector.
double fTimeCoincidenceLimit
float x_pos
position in x-direction (cm).
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
std::vector< double > CrtOverlap(std::vector< double > strip1, std::vector< double > strip2)
std::vector< double > ChannelToLimits(CRTStrip strip)
stream1 can override from command line with o or output services user sbnd
double CorrectTime(CRTStrip strip1, CRTStrip strip2, TVector3 position)
fhicl::Atom< double > TDelaySigma
bool StripHasOverlap(std::string stripName)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
fhicl::Atom< bool > UseG4RefTimeOffset
std::string tagger
Name of the CRT wall (in the form of strings).
CRTHitRecoAlg(const Config &config, double g4RefTime)