Project
Loading...
Searching...
No Matches
AlignableDetector.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#ifndef ALIGNABLEDETECTOR_H
18#define ALIGNABLEDETECTOR_H
19
22#include <TObjArray.h>
23#include <cstdio>
24#include "Align/DOFSet.h"
25#include "Align/utils.h"
30
31class TH1;
32
33namespace o2
34{
35namespace align
36{
38class Controller;
39
40//TODO(milettri) : fix possibly incompatible Detector IDs of O2 and AliROOT
42{
43 public:
45
46 enum { kInitGeomDone = BIT(14),
47 kInitDOFsDone = BIT(15) };
48 enum { kNMaxKalibDOF = 64 };
49 //
50 AlignableDetector() = default;
52 ~AlignableDetector() override;
53
54 auto getDetID() const { return mDetID; }
55 auto getName() const { return mDetID.getName(); }
56 //
57 virtual void cacheReferenceCCDB();
58 virtual void acknowledgeNewRun(int run);
59 virtual void updateL2GRecoMatrices();
60 virtual void applyAlignmentFromMPSol();
61 //
62 int volID2SID(int vid) const;
63 int sID2VolID(int sid) const { return sid < getNSensors() ? mSID2VolID[sid] : -1; } //todo
64 int getNSensors() const { return mSensors.GetEntriesFast(); }
65 int getNVolumes() const { return mVolumes.GetEntriesFast(); }
66 int getVolIDMin() const { return mVolIDMin; }
67 int getVolIDMax() const { return mVolIDMax; }
68 bool sensorOfDetector(int vid) const { return vid >= mVolIDMin && vid <= mVolIDMax; }
69 void setAddError(double y, double z);
70 const double* getAddError() const { return mAddError; }
71 //
72 int getNPoints() const { return mNPoints; }
73 //
74 AlignableSensor* getSensor(int id) const { return (AlignableSensor*)mSensors.UncheckedAt(id); }
76 {
77 int sid = volID2SID(vid);
78 return sid < 0 ? nullptr : getSensor(sid);
79 }
80 AlignableSensor* getSensor(const char* symname) const { return (AlignableSensor*)mSensors.FindObject(symname); }
81 AlignableVolume* getVolume(int id) const { return (AlignableVolume*)mVolumes.UncheckedAt(id); }
82 AlignableVolume* getVolume(const char* symname) const { return (AlignableVolume*)mVolumes.FindObject(symname); }
83 //
84 bool ownsDOFID(int id) const;
85 AlignableVolume* getVolOfDOFID(int id) const;
86 //
87 int getDetLabel() const { return (getDetID() + 1) * 100000; }
88 int getSensLabel(int i) const { return getDetLabel() + i + 1; }
89 int getNonSensLabel(int i) const { return getDetLabel() + i + 50001; }
90 int getSensID(int lbl) const { return (lbl % 100000) < 50001 ? (lbl % 100000) - 1 : -1; }
91 int getNonSensID(int lbl) const { return (lbl % 100000) < 50001 ? -1 : (lbl % 100000) - 50001; }
92
93 void setFreeDOF(int dof);
94 void fixDOF(int dof);
95 void setFreeDOFPattern(uint64_t pat)
96 {
97 mCalibDOF = pat;
98 calcFree();
99 }
100 bool isFreeDOF(int dof) const { return (mCalibDOF & (0x1 << dof)) != 0; }
101 bool isCondDOF(int dof) const;
102 uint64_t getFreeDOFPattern() const { return mCalibDOF; }
103 int getNProcessedPoints() const { return mNProcPoints; }
104 virtual const char* getCalibDOFName(int) const { return nullptr; }
105 virtual double getCalibDOFVal(int) const { return 0; }
106 virtual double getCalibDOFValWithCal(int) const { return 0; }
107 //
108 virtual int initGeom();
109 virtual int assignDOFs();
110 virtual void initDOFs();
111 virtual void terminate();
112 virtual void addVolume(AlignableVolume* vol);
113 virtual void defineVolumes();
114 virtual void defineMatrices();
115 void Print(const Option_t* opt = "") const override;
116
117 virtual void reset();
118 virtual int processPoints(GIndex gid, int npntCut = 0, bool inv = false);
119 virtual bool prepareDetectorData() { return true; }
120
121 virtual void updatePointByTrackInfo(AlignmentPoint* pnt, const trackParam_t* t) const;
122 virtual void setUseErrorParam(int v = 0);
123 int getUseErrorParam() const { return mUseErrorParam; }
124 //
125 // virtual bool AcceptTrack(const AliESDtrack* trc, int trtype) const = 0; FIXME(milettri): needs AliESDtrack
126 // bool CheckFlags(const AliESDtrack* trc, int trtype) const; FIXME(milettri): needs AliESDtrack
127 //
128 virtual void writeSensorPositions(const char* outFName);
129 //
130 void setInitGeomDone() { SetBit(kInitGeomDone); }
131 bool getInitGeomDone() const { return TestBit(kInitGeomDone); }
132 //
133 void setInitDOFsDone() { SetBit(kInitDOFsDone); }
134 bool getInitDOFsDone() const { return TestBit(kInitDOFsDone); }
135 void fixNonSensors();
136 void setFreeDOFPattern(uint32_t pat = 0xffffffff, int lev = -1, const std::string& regexStr = "");
137 void setDOFCondition(int dof, float condErr, int lev = -1, const std::string& regexStr = "");
138 int selectVolumes(std::vector<AlignableVolume*> cont, int lev = -1, const std::string& regexStr = "");
139 //
140 void setDisabled(int tp, bool v)
141 {
142 mDisabled[tp] = v;
143 setObligatory(tp, !v);
144 }
146 {
149 }
150 void setDisabledColl(bool v = true) { setDisabled(utils::Coll, v); }
151 void setDisabledCosm(bool v = true) { setDisabled(utils::Cosm, v); }
152 bool isDisabled(int tp) const { return mDisabled[tp]; }
153 bool isDisabled() const { return IsDisabledColl() && IsDisabledCosm(); }
154 bool IsDisabledColl() const { return isDisabled(utils::Coll); }
155 bool IsDisabledCosm() const { return isDisabled(utils::Cosm); }
156 //
157 void setNPointsSel(int tp, int n) { mNPointsSel[tp] = n; }
160 int getNPointsSel(int tp) const { return mNPointsSel[tp]; }
163 //
164 //
165 bool isObligatory(int tp) const { return mObligatory[tp]; }
166 bool isObligatoryColl() const { return isObligatory(utils::Coll); }
167 bool isObligatoryCosm() const { return isObligatory(utils::Cosm); }
168 void setObligatory(int tp, bool v = true);
171 //
172 void addAutoConstraints() const;
173 void constrainOrphans(const double* sigma, const char* match = nullptr);
174
175 virtual void writePedeInfo(FILE* parOut, const Option_t* opt = "") const;
176 virtual void writeLabeledPedeResults(FILE* parOut) const;
177 virtual void writeCalibrationResults() const;
178 virtual void writeAlignmentResults() const;
179 //
180 protected:
181 void sortSensors();
182 void calcFree(bool condFree = false);
183 //
184 // ------- dummies ---------
187 //
188 protected:
189 //
190 DetID mDetID{}; // detector ID
191 bool mInitDone = false;
192 int mVolIDMin = -1; // min volID for this detector (for sensors only)
193 int mVolIDMax = -1; // max volID for this detector (for sensors only)
194 int mNSensors = 0; // number of sensors (i.e. volID's)
195 int* mSID2VolID = nullptr; //[mNSensors] table of conversion from VolID to sid
196 int mNProcPoints = 0; // total number of points processed
197 //
198 // Detector specific calibration degrees of freedom
199 uint64_t mCalibDOF = 0; // status of calib dof
200 //
201 // Track selection
202 bool mDisabled[utils::NTrackTypes] = {}; // detector disabled/enabled in the track
203 bool mObligatory[utils::NTrackTypes] = {}; // detector must be present in the track
204 int mNPointsSel[utils::NTrackTypes] = {}; // min number of points to require
205 //
206 int mUseErrorParam = 0; // signal that points need to be updated using track info, 0 - no
207 double mAddError[2] = {}; // additional error increment for measurement
208 TObjArray mSensors; // all sensors of the detector
209 TObjArray mVolumes; // all volumes of the detector
210 //
211 // this is transient info
212 int mNPoints = 0;
213 //
214 ClassDefOverride(AlignableDetector, 1); // base class for detector global alignment
215};
216
217} // namespace align
218} // namespace o2
219#endif
End-chain alignment volume in detector branch, where the actual measurement is done.
Base class of alignable volume.
Meausered point in the sensor.
Track model for the alignment.
Interface to contiguous set of DOFs in the controller class.
Collection of auxillary methods.
int32_t i
Extention of GlobalTrackID by flags relevant for verter-track association.
virtual int processPoints(GIndex gid, int npntCut=0, bool inv=false)
bool mDisabled[utils::NTrackTypes]
AlignableDetector & operator=(const AlignableDetector &)
bool mObligatory[utils::NTrackTypes]
int selectVolumes(std::vector< AlignableVolume * > cont, int lev=-1, const std::string &regexStr="")
AlignableDetector(const AlignableDetector &)
AlignableSensor * getSensor(int id) const
int mNPointsSel[utils::NTrackTypes]
virtual void writeLabeledPedeResults(FILE *parOut) const
void calcFree(bool condFree=false)
virtual void acknowledgeNewRun(int run)
virtual void setUseErrorParam(int v=0)
ClassDefOverride(AlignableDetector, 1)
number of points from this detector
void constrainOrphans(const double *sigma, const char *match=nullptr)
virtual void writeSensorPositions(const char *outFName)
virtual double getCalibDOFVal(int) const
void setObligatory(int tp, bool v=true)
virtual void addVolume(AlignableVolume *vol)
virtual void updatePointByTrackInfo(AlignmentPoint *pnt, const trackParam_t *t) const
const double * getAddError() const
AlignableSensor * getSensorByVolId(int vid) const
AlignableVolume * getVolOfDOFID(int id) const
void setDisabled(int tp, bool v)
AlignableVolume * getVolume(int id) const
AlignableVolume * getVolume(const char *symname) const
void setNPointsSel(int tp, int n)
bool sensorOfDetector(int vid) const
virtual double getCalibDOFValWithCal(int) const
void setDOFCondition(int dof, float condErr, int lev=-1, const std::string &regexStr="")
virtual void writeAlignmentResults() const
virtual void writePedeInfo(FILE *parOut, const Option_t *opt="") const
void setFreeDOFPattern(uint64_t pat)
AlignableSensor * getSensor(const char *symname) const
void Print(const Option_t *opt="") const override
void setAddError(double y, double z)
virtual void writeCalibrationResults() const
virtual const char * getCalibDOFName(int) const
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr const char * getName(ID id)
names of defined detectors
Definition DetID.h:145
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
GLdouble n
Definition glcorearb.h:1982
const GLdouble * v
Definition glcorearb.h:832
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
typename track::TrackParametrizationWithError< double > trackParam_t
Definition utils.h:29
void align(gsl::span< ElinkEncoder< BareFormat, CHARGESUM > > elinks)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...