ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignDBTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
35#include "GaudiKernel/ServiceHandle.h"
40#include "GaudiKernel/ToolHandle.h"
41#include <vector>
42#include <string>
43
44class PixelID;
45class SCT_ID;
47
48namespace InDetDD {
52}
53
54class ATLAS_NOT_THREAD_SAFE InDetAlignDBTool: // Global variables and const_cast are used.
55virtual public IInDetAlignDBTool, public AthAlgTool {
56 public:
57 InDetAlignDBTool(const std::string& type, const std::string& name,
58 const IInterface* parent);
59 virtual ~InDetAlignDBTool();
60
61 virtual StatusCode initialize() override;
62 virtual StatusCode finalize() override;
63
64 // tool methods
65 // create null database in TDS for subsequent manipulation
66
67 virtual void createDB() const override;
68
69 // displace a group of modules
70 // modules to effect are specified by dettype (1=pixel, 2=SCT, -1 both),
71 // bec (barrel=0, 2 for both endcaps, -1 for all), layer (0 to n-1, -1=all)
72 // ring (-1=all) and sector (-1=all)
73 // rphidisp,rdisp and zdisp specify the offsets to be used
74 // syst specifies what will be done, 1=systematic displacement of affected
75 // modules, 2=random (rphidisp etc are RMS), 3,4=systematic and random
76 // displacements but interpreting r/phi/zdisp as x/y/z, 5 chooses the
77 // same randomised numbers for all modules;
78 // level specifies the level oill look for the right balance of CERN staff supervisors and ATLAS
79 //USERS supervisors; f transformations affected
80 // skip=n optionally skips n random numbers to enable different patterns
81 virtual void dispGroup(const int dettype, const int bec, const int layer,
82 const int ring, const int sector,
83 const float rphidisp, const float rdisp, const float zdisp,
84 const int syst, const int level, const int skip) const override;
85
86 // write database contents to flat text file or ntuple
87 // for flat file, file gives filename, for ntuple, file is e.g.
88 // /NTUPLES/FILE1
89 virtual void writeFile(const bool ntuple, const std::string& file) const override;
90
91 // write IBLDist txt files
92 virtual void writeIBLDistFile( const std::string& file) const override;
93
94 // write GlobalFolder txt files
95 virtual void writeGlobalFolderFile( const std::string& file) const override;
96
97 // read back database from text file
98 virtual void readTextFile(const std::string& file) const override;
99
100 // read back database from text file
101 // void readOldTextFile(const std::string file) const;
102
103 // read back database from ntuple
104 virtual void readNtuple(const std::string& file) const override;
105
106 // convert an Identifier to a set of integers specifying detector, barrel/ec
107 // (0 for barrel, -1 for endcap C, +1 for endcap A), layer, ring (eta),
108 // sector (phi), and side (0/1, pixel always 0)
109 // same as the fields of the Identifier, except bec is +-1 not +-2 for endcap
110 virtual bool idToDetSet(const Identifier ident,
111 int& det,int& bec,int& layer,int& ring,int& sector,int& side) const override;
112
113 // return the AlignableTransform name where the transform for the given
114 // module can be found, 3 levels corresponding to alignment hierarchy
115 virtual std::string dirkey(const Identifier&, const int) const override;
116 virtual std::string dirkey(const int,const int,const int, const int) const override;
117 virtual std::string dirkey(const int,const int,const int, const int, const int) const override;
118 virtual std::string DBMkey(const int,const int,const int, const int) const override;
119
120 // set a particular transform specified by Identifier
121 virtual bool setTrans(const Identifier& ident, const int level,
122 const Amg::Transform3D& trans) const override;
123
124 // As above but takes translation and rotations alpha, beta, gamma (rotations around x,y,z axes) as input.
125 // Calculates transform as HepGeom::Translate3D(translate) * HepGeom::RotateX3D(alpha) * HepGeom::RotateY3D(beta) * HepGeom::RotateZ3D(gamma)
126 virtual bool setTrans(const Identifier& ident, const int level,
127 const Amg::Vector3D& translate, double alpha, double beta, double gamma) const override;
128
129
130 // tweak a particular transform specified by Identifier (i.e. add to
131 // already existing transformation)
132 virtual bool tweakTrans(const Identifier& ident, const int level,
133 const Amg::Transform3D& trans) const override;
134
135 // As above but takes translation and rotations alpha, beta, gamma (rotations around x,y,z axes) as input.
136 // Calculates transform as HepGeom::Translate3D(translate) * HepGeom::RotateX3D(alpha) * HepGeom::RotateY3D(beta) * HepGeom::RotateZ3D(gamma)
137 virtual bool tweakTrans(const Identifier& ident, const int level,
138 const Amg::Vector3D& translate, double alpha, double beta, double gamma) const override;
139
141 virtual bool tweakIBLDist(const int, const float) const override;
142
144 virtual bool tweakGlobalFolder(const Identifier& ident, const int level,
145 const Amg::Transform3D& trans) const;
146
148 virtual Identifier getL1L2fromL3Identifier( const Identifier& ident
149 , const int& level
150 ) const override;
151
153 virtual Amg::Transform3D getTransL123( const Identifier& ident ) const override;
154
158 virtual Amg::Transform3D getTrans( const Identifier& ident
159 , const int level
160 ) const override;
161
162 // write the transforms to outputstream
163 virtual StatusCode outputObjs() override;
164
165 // write the transform IOVs to IOVDB
166 virtual void fillDB(const std::string& tag,
167 const unsigned int run1, const unsigned int event1,
168 const unsigned int run2, const unsigned int event2) const override;
169
170 // print the transforms, level=1 lists sizes, level=2 lists all transforms
171 virtual void printDB(const int level) const override;
172
173 // sort all the AlignableTransform objects so searches/inserts work properly
174 virtual void sortTrans() const override;
175
176 //calculate three rotations around locX,locY,locY = alpha,beta,gamma out of an HepGeom::Transform3D
177 void extractAlphaBetaGamma(const Amg::Transform3D & trans,
178 double& alpha, double& beta, double &gamma) const override;
179
180 private:
181
182 const PixelID* m_pixid{};
183 const SCT_ID* m_sctid{};
186 bool m_dynamicDB{false};
187 std::vector<const InDetDD::SiDetectorManager *> m_managers;
188
189 std::vector<std::string> m_alignobjs;
190 std::vector<int> m_alignchans;
191
193
194 std::string m_par_dbkey;
195
196 Gaudi::Property<bool> m_par_newdb{this, "NewDB", true, "create database using new (collection) format"}; // FIXME: "New" is misleading
197 Gaudi::Property<bool> m_par_scttwoside{this, "SCTTwoSide", false, "create structures with separated SCT module sides"};
198 Gaudi::Property<int> m_par_fake{this, "FakeDB", 0, "set to 1 to fake full ATLAS geom, 2 to fake CTB geom"};
199 ToolHandle<IAthenaOutputStreamTool> m_par_condstream{this, "CondStream", "AthenaOutputStreamTool/AthenaOutputStreamTool"};
202 Gaudi::Property<std::string> m_par_dbroot{ this, "DBRoot", "/Indet/Align", "Root folder for alignment" };
203 Gaudi::Property<bool> m_par_oldTextFile{this, "OldTextFile", false, "Input text file using old format"};
204 Gaudi::Property<bool> m_forceUserDBConfig{this, "forceUserDBConfig", false, "Set to true to override any DB auto-configuration"};
205 Gaudi::Property<std::string> m_pixmanName{this, "PixelManager", "Pixel", "Pixel manager name" };
206 Gaudi::Property<std::string> m_sctmanName{this, "SCT_Manager", "SCT", "SCT manager name" };
207 Gaudi::Property<bool> m_doPix{this, "AlignPixel", true, "Include Pixel" };
208 Gaudi::Property<bool> m_doStrip{this, "AlignStrip", true, "Include SCT/ITkStrip" };
209
210 AlignableTransform* getTransPtr(const std::string& key) const;
211 const AlignableTransform* cgetTransPtr(const std::string& key) const;
212 void fakeGeom(const int nbpix, const int necpix,
213 const int nbsct, const int necsct);
214};
215
216#endif // INDETALIGNGENTOOLS_ALIGNDBTOOL_H
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Interface to an output stream tool.
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
This class is a collection of AttributeLists where each one is associated with a channel number.
virtual bool idToDetSet(const Identifier, int &, int &, int &, int &, int &, int &) const =0
virtual bool tweakTrans(const Identifier &, const int, const Amg::Transform3D &) const =0
virtual Amg::Transform3D getTransL123(const Identifier &ident) const =0
virtual void writeIBLDistFile(const std::string &file) const =0
virtual bool tweakIBLDist(const int, const float) const =0
virtual StatusCode outputObjs()=0
virtual void writeFile(const bool, const std::string &) const =0
virtual void printDB(const int) const =0
virtual void readNtuple(const std::string &) const =0
virtual void createDB() const =0
virtual Amg::Transform3D getTrans(const Identifier &, const int) const =0
virtual void sortTrans() const =0
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
virtual std::string DBMkey(const int, const int, const int, const int) const =0
virtual void extractAlphaBetaGamma(const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const =0
virtual void writeGlobalFolderFile(const std::string &file) const =0
virtual bool setTrans(const Identifier &, const int, const Amg::Transform3D &) const =0
virtual Identifier getL1L2fromL3Identifier(const Identifier &ident, const int &level) const =0
virtual void fillDB(const std::string &, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const =0
virtual std::string dirkey(const Identifier &, const int) const =0
virtual void readTextFile(const std::string &) const =0
Gaudi::Property< std::string > m_par_dbroot
name of the root folder for constants, which can be set via the <key> syntax.
ToolHandle< IAthenaOutputStreamTool > m_par_condstream
Gaudi::Property< std::string > m_sctmanName
Gaudi::Property< bool > m_forceUserDBConfig
std::vector< std::string > m_alignobjs
Gaudi::Property< int > m_par_fake
const InDetDD::PixelDetectorManager * m_pixman
InDetAlignDBTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< bool > m_par_scttwoside
std::string m_par_dbkey
Gaudi::Property< bool > m_doStrip
Gaudi::Property< bool > m_par_newdb
Gaudi::Property< std::string > m_pixmanName
std::vector< const InDetDD::SiDetectorManager * > m_managers
Gaudi::Property< bool > m_par_oldTextFile
const PixelID * m_pixid
std::vector< int > m_alignchans
const SCT_ID * m_sctid
virtual bool tweakGlobalFolder(const Identifier &ident, const int level, const Amg::Transform3D &trans) const
This is the tweak function for the GlobalFolder DB.
const InDetDD::SCT_DetectorManager * m_sctman
virtual StatusCode finalize() override
CondAttrListCollection * m_attrListCollection
Gaudi::Property< bool > m_doPix
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
Base class for Pixel and SCT Detector managers.
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Message Stream Member.
void initialize()
TFile * file