Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /Validation/DTRecHits/test/plotHitPull.r is written in an unsupported language. File is not indexed.

0001 
0002 /*
0003  * Format plots of Pulllutions, etc. produced by DTRecHits validation.
0004  * The root tree containing the histograms must be already open when 
0005  * executing this macro.
0006  * 
0007  * G. Cerminara 2004
0008  */
0009 #if !defined(__CINT__)||  defined(__MAKECINT__)
0010 #include "TROOT.h"
0011 #include "TStyle.h"
0012 #include "TString.h"
0013 
0014 #include "macros.C"
0015 #include <iostream>
0016 #endif
0017 
0018 using namespace std;
0019 
0020 
0021 // class hRHit;
0022 class HRes1DHit;
0023 class HRes2DHit;
0024 class HRes4DHit;
0025 
0026 void plotHitPull();
0027 void plotWWWHitPull(TString dirBase, int dimSwitch = 1, TString nameDir = TString(""));
0028 void drawPull(bool do1DRecHit, bool do2DRecHit, bool do2DSLPhiRecHit, bool do4DRecHit, bool ThreeIn1, int form);
0029 void plot1DPulls(HRes1DHit * h1, HRes1DHit * h2, HRes1DHit * h3, bool ThreeIn1);
0030 void plot1DPullsVsPos(TString name, HRes1DHit * h1, HRes1DHit * h2, HRes1DHit * h3, bool ThreeIn1) ;
0031 void plot2DPulls(HRes2DHit * h1);
0032 
0033 void plot4DPulls(HRes4DHit * h1);
0034 void plot4DPullVsEta(HRes4DHit * h1);
0035 void plot4DPullVsPhi(HRes4DHit * h1);
0036 
0037 void plot2DPullAngles(HRes2DHit * h1, bool ThreeIn1);
0038 void plot4DPullAngles(HRes4DHit * h1, bool ThreeIn1);
0039 
0040 // Read user input
0041 bool setPullPreferences(bool& do1DRecHit, bool& do2DRecHit, bool& do2DSLPhiRecHit, bool& do4DRecHit, bool& ThreeIn1);
0042 // 
0043 
0044 
0045 
0046 
0047 // This is the main function
0048 void plotHitPull(){
0049   // Load needed macros and files
0050   gROOT->LoadMacro("macros.C");     // Load service macros
0051   gROOT->LoadMacro("Histograms.h"); // Load definition of histograms
0052 
0053   // Get the style
0054   TStyle * style = getStyle("tdr");
0055   /// TStyle * style = getStyle();
0056 
0057   //Main switches
0058   bool do1DRecHit = false; 
0059   bool do2DRecHit = false; 
0060   bool do2DSLPhiRecHit = false; 
0061   bool do4DRecHit = false; 
0062   bool ThreeIn1 = true;  // Plot the 3 steps in a single canvas (where appl.)
0063 
0064   //--------------------------------------------------------------------------------------
0065   //-------------------- Set your preferences here ---------------------------------------
0066 
0067   // Read user input, namely what plots should be produced
0068 
0069   while(!setPullPreferences(do1DRecHit, do2DRecHit, do2DSLPhiRecHit, do4DRecHit, ThreeIn1));
0070   //   do1DRecHit = true; 
0071   //   do2DRecHit = true; 
0072   //   do4DRecHit = true; 
0073 
0074 
0075   int form = 2;          // Form factor of the canvases (where applicable)
0076   //       1. For rectangular shape
0077   //       2. For squared shape
0078 
0079 
0080   // Style options
0081   //  style->SetOptStat("OURMEN");
0082   // style->SetOptStat("RME");
0083   style->SetOptStat(0);
0084   style->SetFitFormat("4.2g");
0085   style->SetOptFit(11);
0086 
0087   //--------------------------------------------------------------------------------------
0088 
0089   // Check the choice
0090   if(!do1DRecHit && !do2DRecHit && !do2DSLPhiRecHit && !do4DRecHit) {
0091     cout << "[plotHitPull]***Error: Nothing to do! Set do1DRecHit, do2DRecHit, do4DRecHit correctly!"
0092       << endl;
0093     return;
0094   }
0095   style->cd();                      // Apply style 
0096 
0097   drawPull(do1DRecHit, do2DRecHit, do2DSLPhiRecHit, do4DRecHit, ThreeIn1, form);
0098 
0099 }
0100 
0101 void plotWWWHitPull(TString dirBase, int dimSwitch, TString nameDir) {
0102   // Load needed macros and files
0103   gROOT->LoadMacro("macros.C");     // Load service macros
0104   gROOT->LoadMacro("Histograms.h"); // Load definition of histograms
0105 
0106   // Get the style
0107   TStyle * style = getStyle();
0108 
0109   //Main switches
0110   bool do1DRecHit = false; 
0111   bool do2DRecHit = false; 
0112   bool do2DSLPhiRecHit = false; 
0113   bool do4DRecHit = false; 
0114 
0115   if(dimSwitch == 1) {
0116     do1DRecHit = true;
0117   } else if(dimSwitch == 2) {
0118     do2DRecHit = true;
0119   } else if(dimSwitch == 3) {
0120     do2DSLPhiRecHit = true;
0121   } else if(dimSwitch == 4) {
0122     do4DRecHit = true;
0123   } else {
0124     cout << "Not a valid option!" << endl;
0125     return;
0126   }
0127 
0128 
0129 
0130   bool ThreeIn1 = false;  // Plot the 3 steps in a single canvas (where appl.)
0131 
0132   int form = 2;          // Form factor of the canvases (where applicable)
0133   //       1. For rectangular shape
0134   //       2. For squared shape
0135 
0136 
0137   // Style options
0138   //  style->SetOptStat("OURMEN");
0139   style->SetOptStat("RME");
0140   style->SetOptFit(101);
0141 
0142   //--------------------------------------------------------------------------------------
0143 
0144   // Check the choice
0145   if(!do1DRecHit && !do2DRecHit && !do2DSLPhiRecHit && !do4DRecHit) {
0146     cout << "[plotHitPull]***Error: Nothing to do! Set do1DRecHit, do2DRecHit, do4DRecHit correctly!"
0147       << endl;
0148     return;
0149   }
0150   style->cd();                      // Apply style 
0151 
0152 
0153   drawPull(do1DRecHit, do2DRecHit, do2DSLPhiRecHit, do4DRecHit, ThreeIn1, form);
0154   TString nameS;
0155   if(nameDir == "") {
0156     cout << "Set the name of the www directory: " << endl;
0157     cin >> nameS;
0158   } else {
0159     nameS = nameDir;
0160   }
0161   TString pwd = gSystem->WorkingDirectory();
0162   gSystem->MakeDirectory(dirBase+nameS);
0163   gSystem->ChangeDirectory(dirBase+nameS);
0164 
0165 
0166   printCanvases(".gif");
0167   gSystem->ChangeDirectory(pwd.Data());
0168 
0169 }
0170 
0171 
0172 void drawPull(bool do1DRecHit, bool do2DRecHit, bool do2DSLPhiRecHit, bool do4DRecHit, bool ThreeIn1, int form) {
0173   // Retrieve histogram sets
0174   TFile *f = gROOT->GetListOfFiles()->Last();
0175   cout << "Loading file: " << f->GetName() << endl;
0176 
0177 
0178 
0179   HRes1DHit *h1RPhi = 0;
0180   HRes1DHit *h2RPhi = 0;
0181   HRes1DHit *h3RPhi = 0;
0182                       
0183   HRes1DHit *h1RZ   = 0;
0184   HRes1DHit *h2RZ   = 0;
0185   HRes1DHit *h3RZ   = 0;
0186                       
0187   HRes1DHit *h1RZ_W0= 0;
0188   HRes1DHit *h2RZ_W0= 0;
0189   HRes1DHit *h3RZ_W0= 0;
0190                       
0191   HRes1DHit *h1RZ_W1= 0;
0192   HRes1DHit *h2RZ_W1= 0;
0193   HRes1DHit *h3RZ_W1= 0;
0194                       
0195   HRes1DHit *h1RZ_W2= 0;
0196   HRes1DHit *h2RZ_W2= 0;
0197   HRes1DHit *h3RZ_W2= 0;
0198 
0199   HRes1DHit *h1Rphi_W0= 0;
0200   HRes1DHit *h2Rphi_W0= 0;
0201   HRes1DHit *h3Rphi_W0= 0;
0202                       
0203   HRes1DHit *h1Rphi_W1= 0;
0204   HRes1DHit *h2Rphi_W1= 0;
0205   HRes1DHit *h3Rphi_W1= 0;
0206                       
0207   HRes1DHit *h1Rphi_W2= 0;
0208   HRes1DHit *h2Rphi_W2= 0;
0209   HRes1DHit *h3Rphi_W2= 0;
0210 
0211   if(do1DRecHit) {
0212     h1RPhi = new HRes1DHit("S1RPhi",f);     // RecHits, 1. step, RPhi
0213     h2RPhi = new HRes1DHit("S2RPhi",f);     // RecHits, 2. step, RPhi
0214     h3RPhi = new HRes1DHit("S3RPhi",f);     // RecHits, 3. step, RPhi
0215 
0216     h1RZ    = new HRes1DHit("S1RZ",f);         // RecHits, 1. step, RZ
0217     h2RZ    = new HRes1DHit("S2RZ",f);      // RecHits, 2. step, RZ
0218     h3RZ    = new HRes1DHit("S3RZ",f);      // RecHits, 3. step, RZ
0219 
0220     h1RZ_W0 = new HRes1DHit("S1RZ_W0",f);   // RecHits, 1. step, RZ, wheel 0
0221     h2RZ_W0 = new HRes1DHit("S2RZ_W0",f);   // RecHits, 2. step, RZ, wheel 0
0222     h3RZ_W0 = new HRes1DHit("S3RZ_W0",f);   // RecHits, 3. step, RZ, wheel 0
0223 
0224     h1RZ_W1 = new HRes1DHit("S1RZ_W1",f);   // RecHits, 1. step, RZ, wheel +-1
0225     h2RZ_W1 = new HRes1DHit("S2RZ_W1",f);   // RecHits, 2. step, RZ, wheel +-1
0226     h3RZ_W1 = new HRes1DHit("S3RZ_W1",f);   // RecHits, 3. step, RZ, wheel +-1
0227 
0228     h1RZ_W2 = new HRes1DHit("S1RZ_W2",f);   // RecHits, 1. step, RZ, wheel +-2
0229     h2RZ_W2 = new HRes1DHit("S2RZ_W2",f);   // RecHits, 2. step, RZ, wheel +-2
0230     h3RZ_W2 = new HRes1DHit("S3RZ_W2",f);   // RecHits, 3. step, RZ, wheel +-2
0231 
0232     h1RPhi_W0 = new HRes1DHit("S1RPhi_W0",f);   // RecHits, 1. step, RPhi, wheel 0
0233     h2RPhi_W0 = new HRes1DHit("S2RPhi_W0",f);   // RecHits, 2. step, RPhi, wheel 0
0234     h3RPhi_W0 = new HRes1DHit("S3RPhi_W0",f);   // RecHits, 3. step, RPhi, wheel 0
0235 
0236     h1RPhi_W1 = new HRes1DHit("S1RPhi_W1",f);   // RecHits, 1. step, RPhi, wheel +-1
0237     h2RPhi_W1 = new HRes1DHit("S2RPhi_W1",f);   // RecHits, 2. step, RPhi, wheel +-1
0238     h3RPhi_W1 = new HRes1DHit("S3RPhi_W1",f);   // RecHits, 3. step, RPhi, wheel +-1
0239 
0240     h1RPhi_W2 = new HRes1DHit("S1RPhi_W2",f);   // RecHits, 1. step, RPhi, wheel +-2
0241     h2RPhi_W2 = new HRes1DHit("S2RPhi_W2",f);   // RecHits, 2. step, RPhi, wheel +-2
0242     h3RPhi_W2 = new HRes1DHit("S3RPhi_W2",f);   // RecHits, 3. step, RPhi, wheel +-2
0243 
0244   }
0245 
0246 
0247 
0248   HRes2DHit *h2DHitRPhi = 0;
0249   HRes2DHit *h2DHitRZ   = 0;
0250   HRes2DHit *h2DHitRZ_W0= 0;
0251   HRes2DHit *h2DHitRZ_W1= 0;
0252   HRes2DHit *h2DHitRZ_W2= 0;
0253   if(do2DRecHit) {
0254     h2DHitRPhi  = new HRes2DHit("RPhi",f);
0255     h2DHitRZ    = new HRes2DHit("RZ",f);
0256     h2DHitRZ_W0 = new HRes2DHit("RZ_W0",f);
0257     h2DHitRZ_W1 = new HRes2DHit("RZ_W1",f);
0258     h2DHitRZ_W2 = new HRes2DHit("RZ_W2",f);
0259   }
0260   
0261   HRes2DHit *h2DSLPhiHit = 0;
0262   if(do2DSLPhiRecHit) {
0263     h2DSLPhiHit = new HRes2DHit("SuperPhi",f);
0264   }
0265 
0266 
0267   HRes4DHit *h4DHit   = 0;
0268   HRes4DHit *h4DHit_W0= 0;
0269   HRes4DHit *h4DHit_W1= 0;
0270   HRes4DHit *h4DHit_W2= 0;
0271   if(do4DRecHit) {
0272     h4DHit    = new HRes4DHit("All", f);
0273     h4DHit_W0 = new HRes4DHit("W0", f);
0274     h4DHit_W1 = new HRes4DHit("W1", f);
0275     h4DHit_W2 = new HRes4DHit("W2", f);
0276   }
0277 
0278 
0279   TCanvas * c1;
0280   int i = 1;
0281 
0282 
0283   if(do1DRecHit) {
0284     // Residual, Rphi
0285     plot1DPulls(h1RPhi,h2RPhi,h3RPhi,ThreeIn1);
0286 
0287     // Residual, RZ 
0288     plot1DPulls(h1RZ,h2RZ,h3RZ,ThreeIn1);
0289 
0290     // Residual, RPhi, per wheel
0291     plot1DPulls(h1RPhi_W0,h2RPhi_W0,h3RPhi_W0,ThreeIn1);
0292     plot1DPulls(h1RPhi_W1,h2RPhi_W1,h3RPhi_W1,ThreeIn1);
0293     plot1DPulls(h1RPhi_W2,h2RPhi_W2,h3RPhi_W2,ThreeIn1);
0294     // Residual, RZ, per wheel
0295     plot1DPulls(h1RZ_W0,h2RZ_W0,h3RZ_W0,ThreeIn1);
0296     plot1DPulls(h1RZ_W1,h2RZ_W1,h3RZ_W1,ThreeIn1);
0297     plot1DPulls(h1RZ_W2,h2RZ_W2,h3RZ_W2,ThreeIn1);
0298   }
0299 
0300   if(do2DRecHit) {
0301     cout << "h2DHitRPhi " << h2DHitRPhi << endl;
0302     plot2DPulls(h2DHitRPhi);
0303     plot2DPulls(h2DHitRZ);
0304     // plot2DPulls(h2DHitRZ_W0);
0305     // plot2DPulls(h2DHitRZ_W1);
0306     // plot2DPulls(h2DHitRZ_W2);
0307   }
0308 
0309   if(do2DSLPhiRecHit) {
0310     plot2DPulls(h2DSLPhiHit);
0311   }
0312 
0313   if(do4DRecHit) {
0314     plot4DPulls(h4DHit);
0315     plot4DPullsRZ(h4DHit);
0316     // plot4DPulls(h4DHit_W0);
0317     // plot4DPulls(h4DHit_W1);
0318     // plot4DPulls(h4DHit_W2);
0319   }
0320 
0321   // Pullvseta:
0322 
0323   // if(do1DRecHit) {
0324   //   const float min = -0.6;
0325   //   const float max =  0.6;
0326   //   c1 = newCanvas("c_1D_S1RPhi_hPullVsEta",form);
0327   //   plotAndProfileXSpread(h1RPhi->hPullVsEta,min,max);
0328 
0329   //   c1 = newCanvas("c_1D_S2RPhi_hPullVsEta",form);
0330   //   plotAndProfileXSpread(h2RPhi->hPullVsEta,min,max);
0331 
0332   //   c1 = newCanvas("c_1D_S3RPhi_hPullVsEta",form);
0333   //   plotAndProfileXSpread(h3RPhi->hPullVsEta,min,max);
0334 
0335   //   c1 = newCanvas("c_1D_S1RZ_hPullVsEta",form);
0336   //   plotAndProfileXSpread(h1RZ->hPullVsEta,min,max);
0337 
0338   //   c1 = newCanvas("c_1D_S2RZ_hPullVsEta",form);
0339   //   plotAndProfileXSpread(h2RZ->hPullVsEta,min,max);
0340 
0341   //   c1 = newCanvas("c_1D_S3RZ_hPullVsEta",form);
0342   //   plotAndProfileXSpread(h3RZ->hPullVsEta,min,max);
0343   // }
0344 
0345   if(false && do2DRecHit) {
0346     c1 = newCanvas("c_2D_RPhi_hPullPosVsEta",form);
0347     plotAndProfileXSpread(h2DHitRPhi->hPullPosVsEta,-5,5);
0348 
0349     c1 = newCanvas("c_2D_RZ_hPullPosVsEta",form);
0350     plotAndProfileXSpread(h2DHitRZ->hPullPosVsEta,-5,5);
0351 
0352     c1 = newCanvas("c_2D_RZ_W0_hPullPosVsEta",form);
0353     plotAndProfileXSpread(h2DHitRZ_W0->hPullPosVsEta,-5,5);
0354 
0355     c1 = newCanvas("c_2D_RZ_W1_hPullPosVsEta",form);
0356     plotAndProfileXSpread(h2DHitRZ_W1->hPullPosVsEta,-5,5);
0357 
0358     c1 = newCanvas("c_2D_RZ_W2_hPullPosVsEta",form);
0359     plotAndProfileXSpread(h2DHitRZ_W2->hPullPosVsEta,-5,5);
0360 
0361     c1 = newCanvas("c_2D_RPhi_hPullAngleVsEta",form);
0362     plotAndProfileXSpread(h2DHitRPhi->hPullAngleVsEta,-5,5);
0363 
0364     c1 = newCanvas("c_2D_RZ_hPullAngleVsEta",form);
0365     plotAndProfileXSpread(h2DHitRZ->hPullAngleVsEta,-5,5);
0366 
0367     c1 = newCanvas("c_2D_RZ_W0_hPullAngleVsEta",form);
0368     plotAndProfileXSpread(h2DHitRZ_W0->hPullAngleVsEta,-5,5);
0369 
0370     c1 = newCanvas("c_2D_RZ_W1_hPullAngleVsEta",form);
0371     plotAndProfileXSpread(h2DHitRZ_W1->hPullAngleVsEta,-5,5);
0372 
0373     c1 = newCanvas("c_2D_RZ_W2_hPullAngleVsEta",form);
0374     plotAndProfileXSpread(h2DHitRZ_W2->hPullAngleVsEta,-5,5);
0375 
0376   }
0377 
0378   if(false && do2DSLPhiRecHit) {
0379     c1 = newCanvas("c_2D_SuperPhi_hPullPosVsEta",form);
0380     plotAndProfileXSpread(h2DSLPhiHit->hPullPosVsEta,-5,5);
0381 
0382     c1 = newCanvas("c_2D_SuperPhi_hPullAngleVsEta",form);
0383     plotAndProfileXSpread(h2DSLPhiHit->hPullAngleVsEta,-5,5);
0384   }
0385 
0386   if(do4DRecHit) {
0387     plot4DPullVsEta(h4DHit);
0388     plot4DPullVsEtaRZ(h4DHit);
0389     // plot4DPullVsEta(h4DHit_W0);
0390     // plot4DPullVsEta(h4DHit_W1);
0391     // plot4DPullVsEta(h4DHit_W2);
0392   }
0393 
0394   // Pullvsphi:
0395 
0396   // if(do1DRecHit) {
0397   //   const float min = -0.6;
0398   //   const float max =  0.6;
0399   //   c1 = newCanvas("c_1D_S1RPhi_hPullVsPhi",form);
0400   //   plotAndProfileXSpread(h1RPhi->hPullVsPhi,min, max);
0401 
0402   //   c1 = newCanvas("c_1D_S2RPhi_hPullVsPhi",form);
0403   //   plotAndProfileXSpread(h2RPhi->hPullVsPhi,min, max);
0404 
0405   //   c1 = newCanvas("c_1D_S3RPhi_hPullVsPhi",form);
0406   //   plotAndProfileXSpread(h3RPhi->hPullVsPhi,min, max);
0407 
0408   //   c1 = newCanvas("c_1D_S1RZ_hPullVsPhi",form);
0409   //   plotAndProfileXSpread(h1RZ->hPullVsPhi,min, max);
0410 
0411   //   c1 = newCanvas("c_1D_S2RZ_hPullVsPhi",form);
0412   //   plotAndProfileXSpread(h2RZ->hPullVsPhi,min, max);
0413 
0414   //   c1 = newCanvas("c_1D_S3RZ_hPullVsPhi",form);
0415   //   plotAndProfileXSpread(h3RZ->hPullVsPhi,min, max);
0416 
0417   // }
0418 
0419   if(false && do2DRecHit) {
0420     c1 = newCanvas("c_2D_RPhi_hPullPosVsPhi",form);
0421     plotAndProfileXSpread(h2DHitRPhi->hPullPosVsPhi,-5,5);
0422 
0423     c1 = newCanvas("c_2D_RZ_hPullPosVsPhi",form);
0424     plotAndProfileXSpread(h2DHitRZ->hPullPosVsPhi,-5,5);
0425 
0426     c1 = newCanvas("c_2D_RZ_W0_hPullPosVsPhi",form);
0427     plotAndProfileXSpread(h2DHitRZ_W0->hPullPosVsPhi,-5,5);
0428 
0429     c1 = newCanvas("c_2D_RZ_W1_hPullPosVsPhi",form);
0430     plotAndProfileXSpread(h2DHitRZ_W1->hPullPosVsPhi,-5,5);
0431 
0432     c1 = newCanvas("c_2D_RZ_W2_hPullPosVsPhi",form);
0433     plotAndProfileXSpread(h2DHitRZ_W2->hPullPosVsPhi,-5,5);
0434 
0435     c1 = newCanvas("c_2D_RPhi_hPullAngleVsPhi",form);
0436     plotAndProfileXSpread(h2DHitRPhi->hPullAngleVsPhi,-5,5);
0437 
0438     c1 = newCanvas("c_2D_RZ_hPullAngleVsPhi",form);
0439     plotAndProfileXSpread(h2DHitRZ->hPullAngleVsPhi,-5,5);
0440 
0441     c1 = newCanvas("c_2D_RZ_W0_hPullAngleVsPhi",form);
0442     plotAndProfileXSpread(h2DHitRZ_W0->hPullAngleVsPhi,-5,5);
0443 
0444     c1 = newCanvas("c_2D_RZ_W1_hPullAngleVsPhi",form);
0445     plotAndProfileXSpread(h2DHitRZ_W1->hPullAngleVsPhi,-5,5);
0446 
0447     c1 = newCanvas("c_2D_RZ_W2_hPullAngleVsPhi",form);
0448     plotAndProfileXSpread(h2DHitRZ_W2->hPullAngleVsPhi,-5,5);
0449 
0450   }
0451 
0452   if(false && do2DSLPhiRecHit) {
0453     c1 = newCanvas("c_2D_SuperPhi_hPullPosVsPhi",form);
0454     plotAndProfileXSpread(h2DSLPhiHit->hPullPosVsPhi,-5,5);
0455 
0456     c1 = newCanvas("c_2D_SuperPhi_hPullAngleVsPhi",form);
0457     plotAndProfileXSpread(h2DSLPhiHit->hPullAngleVsPhi,-5,5);
0458   }
0459 
0460   if(do4DRecHit) {
0461     plot4DPullVsPhi(h4DHit);
0462     plot4DPullVsPhiRZ(h4DHit);
0463     // plot4DPullVsPhi(h4DHit_W0);
0464     // plot4DPullVsPhi(h4DHit_W1);
0465     // plot4DPullVsPhi(h4DHit_W2);
0466   }
0467 
0468 
0469 
0470   // Pullvspos:
0471 
0472   if(do1DRecHit) {
0473     plot1DPullsVsPos("Rphi", h1RPhi, h2RPhi, h3RPhi, ThreeIn1) ;
0474     plot1DPullsVsPos("RZ", h1RZ, h2RZ, h3RZ, ThreeIn1) ;
0475 
0476     plot1DPullsVsPos("RPhi_W0", h1RPhi_W0, h2RPhi_W0, h3RPhi_W0, ThreeIn1) ;
0477     plot1DPullsVsPos("RPhi_W1", h1RPhi_W1, h2RPhi_W1, h3RPhi_W1, ThreeIn1) ;
0478     plot1DPullsVsPos("RPhi_W2", h1RPhi_W2, h2RPhi_W2, h3RPhi_W2, ThreeIn1) ;
0479 
0480     plot1DPullsVsPos("RZ_W0", h1RZ_W0, h2RZ_W0, h3RZ_W0, ThreeIn1) ;
0481     plot1DPullsVsPos("RZ_W1", h1RZ_W1, h2RZ_W1, h3RZ_W1, ThreeIn1) ;
0482     plot1DPullsVsPos("RZ_W2", h1RZ_W2, h2RZ_W2, h3RZ_W2, ThreeIn1) ;
0483   }
0484 
0485   // Pullvsangle:
0486 
0487   if(do1DRecHit) {
0488     plot1DPullsVsAngle("Rphi", h1RPhi, h2RPhi, h3RPhi, ThreeIn1) ;
0489     plot1DPullsVsAngle("RZ", h1RZ, h2RZ, h3RZ, ThreeIn1) ;
0490     plot1DPullsVsAngle("RPhi_W0", h1RPhi_W0, h2RPhi_W0, h3RPhi_W0, ThreeIn1) ;
0491     plot1DPullsVsAngle("RPhi_W1", h1RPhi_W1, h2RPhi_W1, h3RPhi_W1, ThreeIn1) ;
0492     plot1DPullsVsAngle("RPhi_W2", h1RPhi_W2, h2RPhi_W2, h3RPhi_W2, ThreeIn1) ;
0493 
0494     plot1DPullsVsAngle("RZ_W0", h1RZ_W0, h2RZ_W0, h3RZ_W0, ThreeIn1) ;
0495     plot1DPullsVsAngle("RZ_W1", h1RZ_W1, h2RZ_W1, h3RZ_W1, ThreeIn1) ;
0496     plot1DPullsVsAngle("RZ_W2", h1RZ_W2, h2RZ_W2, h3RZ_W2, ThreeIn1) ;
0497   }
0498 
0499 
0500   // if(do2DRecHit) {
0501   //   //cout << "h2DHitRPhi: " << (int)h2DHitRPhi << endl;
0502   //   plot2DPullAngles(h2DHitRPhi, ThreeIn1);
0503   //   plot2DPullAngles(h2DHitRZ, ThreeIn1);
0504   //   plot2DPullAngles(h2DHitRZ_W0, ThreeIn1);
0505   //   plot2DPullAngles(h2DHitRZ_W1, ThreeIn1);
0506   //   plot2DPullAngles(h2DHitRZ_W2, ThreeIn1);
0507   // }
0508 
0509   // if(do2DSLPhiRecHit) {
0510   //   plot2DPullAngles(h2DSLPhiHit, ThreeIn1);
0511   // }
0512 
0513    //if(do4DRecHit) {
0514    //  plot4DPullAngles(h4DHit, ThreeIn1);
0515    //  plot4DPullAngles(h4DHit_W0, ThreeIn1);
0516    //  plot4DPullAngles(h4DHit_W1, ThreeIn1);
0517    //  plot4DPullAngles(h4DHit_W2, ThreeIn1);
0518    //}
0519 
0520   return;
0521 
0522 }
0523 
0524 
0525 void plot1DPulls(HRes1DHit * h1, HRes1DHit * h2, HRes1DHit * h3, bool ThreeIn1) {
0526   int i = 2;
0527 
0528   if(ThreeIn1)
0529     cout << "ThreeIn1 = true!" << endl;
0530   else
0531     cout << "ThreeIn1 = false!" << endl;
0532 
0533   TString N1 = "c_1D_" + h1->name;
0534   TString N2 = "c_1D_" + h2->name;
0535   TString N3 = "c_1D_" + h3->name;
0536   int form = 2;
0537   if (ThreeIn1) c1 = newCanvas(N1.Remove(5,2)+"_hPull",3,1,800,400);
0538   else newCanvas(N1+"_hPull",form);
0539   cout << "h1->hPull " << h1->hPull << endl;
0540   drawGFit(h1->hPull, -5,5,-5,5);
0541 
0542   if (ThreeIn1) c1->cd(i++);
0543   else c1 = newCanvas(N2+"_hPull",form);
0544   //drawGFit(h2->hPull, -5,5,-5,5);
0545 
0546   if (ThreeIn1) c1->cd(i++);
0547   else c1 = newCanvas(N3+"_hPull",form);
0548   drawGFit(h3->hPull, -5,5,-5,5);
0549 
0550   newCanvas(N1+"_hPullSt1",form);
0551   drawGFit(h1->hPullSt[0], -5,5,-5,5);
0552 
0553   newCanvas(N1+"_hPullSt2",form);
0554   drawGFit(h1->hPullSt[1], -5,5,-5,5);
0555 
0556   newCanvas(N1+"_hPullSt3",form);
0557   drawGFit(h1->hPullSt[2], -5,5,-5,5);
0558 
0559   newCanvas(N1+"_hPullSt4",form);
0560   drawGFit(h1->hPullSt[3], -5,5,-5,5);
0561 
0562   newCanvas(N3+"_hPullSt1",form);
0563   drawGFit(h3->hPullSt[0], -5,5,-5,5);
0564 
0565   newCanvas(N3+"_hPullSt2",form);
0566   drawGFit(h3->hPullSt[1], -5,5,-5,5);
0567 
0568   newCanvas(N3+"_hPullSt3",form);
0569   drawGFit(h3->hPullSt[2], -5,5,-5,5);
0570 
0571   newCanvas(N3+"_hPullSt4",form);
0572   drawGFit(h3->hPullSt[3], -5,5,-5,5);
0573 }
0574 
0575 void plot1DPullsVsPos(TString name, HRes1DHit * h1, HRes1DHit * h2, HRes1DHit * h3, bool ThreeIn1) {
0576     bool profile = true;
0577     const float min = -5;
0578     const float max =  5;
0579     
0580     int i = 2;
0581     int form = 2;
0582 
0583     if (ThreeIn1) c1 = newCanvas("c_1D_S1"+name+"_hPullVsPos",3,1,800,400);
0584     else newCanvas("c_1D_S1"+name+"_hPullVsPos",form);
0585     plotAndProfileXSpread(h1->hPullVsPos, min, max, profile);
0586 
0587     if (ThreeIn1) c1->cd(i++);
0588     else c1 = newCanvas("c_1D_S2"+name+"_hPullVsPos",form);
0589     //plotAndProfileXSpread(h2->hPullVsPos, min, max, profile);
0590 
0591     if (ThreeIn1) c1->cd(i++);
0592     else c1 = newCanvas("c_1D_S3"+name+"_hPullVsPos",form);
0593     plotAndProfileXSpread(h3->hPullVsPos, min, max, profile);
0594 }
0595 
0596 void plot1DPullsVsAngle(TString name, HRes1DHit * h1, HRes1DHit * h2, HRes1DHit * h3, bool ThreeIn1) {
0597     bool profile = true;
0598     const float min = -5;
0599     const float max =  5;
0600     
0601     int i = 2;
0602     int form = 2;
0603 
0604     if (ThreeIn1) c1 = newCanvas("c_1D_S1"+name+"_hPullVsAngle",3,1,800,400);
0605     else newCanvas("c_1D_S1"+name+"_hPullVsAngle",form);
0606     plotAndProfileXSpread(h1->hPullVsAngle, min, max, profile);
0607 
0608     if (ThreeIn1) c1->cd(i++);
0609     else c1 = newCanvas("c_1D_S2"+name+"_hPullVsAngle",form);
0610     //plotAndProfileXSpread(h2->hPullVsAngle, min, max, profile);
0611 
0612     if (ThreeIn1) c1->cd(i++);
0613     else c1 = newCanvas("c_1D_S3"+name+"_hPullVsAngle",form);
0614     plotAndProfileXSpread(h3->hPullVsAngle, min, max, profile);
0615 }
0616 
0617 void plot2DPulls(HRes2DHit * h1) {
0618   int i = 2;
0619 
0620   TString N1 = "c_2D_" + h1->name;
0621 
0622   int form = 2;
0623   newCanvas(N1+"_hPullPos",form);
0624   drawGFit(h1->hPullPos, -5,5,-5,5);
0625 
0626   newCanvas(N1+"_hPullAngle",form);
0627   cout << "h1->hPullAngle " << h1->hPullAngle << endl;
0628   drawGFit(h1->hPullAngle, -5,5,-5,5);
0629 }
0630 
0631 void plot4DPulls(HRes4DHit * h1) {
0632   int i = 2;
0633 
0634   TString N1 = "c_4D_" + h1->name;
0635 
0636   int form = 2;
0637   newCanvas(N1+"_hPullX",form);
0638   drawGFit(h1->hPullX, -5,5,-2.5,2.5);
0639 
0640   newCanvas(N1+"_hPullY",form);
0641   drawGFit(h1->hPullY, -5,5,-2.5,2.5);
0642 
0643   newCanvas(N1+"_hPullAlpha",form);
0644   drawGFit(h1->hPullAlpha, -5,5,-2.5,2.5);
0645 
0646   newCanvas(N1+"_hPullBeta",form);
0647   drawGFit(h1->hPullBeta, -5,5,-2.5,2.5);
0648 
0649 }
0650 
0651 void plot4DPullVsEta(HRes4DHit * h1) {
0652   int i = 2;
0653 
0654   TString N1 = "c_4D_" + h1->name;
0655 
0656   int form = 2;
0657   newCanvas(N1+"_hPullXVsEta",form);
0658   plotAndProfileXSpread(h1->hPullXVsEta,-5,5);
0659 
0660   newCanvas(N1+"_hPullYVsEta",form);
0661   plotAndProfileXSpread(h1->hPullYVsEta,-5,5);
0662 
0663   newCanvas(N1+"_hPullAlphaVsEta",form);
0664   plotAndProfileXSpread(h1->hPullAlphaVsEta,-5,5);
0665 
0666   newCanvas(N1+"_hPullBetaVsEta",form);
0667   plotAndProfileXSpread(h1->hPullBetaVsEta,-5,5);
0668 }
0669 
0670 void plot4DPullVsPhi(HRes4DHit * h1) {
0671   int i = 2;
0672 
0673   TString N1 = "c_4D_" + h1->name;
0674 
0675   int form = 2;
0676   newCanvas(N1+"_hPullXVsPhi",form);
0677   plotAndProfileXSpread(h1->hPullXVsPhi,-5,5);
0678 
0679   newCanvas(N1+"_hPullYVsPhi",form);
0680   plotAndProfileXSpread(h1->hPullYVsPhi,-5,5);
0681 
0682   newCanvas(N1+"_hPullAlphaVsPhi",form);
0683   plotAndProfileXSpread(h1->hPullAlphaVsPhi,-5,5);
0684 
0685   newCanvas(N1+"_hPullBetaVsPhi",form);
0686   plotAndProfileXSpread(h1->hPullBetaVsPhi,-5,5);
0687 }
0688 
0689 void plot2DPullAngles(HRes2DHit * h1, bool ThreeIn1) {
0690   int i = 2;
0691 
0692   TString N1 = "c_2D_" + h1->name;
0693 
0694   int form = 2;
0695   if (ThreeIn1) c1 = newCanvas(N1+"_hAngle",3,1,800,400);
0696   else newCanvas(N1+"_hRecAngle",form);
0697   h1->hRecAngle->Draw();
0698 
0699   if (ThreeIn1) c1->cd(i++);
0700   else c1 = newCanvas(N1+"_hSimAngle",form);
0701   h1->hSimAngle->Draw();
0702 
0703   //cout << "h1->hRecVsSimAngle: " << (int)h1->hRecVsSimAngle << endl;
0704 
0705   if (ThreeIn1) c1->cd(i++);
0706   else c1 = newCanvas(N1+"_hRecVsSimAngle",form);
0707   plotAndProfileXSpread(h1->hRecVsSimAngle,-5,5);
0708 
0709 }
0710 
0711 void plot4DPullAngles(HRes4DHit * h1, bool ThreeIn1) {
0712   int i = 2;
0713 
0714   TString N1 = "c_4D_" + h1->name;
0715 
0716   int form = 2;
0717   if (ThreeIn1) c1 = newCanvas(N1+"_hAlpha",3,1,800,400);
0718   else newCanvas(N1+"_hRecAlpha",form);
0719   h1->hRecAlpha->Draw();
0720 
0721   if (ThreeIn1) c1->cd(i++);
0722   else c1 = newCanvas(N1+"_hSimAlpha",form);
0723   h1->hSimAlpha->Draw();
0724 
0725   if (ThreeIn1) c1->cd(i++);
0726   else c1 = newCanvas(N1+"_hRecVsSimAlpha",form);
0727   plotAndProfileXSpread(h1->hRecVsSimAlpha,-5,5);
0728 
0729   i=2;
0730 
0731   if (ThreeIn1) c2 = newCanvas(N1+"_hBeta",3,1,800,400);
0732   else newCanvas(N1+"_hRecBeta",form);
0733   h1->hRecBeta->Draw();
0734 
0735   if (ThreeIn1) c2->cd(i++);
0736   else c1 = newCanvas(N1+"_hSimBeta",form);
0737   h1->hSimBeta->Draw();
0738 
0739   if (ThreeIn1) c2->cd(i++);
0740   else c1 = newCanvas(N1+"_hRecVsSimBeta",form);
0741   plotAndProfileXSpread(h1->hRecVsSimBeta,-5,5);
0742 
0743 }
0744 
0745 void plot4DPullsRZ(HRes4DHit * h1) {
0746   int i = 2;
0747 
0748   TString N1 = "c_4D_" + h1->name;
0749 
0750   int form = 2;
0751   newCanvas(N1+"_hPullYRZ",form);
0752   drawGFit(h1->hPullYRZ, -5,5,-2.5,2.5);
0753 
0754   newCanvas(N1+"_hPullBetaRZ",form);
0755   drawGFit(h1->hPullBetaRZ, -5,5,-2.5,2.5);
0756 
0757 }
0758 
0759 void plot4DPullVsEtaRZ(HRes4DHit * h1) {
0760   int i = 2;
0761 
0762   TString N1 = "c_4D_" + h1->name;
0763 
0764   int form = 2;
0765   newCanvas(N1+"_hPullYVsEtaRZ",form);
0766   plotAndProfileXSpread(h1->hPullYVsEtaRZ,-5.,5., true,-2.5,2.5);
0767 
0768   newCanvas(N1+"_hPullBetaVsEtaRZ",form);
0769   plotAndProfileXSpread(h1->hPullBetaVsEtaRZ,-5.,5., true,-2.5,2.5);
0770 }
0771 
0772 void plot4DPullVsPhiRZ(HRes4DHit * h1) {
0773   int i = 2;
0774 
0775   TString N1 = "c_4D_" + h1->name;
0776 
0777   int form = 2;
0778   newCanvas(N1+"_hPullYVsPhiRZ",form);
0779   plotAndProfileXSpread(h1->hPullYVsPhiRZ,-5,5);
0780 
0781   newCanvas(N1+"_hPullBetaVsPhiRZ",form);
0782   plotAndProfileXSpread(h1->hPullBetaVsPhiRZ,-5,5);
0783 }
0784 
0785 
0786 bool setPullPreferences(bool& do1DRecHit,
0787     bool& do2DRecHit,
0788     bool& do2DSLPhiRecHit,
0789     bool& do4DRecHit,
0790     bool& ThreeIn1) {
0791 
0792 
0793 
0794   int dimension = 0;
0795 
0796   cout << "===================================================" << endl;
0797   cout << "==== plotHitPull User Menu =====================" << endl;
0798   cout << "Chose the plot you want to produce:" << endl;
0799   cout << "1 - 1D RecHit Plots" << endl;
0800   cout << "2 - 2D RecHit Plots" << endl;
0801   cout << "3 - 2D RecHit Plots (only SLPhi from 4D RecHit)" << endl;
0802   cout << "4 - 4D RecHit Plots" << endl;
0803   cout << "-->";
0804   cin >> dimension;
0805 
0806   switch(dimension) 
0807   {
0808     case 1:
0809       {
0810         do1DRecHit = true;
0811         break;
0812       }
0813     case 2:
0814       {
0815         do2DRecHit = true;
0816         break;
0817       }
0818     case 3:
0819       {
0820         do2DSLPhiRecHit = true;
0821         break;
0822       }
0823     case 4:
0824       {
0825         do4DRecHit = true;
0826         break;
0827       }
0828     default:
0829       {
0830         cout << "Error: option not Valid, try again!" << endl;
0831         return false;
0832         //setPullPreferences(do1DRecHit, do2DRecHit, do2DSLPhiRecHit, do4DRecHit, ThreeIn1);
0833         break;
0834       }
0835   }
0836 
0837   return true;
0838   int threeInOne = 0;
0839 
0840   cout << "" << endl;
0841   cout << "Do you want to Plot three histos in one?" << endl;
0842   cout << "0 - No" << endl;
0843   cout << "1 - Yes" << endl;
0844   cout << "-->";
0845 
0846   cin >> threeInOne;
0847 
0848   switch(threeInOne) 
0849   {
0850     case 0:
0851       {
0852         ThreeIn1 = false;
0853         break;
0854       }
0855     case 1:
0856       {
0857         ThreeIn1 = true;
0858         break;
0859       }
0860     default:
0861       {
0862         cout << "Not a valid option: default used!" << endl;    
0863         ThreeIn1 = true;
0864         break;
0865       }
0866   }
0867 
0868   return true;
0869 }
0870