ATLAS Offline Software
TileMuonFitter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TILECOSMICALGS_TILEMUONFITTER_H
6 #define TILECOSMICALGS_TILEMUONFITTER_H
7 
8 /********************************************************************
9  *
10  * NAME: TileMuonFitter
11  * PACKAGE: offline/TileCalorimeter/TileCosmicAlgs
12  *
13  * AUTHOR : J. Maneira
14  * CREATED: 10-Jul-2006
15  * REVISED: February-2008 (w/ L. Andrade)
16  * REVISED: November-2008 (w/ L. Andrade)
17  * REVISED: February-2009 (w/ M. Soares)
18  *
19  * PURPOSE: Create Cell vectors from CaloCellContainer, fit a straight muon
20  * track through a selected subset, calculate horizontal
21  * plane crossing time.
22  * (see .cxx and mainpage.h for more details)
23  *
24  * Input: TileCell (one by one or from CaloCellContainer)
25  * Output: ComissioningEvent/ComTime object
26  * Output: TileEvent/TileCosmicMuon object
27  *
28  ********************************************************************/
29 
30 // Tile includes
33 
34 // Calo includes
37 
38 // Athena includes
43 
44 // Gaudi includes
45 #include "GaudiKernel/ToolHandle.h"
46 
47 
48 // forward declarations
49 class HWIdentifier;
50 class IdentifierHash;
51 class TileID;
52 class TileHWID;
54 
55 // C++ STL includes
56 #include <string>
57 #include <algorithm>
58 
59 //using namespace ROOT::Minuit2;
60 
61 // Auxiliar class to save info about each cell
62 // used in Hough Transform computation
63 class CellInfo {
64  public:
65 
66  float x, y, z; // position
67  float dist; // RoI
68  float e, ev; // energy and energy density
69  bool use; // cell is enabled
70  bool is_out; // cell is not in current track
71  int track_index; // each cell can belong to only one track
72 };
73 
89  public:
90 
92  TileMuonFitter(const std::string& name, ISvcLocator* pSvcLocator);
93  virtual ~TileMuonFitter();
94 
95  virtual StatusCode initialize();
96  virtual StatusCode execute();
97  virtual StatusCode finalize();
98 
102  void buildCells();
103 
105  void setEventDefaults();
106 
109  bool eventSelection();
110 
113  int fitTrack();
114 
117  int houghTrack();
118 
120  void calculateTime();
122  void calculateTimeAtYequal0();
124  void calculateTimeAtZequal0();
125 
127  void buildTileCosmicMuon(int fitok);
129  void buildTileCosmicMuonAtYequal0(int fitok);
131  void buildTileCosmicMuonAtZequal0(int fitok);
132 
134  void buildComTime(int fitok);
136  void buildComTimeAtYequal0(int fitok);
138  void buildComTimeAtZequal0(int fitok);
139 
140  private:
141 
143  void trackIntersection(std::vector<double> & ltop, std::vector<double> & lbot, int index);
145  void trackSegmentIntersection(std::vector<double> & segPath, std::vector<int> & segPartition
146  , std::vector<int> & segModule, std::vector<int> & segSampling, int index);
147 
149  void energyInTrack(std::vector<double> & etop, std::vector<double> & ebot
150  , std::vector<IdentifierHash> & cells, int index);
151 
153  bool checkLBz(double x1);
155  bool checkEBz(double x1);
157  bool checkEBAz(double x1);
159  bool checkEBCz(double x1);
161  bool checkLBr(double x1, uint8_t s1);
163  bool checkEBr(double x1, uint8_t s1);
165  bool checkLBr(double x1);
167  bool checkEBr(double x1);
169  int whichEBr(double x1);
171  int whichLBr(double x1);
173  int whichModule(CLHEP::Hep3Vector tempvec);
174 
175  // Hough Transform auxiliar routines ---------------------------------------
176 
177  std::vector<CellInfo> m_cellInfo;
178 
179  void cart2hough(float x1, float y1, float x2, float y2, double &raio, double &angu);
180  void hough2cart(double r, double a, double offset, double &aa, double &bb);
181  float dist2line(CellInfo &ci, float *pos, float *w);
182  void points2dir(CellInfo &ci1, CellInfo &ci2, float *w);
183  unsigned int CntCells(unsigned int index1, unsigned int index2, double &skew);
184  bool guessTrack(unsigned int &index1, unsigned int &index2);
185  unsigned int buildCellInfoVector();
186  float selectCells(float *p, float *w);
187  bool isHaloMuon(double azy);
188  void doHough(double &rxy, double &axy, double &rzy, double &azy);
189  void addTrack(double aa, double bb, double cc, double dd);
190 
191  protected:
192 
193  // Tile objects
194  const TileID* m_tileID;
198 
202 
204  double m_eThreshold;
213  std::string m_beamType;
217  std::vector<double> m_tileDD_radiusLB;
219  std::vector<double> m_tileDD_radiusEB;
221  std::vector<double> m_tileDD_zEBA;
223  std::vector<double> m_tileDD_zEBC;
225  std::vector<double> m_tileDD_zLB;
226 
228  int m_nCells;
232  std::vector<CLHEP::Hep3Vector> m_cellPosition;
234  std::vector<double> m_cellEnergy;
236  std::vector<double> m_cellWeight;
238  std::vector<double> m_cellTime;
240  std::vector<double> m_cellDeltaTime;
242  std::vector<IdentifierHash> m_cellHash;
243 
245  std::vector<std::vector<double> > m_linePar;
247  std::vector<double> m_fitMinimum;
249  std::vector<double> m_zeroCrossingTime;
250 
251  double m_meanX;
252  double m_meanY;
253  double m_meanZ;
257 
260  bool m_reg1to2;
261 
263 
264  SG::ReadHandleKey<CaloCellContainer> m_cellContainerKey{this, "CaloCellContainer", "AllCalo",
265  "Input CaloCellContainer name" };
266 
268  "TileCosmicMuonKey",
269  "TileCosmicMuonMF",
270  "Output TileCosmicMuonContainer name"};
271 
272  SG::WriteHandleKey<ComTime> m_comTimeKey{this, "ComTimeKey", "ComTimeTileMuon", "Output ComTime name"};
273 
274 };
275 
276 #endif
CellInfo::z
float z
Definition: TileMuonFitter.h:66
TileMuonFitter::m_caloIndex
static const CaloCell_ID::SUBCALO m_caloIndex
Definition: TileMuonFitter.h:262
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
TileMuonFitter::m_tileDD_zLB
std::vector< double > m_tileDD_zLB
Z bounds of LB, loaded from Detector Description.
Definition: TileMuonFitter.h:225
TileMuonFitter::setEventDefaults
void setEventDefaults()
Reset variables.
Definition: TileMuonFitter.cxx:297
beamspotman.r
def r
Definition: beamspotman.py:676
TileMuonFitter
Fits straight cosmic muon track to TileCal event.
Definition: TileMuonFitter.h:88
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
TileMuonFitter::whichModule
int whichModule(CLHEP::Hep3Vector tempvec)
Returns module index for TVector3 input.
Definition: TileMuonFitter.cxx:1369
TileMuonFitter::buildCells
void buildCells()
Creates an internal cell container (just vectors) from the input CaloCellContainer.
Definition: TileMuonFitter.cxx:319
TileMuonFitter::m_cellTime
std::vector< double > m_cellTime
Selected cell's time.
Definition: TileMuonFitter.h:238
ComTime.h
TileMuonFitter::m_zeroCrossingTime
std::vector< double > m_zeroCrossingTime
Time at y=0.
Definition: TileMuonFitter.h:249
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
TileMuonFitter::trackIntersection
void trackIntersection(std::vector< double > &ltop, std::vector< double > &lbot, int index)
Calculates length of track intersection with TileCal (by sampling).
Definition: TileMuonFitter.cxx:827
TileMuonFitter::m_maxBottomIndex
int m_maxBottomIndex
Definition: TileMuonFitter.h:258
TileMuonFitter::houghTrack
int houghTrack()
Fits a straight track to the cells centers, using a Hough Transform algorithm.
Definition: TileMuonFitter.cxx:1807
TileMuonFitter::buildTileCosmicMuon
void buildTileCosmicMuon(int fitok)
Selects between the two next methods.
Definition: TileMuonFitter.cxx:668
index
Definition: index.py:1
TileMuonFitter::eventSelection
bool eventSelection()
Checks if there are good cells on the top and bottom modules.
Definition: TileMuonFitter.cxx:378
TileMuonFitter::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition: TileMuonFitter.h:264
TileMuonFitter::buildComTimeAtYequal0
void buildComTimeAtYequal0(int fitok)
Creates output ComTime object in StoreGate.
Definition: TileMuonFitter.cxx:1447
TileMuonFitter::checkLBr
bool checkLBr(double x1, uint8_t s1)
Checks if x1 is within LB r coordinate bounds for sampling s1.
Definition: TileMuonFitter.cxx:1327
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
TileMuonFitter::cart2hough
void cart2hough(float x1, float y1, float x2, float y2, double &raio, double &angu)
Definition: TileMuonFitter.cxx:1577
TileMuonFitter::buildComTimeAtZequal0
void buildComTimeAtZequal0(int fitok)
Creates output ComTime object in StoreGate.
Definition: TileMuonFitter.cxx:1512
TileMuonFitter::m_tileDD_radiusEB
std::vector< double > m_tileDD_radiusEB
Radial bounds of the 3 samplings in EB, loaded from Detector Description.
Definition: TileMuonFitter.h:219
TileMuonFitter::calculateTimeAtZequal0
void calculateTimeAtZequal0()
Extrapolates cell time to z=0.
Definition: TileMuonFitter.cxx:605
TileMuonFitter::calculateTime
void calculateTime()
Calculates time in reference plane.
Definition: TileMuonFitter.cxx:530
TileMuonFitter::m_cellPosition
std::vector< CLHEP::Hep3Vector > m_cellPosition
Position of selected cell's center.
Definition: TileMuonFitter.h:232
TileMuonFitter::execute
virtual StatusCode execute()
Definition: TileMuonFitter.cxx:253
TileMuonFitter::dist2line
float dist2line(CellInfo &ci, float *pos, float *w)
Definition: TileMuonFitter.cxx:1617
CellInfo::track_index
int track_index
Definition: TileMuonFitter.h:71
TileMuonFitter::m_linePar
std::vector< std::vector< double > > m_linePar
Vector with the fitted four track parameters.
Definition: TileMuonFitter.h:245
TileMuonFitter::buildCellInfoVector
unsigned int buildCellInfoVector()
Definition: TileMuonFitter.cxx:1698
TileMuonFitter::m_maxTopIndex
int m_maxTopIndex
Definition: TileMuonFitter.h:259
SG::ReadHandleKey< CaloCellContainer >
TileMuonFitter::calculateTimeAtYequal0
void calculateTimeAtYequal0()
Extrapolates cell time to y=0.
Definition: TileMuonFitter.cxx:542
HWIdentifier
Definition: HWIdentifier.h:13
CellInfo::dist
float dist
Definition: TileMuonFitter.h:67
TileMuonFitter::m_fitMinimum
std::vector< double > m_fitMinimum
Chi-square minumum.
Definition: TileMuonFitter.h:247
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
TileMuonFitter::m_cellInfo
std::vector< CellInfo > m_cellInfo
Definition: TileMuonFitter.h:177
TileMuonFitter::m_cellEnergy
std::vector< double > m_cellEnergy
Selected cell's energy.
Definition: TileMuonFitter.h:234
CaloCell_ID.h
TileMuonFitter::whichLBr
int whichLBr(double x1)
Returns sampling index if x1 is within LB r coordinate bounds.
Definition: TileMuonFitter.cxx:1359
CellInfo::ev
float ev
Definition: TileMuonFitter.h:68
TileMuonFitter::m_cellWeight
std::vector< double > m_cellWeight
Selected cell's weight for fit.
Definition: TileMuonFitter.h:236
CellInfo::x
float x
Definition: TileMuonFitter.h:66
AthAlgorithm.h
TileHWID
Helper class for TileCal online (hardware) identifiers.
Definition: TileHWID.h:49
TileMuonFitter::checkEBr
bool checkEBr(double x1, uint8_t s1)
Checks if x1 is within EB r coordinate bounds for sampling s1.
Definition: TileMuonFitter.cxx:1338
TileMuonFitter::m_doHoughTransform
bool m_doHoughTransform
Flag to use Hough Transform instead of Fit.
Definition: TileMuonFitter.h:215
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TileMuonFitter::checkEBAz
bool checkEBAz(double x1)
Checks if x1 is within EBA z coordinate bounds.
Definition: TileMuonFitter.cxx:1289
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
TileMuonFitter::~TileMuonFitter
virtual ~TileMuonFitter()
Definition: TileMuonFitter.cxx:125
TileMuonFitter::TileMuonFitter
TileMuonFitter(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: TileMuonFitter.cxx:95
TileMuonFitter::checkLBz
bool checkLBz(double x1)
Checks if x1 is within LB z coordinate bounds.
Definition: TileMuonFitter.cxx:1274
TileMuonFitter::guessTrack
bool guessTrack(unsigned int &index1, unsigned int &index2)
Definition: TileMuonFitter.cxx:1673
TileMuonFitter::CntCells
unsigned int CntCells(unsigned int index1, unsigned int index2, double &skew)
Definition: TileMuonFitter.cxx:1643
TileDetDescrManager
Definition: TileDetDescrManager.h:33
TileID
Helper class for TileCal offline identifiers.
Definition: TileID.h:68
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
TileMuonFitter::m_cellHash
std::vector< IdentifierHash > m_cellHash
Selected cell's identifier hash.
Definition: TileMuonFitter.h:242
TileMuonFitter::m_theTrack
ROOT::Minuit2::TileMuonTrackDistance * m_theTrack
Auxiliary class representing the function to be minimized - weighted sum of squares of orthogonal dis...
Definition: TileMuonFitter.h:201
TileMuonFitter::m_cellDeltaTime
std::vector< double > m_cellDeltaTime
Selected cell's time difference between two PMTs.
Definition: TileMuonFitter.h:240
CellInfo
Definition: TileMuonFitter.h:63
TileMuonFitter::buildTileCosmicMuonAtZequal0
void buildTileCosmicMuonAtZequal0(int fitok)
Creates output TileCosmicMuon object in StoreGate.
Definition: TileMuonFitter.cxx:754
TileMuonFitter::m_meanX
double m_meanX
Definition: TileMuonFitter.h:251
TileMuonFitter::checkEBz
bool checkEBz(double x1)
Checks if x1 is within EB z coordinate bounds.
Definition: TileMuonFitter.cxx:1283
AthAlgorithm
Definition: AthAlgorithm.h:47
TileMuonFitter::m_weightedMeanX
double m_weightedMeanX
Definition: TileMuonFitter.h:254
TileMuonTrackDistance.h
TileMuonFitter::trackSegmentIntersection
void trackSegmentIntersection(std::vector< double > &segPath, std::vector< int > &segPartition, std::vector< int > &segModule, std::vector< int > &segSampling, int index)
Calculates length of track intersection with TileCal (by sampling and module).
Definition: TileMuonFitter.cxx:1053
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
TileMuonFitter::whichEBr
int whichEBr(double x1)
Returns sampling index if x1 is within EB r coordinate bounds.
Definition: TileMuonFitter.cxx:1349
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
TileMuonFitter::m_weightedMeanY
double m_weightedMeanY
Definition: TileMuonFitter.h:255
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TileMuonFitter::checkEBCz
bool checkEBCz(double x1)
Checks if x1 is within EBC z coordinate bounds.
Definition: TileMuonFitter.cxx:1298
TileMuonFitter::m_weightedMeanZ
double m_weightedMeanZ
Definition: TileMuonFitter.h:256
TileMuonFitter::buildTileCosmicMuonAtYequal0
void buildTileCosmicMuonAtYequal0(int fitok)
Creates output TileCosmicMuon object in StoreGate.
Definition: TileMuonFitter.cxx:681
CellInfo::e
float e
Definition: TileMuonFitter.h:68
CellInfo::use
bool use
Definition: TileMuonFitter.h:69
TileMuonFitter::doHough
void doHough(double &rxy, double &axy, double &rzy, double &azy)
Definition: TileMuonFitter.cxx:1759
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
library_scraper.dd
list dd
Definition: library_scraper.py:46
TileMuonFitter::energyInTrack
void energyInTrack(std::vector< double > &etop, std::vector< double > &ebot, std::vector< IdentifierHash > &cells, int index)
Sums up energy in TileCal cells close to the track (by sampling).
Definition: TileMuonFitter.cxx:1382
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
TileMuonFitter::m_tileID
const TileID * m_tileID
Definition: TileMuonFitter.h:194
TileMuonFitter::m_tileDD_zEBC
std::vector< double > m_tileDD_zEBC
Z bounds of EBC, loaded from Detector Description.
Definition: TileMuonFitter.h:223
TileMuonFitter::m_doWeighted
bool m_doWeighted
Flag to weigh or not the chi-square with an energy parameter.
Definition: TileMuonFitter.h:208
TileMuonFitter::m_nCells
int m_nCells
Number of cells selected for fit.
Definition: TileMuonFitter.h:228
TileMuonFitter::buildComTime
void buildComTime(int fitok)
Selects between the two next methods.
Definition: TileMuonFitter.cxx:1435
TileMuonFitter::m_meanZ
double m_meanZ
Definition: TileMuonFitter.h:253
TileMuonFitter::m_beamType
std::string m_beamType
Flag to indicate: cosmics, singlebeam or collisions.
Definition: TileMuonFitter.h:213
a
TList * a
Definition: liststreamerinfos.cxx:10
TileMuonFitter::isHaloMuon
bool isHaloMuon(double azy)
Definition: TileMuonFitter.cxx:1753
TileMuonFitter::addTrack
void addTrack(double aa, double bb, double cc, double dd)
Definition: TileMuonFitter.cxx:1885
TileMuonFitter::points2dir
void points2dir(CellInfo &ci1, CellInfo &ci2, float *w)
Definition: TileMuonFitter.cxx:1631
TileMuonFitter::initialize
virtual StatusCode initialize()
Definition: TileMuonFitter.cxx:131
CellInfo::y
float y
Definition: TileMuonFitter.h:66
TileMuonFitter::m_doDensity
bool m_doDensity
Flag defining the energy weighting parameter: energy density or plain energy.
Definition: TileMuonFitter.h:211
TileMuonFitter::m_tileDD_zEBA
std::vector< double > m_tileDD_zEBA
Z bounds of EBA, loaded from Detector Description.
Definition: TileMuonFitter.h:221
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TileMuonFitter::m_tileDD_radiusLB
std::vector< double > m_tileDD_radiusLB
Radial bounds of the 3 samplings in LB, loaded from Detector Description.
Definition: TileMuonFitter.h:217
TileMuonFitter::finalize
virtual StatusCode finalize()
Definition: TileMuonFitter.cxx:243
TileMuonFitter::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileMuonFitter.h:195
TileMuonFitter::selectCells
float selectCells(float *p, float *w)
Definition: TileMuonFitter.cxx:1732
TileMuonFitter::m_eThreshold
double m_eThreshold
Cell energy threshold.
Definition: TileMuonFitter.h:204
TileContainer.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TileMuonFitter::hough2cart
void hough2cart(double r, double a, double offset, double &aa, double &bb)
Definition: TileMuonFitter.cxx:1603
TileMuonFitter::m_cosmicMuonContainerKey
SG::WriteHandleKey< TileCosmicMuonContainer > m_cosmicMuonContainerKey
Definition: TileMuonFitter.h:267
ROOT::Minuit2::TileMuonTrackDistance
Auxiliary to TileMuonFitter. Chi-square function for Minuit.
Definition: TileMuonTrackDistance.h:70
test_AnalysisBaseEventLoopJob.aa
aa
Definition: test_AnalysisBaseEventLoopJob.py:37
TileMuonFitter::m_reg1to2
bool m_reg1to2
Definition: TileMuonFitter.h:260
TileMuonFitter::m_minimumCells
int m_minimumCells
Minimum number of cells needed for fit.
Definition: TileMuonFitter.h:230
TileMuonFitter::m_meanY
double m_meanY
Definition: TileMuonFitter.h:252
TileMuonFitter::m_tileMgr
const TileDetDescrManager * m_tileMgr
Definition: TileMuonFitter.h:196
CellInfo::is_out
bool is_out
Definition: TileMuonFitter.h:70
TileMuonFitter::m_caloCells
const CaloCellContainer * m_caloCells
Definition: TileMuonFitter.h:197
TileMuonFitter::m_deltaTimeCut
double m_deltaTimeCut
Cell Delta Time cut.
Definition: TileMuonFitter.h:206
python.handimod.cc
int cc
Definition: handimod.py:523
TileMuonFitter::fitTrack
int fitTrack()
Fits a straight track to the cell centers, using the auxiliary class TileMuonTrackDistance.
Definition: TileMuonFitter.cxx:435
TileMuonFitter::m_comTimeKey
SG::WriteHandleKey< ComTime > m_comTimeKey
Definition: TileMuonFitter.h:272