CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MillePedeTrees.h
Go to the documentation of this file.
1 // Original Author: Gero Flucke
2 // last change : $Date: 2012/03/29 08:13:18 $
3 // by : $Author: flucke $
4 
5 #ifndef MILLEPEDETREES_H
6 #define MILLEPEDETREES_H
7 
8 #include "TString.h"
9 
10 class TTree;
11 class TGraph;
12 class TH1;
13 class TH2;
14 class TProfile;
15 
17 {
18  public:
19  explicit MillePedeTrees(const char *fileName, Int_t iter = 1, const char *treeNameAdd = "");
20  virtual ~MillePedeTrees();
21 
22  TH1* Draw(const char *exp, const char *selection, const char *hDef = "", Option_t *opt = "");
23  TH1* CreateHist(const char *exp, const char *select, const char *hDef = "", Option_t *opt = "");
24  TH2* CreateHist2D(const char *expX, const char *expY, const char *select,
25  const char *hDef = "", Option_t *opt = "");
26  TProfile* CreateHistProf(const char *expX, const char *expY, const char *select,
27  const char *hDef = "", Option_t *opt = "");
28  TGraph* CreateGraph(const char *expX, const char *expY, const char *select, Option_t *option="");
29 
30 /* void ScanDiffAbove(UInt_t iPar, float absDiff); */
31 
32  // values: absolute positions and orientations; need a 'position tree' as argument or in front
33  TString Pos() const { return "Pos";}
34  TString Pos(UInt_t ui) const { return Pos() += Bracket(ui);}
35  TString XPos() const { return Pos(0);}
36  TString YPos() const { return Pos(1);}
37  TString ZPos() const { return Pos(2);}
38  TString RPos2(const TString &tree) const; // x^2+y^2
39 /* TString RPos(const TString &tree) const { return Sqrt(RPos2(tree));} // sqrt(x^2+y^2) */
40  TString RPos(const TString &tree) const; // sqrt(x^2+y^2) - y-sign if selected by UseSignedR()
41  // (un)set whether RPos should be signed like y, return old setting
42  bool SetUseSignedR(bool use = true) {bool buf = fUseSignedR; fUseSignedR = use; return buf;}//true: radius gets sign of y
43  bool SetBowsParameters(bool use = true) {bool buf = fBowsParameters; fBowsParameters = use; return buf;}//true: bows param. for pede
44  bool SetSurfDefDeltaBows(bool deltaBows) {const bool buf = fSurfDefDeltaBows; fSurfDefDeltaBows = deltaBows; return buf;} // take care: problems for false if drawing 1-sensor modules!
45 
46  TString Phi(const TString &tree) const;
47  TString OrgPos(const TString &pos) const; // pos x, y, z, r, phi,... on original position
48 
49  TString PhiSwaps(double swapAround, const TString &tree1, const TString &tree2) const;
50  TString Theta(const TString &tree) const;
51  TString Alpha(const TString &tree, bool betaMpiPpi) const;
52  TString Beta (const TString &tree, bool betaMpiPpi) const;
53  TString Gamma(const TString &tree, bool betaMpiPpi) const;
54 
55  // values: alignment parameters; need a 'parameter tree' or MpT() as argument or in front
56  TString Par() const { return "Par";}
57  TString Par(UInt_t ui) const { return Par() += Bracket(ui);}
58  TString XPar() const { return Par(0);}
59  TString YPar() const { return Par(1);}
60  TString ZPar() const { return Par(2);}
61  TString Alpha() const { return Par(3);}
62  TString Beta() const { return Par(4);}
63  TString Gamma() const { return Par(5);}
64  TString DiffPar(const TString &t1, const TString &t2, UInt_t iPar) const {
65  return Parenth(t1 + Par(iPar) += Min() += t2 + Par(iPar));}
66  // values: alignment parameter errors from parameter tree (to be given as tree name)
67  TString ParSi(const TString &tree, UInt_t ui) const;
68  TString XParSi(const TString &tree) const { return ParSi(tree, 0);}
69  TString YParSi(const TString &tree) const { return ParSi(tree, 1);}
70  TString ZParSi(const TString &tree) const { return ParSi(tree, 2);}
71  TString AlphaSi(const TString &tree) const { return ParSi(tree, 3);}
72  TString BetaSi(const TString &tree) const { return ParSi(tree, 4);}
73  TString GammaSi(const TString &tree) const { return ParSi(tree, 5);}
74 
75  // values: Delta positions
76  TString DelPos(UInt_t ui, const TString &tree1, const TString &tree2) const;
77  TString DelR(const TString &tree1, const TString &tree2) const;
78  TString DelRphi(const TString &tree1, const TString &tree2) const;
79  // TString DelRphi_b(const TString &tree1, const TString &tree2) const; // version b
80  TString DelPhi(const TString &tree1, const TString &tree2) const;
81  // values: Delta positions wrt. OrgPosT()
82  TString DelPos(UInt_t ui, const TString &tree) const { return DelPos(ui, tree, OrgPosT());}
83  TString DelR(const TString &tree) const { return DelR(tree, OrgPosT());}
84  TString DelRphi(const TString &tree) const { return DelRphi(tree, OrgPosT());}
85  TString DelPhi(const TString &tree) const { return DelPhi(tree, OrgPosT());}
86  // see also TString DeltaPos(const TString &pos, const TString &tree) const;
87 
88  // '25' and '0x7' DataFormats/DetId/interface/DetId.h:
89  TString SubDetId() const { return "(" + OrgPosT() += "Id>>25)&0x7";}
90  TString AlignableTypeId() const { return OrgPosT() += "ObjId";}
91  TString HieraLev(const TString &tree, Int_t level) const {
92  return Parenth(tree + "HieraLevel==" + Int(level));}
93  TString HieraLev(Int_t level) const {return HieraLev(ParT(), level);}
94  // values: from pede, do not add tree in front
95  TString Valid(UInt_t iParam) const;
96  TString Fixed(UInt_t iParam, bool isFixed = true) const;
97  TString AnyFreePar() const;
98  TString Label(UInt_t iParam) const;
99  TString Cor(UInt_t iParam) const;
100  TString Diff(UInt_t iParam) const;
101  TString PreSi(UInt_t iParam) const;
102  TString ParSi(UInt_t iParam) const;
103  TString ParSiOk(UInt_t iParam) const;
104  TString XParSi() const { return ParSi(0);}
105  TString YParSi() const { return ParSi(1);}
106  TString ZParSi() const { return ParSi(2);}
107  TString AlphaSi() const { return ParSi(3);}
108  TString BetaSi() const { return ParSi(4);}
109  TString GammaSi() const { return ParSi(5);}
110  TString HitsX() const { return MpT() += "HitsX";}
111  TString HitsY() const { return MpT() += "HitsY";}
112  TString DeformValue(UInt_t i, const TString &whichOne) const;//start,result,diff
113  TString NumDeformValues(const TString &whichOne) const; //start,result,diff
114 
115  // symbols
116  TString Dot() const { return ".";}
117  TString Plu() const { return "+";}
118  TString Min() const { return "-";}
119  TString Mal() const { return "*";} // fixme? german...
120  TString Div() const { return "/";}
121  TString AndL() const {return "&&";} // logical and (not '&')
122  TString OrL() const {return "||";} // logical or (not '|')
123  // numbers
124  TString Int(Int_t i) const { return Form("%d", i);}
125  TString Int(UInt_t ui) const { return Form("%u", ui);}
126  TString Flt(Float_t f) const { return Form("%f", f);}
127  // brackets and parentheses
128  TString Bra() const { return "[";}
129  TString Ket() const { return "]";}
130  TString Bracket(UInt_t ui) const { return Bra() += Int(ui) += Ket();}
131  TString Bracket(Int_t i) const { return Bra() += Int(i) += Ket();}
132  TString Bracket(const char *s) const { return (Bra() += s) += Ket();}
133  TString Paren() const { return "(";}
134  TString Thesis() const { return ")";}
135  TString Parenth(const char *s) const { return (Paren() += s) += Thesis();}
136  TString Abs(const char *s) const {return Fun("TMath::Abs", s);}
137  // functions
138  TString Fun(const char *fun, const char *s) const { return fun + Parenth(s);}
139  TString Sqrt(const char *s) const { return Fun("sqrt", s);}
140 
141  // units and names for params
142  TString ToMumMuRad(UInt_t iParam) const { return (iParam < 3 ? "*10000" : "*1000000");}
143  TString ToMumMuRadPede(UInt_t iParam) const;
144  TString ToMumMuRadSurfDef(UInt_t iParam) const;
145  TString Name(UInt_t iParam) const;
146  TString NamePede(UInt_t iParam) const;
147  TString NameSurfDef(UInt_t iParam) const;
148  TString DelName(UInt_t iParam) const { return "#Delta"+Name(iParam);}
149  TString DelNameU(UInt_t iParam) const { return DelName(iParam) += Unit(iParam);}
150  TString Unit(UInt_t iParam) const { return (iParam < 3
151  ? " [#mum]"
152  : (iParam < kNpar ? " [#murad]" : ""));}
153  TString UnitPede(UInt_t iParam) const;
154  TString UnitSurfDef(UInt_t iParam) const;
155  // units and names for position strings (r, rphi, phi, x, y, z)
156  TString ToMumMuRad(const TString &pos) const;
157  TString Name(const TString &pos) const;
158  TString NamePos(UInt_t iPos) const; //0-2 are x, y, z
159  TString DelName(const TString &pos) const;// { return "#Delta"+Name(pos);}
160  TString DelNameU(const TString &pos) const { return DelName(pos) += Unit(pos);}
161  TString Unit(const TString &pos) const;
162 
163  TString DeltaPos(const TString &pos, const TString &tree /* = PosT()*/) const;// delta position to OrgPosT, depending on pos DelPhi,DelRphi,DelPos(0,..) etc.
164  TString SelIs1D() const;
165  TString SelIs2D() const;
166 
167  // tree names
168  TString OrgPosT() const { return fOrgPos + Dot();} // nominal global positions
169  TString MisPosT() const { return fMisPos + Dot();} // misaligned global positions
170  TString MisParT() const { return fMisPar + Dot();} // misalignment
171  TString PosT() const { return fPos + Dot();} // aligned global positions
172  TString ParT() const { return fPar + Dot();} // remaining misalignment
173  TString MpT() const { return fMp + Dot();} // MP tree (parameter, hits,...)
174 
175  TTree* GetMainTree() {return fTree;} // use with care...
176 
177  enum {kLocX = 0, kLocY, kLocZ, kNpar = 6}; // number of parameters we have...
178  protected:
179 
180  private:
181  MillePedeTrees();
182  // utils
183  TTree* CreateTree(const char *fileName, const TString &treeNameAdd);
184 /* TString RemoveHistName(TString &option) const; */
185 
186  // data members
187  TTree *fTree;
188 
189  // tree names
190  TString fOrgPos; // absolute original positions from xml/input DB
191  TString fMisPos; // absolute positions with misalignment applied
192  TString fMisPar; // misalignment parameters
193  TString fPos; // positions after alignment
194  TString fPar; // remaining misalign paramters after alignment (was: alignment parameters)
195  TString fMp; // specials for/from MillePede
196 
197  // special seetings
198  bool fUseSignedR; // if true, Rpos will have sign of y
199  bool fBowsParameters; //true: pede parameter names and titles to 'bows', false: rigid body
200  bool fSurfDefDeltaBows; // true: SurfaceDeformation values as is, otherwise bowMean+Delta and bowMean-Delta
201 };
202 #endif
TString Cor(UInt_t iParam) const
TString HieraLev(Int_t level) const
TString Theta(const TString &tree) const
TString Fun(const char *fun, const char *s) const
TString NumDeformValues(const TString &whichOne) const
int i
Definition: DBlmapReader.cc:9
TString Div() const
TString SelIs1D() const
TString PhiSwaps(double swapAround, const TString &tree1, const TString &tree2) const
TString DelName(UInt_t iParam) const
TString SubDetId() const
TString ToMumMuRad(UInt_t iParam) const
TString ToMumMuRadPede(UInt_t iParam) const
bool SetBowsParameters(bool use=true)
bool SetUseSignedR(bool use=true)
TString Gamma() const
TString MpT() const
TString Beta() const
TString OrgPos(const TString &pos) const
TString DeltaPos(const TString &pos, const TString &tree) const
TString HitsY() const
selection
main part
Definition: corrVsCorr.py:98
TString ZParSi() const
TString ParSi(const TString &tree, UInt_t ui) const
TString AlignableTypeId() const
TString MisPosT() const
TString DelPhi(const TString &tree1, const TString &tree2) const
TString Flt(Float_t f) const
TString Par(UInt_t ui) const
TString ParSiOk(UInt_t iParam) const
TString DeformValue(UInt_t i, const TString &whichOne) const
TString Valid(UInt_t iParam) const
TString ZPos() const
TString HieraLev(const TString &tree, Int_t level) const
TString PreSi(UInt_t iParam) const
TString Paren() const
TString MisParT() const
TString XParSi(const TString &tree) const
TString ZPar() const
TString Bracket(UInt_t ui) const
TString DiffPar(const TString &t1, const TString &t2, UInt_t iPar) const
TString HitsX() const
TString Plu() const
TH2 * CreateHist2D(const char *expX, const char *expY, const char *select, const char *hDef="", Option_t *opt="")
TString NamePede(UInt_t iParam) const
TString Mal() const
TString Fixed(UInt_t iParam, bool isFixed=true) const
TString AndL() const
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
TString Bracket(Int_t i) const
TString Min() const
TString SelIs2D() const
TString AnyFreePar() const
TString DelR(const TString &tree) const
TString NamePos(UInt_t iPos) const
TString PosT() const
TString BetaSi() const
TString DelRphi(const TString &tree) const
bool SetSurfDefDeltaBows(bool deltaBows)
double f[11][100]
TString Int(Int_t i) const
TString GammaSi(const TString &tree) const
TString Label(UInt_t iParam) const
TString GammaSi() const
TString DelPos(UInt_t ui, const TString &tree) const
TString XPar() const
TString YPar() const
TString RPos2(const TString &tree) const
TString YParSi() const
TString Dot() const
TString ZParSi(const TString &tree) const
TString Bracket(const char *s) const
TString Thesis() const
TTree * CreateTree(const char *fileName, const TString &treeNameAdd)
TString RPos(const TString &tree) const
TString Unit(UInt_t iParam) const
TString OrL() const
TString DelPos(UInt_t ui, const TString &tree1, const TString &tree2) const
TString Pos(UInt_t ui) const
TString UnitSurfDef(UInt_t iParam) const
TString Parenth(const char *s) const
TString UnitPede(UInt_t iParam) const
TString DelNameU(UInt_t iParam) const
TString XParSi() const
TString ParT() const
TString OrgPosT() const
TString Bra() const
TString Pos() const
TString DelR(const TString &tree1, const TString &tree2) const
TString BetaSi(const TString &tree) const
TTree * GetMainTree()
TString NameSurfDef(UInt_t iParam) const
TString DelPhi(const TString &tree) const
TString Abs(const char *s) const
TString AlphaSi() const
TString Name(UInt_t iParam) const
TString Par() const
TGraph * CreateGraph(const char *expX, const char *expY, const char *select, Option_t *option="")
TString Sqrt(const char *s) const
TString Alpha() const
virtual ~MillePedeTrees()
TString Phi(const TString &tree) const
tuple level
Definition: testEve_cfg.py:34
TH1 * Draw(const char *exp, const char *selection, const char *hDef="", Option_t *opt="")
TString YParSi(const TString &tree) const
TH1 * CreateHist(const char *exp, const char *select, const char *hDef="", Option_t *opt="")
TProfile * CreateHistProf(const char *expX, const char *expY, const char *select, const char *hDef="", Option_t *opt="")
TString XPos() const
TString Diff(UInt_t iParam) const
TString ToMumMuRadSurfDef(UInt_t iParam) const
TString AlphaSi(const TString &tree) const
TString DelRphi(const TString &tree1, const TString &tree2) const
TString YPos() const
TString Int(UInt_t ui) const
TString Ket() const
TString DelNameU(const TString &pos) const