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