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: 2010/10/26 21:34:25 $
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 
45  TString Phi(const TString &tree) const;
46  TString OrgPos(const TString &pos) const; // pos x, y, z, r, phi,... on original position
47 
48  TString PhiSwaps(double swapAround, const TString &tree1, const TString &tree2) const;
49  TString Theta(const TString &tree) const;
50  TString Alpha(const TString &tree, bool betaMpiPpi) const;
51  TString Beta (const TString &tree, bool betaMpiPpi) const;
52  TString Gamma(const TString &tree, bool betaMpiPpi) const;
53 
54  // values: alignment parameters; need a 'parameter tree' or MpT() as argument or in front
55  TString Par() const { return "Par";}
56  TString Par(UInt_t ui) const { return Par() += Bracket(ui);}
57  TString XPar() const { return Par(0);}
58  TString YPar() const { return Par(1);}
59  TString ZPar() const { return Par(2);}
60  TString Alpha() const { return Par(3);}
61  TString Beta() const { return Par(4);}
62  TString Gamma() const { return Par(5);}
63  TString DiffPar(const TString &t1, const TString &t2, UInt_t iPar) const {
64  return Parenth(t1 + Par(iPar) += Min() += t2 + Par(iPar));}
65  // values: alignment parameter errors from parameter tree (to be given as tree name)
66  TString ParSi(const TString &tree, UInt_t ui) const;
67  TString XParSi(const TString &tree) const { return ParSi(tree, 0);}
68  TString YParSi(const TString &tree) const { return ParSi(tree, 1);}
69  TString ZParSi(const TString &tree) const { return ParSi(tree, 2);}
70  TString AlphaSi(const TString &tree) const { return ParSi(tree, 3);}
71  TString BetaSi(const TString &tree) const { return ParSi(tree, 4);}
72  TString GammaSi(const TString &tree) const { return ParSi(tree, 5);}
73 
74  // values: Delta positions
75  TString DelPos(UInt_t ui, const TString &tree1, const TString &tree2) const;
76  TString DelR(const TString &tree1, const TString &tree2) const;
77  TString DelRphi(const TString &tree1, const TString &tree2) const;
78  // TString DelRphi_b(const TString &tree1, const TString &tree2) const; // version b
79  TString DelPhi(const TString &tree1, const TString &tree2) const;
80  // values: Delta positions wrt. OrgPosT()
81  TString DelPos(UInt_t ui, const TString &tree) const { return DelPos(ui, tree, OrgPosT());}
82  TString DelR(const TString &tree) const { return DelR(tree, OrgPosT());}
83  TString DelRphi(const TString &tree) const { return DelRphi(tree, OrgPosT());}
84  TString DelPhi(const TString &tree) const { return DelPhi(tree, OrgPosT());}
85  // see also TString DeltaPos(const TString &pos, const TString &tree) const;
86 
87  // '25' and '0x7' DataFormats/DetId/interface/DetId.h:
88  TString SubDetId() const { return "(" + OrgPosT() += "Id>>25)&0x7";}
89  TString AlignableTypeId() const { return OrgPosT() += "ObjId";}
90  TString HieraLev(const TString &tree, Int_t level) const {
91  return Parenth(tree + "HieraLevel==" + Int(level));}
92  TString HieraLev(Int_t level) const {return HieraLev(ParT(), level);}
93  // values: from pede, do not add tree in front
94  TString Valid(UInt_t iParam) const;
95  TString Fixed(UInt_t iParam, bool isFixed = true) const;
96  TString AnyFreePar() const;
97  TString Label(UInt_t iParam) const;
98  TString Cor(UInt_t iParam) const;
99  TString Diff(UInt_t iParam) const;
100  TString PreSi(UInt_t iParam) const;
101  TString ParSi(UInt_t iParam) const;
102  TString ParSiOk(UInt_t iParam) const;
103  TString XParSi() const { return ParSi(0);}
104  TString YParSi() const { return ParSi(1);}
105  TString ZParSi() const { return ParSi(2);}
106  TString AlphaSi() const { return ParSi(3);}
107  TString BetaSi() const { return ParSi(4);}
108  TString GammaSi() const { return ParSi(5);}
109  TString HitsX() const { return MpT() += "HitsX";}
110  TString HitsY() const { return MpT() += "HitsY";}
111  TString DeformValue(UInt_t i, const TString &whichOne) const;//start,result,diff
112  TString NumDeformValues(const TString &whichOne) const; //start,result,diff
113 
114  // symbols
115  TString Dot() const { return ".";}
116  TString Plu() const { return "+";}
117  TString Min() const { return "-";}
118  TString Mal() const { return "*";} // fixme? german...
119  TString Div() const { return "/";}
120  TString AndL() const {return "&&";} // logical and (not '&')
121  TString OrL() const {return "||";} // logical or (not '|')
122  // numbers
123  TString Int(Int_t i) const { return Form("%d", i);}
124  TString Int(UInt_t ui) const { return Form("%u", ui);}
125  TString Flt(Float_t f) const { return Form("%f", f);}
126  // brackets and parentheses
127  TString Bra() const { return "[";}
128  TString Ket() const { return "]";}
129  TString Bracket(UInt_t ui) const { return Bra() += Int(ui) += Ket();}
130  TString Bracket(Int_t i) const { return Bra() += Int(i) += Ket();}
131  TString Bracket(const char *s) const { return (Bra() += s) += Ket();}
132  TString Paren() const { return "(";}
133  TString Thesis() const { return ")";}
134  TString Parenth(const char *s) const { return (Paren() += s) += Thesis();}
135  TString Abs(const char *s) const {return Fun("TMath::Abs", s);}
136  // functions
137  TString Fun(const char *fun, const char *s) const { return fun + Parenth(s);}
138  TString Sqrt(const char *s) const { return Fun("sqrt", s);}
139 
140  // units and names for params
141  TString ToMumMuRad(UInt_t iParam) const { return (iParam < 3 ? "*10000" : "*1000000");}
142  TString ToMumMuRadPede(UInt_t iParam) const;
143  TString ToMumMuRadSurfDef(UInt_t iParam) const;
144  TString Name(UInt_t iParam) const;
145  TString NamePede(UInt_t iParam) const;
146  TString NameSurfDef(UInt_t iParam) const;
147  TString DelName(UInt_t iParam) const { return "#Delta"+Name(iParam);}
148  TString DelNameU(UInt_t iParam) const { return DelName(iParam) += Unit(iParam);}
149  TString Unit(UInt_t iParam) const { return (iParam < 3
150  ? " [#mum]"
151  : (iParam < kNpar ? " [#murad]" : ""));}
152  TString UnitPede(UInt_t iParam) const;
153  TString UnitSurfDef(UInt_t iParam) const;
154  // units and names for position strings (r, rphi, phi, x, y, z)
155  TString ToMumMuRad(const TString &pos) const;
156  TString Name(const TString &pos) const;
157  TString DelName(const TString &pos) const;// { return "#Delta"+Name(pos);}
158  TString DelNameU(const TString &pos) const { return DelName(pos) += Unit(pos);}
159  TString Unit(const TString &pos) const;
160 
161  TString DeltaPos(const TString &pos, const TString &tree /* = PosT()*/) const;// delta position to OrgPosT, depending on pos DelPhi,DelRphi,DelPos(0,..) etc.
162  TString SelIs1D() const;
163  TString SelIs2D() const;
164 
165  // tree names
166  TString OrgPosT() const { return fOrgPos + Dot();} // nominal global positions
167  TString MisPosT() const { return fMisPos + Dot();} // misaligned global positions
168  TString MisRelPosT() const { return fMisRelPos + Dot();} // misaligned
169  TString MisParT() const { return fMisPar + Dot();} // misalignment
170  TString PosT() const { return fPos + Dot();} // aligned global positions
171  TString RelPosT() const { return fRelPos + Dot();} // aligned
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
191  TString fMisPos; // absolute positions with misalignment applied
192  TString fMisRelPos; // relative positions with misalignment applied (to abs. orig.?)
193  TString fMisPar; // misalignment parameters
194  TString fPos; // positions after alignment
195  TString fRelPos; // relative positions after alignment (to abs. orig.?)
196  TString fPar; // remaining misalign paramters after alignment (was: alignment parameters)
197  TString fMp; // specials for/from MillePede
198 
199  // special seetings
200  bool fUseSignedR; // if true, Rpos will have sign of y
201  bool fBowsParameters; //true: pede parameter names and titles to 'bows', false: rigid body
202 };
203 #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
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
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
TString Valid(UInt_t iParam) const
TString ZPos() const
TString HieraLev(const TString &tree, Int_t level) const
TString RelPosT() 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
TString Bracket(Int_t i) const
TString Min() const
TString SelIs2D() const
TString AnyFreePar() const
TString DelR(const TString &tree) const
TString PosT() const
TString BetaSi() const
TString DelRphi(const TString &tree) const
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 MisRelPosT() 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
unsigned int UInt_t
Definition: FUTypes.h:12
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
string s
Definition: asciidump.py:422
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