55 std::vector<const recob::Hit*> newCluster;
57 newCluster.push_back(
hit.get());
63 const std::vector<const recob::Hit* >&
cluster)
76 const std::vector<const recob::Hit*>&
cluster,
82 for(
size_t iHit = 0; iHit < cluster.size(); ++iHit)
86 double temptdc = cluster[iHit]->PeakTime();
87 unsigned int tempWire = wireid.
Wire;
88 unsigned int tempPlane = wireid.
Plane;
94 if (wireid.
TPC%6 == 0 or wireid.
TPC%6 == 5)
continue;
96 wireid.
Plane,wireid.
TPC,tempWire,tempPlane,temptdc);
104 wireid.
Plane,wireid.
TPC,tempWire,tempPlane,temptdc);
115 const double pe = cluster[iHit]->Integral();
116 const unsigned int wire = tempWire;
117 const unsigned int wirePlane = tempPlane;
118 const double tdc = temptdc;
119 pm.
Add(wire, tdc, wirePlane, pe);
127 os <<
"PixelMapProducer: " 128 << p.
NTdc() <<
" tdcs X " << p.
NWire() <<
" wires";
139 double intercept = center.Y() - slope*center.Z();
140 if(wireid.
Plane == 2) intercept = 0.;
148 for(
int plane = 0; plane < 2; plane++){
151 for(
int diag_tpc = 0; diag_tpc < nCRM_row; diag_tpc++){
154 int tpc_id = plane == 0 ? (nCRM_row+1)*diag_tpc : (nCRM_row-1)*(nCRM_row-diag_tpc);
174 const std::vector< const recob::Hit*>&
cluster)
177 std::vector<double> time_0;
178 std::vector<double> time_1;
179 std::vector<double> time_2;
182 std::vector<int> wire_0;
183 std::vector<int> wire_1;
184 std::vector<int> wire_2;
187 for(
size_t iHit = 0; iHit < cluster.size(); ++iHit)
191 unsigned int globalWire = wireid.
Wire;
192 unsigned int globalPlane = wireid.
Plane;
193 double globalTime = cluster[iHit]->PeakTime();
197 if (wireid.
TPC%6 == 0 or wireid.
TPC%6 == 5)
continue;
216 time_0.push_back(globalTime);
217 wire_0.push_back(globalWire);
220 time_1.push_back(globalTime);
221 wire_1.push_back(globalWire);
224 time_2.push_back(globalTime);
225 wire_2.push_back(globalWire);
229 double tsum_0 = std::accumulate(time_0.begin(), time_0.end(), 0.0);
230 double tmean_0 = tsum_0 / time_0.size();
232 double tsum_1 = std::accumulate(time_1.begin(), time_1.end(), 0.0);
233 double tmean_1 = tsum_1 / time_1.size();
235 double tsum_2 = std::accumulate(time_2.begin(), time_2.end(), 0.0);
236 double tmean_2 = tsum_2 / time_2.size();
238 std::cout <<
"Boundary wire vector sizes: " << wire_0.size() <<
", " << wire_1.size() <<
", " << wire_2.size() <<
std::endl;
240 auto minwireelement_0= std::min_element(wire_0.begin(), wire_0.end());
241 std::cout<<
"minwire 0: "<<*minwireelement_0<<
std::endl;
242 auto minwireelement_1= std::min_element(wire_1.begin(), wire_1.end());
243 std::cout<<
"minwire 1: "<<*minwireelement_1<<
std::endl;
244 auto minwireelement_2= std::min_element(wire_2.begin(), wire_2.end());
245 std::cout<<
"minwire 2: "<<*minwireelement_2<<
std::endl;
258 if(wire_0.size() > 0) minwire_0 = *minwireelement_0-1;
259 if(wire_1.size() > 0) minwire_1 = *minwireelement_1-1;
260 if(wire_2.size() > 0) minwire_2 = *minwireelement_2-1;
269 unsigned int nWiresTPC = 400;
271 globalWire = localWire;
293 if(tpcMod4 == 0 || tpcMod4 == 3){
298 if(plane == 0) globalPlane = 1;
299 else globalPlane = 0;
303 if(globalPlane != 1){
304 globalWire += (tpc/4)*nWiresTPC;
307 globalWire += ((23-tpc)/4)*nWiresTPC;
314 unsigned int localWire,
double localTDC,
unsigned int plane,
unsigned int tpc,
315 unsigned int& globalWire,
unsigned int& globalPlane,
double& globalTDC)
const 318 unsigned int nWiresTPC = 400;
319 unsigned int wireGap = 4;
323 unsigned int drift_size = (driftLen / driftVel) * 2;
324 unsigned int apa_size = 4*(apaLen / driftVel) * 2;
337 bool includeZGap =
true;
338 if(includeZGap) nWiresTPC += wireGap;
349 if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
350 else globalPlane = plane;
354 if (globalPlane != 1) globalWire += (tpc/4)*nWiresTPC;
355 else globalWire += ((23-tpc)/4)*nWiresTPC;
358 if (tpcMod4 > 1 and globalPlane < 2) globalWire +=
fGeometry->
Nwires(globalPlane, tpc, 0) + offset - localWire;
359 else globalWire += localWire;
361 if(tpcMod4 == 0 || tpcMod4 == 2){
362 globalTDC = drift_size - localTDC;
365 globalTDC = localTDC + drift_size + apa_size;
370 unsigned int localWire,
double localTDC,
unsigned int plane,
unsigned int tpc,
371 unsigned int& globalWire,
unsigned int& globalPlane,
double& globalTDC)
const 373 unsigned int nWiresTPC = 400;
374 unsigned int wireGap = 4;
378 unsigned int drift_size = (driftLen / driftVel) * 2;
379 unsigned int apa_size = 4*(apaLen / driftVel) * 2;
392 bool includeZGap =
true;
393 if(includeZGap) nWiresTPC += wireGap;
414 size_t tpc_x = (tpc%6) - 1;
415 size_t tpc_xy = (tpc%12) - 1;
416 if (tpc_xy > 3) tpc_xy -= 2;
419 if (plane < 2 and tpc%2 == 1) globalPlane = !plane;
420 else globalPlane = plane;
424 if (globalPlane != 1) globalWire += (tpc/12)*nWiresTPC;
425 else globalWire += ((300-tpc)/12)*nWiresTPC;
427 if (tpc_xy > 3 and globalPlane < 2) globalWire +=
fGeometry->
Nwires(globalPlane, tpc, 0) + offset - localWire;
428 else globalWire += localWire;
430 if (tpc_x % 2 == 0) globalTDC = localTDC;
431 else globalTDC = (2*drift_size) - localTDC;
432 if (tpc_x > 1) globalTDC += 2 * (drift_size + apa_size);
440 unsigned int nWiresTPC = 400;
442 globalWire = localWire;
470 if(plane == 0) globalPlane = 1;
471 else globalPlane = 0;
475 if(globalPlane != 1){
476 globalWire += (tpc/4)*nWiresTPC;
479 globalWire += ((12-tpc)/4)*nWiresTPC;
487 unsigned int& globalWire,
double& globalTDC,
unsigned int& globalPlane)
const 504 double spacing = 0.847;
513 double low_bound, upper_bound;
514 int start,
end, diag_tpc;
517 if(globalPlane == 0){
522 diag_tpc = (start/2);
529 diag_tpc = (nCRM_row-(end/2) - 1);
532 if((start % 2)^globalPlane){
534 int diag_idx = diag_tpc + !globalPlane;
535 globalWire = (wire_intercept > (low_bound+upper_bound)*0.5) ? (nWiresTPC-1)*diag_idx + !globalPlane : (nWiresTPC-1)*diag_idx + globalPlane;
539 int diag_idx = diag_tpc;
540 int offset = globalPlane ? std::round((upper_bound - wire_intercept)/spacing) : std::round((wire_intercept-low_bound)/spacing);
541 globalWire = (nWiresTPC-1)*diag_idx + offset + 1;
547 globalWire = localWire + tpc_z*nWiresTPC;
561 std::vector<sim::TrackIDE> IDEs = bt->
HitToTrackIDEs(clockData, hit);
563 tracks.push_back(
k.trackID);
565 process.push_back(p.
Process());
571 if (
abs(pdgParent) == 13 && ((pdg>0)==(pdgParent>0))) {
573 if (p.
Process() ==
"muMinusCaptureAtRest" || p.
Process() ==
"muPlusCaptureAtRest") {
579 energy.push_back(
k.energy);
587 bool usePixelTruth) {
595 for(
size_t iHit = 0; iHit <
cluster.size(); ++iHit) {
599 unsigned int globalWire = wireid.
Wire;
600 unsigned int globalPlane = wireid.
Plane;
607 if (wireid.
TPC%6 == 0 or wireid.
TPC%6 == 5)
continue;
624 std::vector<float>
energy;
625 std::vector<std::string>
process;
650 for (
size_t iSP = 0; iSP < sp.size(); ++iSP) {
654 const double *
pos = sp[iSP]->XYZ();
655 for (
size_t p = 0;
p < 3; ++
p) coordinates[
p] = pos[
p];
658 std::vector<float>
energy;
659 std::vector<std::string>
process;
661 for (
size_t iH = 0; iH <
hit[iSP].size(); ++iH) {
662 features[
hit[iSP][iH]->View()] += hit[iSP][iH]->Integral();
663 GetHitTruth(clockData, hit[iSP][iH], pdgs, tracks, energy, process);
664 map.
AddHit(0, coordinates, features, pdgs, tracks, energy, process);
double fTRes
Timing resolution for pixel map.
bool isVertical() const
Returns if this wire is vertical (theta_z ~ pi/2)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
void AddHit(unsigned int view, std::vector< float > coordinates, std::vector< float > features)
Default AddHit implementation, which just adds pixel value and coordinates.
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
unsigned short fUnwrapped
Use unwrapped pixel maps?
unsigned int NTdc() const
std::ostream & operator<<(std::ostream &os, const PixelMapProducer &p)
WireID_t Wire
Index of the wire within its plane.
Cluster finding and building.
std::string Process() const
Utility class for truth labels.
unsigned int fNTdc
Number of tdcs, width of pixel map.
double Width() const
Width is associated with x coordinate [cm].
void GetDUNE10ktGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
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.
art framework interface to geometry description
PixelMap CreateMapGivenBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Hit * > &cluster, const Boundary &bound)
void GetProtoDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
int PdgCode(Resonance_t res, int Q)
(resonance id, charge) -> PDG code
simb::MCParticle TrackIdToParticle(int const id) const
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
double _getIntercept(geo::WireID wireid) const
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
void Add(const unsigned int &wire, const double &tdc, const unsigned int &view, const double &pe)
bool fProtoDUNE
Do we want to use this for particle extraction from protoDUNE?
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
PlaneID_t Plane
Index of the plane within its TPC.
void GetProtoDUNEGlobalWireTDC(unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, double &globalTDC, unsigned int &globalPlane) const
Detector simulation of raw signals on wires.
std::vector< double > fVDPlane1
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
unsigned int fNWire
Number of wires, length for pixel maps.
Declaration of signal hit object.
double DriftDistance() const
void GetDUNEGlobalWireTDC(detinfo::DetectorPropertiesData const &detProp, unsigned int localWire, double localTDC, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
Contains all timing reference information for the detector.
unsigned int NWire() const
SparsePixelMap CreateSparseMap2D(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > &cluster, bool usePixelTruth=false)
double ActiveWidth() const
Width (associated with x coordinate) of active TPC volume [cm].
PixelMap, basic input to CVN neural net.
PixelMapProducer for CVN.
void GetDUNEGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
Function to convert to a global unwrapped wire number.
Access the description of detector geometry.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void GetDUNEVertDrift3ViewGlobalWire(unsigned int localWire, unsigned int plane, unsigned int tpc, unsigned int &globalWire, unsigned int &globalPlane) const
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::GeometryCore const * fGeometry
SparsePixelMap CreateSparseMap3D(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::SpacePoint > > &sp, std::vector< std::vector< art::Ptr< recob::Hit >>> &hit)
Producer algorithm for PixelMap, input to CVN neural net.
Boundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Hit * > &cluster)
Get boundaries for pixel map representation of cluster.
Ionization energy from a Geant4 track.
void GetHitTruth(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > &hit, std::vector< int > &pdgs, std::vector< int > &tracks, std::vector< float > &energies, std::vector< std::string > &processes)
Create sparse pixel map for SCN applications.
std::vector< double > fVDPlane0
QTextStream & endl(QTextStream &s)
PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &slice)
WireGeo const * WirePtr(geo::WireID const &wireid) const
Returns the specified wire.