29 fGlobalWireMethod(Global),
30 fProngOnly(ProngOnly),
38 art::FindManyP<recob::Wire>
const& fmwire)
57 art::FindManyP<recob::Wire>
const& fmwire,
58 const std::vector<float> &vtx)
75 art::FindManyP<recob::Wire>
const& fmwire,
76 art::FindManyP<recob::Track>
const& fmtrkhit,
77 const std::vector<float> &vtx)
99 art::FindManyP<recob::Wire>
const& fmwire,
100 art::FindManyP<recob::Shower>
const& fmshwhit,
101 const std::vector<float> &vtx)
125 art::FindManyP<recob::Wire>
const& fmwire)
129 if (!fmwire.isValid())
return pm;
132 for (
size_t iwire = 0; iwire <
hitwireidx.size(); ++iwire)
135 std::vector< art::Ptr<recob::Wire> > wireptr = fmwire.at(iHit);
138 for (
size_t iwireptr = 0; iwireptr < wireptr.size(); ++iwireptr){
139 std::vector<geo::WireID> wireids =
geom->
ChannelToWire(wireptr[iwireptr]->Channel());
140 bool goodWID =
false;
141 for (
auto const & wid:wireids){
142 if (wid.Plane == wireid.
Plane &&
143 wid.Wire == wireid.
Wire &&
144 wid.TPC == wireid.
TPC &&
145 wid.Cryostat == wireid.
Cryostat) goodWID =
true;
147 if (!goodWID)
continue;
154 int t0_hit = (hit_first_time < 0) ? 0 : (
int)hit_first_time;
155 int t1_hit = (hit_end_time > 4491) ? 4491 : (
int)hit_end_time;
157 const std::vector<float>& signal = wireptr[0]->Signal();
158 unsigned int globalWire = 0;
161 if (wireid.
TPC%2 == 1) {
167 unsigned int globalplane = wireid.
Plane;
168 for (
int tt = t0_hit;
tt <= t1_hit; ++
tt)
173 if (wireid.
TPC%2 == 0) tdc = -tdc;
175 double globaltick = double(tt);
178 tdc = (
int)globaltick;
185 pm.
Add((
int)globalWire, tdc, globalplane, correctedadc, wireid.
TPC, 0);
200 art::FindManyP<recob::Wire>
const& fmwire,
201 art::FindManyP<recob::Track>
const& fmtrkhit,
202 const bool& ProngOnly)
207 if (!fmwire.isValid())
return pm;
210 unsigned int nhits =
cluster.size();
211 for (
unsigned int ihit= 0; ihit< nhits; ++ihit) {
215 unsigned int planeid = wireid.
Plane;
218 if (wireid.
TPC%2 == 0) peaktime = -peaktime;
220 unsigned int globalWire = 0;
221 unsigned int globalplane = planeid;
224 if (wireid.
TPC%2 == 1) {
229 globalWire = wireid.
Wire;
232 std::cout<<
"Wrong GlobalWireMethod"<<
std::endl;
238 int hit_prong_tag = -1;
239 if (fmtrkhit.isValid() && fmtrkhit.at(ihit).size()!=0) {
240 hit_prong_tag = fmtrkhit.at(ihit)[0]->ID();
243 pm.
Add((
int)globalWire, (
int)round(peaktime), globalplane, correctedHitCharge, wireid.
TPC, hit_prong_tag);
256 art::FindManyP<recob::Wire>
const& fmwire,
257 art::FindManyP<recob::Shower>
const& fmshwhit,
258 const bool& ProngOnly)
263 if (!fmwire.isValid())
return pm;
266 unsigned int nhits =
cluster.size();
267 for (
unsigned int ihit= 0; ihit< nhits; ++ihit) {
271 unsigned int planeid = wireid.
Plane;
274 if (wireid.
TPC%2 == 0) peaktime = -peaktime;
276 unsigned int globalWire = 0;
277 unsigned int globalplane = planeid;
280 if (wireid.
TPC%2 == 1) {
285 globalWire = wireid.
Wire;
288 std::cout<<
"Wrong GlobalWireMethod"<<
std::endl;
294 int hit_prong_tag = -1;
295 if (fmshwhit.isValid() && fmshwhit.at(ihit).size()!=0) {
296 hit_prong_tag = fmshwhit.at(ihit)[0]->ID();
299 pm.
Add((
int)globalWire, (
int)round(peaktime), globalplane, correctedHitCharge, wireid.
TPC, hit_prong_tag);
302 std::cout<<
"FIXME: Produce pixelmap from fmshwhit and prongonly = "<<ProngOnly<<
std::endl;
312 os <<
"RegPixelMapProducer: " 313 << p.
NTdc() <<
" tdcs X " << p.
NWire() <<
" wires";
324 std::vector<float> time_0;
325 std::vector<float> time_1;
326 std::vector<float> time_2;
328 std::vector<int> wire_0;
329 std::vector<int> wire_1;
330 std::vector<int> wire_2;
332 unsigned int temp_wire =
cluster[0]->WireID().Wire;
333 float temp_time_min = 1e5;
334 float temp_time_max = 0;
335 float temp_trms_max = 0;
336 for(
size_t iHit = 0; iHit <
cluster.size(); ++iHit)
340 if (temp_wire != wireid.
Wire ){
341 temp_wire = wireid.
Wire;
347 temp_time_min = 1e5; temp_time_max = 0; temp_trms_max = 0;
349 if (temp_time_min >
cluster[iHit]->PeakTime()) temp_time_min =
cluster[iHit]->PeakTime();
350 if (temp_time_max <
cluster[iHit]->PeakTime()) temp_time_max =
cluster[iHit]->PeakTime();
353 unsigned int planeid = wireid.
Plane;
354 double peaktime =
cluster[iHit]->PeakTime() ;
355 if (wireid.
TPC%2 == 0) peaktime = -peaktime;
357 unsigned int globalWire = 0;
358 unsigned int globalplane = planeid;
364 std::cout <<
"Wrong GlobalWireMethod" <<
std::endl;
374 time_0.push_back(peaktime);
375 wire_0.push_back((
int)globalWire);
378 time_1.push_back(peaktime);
379 wire_1.push_back((
int)globalWire);
382 time_2.push_back(peaktime);
383 wire_2.push_back((
int)globalWire);
388 double tsum_0 = std::accumulate(time_0.begin(), time_0.end(), 0.0);
389 double tmean_0 = tsum_0 / time_0.size();
391 double tsum_1 = std::accumulate(time_1.begin(), time_1.end(), 0.0);
392 double tmean_1 = tsum_1 / time_1.size();
394 double tsum_2 = std::accumulate(time_2.begin(), time_2.end(), 0.0);
395 double tmean_2 = tsum_2 / time_2.size();
398 double wiresum_0 = std::accumulate(wire_0.begin(), wire_0.end(), 0.0);
399 double wiremean_0 = wiresum_0 / wire_0.size();
401 double wiresum_1 = std::accumulate(wire_1.begin(), wire_1.end(), 0.0);
402 double wiremean_1 = wiresum_1 / wire_1.size();
404 double wiresum_2 = std::accumulate(wire_2.begin(), wire_2.end(), 0.0);
405 double wiremean_2 = wiresum_2 / wire_2.size();
438 const std::vector<float> &vtx)
441 unsigned int temp_wire =
cluster[0]->WireID().Wire;
442 float temp_time_min = 1e5;
443 float temp_time_max = 0;
444 float temp_trms_max = 0;
445 for(
size_t iHit = 0; iHit <
cluster.size(); ++iHit)
448 if (temp_wire != wireid.
Wire ){
449 temp_wire = wireid.
Wire;
455 temp_time_min = 1e5; temp_time_max = 0; temp_trms_max = 0;
457 if (temp_time_min >
cluster[iHit]->PeakTime()) temp_time_min =
cluster[iHit]->PeakTime();
458 if (temp_time_max <
cluster[iHit]->PeakTime()) temp_time_max =
cluster[iHit]->PeakTime();
462 double center_wire[3] = {-99999, -99999, -99999};
463 double center_tick[3] = {-99999, -99999, -99999};
464 unsigned int size_vtx = (
unsigned int) vtx.size();
466 double regvtx_loc[3] = {(double)vtx[0], (
double)vtx[1], (double)vtx[2]};
471 for (
int iplane = 0; iplane<3; iplane++){
482 double time1 = detProp.
ConvertXToTicks(regvtx_loc[0], iplane, rawtpc, rawcrys);
484 std::cout <<
"You Can't use this with GlobalWireMethod = 1" <<
std::endl;
487 unsigned int globalWire = (double)w1.
Wire;
488 unsigned int globalPlane = w1.
Plane;
489 double globalTDC = time1;
491 center_wire[globalPlane] = globalWire;
493 center_tick[globalPlane] = (
int)globalTDC;
495 std::cout <<
"Wrong Global Wire Method" <<
std::endl;
500 }
else if ( size_vtx == 6){
501 for (
int ii = 0; ii < 3; ii++){
502 center_wire[ii] = vtx[ii*2+1];
503 center_tick[ii] = vtx[ii*2];
506 std::cout <<
"Wrong reconstructed vertex" <<
std::endl;
507 std::cout <<
"-->" << size_vtx <<
std::endl;
511 int shift = 56*
fWRes;
516 RegCNNBoundary bound(
fNWire,
fNTdc,
fWRes,
fTRes,round(center_wire[0]),round(center_wire[1]),round(center_wire[2]),round(center_tick[0]),round(center_tick[1]),round(center_tick[2]));
523 double globalWire = -9999;
527 double WireCentre[3] = {0};
531 if (wireID.
TPC % 2 == 0) { temp_tpc = 0; }
532 else { temp_tpc = 1; }
538 int block = wireID.
TPC / 4;
539 globalWire = (double)( ((
int)nwires*block) + wireID.
Wire );
541 return round(globalWire);
545 std::vector<unsigned int>
getUniques(std::vector<unsigned int> coll)
547 std::vector<unsigned int> uniques;
548 for (
unsigned int tpc : coll)
550 if (std::find(uniques.begin(), uniques.end(), tpc) == uniques.end())
551 uniques.push_back(tpc);
559 std::vector<unsigned int> list_TPCs;
560 std::map<unsigned int, double> map_mean_U, map_mean_V, map_Twei_U, map_Twei_V;
561 int nhits_z[24] = {0};
562 for (
unsigned int iHit = 0; iHit <
cluster.size(); ++iHit)
565 if (wireid.
Plane == 2){
566 nhits_z[wireid.
TPC] += 1;
569 if (
cluster[iHit]->PeakTime() < 150){
570 double Twei =
cluster[iHit]->PeakTime()+1.;
571 list_TPCs.push_back(wireid.
TPC);
572 if (wireid.
Plane == 0){
574 map_Twei_U[wireid.
TPC] += 1.0/Twei;
576 if (wireid.
Plane == 1){
578 map_Twei_V[wireid.
TPC] += 1.0/Twei;
582 std::vector<unsigned int> unique_TPCs =
getUniques(list_TPCs);
583 for (
unsigned int tmp_idx : unique_TPCs)
585 if (map_Twei_U[tmp_idx]>0) map_mean_U[tmp_idx] /= map_Twei_U[tmp_idx];
586 if (map_Twei_V[tmp_idx]>0) map_mean_V[tmp_idx] /= map_Twei_V[tmp_idx];
589 if (unique_TPCs.size() > 1){
592 unsigned int nmax_tpcs[2] = {10000,10000};
593 for (
unsigned int ii = 0; ii < unique_TPCs.size()-1; ++ii)
595 unsigned int tpc1 = unique_TPCs[ii];
596 unsigned int tpc2 = unique_TPCs[ii+1];
597 if (tpc1/4 != tpc2/4)
continue;
598 if (tpc1%2 == tpc2%2)
continue;
599 int sum = nhits_z[tpc1] + nhits_z[tpc2];
606 if (nmax_tpcs[0] < 10000 && nmax_tpcs[1] < 10000){
607 double offsetU = 0, offsetV = 0;
608 if (map_Twei_U[nmax_tpcs[0]] > 0 && map_Twei_U[nmax_tpcs[1]] > 0) offsetU = map_mean_U[nmax_tpcs[0]] - map_mean_U[nmax_tpcs[1]];
609 if (map_Twei_V[nmax_tpcs[0]] > 0 && map_Twei_V[nmax_tpcs[1]] > 0) offsetV = map_mean_V[nmax_tpcs[0]] - map_mean_V[nmax_tpcs[1]];
618 unsigned int& globalWire,
unsigned int& globalPlane,
620 unsigned int localWire = wireID.
Wire;
621 unsigned int plane = wireID.
Plane;
622 unsigned int tpc = wireID.
TPC;
624 unsigned int nWiresTPC = 400;
625 unsigned int wireGap = 4;
631 double drift_size = (driftLen / driftVel) * 2;
632 double apa_size = 4*(apaLen / driftVel) * 2;
642 bool includeZGap =
true;
643 if(includeZGap) nWiresTPC += wireGap;
658 if(tpcMod4 == 0 || tpcMod4 == 3){
664 if(plane == 0) globalPlane = 1;
665 else globalPlane = 0;
668 if(globalPlane != 1){
669 globalWire += (tpc/4)*nWiresTPC + (tpcMod4>1)*offset + localWire;
672 globalWire += ((23-tpc)/4)*nWiresTPC + (tpcMod4>1)*offset + localWire;
675 if(tpcMod4 == 0 || tpcMod4 == 2){
677 globalTDC = drift_size - localTDC;
681 globalTDC = localTDC + drift_size + apa_size;
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
RegCNNBoundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster)
Get boundaries for pixel map representation of cluster.
RegPixelMap CreateMap(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, art::FindManyP< recob::Wire > const &fmwire)
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
double GetGlobalWire(const geo::WireID &wireID)
Function to convert to a global unwrapped wire number.
geo::WireID WireID() const
RegPixelMap, basic input to CNN neural net.
The data type to uniquely identify a Plane.
bool isValid
Whether this ID points to a valid element.
unsigned int NWire() const
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
double ElectronLifetime() const
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
WireID_t Wire
Index of the wire within its plane.
Producer algorithm for RegPixelMap, input to CVN neural net.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Cluster finding and building.
void Add(const int &wire, const int &tdc, const unsigned int &view, const double &pe, const unsigned int &tpc, int hit_prong_tag)
RegPixelMap CreateMapGivenBoundaryByHit(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, const RegCNNBoundary &bound, art::FindManyP< recob::Wire > const &fmwire, art::FindManyP< recob::Track > const &fmtrkhit, const bool &ProngOnly)
double Width() const
Width is associated with x coordinate [cm].
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
RegPixelMapProducer(unsigned int nWire, unsigned int wRes, unsigned int nTdc, double tRes, int Global, bool ProngOnly, bool ByHit)
art::ServiceHandle< geo::Geometry > geom
void ShiftGlobalWire(std::vector< art::Ptr< recob::Hit > > const &cluster)
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
RegPixelMap CreateMapGivenBoundary(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > const &cluster, const RegCNNBoundary &bound, art::FindManyP< recob::Wire > const &fmwire)
Signal from induction planes.
RegPixelMapProducer for RegCNN modified from PixelMapProducer.h.
Collection of exceptions for Geometry system.
std::vector< int > tmin_each_wire
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
double ConvertXToTicks(double X, int p, int t, int c) const
unsigned int fNWire
Number of wires, length for pixel maps.
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
PlaneID_t Plane
Index of the plane within its TPC.
unsigned int fNTdc
Number of tdcs, width of pixel map.
Detector simulation of raw signals on wires.
std::vector< float > trms_max_each_wire
void GetDUNEGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, const geo::WireID &wireID, double localTDC, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC)
unsigned int NTdc() const
std::vector< int > hitwireidx
Defines an enumeration for cellhit classification.
std::vector< int > tmax_each_wire
float PeakTime() const
Time of the signal peak, in tick units.
double DriftDistance() const
Contains all timing reference information for the detector.
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
geo::WireID ClosestWireID(geo::WireID::WireID_t wireNo) const
Returns the closest valid wire ID to the specified wire.
std::ostream & operator<<(std::ostream &os, const RegPixelMap3DProducer &p)
Exception thrown on invalid wire number.
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
std::vector< unsigned int > getUniques(std::vector< unsigned int > coll)
detail::Node< FrameID, bool > PlaneID
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
TPCID_t TPC
Index of the TPC within its cryostat.
geo::WireID suggestedWireID() const
Returns a better wire ID.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
bool hasSuggestedWire() const
Returns whether we known a better wire number.
QTextStream & endl(QTextStream &s)
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const