15 std::vector<std::string> usedTaggers;
16 std::vector<std::string> usedModules;
17 std::vector<std::string> usedStrips;
24 for(
auto const& auxDet : auxDets){
27 std::set<std::string> volNames = {auxDet.TotalVolume()->GetName()};
31 std::string
path =
"";
32 for (
size_t inode = 0; inode < paths.at(0).size(); inode++){
33 path += paths.at(0).at(inode)->GetName();
34 if(inode < paths.at(0).size() - 1){
41 for(
size_t i = 0; i < auxDet.NSensitiveVolume(); i++){
47 manager->cd(path.c_str());
53 TGeoNode* nodeArray = manager->GetCurrentNode();
54 TGeoNode* nodeStrip = nodeArray->GetDaughter(i);
55 TGeoNode* nodeModule = manager->GetMother(1);
56 TGeoNode* nodeTagger = manager->GetMother(2);
57 TGeoNode* nodeDet = manager->GetMother(3);
60 std::string taggerName = nodeTagger->GetName();
61 if(std::find(usedTaggers.begin(), usedTaggers.end(), taggerName) == usedTaggers.end()){
62 usedTaggers.push_back(taggerName);
65 double halfWidth = ((TGeoBBox*)nodeTagger->GetVolume()->GetShape())->GetDX();
66 double halfHeight = ((TGeoBBox*)nodeTagger->GetVolume()->GetShape())->GetDY();
67 double halfLength = ((TGeoBBox*)nodeTagger->GetVolume()->GetShape())->GetDZ()/2;
70 double limits[3] = {halfWidth, halfHeight, halfLength};
72 nodeTagger->LocalToMaster(limits, limitsDet);
73 double limitsWorld[3];
74 nodeDet->LocalToMaster(limitsDet, limitsWorld);
76 double limits2[3] = {-halfWidth, -halfHeight, -halfLength};
78 nodeTagger->LocalToMaster(limits2, limitsDet2);
79 double limitsWorld2[3];
80 nodeDet->LocalToMaster(limitsDet2, limitsWorld2);
84 tagger.
name = taggerName;
85 tagger.
minX = std::min(limitsWorld[0], limitsWorld2[0]);
86 tagger.
maxX = std::max(limitsWorld[0], limitsWorld2[0]);
87 tagger.
minY = std::min(limitsWorld[1], limitsWorld2[1]);
88 tagger.
maxY = std::max(limitsWorld[1], limitsWorld2[1]);
89 tagger.
minZ = std::min(limitsWorld[2], limitsWorld2[2]);
90 tagger.
maxZ = std::max(limitsWorld[2], limitsWorld2[2]);
96 std::string moduleName = nodeModule->GetName();
97 if(std::find(usedModules.begin(), usedModules.end(), moduleName) == usedModules.end()){
98 usedModules.push_back(moduleName);
102 double halfWidth = auxDet.HalfWidth1();
103 double halfHeight = auxDet.HalfHeight();
104 double halfLength = auxDet.Length()/2;
107 double limits[3] = {halfWidth, halfHeight, halfLength};
108 double limitsWorld[3];
109 auxDet.LocalToWorld(limits, limitsWorld);
111 double limits2[3] = {-halfWidth, -halfHeight, -halfLength};
112 double limitsWorld2[3];
113 auxDet.LocalToWorld(limits2, limitsWorld2);
116 double origin[3] = {0, 0, 0};
117 double modulePosMother[3];
118 nodeModule->LocalToMaster(origin, modulePosMother);
119 size_t planeID = (modulePosMother[2] > 0);
121 bool top = (planeID == 1) ? (modulePosMother[1] > 0) : (modulePosMother[0] < 0);
125 module.
name = moduleName;
127 module.
minX = std::min(limitsWorld[0], limitsWorld2[0]);
128 module.
maxX = std::max(limitsWorld[0], limitsWorld2[0]);
129 module.
minY = std::min(limitsWorld[1], limitsWorld2[1]);
130 module.
maxY = std::max(limitsWorld[1], limitsWorld2[1]);
131 module.
minZ = std::min(limitsWorld[2], limitsWorld2[2]);
132 module.
maxZ = std::max(limitsWorld[2], limitsWorld2[2]);
133 module.
normal = auxDet.GetNormalVector();
137 module.
tagger = taggerName;
142 std::string stripName = nodeStrip->GetName();
143 if(std::find(usedStrips.begin(), usedStrips.end(), stripName) == usedStrips.end()){
144 usedStrips.push_back(stripName);
151 double halfWidth = auxDetSensitive.
HalfWidth1();
152 double halfHeight = auxDetSensitive.
HalfHeight();
153 double halfLength = auxDetSensitive.
Length()/2;
156 double limits[3] = {halfWidth, halfHeight, halfLength};
157 double limitsWorld[3];
160 double limits2[3] = {-halfWidth, -halfHeight, -halfLength};
161 double limitsWorld2[3];
166 strip.
name = stripName;
168 strip.
minX = std::min(limitsWorld[0], limitsWorld2[0]);
169 strip.
maxX = std::max(limitsWorld[0], limitsWorld2[0]);
170 strip.
minY = std::min(limitsWorld[1], limitsWorld2[1]);
171 strip.
maxY = std::max(limitsWorld[1], limitsWorld2[1]);
172 strip.
minZ = std::min(limitsWorld[2], limitsWorld2[2]);
173 strip.
maxZ = std::max(limitsWorld[2], limitsWorld2[2]);
175 strip.
width = halfHeight * 2.;
177 strip.
module = moduleName;
180 uint32_t channel0 = 32 * ad_i + 2 * sv_i + 0;
181 uint32_t channel1 = 32 * ad_i + 2 * sv_i + 1;
183 double sipm0Y = -halfHeight;
184 double sipm1Y = halfHeight;
187 double sipmX = halfWidth;
189 double sipm0XYZ[3] = {sipmX, sipm0Y, 0};
190 double sipm0XYZWorld[3];
195 sipm0.
x = sipm0XYZWorld[0];
196 sipm0.
y = sipm0XYZWorld[1];
197 sipm0.
z = sipm0XYZWorld[2];
198 sipm0.
strip = stripName;
202 double sipm1XYZ[3] = {sipmX, sipm1Y, 0};
203 double sipm1XYZWorld[3];
208 sipm1.
x = sipm1XYZWorld[0];
209 sipm1.
y = sipm1XYZWorld[1];
210 sipm1.
z = sipm1XYZWorld[2];
211 sipm1.
strip = stripName;
215 strip.
sipms = std::make_pair(channel0, channel1);
229 std::string taggerName =
module.second.tagger;
230 std::string moduleName =
module.second.name;
244 std::vector<double>
limits;
246 std::vector<double> minXs;
247 std::vector<double> minYs;
248 std::vector<double> minZs;
249 std::vector<double> maxXs;
250 std::vector<double> maxYs;
251 std::vector<double> maxZs;
253 minXs.push_back(
tagger.second.minX);
254 minYs.push_back(
tagger.second.minY);
255 minZs.push_back(
tagger.second.minZ);
256 maxXs.push_back(
tagger.second.maxX);
257 maxYs.push_back(
tagger.second.maxY);
258 maxZs.push_back(
tagger.second.maxZ);
260 limits.push_back(*std::min_element(minXs.begin(), minXs.end()));
261 limits.push_back(*std::min_element(minYs.begin(), minYs.end()));
262 limits.push_back(*std::min_element(minZs.begin(), minZs.end()));
263 limits.push_back(*std::max_element(maxXs.begin(), maxXs.end()));
264 limits.push_back(*std::max_element(maxYs.begin(), maxYs.end()));
265 limits.push_back(*std::max_element(maxZs.begin(), maxZs.end()));
298 nullTagger.
null =
true;
306 if(tagger_i == index)
return tagger.second;
310 nullTagger.
null =
true;
322 nullModule.
null =
true;
330 if(module_i == index)
return module.second;
334 nullModule.
null =
true;
344 if(stripName ==
strip.first)
return strip.second;
347 nullStrip.
null =
true;
355 if(strip_i == index)
return strip.second;
359 nullStrip.
null =
true;
377 for(
auto const& sipm :
fSipms){
378 if(sipm.second.channel == channel){
379 return sipm.second.strip;
391 2*
fStrips.at(stripName).sensitiveVolumeID);
394 double halfHeight = sensitiveGeo.HalfHeight();
395 double halfLength = sensitiveGeo.HalfLength();
401 double l1[3] = {halfWidth, -halfHeight + x + ex, halfLength};
403 sensitiveGeo.LocalToWorld(l1, w1);
406 double l2[3] = {-halfWidth, -halfHeight + x - ex, -halfLength};
408 sensitiveGeo.LocalToWorld(l2, w2);
411 std::vector<double>
limits = {std::min(w1[0],w2[0]), std::max(w1[0],w2[0]),
412 std::min(w1[1],w2[1]), std::max(w1[1],w2[1]),
413 std::min(w1[2],w2[2]), std::max(w1[2],w2[2])};
419 for(
auto const& sipm :
fSipms){
420 if(sipm.second.channel == channel){
421 geo::Point_t position {sipm.second.x, sipm.second.y, sipm.second.z};
432 if(stripName ==
strip.first)
return strip.second.sipms;
434 return std::make_pair(-99999, -99999);
441 for(
auto const& sipm :
fSipms){
442 if(sipm.second.channel == channel){
443 geo::Point_t pos {sipm.second.x, sipm.second.y, sipm.second.z};
445 int otherChannel = channel + 1;
446 if(channel % 2) otherChannel = channel - 1;
448 if(fSipms.at(otherChannel).x != pos.X()) distance = position.X() - pos.X();
449 if(fSipms.at(otherChannel).y != pos.Y()) distance = position.Y() - pos.Y();
450 if(fSipms.at(otherChannel).z != pos.Z()) distance = position.Z() - pos.Z();
469 if(stripName ==
strip.first){
475 if(xdiff > ydiff && xdiff > zdiff) distance = position.X() - pos.X();
476 if(ydiff > xdiff && ydiff > zdiff) distance = position.Y() - pos.Y();
477 if(zdiff > xdiff && zdiff > ydiff) distance = position.Z() - pos.Z();
493 return point.X() > limits[0] && point.Y() > limits[1] && point.Z() > limits[2]
494 && point.X() < limits[3] && point.Y() < limits[4] && point.Z() < limits[5];
500 if(tagger.
null)
return false;
501 double x = point.X();
502 double y = point.Y();
503 double z = point.Z();
505 double ymin = tagger.
minY;
506 double zmin = tagger.
minZ;
507 double xmax = tagger.
maxX;
508 double ymax = tagger.
maxY;
509 double zmax = tagger.
maxZ;
511 return x > xmin && x < xmax && y > ymin && y < ymax && z > zmin && z < zmax;
517 if(module.
null)
return false;
518 double x = point.X();
519 double y = point.Y();
520 double z = point.Z();
522 double ymin = module.
minY;
523 double zmin = module.
minZ;
524 double xmax = module.
maxX;
525 double ymax = module.
maxY;
526 double zmax = module.
maxZ;
528 return x > xmin && x < xmax && y > ymin && y < ymax && z > zmin && z < zmax;
534 if(strip.
null)
return false;
535 double x = point.X();
536 double y = point.Y();
537 double z = point.Z();
539 double ymin = strip.
minY;
540 double zmin = strip.
minZ;
541 double xmax = strip.
maxX;
542 double ymax = strip.
maxY;
543 double zmax = strip.
maxZ;
545 return x > xmin && x < xmax && y > ymin && y < ymax && z > zmin && z < zmax;
552 double minX = std::max(module1.
minX, module2.
minX);
553 double maxX = std::min(module1.
maxX, module2.
maxX);
554 double minY = std::max(module1.
minY, module2.
minY);
555 double maxY = std::min(module1.
maxY, module2.
maxY);
556 double minZ = std::max(module1.
minZ, module2.
minZ);
557 double maxZ = std::min(module1.
maxZ, module2.
maxZ);
560 return (minX<maxX && minY<maxY) || (minX<maxX && minZ<maxZ) || (minY<maxY && minZ<maxZ);
567 size_t planeID = module.
planeID;
569 std::string taggerName = module.
tagger;
571 for(
auto const& module2 :
fTaggers[taggerName].modules){
573 if(module2.second.planeID == planeID)
continue;
596 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
597 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
611 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
612 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
630 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
631 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
634 if(i == particle.NumberTrajectoryPoints()-1)
continue;
635 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
636 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
646 if(i == particle.NumberTrajectoryPoints()-1)
continue;
647 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
648 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
658 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
659 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
663 if(i == particle.NumberTrajectoryPoints()-1)
continue;
664 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
665 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
683 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
684 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
686 if(i == particle.NumberTrajectoryPoints()-1)
continue;
687 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
688 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
697 if(i == particle.NumberTrajectoryPoints()-1)
continue;
698 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
699 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
709 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
710 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
714 if(i == particle.NumberTrajectoryPoints()-1)
continue;
715 geo::Point_t next {particle.Vx(i+1), particle.Vy(i+1), particle.Vz(i+1)};
716 geo::Point_t mid {(point.X()+next.X())/2, (point.Y()+next.Y())/2, (point.Z()+next.Z())/2};
726 std::vector<std::string> stripNames;
729 for(
auto const& module : tagger.second.
modules){
731 for(
auto const& strip : module.second.
strips){
733 if(std::find(stripNames.begin(), stripNames.end(), strip.first) != stripNames.end())
continue;
734 stripNames.push_back(strip.first);
746 TVector3 normal (0,0,0);
747 for(
auto const& module :
GetTagger(taggerName).modules){
748 normal.SetXYZ(module.second.
normal.X(), module.second.
normal.Y(), module.second.
normal.Z());
752 if(normal.X()<0.5 && normal.X()>-0.5) normal.SetX(0);
753 if(normal.Y()<0.5 && normal.Y()>-0.5) normal.SetY(0);
754 if(normal.Z()<0.5 && normal.Z()>-0.5) normal.SetZ(0);
763 TVector3 start (particle.Vx(), particle.Vy(), particle.Vz());
764 TVector3
end (particle.EndX(), particle.EndY(), particle.EndZ());
765 TVector3 diff =
end - start;
767 if(normal.X() == 1 && start.X() >
end.X()) diff = start -
end;
768 if(normal.X() == -1 && start.X() <
end.X()) diff = start -
end;
769 if(normal.Y() == 1 && start.Y() >
end.Y()) diff = start -
end;
770 if(normal.Y() == -1 && start.Y() <
end.Y()) diff = start -
end;
771 if(normal.Z() == 1 && start.Z() >
end.Z()) diff = start -
end;
772 if(normal.Z() == -1 && start.Z() <
end.Z()) diff = start -
end;
774 return normal.Angle(diff);
782 bool startOutside =
false;
783 bool endOutside =
false;
785 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
786 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
790 else if(i == 0) startOutside =
true;
791 else if(i == particle.NumberTrajectoryPoints()-1) endOutside =
true;
793 return enters && (startOutside || endOutside);
800 bool startOutside =
false;
801 bool endOutside =
false;
803 for(
size_t i = 0; i < particle.NumberTrajectoryPoints(); i++){
804 geo::Point_t point {particle.Vx(i), particle.Vy(i), particle.Vz(i)};
808 else if(i == 0) startOutside =
true;
809 else if(i == particle.NumberTrajectoryPoints()-1) endOutside =
true;
811 return startOutside && enters && endOutside;
820 std::vector<std::string> crossedModules;
821 for(
auto const& module :
fTaggers[taggerName].modules){
823 if(crossPoint.X() != -99999) crossedModules.push_back(module.second.
name);
827 for(
size_t i = 0; i < crossedModules.size(); i++){
830 for(
size_t j = i; j < crossedModules.size(); j++){
process_name opflash particleana ie ie ie z
bool IsInsideModule(const CRTModuleGeo &module, geo::Point_t point)
const geo::AuxDetGeometryCore * fAuxDetGeoCore
finds tracks best matching by with limits
size_t NumModules() const
const geo::GeometryCore * geometry
process_name opflash particleana ie x
std::map< std::string, CRTModuleGeo > modules
geo::Vector_t GetNormalVector() const
Returns the unit normal vector to the detector.
CRTTaggerGeo GetTagger(std::string taggerName) const
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
bool IsInsideStrip(const CRTStripGeo &strip, geo::Point_t point)
geo::GeometryCore const * fGeometryService
std::map< std::string, CRTModuleGeo > fModules
geo::Point_t StripCrossingPoint(std::string stripName, const simb::MCParticle &particle)
std::map< std::string, CRTStripGeo > strips
bool IsInsideTagger(const CRTTaggerGeo &tagger, geo::Point_t point)
double HalfWidth1() const
Description of geometry of one set of auxiliary detectors.
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
CRTModuleGeo GetModule(std::string moduleName) const
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
double HalfHeight() const
process_name opflash particleana ie ie y
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
const AuxDetSensitiveGeo & ChannelToAuxDetSensitive(std::string const &auxDetName, uint32_t const &channel) const
std::map< std::string, CRTTaggerGeo > fTaggers
std::string ChannelToStripName(size_t channel) const
auto end(FixedBins< T, C > const &) noexcept
bool IsInsideCRT(TVector3 point)
double DistanceDownStrip(geo::Point_t position, std::string stripName) const
CRTStripGeo GetStrip(std::string stripName) const
std::pair< int, int > GetStripSipmChannels(std::string stripName) const
size_t NumTaggers() const
Description of geometry of one entire detector.
std::pair< int, int > sipms
bool CrossesTagger(const CRTTaggerGeo &tagger, const simb::MCParticle &particle)
std::string GetTaggerName(std::string name) const
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
std::vector< double > StripLimitsWithChargeSharing(std::string stripName, double x, double ex)
bool CheckOverlap(const CRTModuleGeo &module1, const CRTModuleGeo &module2)
std::vector< std::string > CrossesStrips(const simb::MCParticle &particle)
double AngleToTagger(std::string taggerName, const simb::MCParticle &particle)
std::map< int, CRTSipmGeo > fSipms
std::vector< AuxDetGeo > const & AuxDetGeoVec() const
Returns the full list of pointer to the auxiliary detectors.
const TGeoVolume * TotalVolume() const
geo::Point_t TaggerCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
geo::Point_t ModuleCrossingPoint(std::string moduleName, const simb::MCParticle &particle)
bool EntersVolume(const simb::MCParticle &particle)
stream1 can override from command line with o or output services user sbnd
std::vector< std::vector< TGeoNode const * > > FindAllVolumePaths(std::set< std::string > const &vol_names) const
Returns paths of all nodes with volumes with the specified names.
std::vector< double > CRTLimits() const
std::map< std::string, CRTStripGeo > fStrips
bool CrossesModule(const CRTModuleGeo &module, const simb::MCParticle &particle)
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
bool StripHasOverlap(std::string stripName)
void LocalToWorld(const double *auxdet, double *world) const
Transform point from local auxiliary detector frame to world frame.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
geo::Point_t ChannelToSipmPosition(size_t channel) const
bool HasOverlap(const CRTModuleGeo &module)
bool ValidCrossingPoint(std::string taggerName, const simb::MCParticle &particle)
bool CrossesStrip(const CRTStripGeo &strip, const simb::MCParticle &particle)
constexpr Point origin()
Returns a origin position with a point of the specified type.
bool CrossesVolume(const simb::MCParticle &particle)
double DistanceBetweenSipms(geo::Point_t position, size_t channel) const