CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PlotMillePede.h
Go to the documentation of this file.
1 #ifndef PLOTMILLEPEDE_H
2 #define PLOTMILLEPEDE_H
3 // Original Author: Gero Flucke
4 // last change : $Date: 2012/06/25 13:19:30 $
5 // by : $Author: flucke $
6 //
7 // PlotMillePede is a class to interprete the content of the ROOT
8 // TTrees that are stored as output of the millepede alignment algorithm.
9 // The histograms are created by the methods inherited from the
10 // MillePedeTrees class. Drawn quantities and selections are handled
11 // as strings as they can be understood by TTree::Draw(..) commands.
12 //
13 // The main methods all start with 'Draw', so you can use tab completion
14 // on what is available:
15 // PlotMillePede p("treeFile.root"); // file form pede step
16 // p.Draw<tab>
17 //
18 // Management of the created histograms is done using the ('ancient')
19 // class GFHistManager. A pointer to that class can be accessed by
20 // GFHistManager *man = p.GetHistManager();
21 // and then be used manipulate the drawings, e.g. by
22 // man->SetLogY();
23 // or
24 // man->SetNumHistsXY(3,1);
25 // man->Draw();
26 //
27 // By calling new p.Draw..(..) commands, usually previously drawn canvases are
28 // deleted. But most methods provide either a boolean flag 'addPlots' or
29 // understand the option 'add'. If the flag is true or the option string
30 // contains 'add', canvases from previous Draw-commands are kept (in fact they
31 // are re-drawn).
32 //
33 // General Options
34 // ===============
35 // A title can be set by 'void SetTitle(const char *title)':
36 // The title will appear as part of all histogram titles.
37 //
38 // The x-axis ranges of many histograms can be controlled by calling one of
39 // void SetMaxDev(Float_t maxDevDown, Float_t maxDevUp); // set x-axis range for result plots
40 // void SetMaxDev(Float_t maxDev); // set symmetric x-axis range for result plots
41 // before calling a Draw-method. Similarly, the number of bins can be controlled via
42 // Int_t SetNbins(Int_t nBins); // set number of bins for some result plots
43 // that returns the previous setting (default: 101)
44 //
45 // When drawing pede parameters using DrawPede<...>, the class cannot know
46 // what type of parameters that are, e.g. RigidBodyParameters or
47 // (Two)BowedSurface(s)Parameters. To get correct axis labels and units you
48 // can switch between these two using p.SetBowsParameters(bool).
49 // If you do not choose, RigidBodyParameters are expected.
50 //
51 // If something is plotted versus the radius, you can choose to use the signed
52 // radius instead that uses the sign of the y-coordinate:
53 // p.SetUseSignedR(bool)
54 //
55 // When drawing surface deformation values of double sensor modules (TOB, TEC R5-7),
56 // by default the bow parameters as stored in TwoBowedSurfacesDeformations are plotted,
57 // i.e. the average w_20, w_11, w_02 and their differences. You might want to see
58 // instead the full bow of sensor one and two instead, e.g. w_20^1 and w_20^2.
59 // This can be chosen by calling p.SetSurfDefDeltaBows(false).
60 //
61 //
62 // Alignable Selections
63 // ====================
64 // Several cuts can be set and are active until reset for all drawing routines
65 // called after setting them. Active selections are mentioned in histogram titles.
66 // The possibilites to set cuts are:
67 //
68 // 1) Select subdetector(s):
69 // void SetSubDetId(Int_t subDetId);
70 // * 1-6 are TPB, TPE, TIB, TID, TOB, TEC,
71 // * -1 means: reset, i.e. take all
72 // * using (repeated) calls of
73 // void AddSubDetId(Int_t subDetId);
74 // leads to an OR selection of subdetectors
75 // * can use void SetSubDetIds(Int_t id1, Int_t id2,
76 // Int_t id3 = -1, Int_t id4 = -1, Int_t id5 = -1);
77 // i.e. call 'SetSubDetId(id1)' and subsequently AddSubDetId(id<n>) for all
78 // n > 1 with id<n> > 0.
79 //
80 // 2) Special alignable types:
81 // Int_t SetAlignableTypeId(Int_t alignableTypeId);
82 // * DetUnit=1,
83 // * Det=2,
84 // * TIBString=15,
85 // * etc. from CommonAlignment/interface/StructureType.h
86 // * -1 resets
87 // The methods returns the previous setting.
88 //
89 // 3) Select hierarchy level:
90 // In case of hierarchical alignment, one can look at the parameters etc. of each
91 // (active!) hierarchy level separately:
92 // Int_t SetHieraLevel(Int_t hieraLevel);
93 // * 0 (default!): lowest level only
94 // * 1,2,...: first, second,... larger structures only
95 // * -1: resets, shows all levels
96 // The methods returns the previous setting.
97 //
98 // 4) General selection:
99 // void AddAdditionalSel(const char *selection);
100 // * whatever selection string that is valid on the TTree's...
101 // * ... therefore for experts
102 // * current setting cleared by 'ClearAdditionalSel()'
103 //
104 // 4a) Strip stereo, rphi, 1Dlayer/double sided selection:
105 // * Known keywords for AddAdditionalSel(..)
106 // * StripStereo: only Id's of stereo modules in 2D layers/rings
107 // * StripRphi: only Id's of rphi modules in 2D layers/rings
108 // * StripDoubleOr1D: only Id's from 1D layers or composed Dets in 2D layers/rings
109 // * Not<one of above>: the opposite of the above three selections
110 //
111 // 4b) Geometrical and N(hit) selection:
112 // void AddAdditionalSel(const TString &xyzrPhiNhit, Float_t min, Float_t max);
113 // This method makes internal use of the above "AddAdditionalSel(const char *)".
114 // Selects quantity 'xyzrPhiNhit' between 'min' and 'max' where
115 // 'xyzrPhiNhit' can be any of x, y, z, r, phi, Nhit.
116 // (Concerning 'Nhit' see also the comment about IOV handling below.)
117 // Also cleared by 'ClearAdditionalSel()'.
118 //
119 // 5) Selecting predefined detector layers
120 // bool SetDetLayerCuts(unsigned int detLayer, bool silent = false);
121 // This makes use of SetSubDetId(..) and AddAdditionalSel(..)
122 // to select detector layers (or rings), e.g. TIB L1 stereo or TID R3.
123 // Note this changes the internal state of cuts defined by previous calls
124 // to these two methods! Therefore a warning is printed if such cuts are
125 // set before. If this silent == true, this warning is suppressed.
126 // Returns false if 'detLayer' not supported.
127 //
128 //
129 // IOV handling
130 // ============
131 // In case of IOV dependent alignment, results are stored for each IOV.
132 // The second argument of the constructor decides which IOV is used.
133 // The default is 1 that is also valid in case there is no IOV dependence.
134 // To draw the time dependence of parameters vs IOV numbers, use the class
135 // PlotMillePedeIOV.
136 //
137 // Note that the hit statistics is (unfortunately) counted without
138 // taking care of IOV boundaries, i.e. whatever IOV is chosen, the number of
139 // hits per alignable is always the same, i.e. the sum of all IOVs.
140 
141 
142 #include "MillePedeTrees.h"
143 #include <TArrayI.h>
144 
145 class GFHistManager;
146 
148 {
149  public:
150  explicit PlotMillePede(const char *fileName, Int_t iov = 1, Int_t hieraLevel = 0,
151  bool useDiff = false);// iter=1/2: singlerun/merged; heiraLev: -1 ignore, 0 lowest level, etc.; useDiff = true only for before2007_02_26
152  PlotMillePede(const char *fileName, Int_t iov, Int_t hieraLevel, const char *treeNameAdd);
153  virtual ~PlotMillePede();
154 
155  void SetTitle(const char *title) {fTitle = title;}
156  const TString& GetTitle() const { return fTitle;}
158 
159  void DrawAll(Option_t *opt = "rogpmeh"); // r=ParamResult,o=OrigParam,g=GlobCorr,p=Pull,m=MisVsLocation,e=ErrorVsHit,h=HitMaps
160 
161  void DrawParam(bool addPlots = false, const TString &sel = ""); // default: not fixed params
162  void DrawPedeParam(Option_t *option = "", unsigned int nNonRigidParam = 12);//"add": add plots, "vs": p_i vs p_j; params beyond rigid body
163  void DrawPedeParamVsLocation(Option_t *option = "", unsigned int nNonRigidParam = 12);//"add" to add plots; params beyond rigid body
164  void DrawSurfaceDeformations(const TString &whichOne = "result start", Option_t *option = "",
165  unsigned int maxNumPars = 12, unsigned int firstPar = 0);//"start result diff"; "add" to add plots, "all" to erase selection to be valid, "nolimit" w/o axis limits
166  void DrawSurfaceDeformationsVsLocation(const TString &whichOne = "result",
167  Option_t *option = "",
168  unsigned int maxNumPar = 11,
169  unsigned int firstPar = 0); //
170 
171  void DrawSurfaceDeformationsLayer(Option_t *option = "", const unsigned int firstDetLayer = 22,
172  const unsigned int lastDetLayer = 33,
173  const TString &whichOne = "result",
174  unsigned int maxNumPars = 12);//"add", "verbose", "verboseByParam", "nolimit", "spread"; which det layers; "start", "result", "diff"
175 
176 
177 
178  void DrawOrigParam(bool addPlots = false, const TString &sel = ""); //this->AnyFreePar()
179  void DrawOrigPos(bool addPlots = false, const TString &sel = "");
180 
181 /* void DrawParamDiff(bool addPlots = false); */
182  void DrawParamResult(Option_t *option = ""); // 'add' to add plots, 'withFixed' to plot also fixed
183  void DrawPosResult(bool addPlots = false, const TString &selection = "");// sel=SelIs2D()/SelIs1D()
184  void DrawPosMisVsLocation(bool addPlots=false, const TString &selection="", Option_t *option="");// sel=e.g. SelIs2D()/SelIs1D(), opt="start" starting misalignment profile
185  void DrawGlobCorr(bool addPlots = false, const TString &sel = "", Option_t *opt = "",
186  Float_t min = 0., Float_t max = 1.);// opt "nal" (no axis limit), otherwise take min/max; opt 'valid' for pede rad OK
187 
188  void DrawPull(Option_t *opt = "");// 'add' to add plots, 'valid' to select only valid parameter, 'nolimit' for pulls without prior axis limits
189 
190  void DrawMisVsLocation(bool addPlots = false, const TString &sel = "", Option_t *opt = "");//opt: vse0,vse1,mis,withfixed
191  void DrawLabelDiffAbove(UInt_t iPar, float minDiff, bool addPlots = false);
192  void DrawErrorVsHit(bool addPlots = false, const TString &sel = "");
193  void DrawHitMaps(bool addPlots = false, bool inclFullFixed = true);
194  void DrawBigPullLabel(float minPull, bool addPlots = false);
195  void DrawBigPullPos(float minPull, bool addPlots = false);
196  void DrawSubDetId(bool addPlots = false);
197  void DrawXyArrow(Double_t factor, Option_t *option = ""); // opt. "add", "zcirc"
198  void ScanSelection(const char *sel = 0, const char *addColumns = 0); // scan tree with selection, if !sel, take basic selection, addColumns like ":ObjId:HitsY" to add columns ObjId and HitsY
199  void ScanPedeParAbove(UInt_t iPar, float absMin = 1.e5); // scan tree, selecting large parameters
200 
201  void DrawCheck();
202  TString Unique(const char *name) const;
203 
204  void SetMaxDev(Float_t maxDev); // set symmetric x-axis range around 0 for some result plots
205  void SetMaxDev(Float_t maxDevDown, Float_t maxDevUp); // set x-axis range for some result plots
206  Int_t SetNbins(Int_t nBins) {const Int_t buf = fNbins; fNbins = nBins; return buf;} // set number of bins for some result plots
207  Float_t GetMaxDevDown() const {return fMaxDevDown;}// lower x-axis range for some result plots
208  Float_t GetMaxDevUp() const {return fMaxDevUp;} // upper x-axis range for some result plots
209  Int_t GetNbins() const {return fNbins;} // number of bins for some result plots
210  const TArrayI* GetSubDetIds() const { return &fSubDetIds;} // selected subdets
211  void SetSubDetId(Int_t subDetId); // 1-6 are TPB, TPE, TIB, TID, TOB, TEC, -1 means: take all
212  void AddSubDetId(Int_t subDetId); // 1-6 are TPB, TPE, TIB, TID, TOB, TEC
213  void SetSubDetIds(Int_t id1, Int_t id2, Int_t id3 = -1, Int_t id4 = -1, Int_t id5 = -1); // ignores id<n> <= 0
214  Int_t SetAlignableTypeId(Int_t alignableTypeId);//detunit=1,det=2,...,TIBString=15,etc. from StructureType.h (-1: all)
215  Int_t SetHieraLevel(Int_t hieraLevel); // select hierarchical level (-1: all)
216  void AddAdditionalSel(const char *selection);// special select; StripDoubleOr1D,StripRphi,StripStereo (may be prepended by 'Not')
217  void AddAdditionalSel(const TString &xyzrPhiNhit, Float_t min, Float_t max); // min <= x,y,z,r,phi,Nhit < max
218 
219  const TString GetAdditionalSel () const { return fAdditionalSel;}
221 
222  bool SetDetLayerCuts(unsigned int detLayer, bool silent = false); // e.g. TIB L1 stereo (false if 'detLayer' not supported); if silent, no warnings
223  TString DetLayerLabel(unsigned int detLayer) const; // e.g. 'TIB L1S'
224 
225 
226  void AddBasicSelection(TString &sel) const;
227 
228  TString FinalMisAlignment(UInt_t iPar) const;
229  TString TitleAdd() const; // for subdet settings etc.
230  TString AlignableObjIdString(Int_t objId) const;
231 
232  void CopyAddBinning(TString &name, const TH1 *hist) const;// extend 'name' taking binning from hist
233  private:
234  Int_t PrepareAdd(bool addPlots);
235 
236  TString fTitle; // added to hist titles
238  Int_t fHieraLevel; // which hierarchical level to require (-1: all)
239  bool fUseDiff; // true: result is diff between MisParT() and ParT()
240  // false: result is ParT() (from 2007-02-27th on...)
241  TArrayI fSubDetIds; // select subdets (empty: take all)
242  Int_t fAlignableTypeId; // select ony alignables of type det,detunit,rod,etc.(-1: take all)
243  TString fAdditionalSel; // selection to be set by user, used in AddBasicSelection
244  TString fAdditionalSelTitle; // title add-on for fAdditionalSel
245  Float_t fMaxDevUp; // max deviation in result plot (upwards)
246  Float_t fMaxDevDown; // max deviation in result plot (downwards)
247  Int_t fNbins; // number of bins between fMaxDevDown and fMaxDevUp
248 };
249 
250 #endif
bool SetDetLayerCuts(unsigned int detLayer, bool silent=false)
Int_t SetNbins(Int_t nBins)
PlotMillePede(const char *fileName, Int_t iov=1, Int_t hieraLevel=0, bool useDiff=false)
void DrawPedeParamVsLocation(Option_t *option="", unsigned int nNonRigidParam=12)
void DrawAll(Option_t *opt="rogpmeh")
void AddAdditionalSel(const char *selection)
TString DetLayerLabel(unsigned int detLayer) const
void DrawPosMisVsLocation(bool addPlots=false, const TString &selection="", Option_t *option="")
void SetMaxDev(Float_t maxDev)
void DrawBigPullLabel(float minPull, bool addPlots=false)
void DrawXyArrow(Double_t factor, Option_t *option="")
void DrawMisVsLocation(bool addPlots=false, const TString &sel="", Option_t *opt="")
void SetSubDetId(Int_t subDetId)
Float_t fMaxDevDown
virtual ~PlotMillePede()
selection
main part
Definition: corrVsCorr.py:98
void DrawErrorVsHit(bool addPlots=false, const TString &sel="")
Int_t SetHieraLevel(Int_t hieraLevel)
void DrawPedeParam(Option_t *option="", unsigned int nNonRigidParam=12)
Float_t fMaxDevUp
void DrawSurfaceDeformations(const TString &whichOne="result start", Option_t *option="", unsigned int maxNumPars=12, unsigned int firstPar=0)
Int_t SetAlignableTypeId(Int_t alignableTypeId)
void CopyAddBinning(TString &name, const TH1 *hist) const
GFHistManager * GetHistManager()
Int_t GetNbins() const
void DrawPosResult(bool addPlots=false, const TString &selection="")
void ClearAdditionalSel()
void DrawSurfaceDeformationsVsLocation(const TString &whichOne="result", Option_t *option="", unsigned int maxNumPar=11, unsigned int firstPar=0)
void DrawCheck()
Float_t GetMaxDevUp() const
tuple iov
Definition: o2o.py:307
TString AlignableObjIdString(Int_t objId) const
TString fAdditionalSelTitle
TArrayI fSubDetIds
const TString GetAdditionalSel() const
const TArrayI * GetSubDetIds() const
TString Unique(const char *name) const
void DrawGlobCorr(bool addPlots=false, const TString &sel="", Option_t *opt="", Float_t min=0., Float_t max=1.)
Float_t GetMaxDevDown() const
void DrawPull(Option_t *opt="")
T min(T a, T b)
Definition: MathUtil.h:58
void ScanPedeParAbove(UInt_t iPar, float absMin=1.e5)
void DrawOrigParam(bool addPlots=false, const TString &sel="")
void SetSubDetIds(Int_t id1, Int_t id2, Int_t id3=-1, Int_t id4=-1, Int_t id5=-1)
Int_t fAlignableTypeId
void AddBasicSelection(TString &sel) const
void DrawParamResult(Option_t *option="")
void DrawParam(bool addPlots=false, const TString &sel="")
void SetTitle(const char *title)
const TString & GetTitle() const
void AddSubDetId(Int_t subDetId)
void DrawHitMaps(bool addPlots=false, bool inclFullFixed=true)
unsigned int subDetId[13]
void DrawBigPullPos(float minPull, bool addPlots=false)
void DrawSurfaceDeformationsLayer(Option_t *option="", const unsigned int firstDetLayer=22, const unsigned int lastDetLayer=33, const TString &whichOne="result", unsigned int maxNumPars=12)
void ScanSelection(const char *sel=0, const char *addColumns=0)
void DrawLabelDiffAbove(UInt_t iPar, float minDiff, bool addPlots=false)
void DrawOrigPos(bool addPlots=false, const TString &sel="")
TString fAdditionalSel
void DrawSubDetId(bool addPlots=false)
Int_t PrepareAdd(bool addPlots)
GFHistManager * fHistManager
TString TitleAdd() const
TString FinalMisAlignment(UInt_t iPar) const