ATLAS Offline Software
InDetAlignDBTool.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 INDETALIGNGENTOOLS_ALIGNDBTOOL_H
6 #define INDETALIGNGENTOOLS_ALIGNDBTOOL_H
7 // InDetAlignDBTool.h
8 // an AlgTool to manage the inner detector alignment database classes
9 // Richard Hawkings, started 8/4/05
10 //
11 // This AlgTool provides utilities to manage the ID alignment conditions
12 // data in the transient store, and to read and write it in a variety of
13 // formats
14 // Tool methods provided:
15 // createDB - create a 'null' set of AlignableTransforms, with no shifts
16 // dispGroup - apply a pattern to displace a group of modules randomly
17 // or systematically
18 // printDB - printout details of all the module transforms
19 // writeFile - export database contents on a text file or ntuple
20 // readTextFile - import database from text file
21 // readNtuple - import database from ntuple
22 //
23 // The following utility methods are also exposed
24 // idToDetSet - convert an SCT/pixel Identifier to set of integers
25 // specifying detector,barrel/ec,layer,ring, sector (and side for SCT)
26 // dirkey - return the AlignableTransform TDS key for a given module
27 // (by Identifier or set of integers)
28 // setTrans - set the transformation for a particular module, identified by
29 // a given Identifier
30 // tweakTrans - tweak (add to existing transform) the transformation for
31 // a particular module, identified by a given Identifier
32 
33 #include <vector>
34 #include <string>
36 #include "GaudiKernel/ServiceHandle.h"
41 #include "GaudiKernel/ToolHandle.h"
42 
43 class PixelID;
44 class SCT_ID;
45 class AlignableTransform;
46 
47 namespace InDetDD {
48  class PixelDetectorManager;
49  class SCT_DetectorManager;
50  class SiDetectorManager;
51 }
52 
53 class ATLAS_NOT_THREAD_SAFE InDetAlignDBTool: // Global variables and const_cast are used.
54 virtual public IInDetAlignDBTool, public AthAlgTool {
55  public:
56  InDetAlignDBTool(const std::string& type, const std::string& name,
57  const IInterface* parent);
58  virtual ~InDetAlignDBTool();
59 
60  virtual StatusCode initialize() override;
61  virtual StatusCode finalize() override;
62 
63  // tool methods
64  // create null database in TDS for subsequent manipulation
65 
66  virtual void createDB() const override;
67 
68  // displace a group of modules
69  // modules to effect are specified by dettype (1=pixel, 2=SCT, -1 both),
70  // bec (barrel=0, 2 for both endcaps, -1 for all), layer (0 to n-1, -1=all)
71  // ring (-1=all) and sector (-1=all)
72  // rphidisp,rdisp and zdisp specify the offsets to be used
73  // syst specifies what will be done, 1=systematic displacement of affected
74  // modules, 2=random (rphidisp etc are RMS), 3,4=systematic and random
75  // displacements but interpreting r/phi/zdisp as x/y/z, 5 chooses the
76  // same randomised numbers for all modules;
77  // level specifies the level oill look for the right balance of CERN staff supervisors and ATLAS
78  //USERS supervisors; f transformations affected
79  // skip=n optionally skips n random numbers to enable different patterns
80  virtual void dispGroup(const int dettype, const int bec, const int layer,
81  const int ring, const int sector,
82  const float rphidisp, const float rdisp, const float zdisp,
83  const int syst, const int level, const int skip) const override;
84 
85  // write database contents to flat text file or ntuple
86  // for flat file, file gives filename, for ntuple, file is e.g.
87  // /NTUPLES/FILE1
88  virtual void writeFile(const bool ntuple, const std::string& file) const override;
89 
90  // write IBLDist txt files
91  virtual void writeIBLDistFile( const std::string& file) const override;
92 
93  // write GlobalFolder txt files
94  virtual void writeGlobalFolderFile( const std::string& file) const override;
95 
96  // read back database from text file
97  virtual void readTextFile(const std::string& file) const override;
98 
99  // read back database from text file
100  // void readOldTextFile(const std::string file) const;
101 
102  // read back database from ntuple
103  virtual void readNtuple(const std::string& file) const override;
104 
105  // convert an Identifier to a set of integers specifying detector, barrel/ec
106  // (0 for barrel, -1 for endcap C, +1 for endcap A), layer, ring (eta),
107  // sector (phi), and side (0/1, pixel always 0)
108  // same as the fields of the Identifier, except bec is +-1 not +-2 for endcap
109  virtual bool idToDetSet(const Identifier ident,
110  int& det,int& bec,int& layer,int& ring,int& sector,int& side) const override;
111 
112  // return the AlignableTransform name where the transform for the given
113  // module can be found, 3 levels corresponding to alignment hierarchy
114  virtual std::string dirkey(const Identifier&, const int) const override;
115  virtual std::string dirkey(const int,const int,const int, const int) const override;
116  virtual std::string dirkey(const int,const int,const int, const int, const int) const override;
117  virtual std::string DBMkey(const int,const int,const int, const int) const override;
118 
119  // set a particular transform specified by Identifier
120  virtual bool setTrans(const Identifier& ident, const int level,
121  const Amg::Transform3D& trans) const override;
122 
123  // As above but takes translation and rotations alpha, beta, gamma (rotations around x,y,z axes) as input.
124  // Calculates transform as HepGeom::Translate3D(translate) * HepGeom::RotateX3D(alpha) * HepGeom::RotateY3D(beta) * HepGeom::RotateZ3D(gamma)
125  virtual bool setTrans(const Identifier& ident, const int level,
126  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const override;
127 
128 
129  // tweak a particular transform specified by Identifier (i.e. add to
130  // already existing transformation)
131  virtual bool tweakTrans(const Identifier& ident, const int level,
132  const Amg::Transform3D& trans) const override;
133 
134  // As above but takes translation and rotations alpha, beta, gamma (rotations around x,y,z axes) as input.
135  // Calculates transform as HepGeom::Translate3D(translate) * HepGeom::RotateX3D(alpha) * HepGeom::RotateY3D(beta) * HepGeom::RotateZ3D(gamma)
136  virtual bool tweakTrans(const Identifier& ident, const int level,
137  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const override;
138 
140  virtual bool tweakIBLDist(const int, const float) const override;
141 
143  virtual bool tweakGlobalFolder(const Identifier& ident, const int level,
144  const Amg::Transform3D& trans) const;
145 
148  , const int& level
149  ) const override;
150 
152  virtual Amg::Transform3D getTransL123( const Identifier& ident ) const override;
153 
157  virtual Amg::Transform3D getTrans( const Identifier& ident
158  , const int level
159  ) const override;
160 
161  // write the transforms to outputstream
162  virtual StatusCode outputObjs() override;
163 
164  // write the transform IOVs to IOVDB
165  virtual void fillDB(const std::string& tag,
166  const unsigned int run1, const unsigned int event1,
167  const unsigned int run2, const unsigned int event2) const override;
168 
169  // print the transforms, level=1 lists sizes, level=2 lists all transforms
170  virtual void printDB(const int level) const override;
171 
172  // sort all the AlignableTransform objects so searches/inserts work properly
173  virtual void sortTrans() const override;
174 
175  //calculate three rotations around locX,locY,locY = alpha,beta,gamma out of an HepGeom::Transform3D
176  void extractAlphaBetaGamma(const Amg::Transform3D & trans,
177  double& alpha, double& beta, double &gamma) const override;
178 
179  private:
180 
181  const PixelID* m_pixid;
182  const SCT_ID* m_sctid;
185  std::vector<const InDetDD::SiDetectorManager *> m_managers;
186 
187  std::vector<std::string> m_alignobjs;
188  std::vector<int> m_alignchans;
189 
191 
192  bool m_par_newdb; // create database using new (collection) format
193  bool m_par_scttwoside; // create structures with separated SCT module sides
194  int m_par_fake; // set to 1 to fake full ATLAS geom, 2 to fake CTB geom
195  ToolHandle<IAthenaOutputStreamTool> m_par_condstream;
198  Gaudi::Property<std::string> m_par_dbroot{ this, "AlignmentRootFolder", "/Indet/Align", "Root folder for alignment" };
201  std::string m_par_dbkey;
202  bool m_par_oldTextFile; // Input text file using old format
203 
204  AlignableTransform* getTransPtr(const std::string& key) const;
205  const AlignableTransform* cgetTransPtr(const std::string& key) const;
206  void fakeGeom(const int nbpix, const int necpix,
207  const int nbsct, const int necsct);
208 
211 
212  Gaudi::Property<std::string> m_pixmanName{this, "PixelManager", "Pixel", "Pixel manager name" };
213  Gaudi::Property<std::string> m_sctmanName{this, "SCT_Manager", "SCT", "SCT manager name" };
214 
215 };
216 
217 #endif // INDETALIGNGENTOOLS_ALIGNDBTOOL_H
IInDetAlignDBTool::dirkey
virtual std::string dirkey(const Identifier &, const int) const =0
IInDetAlignDBTool::getTrans
virtual Amg::Transform3D getTrans(const Identifier &, const int) const =0
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
InDetAlignDBTool
Definition: InDetAlignDBTool.h:54
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
IInDetAlignDBTool::getL1L2fromL3Identifier
virtual Identifier getL1L2fromL3Identifier(const Identifier &ident, const int &level) const =0
IInDetAlignDBTool::printDB
virtual void printDB(const int) const =0
IInDetAlignDBTool::getTransL123
virtual Amg::Transform3D getTransL123(const Identifier &ident) const =0
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
InDetAlignDBTool::m_par_newdb
bool m_par_newdb
Definition: InDetAlignDBTool.h:192
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
python.createDBForTest.createDB
def createDB(folder, sqlite, currents)
Definition: createDBForTest.py:5
IInDetAlignDBTool::sortTrans
virtual void sortTrans() const =0
initialize
void initialize()
Definition: run_EoverP.cxx:894
IInDetAlignDBTool::tweakTrans
virtual bool tweakTrans(const Identifier &, const int, const Amg::Transform3D &) const =0
InDetAlignDBTool::m_par_oldTextFile
bool m_par_oldTextFile
Definition: InDetAlignDBTool.h:202
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
IInDetAlignDBTool::DBMkey
virtual std::string DBMkey(const int, const int, const int, const int) const =0
InDetAlignGenToolsConfig.InDetAlignDBTool
def InDetAlignDBTool(flags, name="InDetAlignDBTool", **kwargs)
Definition: InDetAlignGenToolsConfig.py:14
IInDetAlignDBTool::readTextFile
virtual void readTextFile(const std::string &) const =0
InDetAlignDBTool::m_managers
std::vector< const InDetDD::SiDetectorManager * > m_managers
Definition: InDetAlignDBTool.h:185
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
InDetAlignDBTool::m_dynamicDB
bool m_dynamicDB
Definition: InDetAlignDBTool.h:209
InDetAlignDBTool::m_alignchans
std::vector< int > m_alignchans
Definition: InDetAlignDBTool.h:188
TRT::Hit::side
@ side
Definition: HitInfo.h:83
IAthenaOutputStreamTool.h
Interface to an output stream tool.
InDetAlignDBTool::m_par_fake
int m_par_fake
Definition: InDetAlignDBTool.h:194
IInDetAlignDBTool::idToDetSet
virtual bool idToDetSet(const Identifier, int &, int &, int &, int &, int &, int &) const =0
IInDetAlignDBTool::tweakIBLDist
virtual bool tweakIBLDist(const int, const float) const =0
IInDetAlignDBTool::outputObjs
virtual StatusCode outputObjs()=0
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:26
InDetAlignDBTool::m_pixid
const PixelID * m_pixid
Definition: InDetAlignDBTool.h:181
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
maskDeadModules.run1
run1
Definition: maskDeadModules.py:40
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
IInDetAlignDBTool::readNtuple
virtual void readNtuple(const std::string &) const =0
AthAlgTool.h
file
TFile * file
Definition: tile_monitor.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
IInDetAlignDBTool
Definition: IInDetAlignDBTool.h:23
IInDetAlignDBTool::writeGlobalFolderFile
virtual void writeGlobalFolderFile(const std::string &file) const =0
IInDetAlignDBTool.h
AlignableTransform
Definition: AlignableTransform.h:24
InDetAlignDBTool::m_par_condstream
ToolHandle< IAthenaOutputStreamTool > m_par_condstream
Definition: InDetAlignDBTool.h:195
InDetAlignDBTool::m_par_scttwoside
bool m_par_scttwoside
Definition: InDetAlignDBTool.h:193
IInDetAlignDBTool::extractAlphaBetaGamma
virtual void extractAlphaBetaGamma(const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const =0
ReadCellNoiseFromCoolCompare.run2
run2
Definition: ReadCellNoiseFromCoolCompare.py:53
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
InDetAlignDBTool::m_pixman
const InDetDD::PixelDetectorManager * m_pixman
Definition: InDetAlignDBTool.h:183
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IInDetAlignDBTool::writeIBLDistFile
virtual void writeIBLDistFile(const std::string &file) const =0
IInDetAlignDBTool::dispGroup
virtual void dispGroup(const int, const int, const int, const int, const int, const float, const float, const float, const int, const int, const int) const =0
InDetAlignDBTool::m_sctman
const InDetDD::SCT_DetectorManager * m_sctman
Definition: InDetAlignDBTool.h:184
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
IInDetAlignDBTool::writeFile
virtual void writeFile(const bool, const std::string &) const =0
SCT_ID
Definition: SCT_ID.h:68
InDetAlignDBTool::m_par_dbkey
std::string m_par_dbkey
the base part of the key for loading AlignableTransform objects from the Transient Data Store.
Definition: InDetAlignDBTool.h:201
InDetAlignDBTool::m_sctid
const SCT_ID * m_sctid
Definition: InDetAlignDBTool.h:182
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDetAlignDBTool::m_forceUserDBConfig
bool m_forceUserDBConfig
Definition: InDetAlignDBTool.h:210
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
skip
bool skip
Definition: TrigGlobEffCorrValidation.cxx:190
AthAlgTool
Definition: AthAlgTool.h:26
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
checker_macros.h
Define macros for attributes used to control the static checker.
PixelID
Definition: PixelID.h:67
IInDetAlignDBTool::setTrans
virtual bool setTrans(const Identifier &, const int, const Amg::Transform3D &) const =0
IInDetAlignDBTool::fillDB
virtual void fillDB(const std::string &, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const =0
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
InDetAlignDBTool::m_alignobjs
std::vector< std::string > m_alignobjs
Definition: InDetAlignDBTool.h:187
InDetAlignDBTool::m_attrListCollection
CondAttrListCollection * m_attrListCollection
Definition: InDetAlignDBTool.h:190
Identifier
Definition: IdentifierFieldParser.cxx:14