CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/Alignment/MillePedeAlignmentAlgorithm/macros/PlotMillePede.h

Go to the documentation of this file.
00001 #ifndef PLOTMILLEPEDE_H
00002 #define PLOTMILLEPEDE_H
00003 // Original Author: Gero Flucke
00004 // last change    : $Date: 2010/10/26 21:34:25 $
00005 // by             : $Author: flucke $
00006 //
00007 // PlotMillePede is a class to interprete the content of the ROOT
00008 // TTrees that are stored as output of the millepede alignment algorithm.
00009 // The histograms are created by the methods inherited from the
00010 // MillePedeTrees class. Drawn quantities and selections are handled
00011 // as strings as they can be understood by TTree::Draw(..) commands.
00012 //
00013 // The main methods all start with 'Draw', so you can use tab completion
00014 // on what is available:
00015 //     PlotMillePede p("treeFile.root"); // file form pede step
00016 //     p.Draw<tab>
00017 //
00018 // Management of the created histograms is done using the ('ancient')
00019 // class GFHistManager. A pointer to that class can be accessed by
00020 //     GFHistManager *man = p.GetHistManager();
00021 // and then be used manipulate the drawings, e.g. by  
00022 //     man->SetLogY();
00023 // or
00024 //     man->SetNumHistsXY(3,1);
00025 //     man->Draw();
00026 //
00027 // By calling new p.Draw..(..) commands, usually previously drawn canvases are
00028 // deleted. But most methods provide either a boolean flag 'addPlots' or
00029 // understand the option 'add'. If the flag is true or the optione string
00030 // contains 'add', canvases from previous Draw-commands are kept (in fact they
00031 // are re-drawn).
00032 //
00033 // A title can be set by 'void SetTitle(const char *title)':
00034 // The title will appear as part of all histogram titles.
00035 //
00036 // Several cuts can be set and are active until reset for all drawing routines
00037 // called after setting them. Active selections are mentioned in histogram titles.
00038 // The possibilites to set cuts are:
00039 //
00040 // 1) Select subdetector(s):
00041 // void SetSubDetId(Int_t subDetId);
00042 //  *  1-6 are TPB, TPE, TIB, TID, TOB, TEC, 
00043 //  *  -1 means: reset, i.e. take all
00044 //  * using (repeated) calls of
00045 //    void AddSubDetId(Int_t subDetId);
00046 //    leads to an OR selection of subdetectors
00047 //
00048 // 2) Special alignable types:
00049 // Int_t SetAlignableTypeId(Int_t alignableTypeId);
00050 //  * DetUnit=1,
00051 //  * Det=2,
00052 //  * TIBString=15,
00053 //  * etc. from CommonAlignment/interface/StructureType.h 
00054 //  * -1 resets
00055 // The methods returns the previous setting.
00056 //
00057 // 3) Select hierarchy level:
00058 // In case of hierarchical alignment, one can look at the parameters etc. of each 
00059 // (active!) hierarchy level separately:
00060 // Int_t SetHieraLevel(Int_t hieraLevel);
00061 //  * 0 (default!): lowest level only
00062 //  * 1,2,...: first, second,... larger structures only
00063 //  * -1: resets, shows all levels
00064 // The methods returns the previous setting.
00065 //
00066 // 4) General selection:
00067 // void AddAdditionalSel(const char *selection);
00068 //  * whatever selection string that is valid on the TTree's...
00069 //  * ... therefore for experts 
00070 //  * current setting cleared by 'ClearAdditionalSel()'
00071 //
00072 // 4a) Strip stereo, rphi, 1Dlayer/double sided selection:
00073 //  * Known keywords for AddAdditionalSel(..)
00074 //     * StripStereo:     only Id's of stereo modules in 2D layers/rings 
00075 //     * StripRphi:       only Id's of rphi modules in 2D layers/rings 
00076 //     * StripDoubleOr1D: only Id's from 1D layers or composed Dets in 2D layers/rings
00077 //
00078 // 4b) Geometrical and N(hit) selection:
00079 // void AddAdditionalSel(const TString &xyzrPhiNhit, Float_t min, Float_t max);
00080 //  This method makes internal use of the above "AddAdditionalSel(const char *)".
00081 //  Selects quantity 'xyzrPhiNhit' between 'min' and 'max' where
00082 //  'xyzrPhiNhit' can be any of x, y, z, r, phi, Nhit.
00083 //  Also cleared by 'ClearAdditionalSel()'.
00084 
00085 #include "MillePedeTrees.h"
00086 #include <TArrayI.h>
00087 
00088 class GFHistManager;
00089 
00090 class PlotMillePede : public MillePedeTrees
00091 {
00092  public:
00093   explicit PlotMillePede(const char *fileName, Int_t iter = 2, Int_t hieraLevel = 0,
00094                          bool useDiff = false);// iter=1/2: singlerun/merged; heiraLev: -1 ignore, 0 lowest level, etc.; useDiff = true only for before2007_02_26
00095   PlotMillePede(const char *fileName, Int_t iter, Int_t hieraLevel, const char *treeNameAdd);
00096   virtual ~PlotMillePede();
00097 
00098   void SetTitle(const char *title) {fTitle = title;}
00099   const TString& GetTitle() const { return fTitle;}
00100   GFHistManager* GetHistManager() { return fHistManager;}
00101 
00102   void DrawAll(Option_t *opt = "rogpmeh"); // r=ParamResult,o=OrigParam,g=GlobCorr,p=Pull,m=MisVsLocation,e=ErrorVsHit,h=HitMaps
00103 
00104   void DrawParam(bool addPlots = false, const TString &sel = ""); // default: not fixed params
00105   void DrawPedeParam(Option_t *option = "", unsigned int nNonRigidParam = 12);//"add": add plots, "vs": p_i vs p_j; params beyond rigid body 
00106   void DrawPedeParamVsLocation(Option_t *option = "", unsigned int nNonRigidParam = 12);//"add" to add plots; params beyond rigid body 
00107   void DrawOrigParam(bool addPlots = false, const TString &sel = ""); //this->AnyFreePar()
00108   void DrawOrigPos(bool addPlots = false, const TString &sel = "");
00109 
00110 /*   void DrawParamDiff(bool addPlots = false); */
00111   void DrawParamResult(bool addPlots = false);
00112   void DrawPosResult(bool addPlots = false, const TString &selection = "");// sel=SelIs2D()/SelIs1D()
00113   void DrawPosMisVsLocation(bool addPlots=false, const TString &selection="", Option_t *option="");// sel=e.g. SelIs2D()/SelIs1D(), opt="start" starting misalignment profile
00114   void DrawGlobCorr(bool addPlots = false, const TString &sel = "", Option_t *opt = "",
00115                     Float_t min = 0., Float_t max = 1.);// opt "nal" (no axis limit), otherwise take min/max; opt 'valid' for pede rad OK
00116 
00117   void DrawPull(Option_t *opt = "");// 'add' to add plots, 'valid' to select only valid parameter, 'nolimit' for pulls without prior axis limits
00118 
00119   void DrawMisVsLocation(bool addPlots = false, const TString &sel = "", Option_t *opt = "");//opt: vse0,vse1,mis,withfixed
00120   void DrawLabelDiffAbove(UInt_t iPar, float minDiff, bool addPlots = false);
00121   void DrawErrorVsHit(bool addPlots = false, const TString &sel = "");
00122   void DrawHitMaps(bool addPlots = false, bool inclFullFixed = true);
00123   void DrawBigPullLabel(float minPull, bool addPlots = false);
00124   void DrawBigPullPos(float minPull, bool addPlots = false);
00125   void DrawSubDetId(bool addPlots = false);
00126   void DrawXyArrow(Double_t factor, Option_t *option = ""); // opt. "add", "zcirc"
00127   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
00128   void ScanPedeParAbove(UInt_t iPar, float absMin = 1.e5); // scan tree, selecting large parameters
00129 
00130   void DrawCheck();
00131   TString Unique(const char *name) const;
00132 
00133   Float_t SetMaxDev(Float_t maxDev); // set x-axis range for result plots
00134   const TArrayI* GetSubDetIds() const { return &fSubDetIds;} // selected subdets
00135   void SetSubDetId(Int_t subDetId); // 1-6 are TPB, TPE, TIB, TID, TOB, TEC, -1 means: take all
00136   void AddSubDetId(Int_t subDetId); // 1-6 are TPB, TPE, TIB, TID, TOB, TEC
00137   Int_t SetAlignableTypeId(Int_t alignableTypeId);//detunit=1,det=2,...,TIBString=15,etc. from StructureType.h (-1: all)
00138   Int_t SetHieraLevel(Int_t hieraLevel); // select hierarchical level (-1: all)
00139   void AddAdditionalSel(const char *selection);// special select; StripDoubleOr1D,StripRphi,StripStereo
00140   void AddAdditionalSel(const TString &xyzrPhiNhit, Float_t min, Float_t max); // x,y,z,r,phi,Nhit
00141 
00142   const TString GetAdditionalSel () const { return fAdditionalSel;}
00143   void ClearAdditionalSel () { fAdditionalSel = ""; fAdditionalSelTitle = "";}
00144   void AddBasicSelection(TString &sel) const;
00145 
00146   TString FinalMisAlignment(UInt_t iPar) const;
00147   TString TitleAdd() const; // for subdet settings etc.
00148 
00149   void CopyAddBinning(TString &name, const TH1 *hist) const;// extend 'name' taking binning from hist
00150  private: 
00151   Int_t PrepareAdd(bool addPlots);
00152 
00153   TString        fTitle; // added to hist titles
00154   GFHistManager *fHistManager;
00155   Int_t          fHieraLevel; // which hierarchical level to require (-1: all)
00156   bool           fUseDiff; // true: result is diff between MisParT() and ParT()
00157                            // false: result is ParT() (from 2007-02-27th on...)
00158   TArrayI       fSubDetIds; // select subdets (empty: take all)
00159   Int_t          fAlignableTypeId; // select ony alignables of type det,detunit,rod,etc.(-1: take all)
00160   TString       fAdditionalSel; // selection to be set by user, used in AddBasicSelection
00161   TString       fAdditionalSelTitle; // title add-on for fAdditionalSel
00162   Float_t        fMaxDev;   // max deviation in result plot - so far only there...
00163 };
00164 
00165 #endif