ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignDBTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
43class PixelID;
44class SCT_ID;
46
47namespace InDetDD {
51}
52
53class ATLAS_NOT_THREAD_SAFE InDetAlignDBTool: // Global variables and const_cast are used.
54virtual 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
147 virtual Identifier getL1L2fromL3Identifier( const Identifier& ident
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 bool m_dynamicDB{false};
186 std::vector<const InDetDD::SiDetectorManager *> m_managers;
187
188 std::vector<std::string> m_alignobjs;
189 std::vector<int> m_alignchans;
190
192
193 std::string m_par_dbkey;
194
195 Gaudi::Property<bool> m_par_newdb{this, "NewDB", true, "create database using new (collection) format"}; // FIXME: "New" is misleading
196 Gaudi::Property<bool> m_par_scttwoside{this, "SCTTwoSide", false, "create structures with separated SCT module sides"};
197 Gaudi::Property<int> m_par_fake{this, "FakeDB", 0, "set to 1 to fake full ATLAS geom, 2 to fake CTB geom"};
198 ToolHandle<IAthenaOutputStreamTool> m_par_condstream{this, "CondStream", "AthenaOutputStreamTool/AthenaOutputStreamTool"};
201 Gaudi::Property<std::string> m_par_dbroot{ this, "DBRoot", "/Indet/Align", "Root folder for alignment" };
202 Gaudi::Property<bool> m_par_oldTextFile{this, "OldTextFile", false, "Input text file using old format"};
203 Gaudi::Property<bool> m_forceUserDBConfig{this, "forceUserDBConfig", false, "Set to true to override any DB auto-configuration"};
204 Gaudi::Property<std::string> m_pixmanName{this, "PixelManager", "Pixel", "Pixel manager name" };
205 Gaudi::Property<std::string> m_sctmanName{this, "SCT_Manager", "SCT", "SCT manager name" };
206 Gaudi::Property<bool> m_doPix{this, "AlignPixel", true, "Include Pixel" };
207 Gaudi::Property<bool> m_doStrip{this, "AlignStrip", true, "Include SCT/ITkStrip" };
208
209 AlignableTransform* getTransPtr(const std::string& key) const;
210 const AlignableTransform* cgetTransPtr(const std::string& key) const;
211 void fakeGeom(const int nbpix, const int necpix,
212 const int nbsct, const int necsct);
213};
214
215#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:67
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