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(),
144 [](
const CRTStrip &
a,
const CRTStrip & b) ->
bool{
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(),
150 [](
const CRTStrip &
a,
const CRTStrip & b) ->
bool{
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);
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;
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;
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));
bool CheckModuleOverlap(uint32_t channel)
enum::sbnd::CRTPlane GetPlaneIndex(std::string tagger)
double CorrectNpe(CRTStrip strip1, CRTStrip strip2, TVector3 position)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
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)
double fTimeCoincidenceLimit
std::vector< double > CrtOverlap(std::vector< double > strip1, std::vector< double > strip2)
std::vector< double > ChannelToLimits(CRTStrip strip)
double CorrectTime(CRTStrip strip1, CRTStrip strip2, TVector3 position)