]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDAlignFaker.h
minor updates
[u/mrichter/AliRoot.git] / FMD / AliFMDAlignFaker.h
1 #ifndef ALIFMDALIGNFAKER_H
2 #define ALIFMDALIGNFAKER_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
4  * reserved. 
5  *
6  * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
7  *
8  * See cxx source for full Copyright notice                               
9  */
10 /** @file    AliFMDAlignFaker.h
11     @author  Christian Holm Christensen <cholm@nbi.dk>
12     @date    Sun Mar 26 18:26:39 2006
13     @brief   Make fake alignment 
14 */
15 //____________________________________________________________________
16 //
17 //  Class 
18 //  to 
19 //  make 
20 //  fake 
21 //  alignment
22 //  parameters 
23 //
24 #ifndef ROOT_TTask
25 # include <TTask.h>
26 #endif
27 #ifndef ROOT_TVector3
28 # include <TVector3.h>
29 #endif
30 class TClonesArray;
31 class TString;
32
33 /** @class AliFMDAlignFaker 
34     @brief This task creates fake alignment. 
35     Which alignment, depends on the bit mask passed to the
36     constructor, or added by `AddAlign'.
37
38     The default is to write all alignment parameters to a local
39     storage @c local://cdb which is a directory in the current
40     directory.
41     @ingroup FMD_util
42 */
43 class AliFMDAlignFaker : public TTask
44 {
45 public:
46   /** What to make alignments for */
47   enum EWhat {
48     /** MAke alignment for sensors */
49     kSensors =  1, 
50     /** Make alignment for half-rings */
51     kHalves
52   };
53   enum {
54     /** All types of alignment */
55     kAll             = (1<<kHalves|1<<kSensors)
56   };
57   /** Constructor 
58       @param mask Bit mask of what to make alignments for 
59       @param geo  File to read geometry from, if needed
60       @param loc  Where to store the result */
61   AliFMDAlignFaker(Int_t mask=kAll, 
62                    const char* geo="geometry.root",
63                    const char* loc="local://cdb");
64   /** Destructor */
65   virtual ~AliFMDAlignFaker() {}
66   /** Add something to make alignment for 
67       @param w Bit of alignment mask */
68   void AddAlign(EWhat w) { SETBIT(fMask, w); }
69   /** Remove something to make alignment for 
70       @param w Bit of alignment mask */
71   void RemoveAlign(EWhat w) { CLRBIT(fMask, w); }
72   /** Set alignment select mask 
73       @param mask Bit mask */
74   void SetAlign(Int_t mask) { fMask = mask; }
75   /** Set the displacement (translation) of sensors.  The displacement
76       is selected random uniformly between the corresponding minimum
77       and maximum. 
78       @param x1 Minimum X displacement (in centimeters)
79       @param y1 Minimum Y displacement (in centimeters)
80       @param z1 Minimum Z displacement (in centimeters)
81       @param x2 Maximum X displacement (in centimeters)
82       @param y2 Maximum Y displacement (in centimeters)
83       @param z2 Maximum Z displacement (in centimeters) */
84   void SetSensorDisplacement(Double_t x1=0,   Double_t y1=0,   Double_t z1=0,
85                              Double_t x2=.01, Double_t y2=.01, Double_t z2=0);
86   /** Set the rotation of sensors.  The displacement is selected
87       random uniformly between the corresponding minimum and maximum.
88       @param x1 Minimum X rotation (in degrees)
89       @param y1 Minimum Y rotation (in degrees)
90       @param z1 Minimum Z rotation (in degrees)
91       @param x2 Maximum X rotation (in degrees)
92       @param y2 Maximum Y rotation (in degrees)
93       @param z2 Maximum Z rotation (in degrees) */
94   void SetSensorRotation(Double_t x1=0,  Double_t y1=0,  Double_t z1=0,
95                          Double_t x2=.5, Double_t y2=.5, Double_t z2=.5);
96   /** Set the displacement (translation) of half-rings.  The
97       displacement is selected random uniformly between the
98       corresponding minimum and maximum.
99       @param x1 Minimum X displacement
100       @param y1 Minimum Y displacement
101       @param z1 Minimum Z displacement
102       @param x2 Maximum X displacement
103       @param y2 Maximum Y displacement
104       @param z2 Maximum Z displacement */
105   void SetHalfDisplacement(Double_t x1=0,   Double_t y1=0,   Double_t z1=0,
106                            Double_t x2=.05, Double_t y2=.05, Double_t z2=.05);
107   /** Set the rotation of half-rings.  The displacement is selected
108       random uniformly between the corresponding minimum and maximum.
109       @param x1 Minimum X rotation (in degrees)
110       @param y1 Minimum Y rotation (in degrees)
111       @param z1 Minimum Z rotation (in degrees)
112       @param x2 Maximum X rotation (in degrees)
113       @param y2 Maximum Y rotation (in degrees)
114       @param z2 Maximum Z rotation (in degrees) */
115   void SetHalfRotation(Double_t x1=0, Double_t y1=0, Double_t z1=0,
116                        Double_t x2=0, Double_t y2=0, Double_t z2=0);
117   /** Set the output file name.  Should be a valid CDB URL.
118       @param file CDB URL */
119   void SetOutput(const char* file) { SetTitle(file); }
120   /** Set the file to read the geometry from. 
121       @param file File name */
122   void SetGeometryFile(const char* file) { SetName(file); }
123   /** Make the alignment objects. 
124       @param option Not used. */
125   void Exec(Option_t* option="");
126 protected:
127   AliFMDAlignFaker(const AliFMDAlignFaker& o) : TTask(o) {}
128   AliFMDAlignFaker& operator=(const AliFMDAlignFaker&) { return *this; }
129   
130   /** Make the alignment object for a path
131       @param path   Node path.
132       @param volID  Volume identifier 
133       @param transX Translation in X
134       @param transY Translation in Y
135       @param transZ Translation in Z
136       @param rotX   Rotation around X axis
137       @param rotY   Rotation around Y axis
138       @param rotZ   Rotation around Z axis
139       @return @c true on success */
140   Bool_t MakeAlign(const TString& path, Int_t volID, 
141                    Double_t transX, Double_t transY, Double_t transZ,
142                    Double_t rotX, Double_t rotY, Double_t rotZ);
143   /** Align a sensor 
144       @param path of a sensor 
145       @param id Volume id */
146   Bool_t MakeAlignSensor(const TString& path, Int_t id);
147   /** Align a half-ring
148       @param path of a sensor 
149       @param id Volume id */
150   Bool_t MakeAlignHalf(const TString& path, Int_t id);
151   /** Write to CDB */
152   void   WriteToCDB();
153   /** Write to file */
154   void   WriteToFile();
155   
156   Long_t        fMask;            // What to write 
157   TVector3      fSensorTransMin;  // Minimum translations of a sensor
158   TVector3      fSensorTransMax;  // Maximum translations of a sensor
159   TVector3      fSensorRotMin;    // Minimum rotation of a sensor
160   TVector3      fSensorRotMax;    // Maximum rotation of a sensor
161   TVector3      fHalfTransMin;    // Minimum translations of a half-ring
162   TVector3      fHalfTransMax;    // Maximum translations of a half-ring
163   TVector3      fHalfRotMin;      // Minimum rotation of a half-ring    
164   TVector3      fHalfRotMax;      // Maximum rotation of a half-ring 
165   Int_t         fRunMin;          // Run validity start 
166   Int_t         fRunMax;          // Run validity end
167   TClonesArray* fArray;           // Cache
168   
169   ClassDef(AliFMDAlignFaker,0)
170 };
171
172 #endif
173 //____________________________________________________________________
174 //
175 // Local Variables:
176 //   mode: C++
177 // End:
178 //
179 // EOF
180 //
181