LiveGeometry.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file LiveGeometry.h
3 /// \author bays@caltech.edu
4 ////////////////////////////////////////////////////////////////////////
5 #ifndef GEO_LIVEGEOMETRY_H
6 #define GEO_LIVEGEOMETRY_H
7 
9 
14 
15 #include "fhiclcpp/types/Atom.h"
16 
17 #include "TVector3.h"
18 
19 /// Detector geometry information
20 namespace geo {
21  /// The instrumented geometry of one entire detector (near, far, ipnd)
23  {
24  public:
25  struct Params
26  {
28  {
29  fhicl::Name("CheckBadChannels"),
30  fhicl::Comment("Should we check bad channels and call DCMs bad if they have too many?")
31  };
34  };
35 
36  // Allows 'nova --print-description' to work
38 
40  ~LiveGeometry();
41 
42  void postBeginSubRun(art::SubRun const& subrun);
43  void preBeginEvent(art::Event const& evt,
45 
46  /// \name Projected Distances
47  //@{
48  double ProjectedDistanceToEdge(TVector3 vertex, TVector3 dir);
49  double ProjectedLiveDistanceToEdge(TVector3 vertex, TVector3 dir);
50  double ProjectedDistanceToNextBadRegion(TVector3 vertex, TVector3 dir);
51  bool ProjectedDistance(TVector3 vertex, TVector3 dir, double &distToEdge, double &distToNextBad, double &distDead);
52  //@}
53 
54  /// \name Projected Number of Cells
55  //@{
56  int ProjectedCellsToEdge(TVector3 vertex, TVector3 dir);
57  int ProjectedLiveCellsToEdge(TVector3 vertex, TVector3 dir); ///< recommended projection to use
58  int ProjectedCellsToNextBadRegion(TVector3 vertex, TVector3 dir);
59  //@}
60 
61  /// \name Checking if Live
62  //@{
63  double GetBadBoxCorner(bool view, int coord, int i); ///< Get the corner of a bad box (hook for evend display)
64  int NumBadBoxesX(); ///< Size of the vector of bad boxes in the XZ view
65  int NumBadBoxesY(); ///< Size of the vector of bad boxes in the YZ view
66  bool IsPointLiveInfo(TVector3 vertex, int &info); ///< Note the muon catcher is considered bad; use in combination with InMuonCatcher if needed
67  bool IsPointLive(TVector3 vertex); ///< Note the muon catcher is considered bad; use in combination with InMuonCatcher if needed
68  int DCMStatus(unsigned int dib, unsigned int dcm); ///< returns: 0: RH says is bad; 1: good; 2: bad, either BC or DCM drop
69  double DistToClosestBadRegion(TVector3 vertex);
70  //@}
71 
72  /// \name Define a fully good volume; used to be in Geometry Service
73  //@{
74  double InstrumentedDetLength(); ///< get instrumented detector length of downstream part
75  double InstrumentedDetFront(); ///< get instrumented detector front of downstream part
76  double InstrumentedDetBack(); ///< get instrumented detector back of downstream part
77  int InstrumentedDetEnds(double &frontDwnstrm, double &backDwnstrm, double &frontUpstrm, double &backUpstrm); ///< give all detector ends information; most general
78  void SetInstrumentation(); ///< calculate the detector end information
79  //@}
80 
81  /// \name Distances to Edge
82  //@{
83  double DistToEdgeXPlus(TVector3 vertex);
84  double DistToEdgeXMinus(TVector3 vertex);
85  double DistToTop(TVector3 vertex);
86  double DistToBottom(TVector3 vertex);
87  double DistToFront(TVector3 vertex);
88  double DistToBack(TVector3 vertex);
89  double DistToEdgeX(TVector3 vertex);
90  double DistToEdgeY(TVector3 vertex);
91  double DistToEdgeXY(TVector3 vertex);
92  double DistToEdgeZ(TVector3 vertex);
93  //@}
94 
95  /// \name Number of Cells/Planes to Edge
96  //@{
97  int CellsToEdgeXPlus(TVector3 vertex);
98  int CellsToEdgeXMinus(TVector3 vertex);
99  int CellsToTop(TVector3 vertex);
100  int CellsToBottom(TVector3 vertex);
101  int PlanesToFront(TVector3 vertex);
102  int PlanesToBack(TVector3 vertex);
103  int CellsToEdgeX(TVector3 vertex);
104  int CellsToEdgeY(TVector3 vertex);
105  int CellsToEdgeXY(TVector3 vertex);
106  int PlanesToEdge(TVector3 vertex);
107  //@}
108 
109  /// \name ND Muon Catcher Functions
110  //@{
111  bool InMuonCatcher(TVector3 vertex);
112  int DoWeEnterMC(TVector3 vertex, TVector3 dir);
113  double ProjectedDistanceInMC(TVector3 vertex, TVector3 dir);
114  int ProjectedCellsInMC(TVector3 vertex, TVector3 dir);
115  int FullNDProjectedCells(TVector3 vertex, TVector3 dir);
116  double XPositionAtTransition(TVector3 vertex, TVector3 dir);
117  double YPositionAtTransition(TVector3 vertex, TVector3 dir);
118  double DistanceToEdgeInMC(TVector3 vertex, int &wall);
119  int CellsToEdgeInMC(TVector3 vertex, int &wall);
120  double ProjectedAirDist(TVector3 vertex, TVector3 dir);
121  double ProjectedSteelDist(TVector3 vertex, TVector3 dir);
122  //@}
123 
124  /// \name Other
125  //@{
126  double LiveDetectorVolume(); ///< in ktons
127  int ProjectedWall(TVector3 vertex, TVector3 dir); ///< if we assume the downstream InstrumentedDetEnds, what wall would this projected track exit from?
128  int NBadDCMBC();
129  int NDropouts();
130  int TotalDropouts();
131  /// Z position at which the muon catcher starts
132  double MCFrontZ() const {return fMCFront;}
133  //@}
134 
135  protected:
136  double fEdgeFrontXZ=0, fEdgeBackXZ=0, fEdgeXMinusXZ=0, fEdgeXPlusXZ=0; ///< proper 2D detector boundaries in XZ
137  double fEdgeFrontYZ=0, fEdgeBackYZ=0, fEdgeTopYZ=0, fEdgeBottomYZ=0; ///< proper 2D detector boundaries in YZ
138  double fMCFront=0, fMCBack=0, fMCEdge=0, fMCTop=0; ///< muon catcher boundaries
139 
141 
142  bool fSetup = false; ///< have we done setup yet this run
143  bool fEvFlag = false; ///< have we read in information for this event yet? (don't use preBeginEvent since race w/ BadChan)
145  int fDCMs[12][14];
146  int fFrontUpstream = -5;
147  int fBackUpstream = -5;
149  int fBackDownstream = -5;
150  int fNumDiblocks = 0;
151  int fNumDCMs = 0;
152  int fNumCells = 0;
153  int fNumChannels = 0;
154  int fWall = 0;
155  int fNDropouts = 0;
156  int fTotalDropouts = 0;
157  int fNEvents = 0;
158  int fNBadChan = 0;
159  float fMassKtons;
160  struct BadBox
161  {
162 
163  float Z1; ///< point 1 for minima, point 2 for maxima
164  float Z2;
165  float XY1;
166  float XY2;
167  unsigned int type; ///< 0 means uninstrumented, 1 means bad
168  bool edge; ///< are we connected to the detector edge?
169  };
170 
171  std::vector<BadBox> fBadBoxXZ, fBadBoxYZ;
172 
173  /// \name Private Functions for Determining Bad Boxes
174  //@{
175  void SetupLiveGeo(); ///< Necessary set up before anything; get boudnaries, find and fill bad boxes
176  void FillBadBoxes(); ///< Fill bad and uninstrumented regions of detector
177  void GetDetectorEdges(); ///< Get proper detector boundaries for each view
178  void GetRHInfo(); ///< Get uninstrumented regions from RunHistory
179  void GetBCInfo(); ///< Get bad regions from BadChannels
180  void GetEvInfo(); ///< Get event by event information
181  //@}
182 
183  };
184 }
186 #endif // GEO_GEOMETRY_H
187 ////////////////////////////////////////////////////////////////////////
int PlanesToEdge(TVector3 vertex)
const XML_Char XML_Encoding * info
Definition: expat.h:530
double GetBadBoxCorner(bool view, int coord, int i)
Get the corner of a bad box (hook for evend display)
Definition: event.h:34
int CellsToEdgeY(TVector3 vertex)
double fMCTop
muon catcher boundaries
Definition: LiveGeometry.h:138
unsigned int type
0 means uninstrumented, 1 means bad
Definition: LiveGeometry.h:167
LiveGeometry(const Parameters &params, art::ActivityRegistry &reg)
double ProjectedSteelDist(TVector3 vertex, TVector3 dir)
int CellsToEdgeXMinus(TVector3 vertex)
double DistToEdgeXY(TVector3 vertex)
void preBeginEvent(art::Event const &evt, art::ScheduleContext)
double DistToEdgeY(TVector3 vertex)
The instrumented geometry of one entire detector (near, far, ipnd)
Definition: LiveGeometry.h:22
std::string fCalHitLabel
Definition: LiveGeometry.h:144
int NumBadBoxesX()
Size of the vector of bad boxes in the XZ view.
int CellsToTop(TVector3 vertex)
int CellsToBottom(TVector3 vertex)
int ProjectedCellsToNextBadRegion(TVector3 vertex, TVector3 dir)
double DistanceToEdgeInMC(TVector3 vertex, int &wall)
int fDCMs[12][14]
Definition: LiveGeometry.h:145
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:86
bool fSetup
have we done setup yet this run
Definition: LiveGeometry.h:142
double DistToClosestBadRegion(TVector3 vertex)
double DistToEdgeX(TVector3 vertex)
double DistToFront(TVector3 vertex)
std::vector< BadBox > fBadBoxYZ
Definition: LiveGeometry.h:171
double DistToBack(TVector3 vertex)
double LiveDetectorVolume()
in ktons
int ProjectedCellsToEdge(TVector3 vertex, TVector3 dir)
void GetBCInfo()
Get bad regions from BadChannels.
int ProjectedLiveCellsToEdge(TVector3 vertex, TVector3 dir)
recommended projection to use
float Z1
point 1 for minima, point 2 for maxima
Definition: LiveGeometry.h:163
double MCFrontZ() const
Z position at which the muon catcher starts.
Definition: LiveGeometry.h:132
void postBeginSubRun(art::SubRun const &subrun)
bool ProjectedDistance(TVector3 vertex, TVector3 dir, double &distToEdge, double &distToNextBad, double &distDead)
double DistToTop(TVector3 vertex)
fhicl::Atom< bool > CheckBadChannels
Definition: LiveGeometry.h:28
double InstrumentedDetLength()
get instrumented detector length of downstream part
double ProjectedLiveDistanceToEdge(TVector3 vertex, TVector3 dir)
void SetInstrumentation()
calculate the detector end information
int ProjectedCellsInMC(TVector3 vertex, TVector3 dir)
double DistToBottom(TVector3 vertex)
double DistToEdgeZ(TVector3 vertex)
double fEdgeBottomYZ
proper 2D detector boundaries in YZ
Definition: LiveGeometry.h:137
int CellsToEdgeXY(TVector3 vertex)
double YPositionAtTransition(TVector3 vertex, TVector3 dir)
double InstrumentedDetFront()
get instrumented detector front of downstream part
Encapsulate the geometry of one entire detector (near, far, ndos)
std::vector< BadBox > fBadBoxXZ
Definition: LiveGeometry.h:171
int evt
void GetEvInfo()
Get event by event information.
int FullNDProjectedCells(TVector3 vertex, TVector3 dir)
int CellsToEdgeInMC(TVector3 vertex, int &wall)
double InstrumentedDetBack()
get instrumented detector back of downstream part
bool fEvFlag
have we read in information for this event yet? (don&#39;t use preBeginEvent since race w/ BadChan) ...
Definition: LiveGeometry.h:143
int CellsToEdgeXPlus(TVector3 vertex)
void GetRHInfo()
Get uninstrumented regions from RunHistory.
bool IsPointLiveInfo(TVector3 vertex, int &info)
Note the muon catcher is considered bad; use in combination with InMuonCatcher if needed...
void SetupLiveGeo()
Necessary set up before anything; get boudnaries, find and fill bad boxes.
void GetDetectorEdges()
Get proper detector boundaries for each view.
int CellsToEdgeX(TVector3 vertex)
fhicl::Atom< std::string > CalHitLabel
Definition: LiveGeometry.h:33
int ProjectedWall(TVector3 vertex, TVector3 dir)
if we assume the downstream InstrumentedDetEnds, what wall would this projected track exit from...
fhicl::Atom< bool > Verbose
Definition: LiveGeometry.h:32
double ProjectedDistanceInMC(TVector3 vertex, TVector3 dir)
double DistToEdgeXMinus(TVector3 vertex)
TDirectory * dir
Definition: macro.C:5
double ProjectedDistanceToNextBadRegion(TVector3 vertex, TVector3 dir)
bool edge
are we connected to the detector edge?
Definition: LiveGeometry.h:168
bool IsPointLive(TVector3 vertex)
Note the muon catcher is considered bad; use in combination with InMuonCatcher if needed...
double XPositionAtTransition(TVector3 vertex, TVector3 dir)
double ProjectedAirDist(TVector3 vertex, TVector3 dir)
int DCMStatus(unsigned int dib, unsigned int dcm)
returns: 0: RH says is bad; 1: good; 2: bad, either BC or DCM drop
double fEdgeXPlusXZ
proper 2D detector boundaries in XZ
Definition: LiveGeometry.h:136
bool InMuonCatcher(TVector3 vertex)
Helper for AttenCurve.
Definition: Path.h:10
int InstrumentedDetEnds(double &frontDwnstrm, double &backDwnstrm, double &frontUpstrm, double &backUpstrm)
give all detector ends information; most general
void FillBadBoxes()
Fill bad and uninstrumented regions of detector.
int NumBadBoxesY()
Size of the vector of bad boxes in the YZ view.
int PlanesToBack(TVector3 vertex)
double ProjectedDistanceToEdge(TVector3 vertex, TVector3 dir)
int DoWeEnterMC(TVector3 vertex, TVector3 dir)
double DistToEdgeXPlus(TVector3 vertex)
int PlanesToFront(TVector3 vertex)
enum BeamMode string