CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Alignment/OfflineValidation/scripts/comparisonPlots.cc

Go to the documentation of this file.
00001 #include "comparisonPlots.h"
00002 #include <string>
00003 #include <sstream>
00004 
00005 #include "TProfile.h"
00006 #include "TList.h"
00007 #include "TNtuple.h"
00008 #include "TString.h"
00009 #include <iostream>
00010 #include "TStyle.h"
00011 #include "TGraph.h"
00012 #include "TMultiGraph.h"
00013 #include "THStack.h"
00014 
00015 
00016 comparisonPlots::comparisonPlots(std::string filename, std::string outputDir, std::string outputFilename)
00017 {
00018         
00019         _outputDir = outputDir;
00020         
00021         fin = new TFile(filename.c_str());
00022         fin->cd();
00023         
00024         output = new TFile((outputDir+outputFilename).c_str(),"recreate");
00025         output->cd();
00026         
00027         readTree();
00028         
00029 }
00030 
00031 void comparisonPlots::readTree(){
00032         
00033         data = (TTree*)fin->Get("alignTree");
00034         data->SetBranchAddress("id",&id_);
00035         data->SetBranchAddress("mid",&mid_);
00036         data->SetBranchAddress("level",&level_);
00037         data->SetBranchAddress("mlevel",&mlevel_);
00038         data->SetBranchAddress("sublevel",&sublevel_);
00039         data->SetBranchAddress("x",&x_);
00040         data->SetBranchAddress("y",&y_);
00041         data->SetBranchAddress("z",&z_);
00042         data->SetBranchAddress("alpha",&alpha_);
00043         data->SetBranchAddress("beta",&beta_);
00044         data->SetBranchAddress("gamma",&gamma_);
00045         data->SetBranchAddress("phi",&phi_);
00046         data->SetBranchAddress("eta",&eta_);
00047         data->SetBranchAddress("r",&r_);
00048         data->SetBranchAddress("dx",&dx_);
00049         data->SetBranchAddress("dy",&dy_);
00050         data->SetBranchAddress("dz",&dz_);
00051         data->SetBranchAddress("dphi",&dphi_);
00052         data->SetBranchAddress("dr",&dr_);      
00053         data->SetBranchAddress("dalpha",&dalpha_);
00054         data->SetBranchAddress("dbeta",&dbeta_);
00055         data->SetBranchAddress("dgamma",&dgamma_);
00056         data->SetBranchAddress("useDetId",&useDetId_);
00057         data->SetBranchAddress("detDim",&detDim_);
00058 }
00059 
00060 void comparisonPlots::plot3x5(TCut Cut, char* dirName, bool savePlot, std::string plotName, bool autolimits, int ColorCode ){
00061         
00062   //int ColorCodeHalfBarrels = 1; //color seperation of moodules corresponding to the different subdets
00063   //if you want to seperate corresponding to the halfbarrels (+z or -z) set colorcode !=1
00064    gStyle->SetTitleAlign(22);
00065   gStyle->SetTitleX(0.5);
00066   gStyle->SetTitleY(0.97);
00067   //gStyle->SetShadowColor(0);
00068    //gStyle->SetTitleSize(.5);
00069   gStyle->SetTitleFont(62);
00070   
00071   // ---------  create directory for histograms ---------
00072   //const char* dirName = Cut;
00073         TDirectory* plotDir = output->mkdir( dirName );
00074         
00075         // ---------  get right limits for histogram ---------
00076         double minimumR, maximumR;
00077         double minimumZ, maximumZ;
00078         double minimumPhi, maximumPhi;
00079         double minimumDR, maximumDR;
00080         double minimumDZ, maximumDZ;
00081         double minimumRDPhi, maximumRDPhi;
00082         double minimumDX, maximumDX;
00083         double minimumDY, maximumDY;
00084         if (autolimits){
00085                 // ---------  get right limits for histogram ---------
00086                 TH1F* phr = new TH1F("phr", "phr", 200, 0, 200);
00087                 TH1F* phz = new TH1F("phz", "phz", 400, -300, 300);
00088                 TH1F* phphi = new TH1F("phphi", "phphi", 200, -3.15, 3.15);
00089                 TH1F* phdr = new TH1F("phdr", "phdr", 2000, -10, 10);
00090                 TH1F* phdz = new TH1F("phdz", "phdz", 2000, -10, 10);
00091                 TH1F* phrdphi = new TH1F("phrdphi", "phrdphi", 200, -10, 10);
00092                 TH1F* phdx = new TH1F("phdx", "phy", 2000, -10, 10);
00093                 TH1F* phdy = new TH1F("phdy", "phy", 2000, -10, 10);
00094                 data->Project("phr","r",Cut);
00095                 data->Project("phz","z",Cut);
00096                 data->Project("phphi","phi",Cut);
00097                 data->Project("phdr","dr",Cut);
00098                 data->Project("phdz","dz",Cut);
00099                 data->Project("phrdphi","r*dphi",Cut);
00100                 data->Project("phdx","dx",Cut);
00101                 data->Project("phdy","dy",Cut);
00102                 getHistMaxMin(phr, maximumR, minimumR, 0);
00103                 getHistMaxMin(phz, maximumZ, minimumZ, 0);
00104                 getHistMaxMin(phphi, maximumPhi, minimumPhi, 0);
00105                 getHistMaxMin(phdr, maximumDR, minimumDR, 1);
00106                 getHistMaxMin(phdz, maximumDZ, minimumDZ, 1);
00107                 getHistMaxMin(phrdphi, maximumRDPhi, minimumRDPhi, 1);
00108                 getHistMaxMin(phdx, maximumDX, minimumDX, 1);
00109                 getHistMaxMin(phdy, maximumDY, minimumDY, 1);
00110         }
00111         else{
00112                 minimumR = 0., maximumR = 200.; 
00113                 minimumZ = -300., maximumZ = 300.; 
00114                 minimumPhi = -3.15, maximumPhi = 3.15;
00115                 minimumDR = -1, maximumDR = 1;
00116                 minimumDZ = -1, maximumDZ = 1;
00117                 minimumRDPhi = -1, maximumRDPhi = 1;
00118                 minimumDX = -1, maximumDX = 1;
00119                 minimumDY = -1, maximumDY = 1;
00120         }
00121         
00122         
00123         // ---------  declare histograms ---------
00124         TH1F* h_dr = new TH1F("h_dr", "#Delta r", 2000, minimumDR, maximumDR);
00125         TH1F* h_dz = new TH1F("h_dz", "#Delta z", 2000, minimumDZ, maximumDZ);
00126         TH1F* h_rdphi = new TH1F("h_rdphi", "r* #Delta #phi", 2000, minimumRDPhi, maximumRDPhi);
00127         TH2F* h_drVr = new TH2F("h_drVr","#Delta r vs. r",200,minimumR,maximumR,200,minimumDR,maximumDR);
00128         TH2F* h_dzVr = new TH2F("h_dzVr","#Delta z vs. r",200,minimumR,maximumR,200,minimumDZ,maximumDZ);
00129         TH2F* h_rdphiVr = new TH2F("h_rdphiVr","r#Delta #phi vs. r",200,minimumR,maximumR,200,minimumRDPhi,maximumRDPhi);
00130         TH2F* h_dxVr = new TH2F("h_dxVr","#Delta x vs. r", 200,minimumR,maximumR, 200,minimumDX,maximumDX);
00131         TH2F* h_dyVr = new TH2F("h_dyVr","#Delta y vs. r", 200,minimumR,maximumR, 200,minimumDY,maximumDY);
00132         TH2F* h_drVz = new TH2F("h_drVz","#Delta r vs. z", 200,minimumZ,maximumZ, 200,minimumDR,maximumDR);
00133         TH2F* h_dzVz = new TH2F("h_dzVz","#Delta z vs. z", 200,minimumZ,maximumZ, 200,minimumDZ,maximumDZ);
00134         TH2F* h_rdphiVz = new TH2F("h_rdphiVz","r#Delta #phi vs. z", 200,minimumZ,maximumZ, 200,minimumRDPhi,maximumRDPhi);
00135         TH2F* h_dxVz = new TH2F("h_dxVz","#Delta x vs. z", 200,minimumZ,maximumZ, 200,minimumDX,maximumDX);
00136         TH2F* h_dyVz = new TH2F("h_dyVz","#Delta y vs. z", 200,minimumZ,maximumZ, 200,minimumDY,maximumDY);
00137         TH2F* h_drVphi = new TH2F("h_drVphi","#Delta r vs. #phi", 200,minimumPhi,maximumPhi,200,minimumDR,maximumDR);
00138         TH2F* h_dzVphi = new TH2F("h_dzVphi","#Delta z vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDZ,maximumDZ);
00139         TH2F* h_rdphiVphi = new TH2F("h_rdphiVphi","r#Delta #phi vs. #phi", 200,minimumPhi,maximumPhi,200,minimumRDPhi,maximumRDPhi);
00140         TH2F* h_dxVphi = new TH2F("h_dxVphi","#Delta x vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDX,maximumDX);
00141         TH2F* h_dyVphi = new TH2F("h_dyVphi","#Delta y vs. #phi", 200,minimumPhi,maximumPhi, 200,minimumDY,maximumDY);
00142         
00143         h_drVr->SetMarkerStyle(6);
00144         h_dzVr->SetMarkerStyle(6);
00145         h_rdphiVr->SetMarkerStyle(6);
00146         h_dxVr->SetMarkerStyle(6);
00147         h_dyVr->SetMarkerStyle(6);
00148         h_drVz->SetMarkerStyle(6);
00149         h_dzVz->SetMarkerStyle(6);
00150         h_rdphiVz->SetMarkerStyle(6);
00151         h_dxVz->SetMarkerStyle(6);
00152         h_dyVz->SetMarkerStyle(6);
00153         h_drVphi->SetMarkerStyle(6);
00154         h_dzVphi->SetMarkerStyle(6);
00155         h_rdphiVphi->SetMarkerStyle(6);
00156         h_dxVphi->SetMarkerStyle(6);
00157         h_dyVphi->SetMarkerStyle(6);
00158         
00159         
00160         int j = 2;
00161         TCut zCut[6];
00162         zCut[0] = "z < 0";
00163         zCut[1] = "z >= 0";
00164 
00165 
00166         if (ColorCode == 1) {
00167           j = 6;
00168           zCut[6];
00169           zCut[0] = "sublevel==1";
00170           zCut[1] = "sublevel==2";
00171           zCut[2] = "sublevel==3";
00172           zCut[3] = "sublevel==4";
00173           zCut[4] = "sublevel==5";
00174           zCut[5] = "sublevel==6";
00175         } 
00176          
00177         // ---------  project tree onto histograms ---------
00178         data->Project("h_dr","dr",Cut);
00179         data->Project("h_dz","dz",Cut);
00180         data->Project("h_rdphi","r*dphi",Cut);
00181         
00182 
00183         data->Project("h_drVr", "dr:r",Cut);
00184         TGraph* gr_drVr_Array[j];
00185         TMultiGraph* mgr_drVr=new TMultiGraph();
00186         for ( int i = 0; i < j; i++) {
00187                 data->Draw("dr:r",Cut+zCut[i]);   
00188                 gr_drVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00189                 gr_drVr_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00190                 gr_drVr_Array[i]->SetMarkerStyle(6);      
00191                 mgr_drVr->Add(gr_drVr_Array[i],"p");
00192         }       
00193         
00194         data->Project("h_dzVr", "dz:r",Cut);
00195         TGraph* gr_dzVr_Array[j];
00196         TMultiGraph* mgr_dzVr=new TMultiGraph();
00197         for ( int i = 0; i < j; i++) {
00198                 data->Draw("dz:r",Cut+zCut[i]);   
00199                 gr_dzVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00200                 gr_dzVr_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00201                 gr_dzVr_Array[i]->SetMarkerStyle(6);      
00202                 mgr_dzVr->Add(gr_dzVr_Array[i],"p");
00203         }
00204         
00205         data->Project("h_rdphiVr", "r*dphi:r",Cut);
00206         TGraph* gr_rdphiVr_Array[j];
00207         TMultiGraph* mgr_rdphiVr=new TMultiGraph();
00208         for ( int i = 0; i < j; i++) {
00209                 data->Draw("r*dphi:r",Cut+zCut[i]);       
00210                 gr_rdphiVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00211                 gr_rdphiVr_Array[i]->SetMarkerColor(int(i/4)+i+1);        
00212                 gr_rdphiVr_Array[i]->SetMarkerStyle(6);   
00213                 mgr_rdphiVr->Add(gr_rdphiVr_Array[i],"p");
00214         }
00215         
00216         data->Project("h_dxVr", "dx:r",Cut);
00217         TGraph* gr_dxVr_Array[j];
00218         TMultiGraph* mgr_dxVr=new TMultiGraph();
00219         for ( int i = 0; i < j; i++) {
00220                 data->Draw("dx:r",Cut+zCut[i]);   
00221                 gr_dxVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00222                 gr_dxVr_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00223                 gr_dxVr_Array[i]->SetMarkerStyle(6);      
00224                 mgr_dxVr->Add(gr_dxVr_Array[i],"p");
00225         }
00226         
00227         data->Project("h_dyVr", "dy:r",Cut);
00228         TGraph* gr_dyVr_Array[j];
00229         TMultiGraph* mgr_dyVr=new TMultiGraph();
00230         for ( int i = 0; i < j; i++) {
00231                 data->Draw("dy:r",Cut+zCut[i]);   
00232                 gr_dyVr_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00233                 gr_dyVr_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00234                 gr_dyVr_Array[i]->SetMarkerStyle(6);      
00235                 mgr_dyVr->Add(gr_dyVr_Array[i],"p");
00236         }
00237         
00238         data->Project("h_drVz", "dr:z",Cut);
00239         TGraph* gr_drVz_Array[j];
00240         TMultiGraph* mgr_drVz=new TMultiGraph();
00241         for ( int i = 0; i < j; i++) {
00242                 data->Draw("dr:z",Cut+zCut[i]);   
00243                 gr_drVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00244                 gr_drVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00245                 gr_drVz_Array[i]->SetMarkerStyle(6);      
00246                 mgr_drVz->Add(gr_drVz_Array[i],"p");
00247         }
00248         
00249         data->Project("h_dzVz", "dz:z",Cut);
00250         TGraph* gr_dzVz_Array[j];
00251         TMultiGraph* mgr_dzVz=new TMultiGraph();
00252         for ( int i = 0; i < j; i++) {
00253                 data->Draw("dz:z",Cut+zCut[i]);   
00254                 gr_dzVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00255                 gr_dzVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00256                 gr_dzVz_Array[i]->SetMarkerStyle(6);      
00257                 mgr_dzVz->Add(gr_dzVz_Array[i],"p");
00258         }
00259         
00260         data->Project("h_rdphiVz", "r*dphi:z",Cut);
00261         TGraph* gr_rdphiVz_Array[j];
00262         TMultiGraph* mgr_rdphiVz=new TMultiGraph();
00263         for ( int i = 0; i < j; i++) {
00264                 data->Draw("r*dphi:z",Cut+zCut[i]);       
00265                 gr_rdphiVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00266                 gr_rdphiVz_Array[i]->SetMarkerColor(int(i/4)+i+1);        
00267                 gr_rdphiVz_Array[i]->SetMarkerStyle(6);   
00268                 mgr_rdphiVz->Add(gr_rdphiVz_Array[i],"p");
00269         }
00270         
00271         data->Project("h_dxVz", "dx:z",Cut);
00272         TGraph* gr_dxVz_Array[j];
00273         TMultiGraph* mgr_dxVz=new TMultiGraph();
00274         for ( int i = 0; i < j; i++) {
00275                 data->Draw("dx:z",Cut+zCut[i]);   
00276                 gr_dxVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00277                 gr_dxVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00278                 gr_dxVz_Array[i]->SetMarkerStyle(6);      
00279                 mgr_dxVz->Add(gr_dxVz_Array[i],"p");
00280         }
00281         
00282         data->Project("h_dyVz", "dy:z",Cut);
00283         TGraph* gr_dyVz_Array[j];
00284         TMultiGraph* mgr_dyVz=new TMultiGraph();
00285         for ( int i = 0; i < j; i++) {
00286                 data->Draw("dy:z",Cut+zCut[i]);   
00287                 gr_dyVz_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00288                 gr_dyVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00289                 gr_dyVz_Array[i]->SetMarkerStyle(6);      
00290                 mgr_dyVz->Add(gr_dyVz_Array[i],"p");
00291         }
00292         
00293         data->Project("h_drVphi", "dr:phi",Cut);
00294         TGraph* gr_drVphi_Array[j];
00295         TMultiGraph* mgr_drVphi=new TMultiGraph();
00296         for ( int i = 0; i < j; i++) {
00297                 data->Draw("dr:phi",Cut+zCut[i]);         
00298                 gr_drVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00299                 gr_drVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00300                 gr_drVphi_Array[i]->SetMarkerStyle(6);    
00301                 mgr_drVphi->Add(gr_drVphi_Array[i],"p");
00302         }
00303         
00304         data->Project("h_dzVphi", "dz:phi",Cut);
00305         TGraph* gr_dzVphi_Array[j];
00306         TMultiGraph* mgr_dzVphi=new TMultiGraph();
00307         for ( int i = 0; i < j; i++) {
00308                 data->Draw("dz:phi",Cut+zCut[i]);         
00309                 gr_dzVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00310                 gr_dzVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00311                 gr_dzVphi_Array[i]->SetMarkerStyle(6);    
00312                 mgr_dzVphi->Add(gr_dzVphi_Array[i],"p");
00313         }
00314         
00315         data->Project("h_rdphiVphi", "r*dphi:phi",Cut);
00316         TGraph* gr_rdphiVphi_Array[j];
00317         TMultiGraph* mgr_rdphiVphi=new TMultiGraph();
00318         for ( int i = 0; i < j; i++) {
00319                 data->Draw("r*dphi:phi",Cut+zCut[i]);     
00320                 gr_rdphiVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00321                 gr_rdphiVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);      
00322                 gr_rdphiVphi_Array[i]->SetMarkerStyle(6);         
00323                 mgr_rdphiVphi->Add(gr_rdphiVphi_Array[i],"p");
00324         }
00325         
00326         data->Project("h_dxVphi", "dx:phi",Cut);
00327         TGraph* gr_dxVphi_Array[j];
00328         TMultiGraph* mgr_dxVphi=new TMultiGraph();
00329         for ( int i = 0; i < j; i++) {
00330                 data->Draw("dx:phi",Cut+zCut[i]);         
00331                 gr_dxVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00332                 gr_dxVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00333                 gr_dxVphi_Array[i]->SetMarkerStyle(6);    
00334                 mgr_dxVphi->Add(gr_dxVphi_Array[i],"p");
00335         }
00336         
00337         data->Project("h_dyVphi", "dy:phi",Cut);
00338         TGraph* gr_dyVphi_Array[j];
00339         TMultiGraph* mgr_dyVphi=new TMultiGraph();
00340         for ( int i = 0; i < j; i++) {
00341                 data->Draw("dy:phi",Cut+zCut[i]);         
00342                 gr_dyVphi_Array[i] = new TGraph(data->GetSelectedRows(),data->GetV2(),data->GetV1());
00343                 gr_dyVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00344                 gr_dyVphi_Array[i]->SetMarkerStyle(6);    
00345                 mgr_dyVphi->Add(gr_dyVphi_Array[i],"p");
00346         }
00347         
00348         
00349         
00350         // ---------  draw histograms ---------
00351         TCanvas* c0 = new TCanvas("c0", "c0", 200, 10, 900, 300);
00352         c0->SetFillColor(0);
00353         c0->Divide(3,1);
00354         c0->cd(1);
00355         h_dr->Draw();
00356         c0->cd(2);
00357         h_dz->Draw();
00358         c0->cd(3);
00359         h_rdphi->Draw();
00360         if (savePlot) c0->Print((_outputDir+"plot3x1_"+plotName).c_str());
00361         
00362         mgr_drVr->SetTitle("#Delta r vs. r");
00363         //TStyle::SetTitleAlign(23)
00364         mgr_dzVr->SetTitle("#Delta z vs. r");           
00365         mgr_rdphiVr->SetTitle("r#Delta #phi vs. r");    
00366         mgr_dxVr->SetTitle("#Delta x vs. r");           
00367         mgr_dyVr->SetTitle("#Delta y vs. r");           
00368         mgr_drVz->SetTitle("#Delta r vs. z");           
00369         mgr_dzVz->SetTitle("#Delta z vs. z");           
00370         mgr_rdphiVz->SetTitle("r#Delta #phi vs. z");    
00371         mgr_dxVz->SetTitle("#Delta x vs. z");           
00372         mgr_dyVz->SetTitle("#Delta y vs. z");           
00373         mgr_drVphi->SetTitle("#Delta r vs. #phi");      
00374         mgr_dzVphi->SetTitle("#Delta z vs. #phi");      
00375         mgr_rdphiVphi->SetTitle("r#Delta #phi vs. #phi");
00376         mgr_dxVphi->SetTitle("#Delta x vs. #phi");      
00377         mgr_dyVphi->SetTitle("#Delta y vs. #phi");   
00378         
00379         // ---------  draw histograms ---------
00380         TCanvas* c = new TCanvas("c", "c", 200, 10, 1200, 700);
00381         c->SetFillColor(0);
00382         data->SetMarkerSize(0.5);
00383         data->SetMarkerStyle(6);
00384         c->Divide(5,3);
00385         c->cd(1);
00386         if (!autolimits) h_drVr->Draw();
00387         if (autolimits) mgr_drVr->Draw("a");
00388         c->Update();
00389         c->cd(2);
00390         if (!autolimits) h_dzVr->Draw();
00391         if (autolimits) mgr_dzVr->Draw("a");
00392         c->Update();
00393         c->cd(3);
00394         if (!autolimits) h_rdphiVr->Draw();
00395         if (autolimits) mgr_rdphiVr->Draw("a");
00396         c->cd(4);
00397         if (!autolimits) h_dxVr->Draw();
00398         if (autolimits) mgr_dxVr->Draw("a");
00399         c->cd(5);
00400         if (!autolimits) h_dyVr->Draw();
00401         if (autolimits) mgr_dyVr->Draw("a");
00402         c->cd(6);
00403         if (!autolimits) h_drVz->Draw();
00404         if (autolimits) mgr_drVz->Draw("a");
00405         c->cd(7);
00406         if (!autolimits) h_dzVz->Draw();
00407         if (autolimits) mgr_dzVz->Draw("a");
00408         c->cd(8);
00409         if (!autolimits) h_rdphiVz->Draw();
00410         if (autolimits) mgr_rdphiVz->Draw("a");
00411         c->cd(9);
00412         if (!autolimits) h_dxVz->Draw();
00413         if (autolimits) mgr_dxVz->Draw("a");
00414         c->cd(10);
00415         if (!autolimits) h_dyVz->Draw();
00416         if (autolimits) mgr_dyVz->Draw("a");
00417         c->cd(11);
00418         if (!autolimits) h_drVphi->Draw();
00419         if (autolimits) mgr_drVphi->Draw("a");
00420         c->cd(12);
00421         if (!autolimits) h_dzVphi->Draw();
00422         if (autolimits) mgr_dzVphi->Draw("a");
00423         c->cd(13);
00424         if (!autolimits) h_rdphiVphi->Draw();
00425         if (autolimits) mgr_rdphiVphi->Draw("a");
00426         c->cd(14);
00427         if (!autolimits) h_dxVphi->Draw();
00428         if (autolimits) mgr_dxVphi->Draw("a");
00429         c->cd(15);
00430         if (!autolimits) h_dyVphi->Draw();
00431         if (autolimits) mgr_dyVphi->Draw("a");
00432         
00433         c->Update();
00434         
00435         // ---------  set output directory for histograms ---------
00436         plotDir->cd();
00437         h_dr->Write(); h_dz->Write(); h_rdphi->Write();
00438         h_drVr->Write(); h_dzVr->Write(); h_rdphiVr->Write(); h_dxVr->Write(); h_dyVr->Write();
00439         h_drVz->Write(); h_dzVz->Write(); h_rdphiVz->Write(); h_dxVz->Write(); h_dyVz->Write();
00440         h_drVphi->Write(); h_dzVphi->Write(); h_rdphiVphi->Write(); h_dxVphi->Write(); h_dyVphi->Write();
00441         
00442         if (savePlot) c->Print((_outputDir+"plot3x5_"+plotName).c_str());
00443         
00444 }
00445 
00446 void comparisonPlots::plot3x5Profile(TCut Cut, char* dirName, int nBins, bool savePlot, std::string plotName, bool autolimits,int ColorCode ){
00447 
00448   //for all histograms set the title centered
00449   gStyle->SetTitleAlign(22);
00450   gStyle->SetTitleX(0.5);
00451   gStyle->SetTitleY(0.97);
00452   //gStyle->SetShadowColor(0);
00453    //gStyle->SetTitleSize(.5);
00454   gStyle->SetTitleFont(62);
00455   //int ColorCodeHalfBarrels = 1; //color seperation of moodules corresponding to the different subdets
00456   //if you want to seperate corresponding to the halfbarrels (+z or -z) set colorcode !=1
00457         // ---------  create directory for histograms ---------
00458         //const char* dirName = Cut;
00459         string s;// = "profile";
00460         s = s + dirName;
00461         s.append("_profile");
00462         TDirectory* plotDir = output->mkdir( s.data() );
00463         
00464 
00465         int j = 2;
00466         TCut zCut[6];
00467         zCut[0] = "z < 0";
00468         zCut[1] = "z >= 0";
00469 
00470 
00471         if (ColorCode == 1) {
00472           j = 6;
00473           zCut[6];
00474           zCut[0] = "sublevel==1";
00475           zCut[1] = "sublevel==2";
00476           zCut[2] = "sublevel==3";
00477           zCut[3] = "sublevel==4";
00478           zCut[4] = "sublevel==5";
00479           zCut[5] = "sublevel==6";
00480           
00481         } 
00482         
00483         double minimumR, maximumR;
00484         double minimumZ, maximumZ;
00485         double minimumPhi, maximumPhi;
00486         double minimumDR, maximumDR;
00487         double minimumDZ, maximumDZ;
00488         double minimumRDPhi, maximumRDPhi;
00489         double minimumDX, maximumDX;
00490         double minimumDY, maximumDY;
00491         if (autolimits){
00492                 // ---------  get right limits for histogram ---------
00493                 TH1F* phr = new TH1F("phr", "phr", 200, 0, 200);
00494                 TH1F* phz = new TH1F("phz", "phz", 400, -300, 300);
00495                 TH1F* phphi = new TH1F("phphi", "phphi", 200, -3.15, 3.15);
00496                 TH1F* phdr = new TH1F("phdr", "phdr", 2000, -10, 10);
00497                 TH1F* phdz = new TH1F("phdz", "phdz", 2000, -10, 10);
00498                 TH1F* phrdphi = new TH1F("phrdphi", "phrdphi", 200, -10, 10);
00499                 TH1F* phdx = new TH1F("phdx", "phy", 2000, -10, 10);
00500                 TH1F* phdy = new TH1F("phdy", "phy", 2000, -10, 10);
00501                 data->Project("phr","r",Cut);
00502                 data->Project("phz","z",Cut);
00503                 data->Project("phphi","phi",Cut);
00504                 data->Project("phdr","dr",Cut);
00505                 data->Project("phdz","dz",Cut);
00506                 data->Project("phrdphi","r*dphi",Cut );
00507                 data->Project("phdx","dx",Cut );
00508                 data->Project("phdy","dy",Cut );
00509                 getHistMaxMin(phr, maximumR, minimumR, 0);
00510                 getHistMaxMin(phz, maximumZ, minimumZ, 0);
00511                 getHistMaxMin(phphi, maximumPhi, minimumPhi, 0);
00512                 getHistMaxMin(phdr, maximumDR, minimumDR, 1);
00513                 getHistMaxMin(phdz, maximumDZ, minimumDZ, 1);
00514                 getHistMaxMin(phrdphi, maximumRDPhi, minimumRDPhi, 1);
00515                 getHistMaxMin(phdx, maximumDX, minimumDX, 1);
00516                 getHistMaxMin(phdy, maximumDY, minimumDY, 1);
00517         }
00518         else{
00519                 minimumR = 0., maximumR = 120.; 
00520                 minimumZ = -300., maximumZ = 300.; 
00521                 minimumPhi = -3.15, maximumPhi = 3.15;
00522                 minimumDR = -1, maximumDR = 1;
00523                 minimumDZ = -1, maximumDZ = 1;
00524                 minimumRDPhi = -1, maximumRDPhi = 1;
00525                 minimumDX = -1, maximumDX = 1;
00526                 minimumDY = -1, maximumDY = 1;
00527         }
00528         
00529         // ---------  declare histograms ---------
00530         TProfile* hprof_drVr = new TProfile("hprof_drVr","#Delta r vs. r",nBins,minimumR,maximumR,minimumDR,maximumDR);
00531         TProfile* hprof_dzVr = new TProfile("hprof_dzVr","#Delta z vs. r",nBins,minimumR,maximumR,minimumDZ,maximumDZ);
00532         TProfile* hprof_rdphiVr = new TProfile("hprof_rdphiVr","r#Delta #phi vs. r",nBins,minimumR,maximumR,minimumRDPhi,maximumRDPhi);
00533         TProfile* hprof_dxVr = new TProfile("hprof_dxVr","#Delta x vs. r", nBins,minimumR,maximumR,minimumDX,maximumDX);
00534         TProfile* hprof_dyVr = new TProfile("hprof_dyVr","#Delta y vs. r", nBins,minimumR,maximumR,minimumDY,maximumDY);
00535         TProfile* hprof_drVz = new TProfile("hprof_drVz","#Delta r vs. z", nBins,minimumZ,maximumZ,minimumDR,maximumDR);
00536         TProfile* hprof_dzVz = new TProfile("hprof_dzVz","#Delta z vs. z", nBins,minimumZ,maximumZ,minimumDZ,maximumDZ);
00537         TProfile* hprof_rdphiVz = new TProfile("hprof_rdphiVz","r#Delta #phi vs. z", nBins,minimumZ,maximumZ,minimumRDPhi,maximumRDPhi);
00538         TProfile* hprof_dxVz = new TProfile("hprof_dxVz","#Delta x vs. z", nBins,minimumZ,maximumZ,minimumDX,maximumDX);
00539         TProfile* hprof_dyVz = new TProfile("hprof_dyVz","#Delta y vs. z", nBins,minimumZ,maximumZ,minimumDY,maximumDY);
00540         TProfile* hprof_drVphi = new TProfile("hprof_drVphi","#Delta r vs. #phi", nBins,minimumPhi,maximumPhi,minimumDR,maximumDR);
00541         TProfile* hprof_dzVphi = new TProfile("hprof_dzVphi","#Delta z vs. #phi", nBins,minimumPhi,maximumPhi,minimumDZ,maximumDZ);
00542         TProfile* hprof_rdphiVphi = new TProfile("hprof_rdphiVphi","r#Delta #phi vs. #phi", nBins,minimumPhi,maximumPhi,minimumRDPhi,maximumRDPhi);
00543         TProfile* hprof_dxVphi = new TProfile("hprof_dxVphi","#Delta x vs. #phi", nBins,minimumPhi,maximumPhi,minimumDX,maximumDX);
00544         TProfile* hprof_dyVphi = new TProfile("hprof_dyVphi","#Delta y vs. #phi", nBins,minimumPhi,maximumPhi,minimumDY,maximumDY);
00545         
00546         TProfile* gr_drVr_Array[j];
00547         THStack* mgr_drVr=new THStack("mgr_drVr","");
00548         
00549         for ( int i = 0; i < j; i++) {
00550           data->Draw("dr:r>>hprof_drVr",Cut+zCut[i],"prof");
00551           if (hprof_drVr->GetEntries()>0){
00552           gr_drVr_Array[i] =(TProfile*)hprof_drVr->Clone() ;//data->Draw("dr:r",Cut+zCut[i],"prof");
00553           gr_drVr_Array[i]->SetMarkerColor(int(i/4)+i+1);
00554           gr_drVr_Array[i]->SetLineColor(int(i/4)+i+1);
00555           mgr_drVr->Add(gr_drVr_Array[i]);
00556           }
00557         }
00558         //y-axis scaled 2 times the max value for values >5 micron
00559         //for max values<5 micron set fixed range to 10 micron
00560         if ( (mgr_drVr->GetMaximum("nostack")>0.00005)||(mgr_drVr->GetMinimum("nostack")<-0.00005) ){
00561         mgr_drVr->SetMaximum( 2.*mgr_drVr->GetMaximum("nostack") );
00562         mgr_drVr->SetMinimum( 2.*mgr_drVr->GetMinimum("nostack") );
00563         }
00564         else{
00565           mgr_drVr->SetMaximum(100*mgr_drVr->GetMaximum("nostack"));
00566           mgr_drVr->SetMinimum( 100.*mgr_drVr->GetMinimum("nostack"));
00567         }
00568         
00569         //data->Project("hprof_dzVr", "dz:r",Cut,"prof");
00570         TProfile* gr_dzVr_Array[j];
00571         THStack* mgr_dzVr=new THStack("mgr_dzVr","");
00572         for ( int i = 0; i < j; i++) {
00573           data->Draw("dz:r>>hprof_dzVr",Cut+zCut[i],"prof");      
00574           if (hprof_dzVr->GetEntries()>0){
00575           gr_dzVr_Array[i] =(TProfile*)hprof_dzVr->Clone() ; 
00576           gr_dzVr_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00577           gr_dzVr_Array[i]->SetLineColor(int(i/4)+i+1);
00578           mgr_dzVr->Add(gr_dzVr_Array[i]);
00579           }
00580         }
00581         if ( (mgr_dzVr->GetMaximum("nostack")>0.00005)||(mgr_dzVr->GetMinimum("nostack")<-0.00005) ){
00582           mgr_dzVr->SetMaximum( 2.*mgr_dzVr->GetMaximum("nostack") );
00583           mgr_dzVr->SetMinimum( 2.*mgr_dzVr->GetMinimum("nostack") );
00584         }       
00585         else{
00586           mgr_dzVr->SetMaximum( 100.*mgr_dzVr->GetMaximum("nostack") );
00587           mgr_dzVr->SetMinimum( 100.*mgr_dzVr->GetMinimum("nostack") );
00588         }
00589 
00590         //data->Project("hprof_rdphiVr", "r*dphi:r",Cut,"prof");
00591         TProfile* gr_rdphiVr_Array[j];
00592         THStack* mgr_rdphiVr=new THStack();
00593         for ( int i = 0; i < j; i++) {
00594           data->Draw("r*dphi:r>>hprof_rdphiVr",Cut+zCut[i],"prof");       
00595           if (hprof_rdphiVr->GetEntries()>0){
00596           gr_rdphiVr_Array[i] = (TProfile*)hprof_rdphiVr->Clone() ; 
00597           gr_rdphiVr_Array[i]->SetMarkerColor(int(i/4)+i+1);      
00598           gr_rdphiVr_Array[i]->SetLineColor(int(i/4)+i+1);        
00599           mgr_rdphiVr->Add(gr_rdphiVr_Array[i]);
00600           }
00601         }
00602         if ( (mgr_rdphiVr->GetMaximum("nostack")>0.00005)||(mgr_rdphiVr->GetMinimum("nostack")<-0.00005) ){
00603         mgr_rdphiVr->SetMaximum( 2.*mgr_rdphiVr->GetMaximum("nostack") );
00604         mgr_rdphiVr->SetMinimum( 2.*mgr_rdphiVr->GetMinimum("nostack") );
00605         }
00606         else{
00607         mgr_rdphiVr->SetMaximum( 100.*mgr_rdphiVr->GetMaximum("nostack") );
00608         mgr_rdphiVr->SetMinimum( 100.*mgr_rdphiVr->GetMinimum("nostack") );
00609         }
00610           
00611         //data->Project("hprof_dxVr", "dx:r",Cut,"prof");
00612         TProfile* gr_dxVr_Array[j];
00613         THStack* mgr_dxVr=new THStack();
00614         for ( int i = 0; i < j; i++) {
00615           data->Draw("dx:r>>hprof_dxVr",Cut+zCut[i],"prof");
00616           if (hprof_dxVr->GetEntries()>0){
00617           gr_dxVr_Array[i] =  (TProfile*)hprof_dxVr->Clone() ; 
00618           gr_dxVr_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00619           gr_dxVr_Array[i]->SetLineColor(int(i/4)+i+1);   
00620           mgr_dxVr->Add(gr_dxVr_Array[i]);
00621           }
00622         }
00623         if ( (mgr_dxVr->GetMaximum("nostack")>0.00005)||(mgr_dxVr->GetMinimum("nostack")<-0.00005) ){
00624         mgr_dxVr->SetMaximum( 2.*mgr_dxVr->GetMaximum("nostack") );
00625         mgr_dxVr->SetMinimum( 2.*mgr_dxVr->GetMinimum("nostack") );
00626         }
00627         else{
00628           mgr_dxVr->SetMaximum( 100.*mgr_dxVr->GetMaximum("nostack") );
00629           mgr_dxVr->SetMinimum( 100.*mgr_dxVr->GetMinimum("nostack") );
00630 }
00631         
00632         //data->Project("hprof_dyVr", "dy:r",Cut,"prof");
00633         TProfile* gr_dyVr_Array[j];
00634         THStack* mgr_dyVr=new THStack();
00635         for ( int i = 0; i < j; i++) {
00636           data->Draw("dy:r>>hprof_dyVr",Cut+zCut[i],"prof");      
00637           if (hprof_dyVr->GetEntries()>0){
00638             gr_dyVr_Array[i] = (TProfile*)hprof_dyVr->Clone() ;
00639             gr_dyVr_Array[i]->SetMarkerColor(int(i/4)+i+1);       
00640             gr_dyVr_Array[i]->SetLineColor(int(i/4)+i+1);         
00641             mgr_dyVr->Add(gr_dyVr_Array[i]);
00642           }
00643         }
00644         if ( (mgr_dyVr->GetMaximum("nostack")>0.00005)||(mgr_dyVr->GetMinimum("nostack")<-0.00005) ){
00645           mgr_dyVr->SetMaximum( 2.*mgr_dyVr->GetMaximum("nostack") );
00646           mgr_dyVr->SetMinimum( 2.*mgr_dyVr->GetMinimum("nostack") );
00647         }
00648         else{
00649           mgr_dyVr->SetMaximum( 100.*mgr_dyVr->GetMaximum("nostack") );
00650           mgr_dyVr->SetMinimum( 100.*mgr_dyVr->GetMinimum("nostack") );
00651         }
00652         //data->Project("hprof_drVz", "dr:z",Cut,"prof");
00653         TProfile* gr_drVz_Array[j];
00654         THStack* mgr_drVz=new THStack();
00655         for ( int i = 0; i < j; i++) {
00656           data->Draw("dr:z>>hprof_drVz",Cut+zCut[i],"prof");      
00657           if (hprof_drVz->GetEntries()>0){
00658             gr_drVz_Array[i] = (TProfile*)hprof_drVz->Clone() ; 
00659             gr_drVz_Array[i]->SetMarkerColor(int(i/4)+i+1);       
00660             gr_drVz_Array[i]->SetLineColor(int(i/4)+i+1);         
00661             mgr_drVz->Add(gr_drVz_Array[i]);
00662           }
00663         }
00664         if ( (mgr_drVr->GetMaximum("nostack")>0.00005)||(mgr_drVr->GetMinimum("nostack")<-0.00005) ){
00665         mgr_drVz->SetMaximum( 2.*mgr_drVz->GetMaximum("nostack") );
00666         mgr_drVz->SetMinimum( 2.*mgr_drVz->GetMinimum("nostack") );
00667         }
00668         else{
00669         mgr_drVz->SetMaximum( 100.*mgr_drVz->GetMaximum("nostack") );
00670         mgr_drVz->SetMinimum( 100.*mgr_drVz->GetMinimum("nostack") );
00671         }
00672         //data->Project("hprof_dzVz", "dz:z",Cut,"prof");
00673         TProfile* gr_dzVz_Array[j];
00674         THStack* mgr_dzVz=new THStack();
00675         for ( int i = 0; i < j; i++) {
00676                 data->Draw("dz:z>>hprof_dzVz",Cut+zCut[i],"prof");        
00677                 if (hprof_dzVz->GetEntries()>0){
00678                 gr_dzVz_Array[i] =  (TProfile*)hprof_dzVz->Clone() ;
00679                 gr_dzVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00680                 gr_dzVz_Array[i]->SetLineColor(int(i/4)+i+1);     
00681                 mgr_dzVz->Add(gr_dzVz_Array[i]);
00682                 }
00683         }
00684         if ( (mgr_dzVr->GetMaximum("nostack")>0.00005)||(mgr_dzVr->GetMinimum("nostack")<-0.00005) ){
00685         mgr_dzVz->SetMaximum( 2.*mgr_dzVz->GetMaximum("nostack") );
00686         mgr_dzVz->SetMinimum( 2.*mgr_dzVz->GetMinimum("nostack") );
00687         }
00688         else{
00689         mgr_dzVz->SetMaximum( 100.*mgr_dzVz->GetMaximum("nostack") );
00690         mgr_dzVz->SetMinimum( 100.*mgr_dzVz->GetMinimum("nostack") );
00691         }
00692 
00693         //data->Project("hprof_rdphiVz", "r*dphi:z",Cut,"prof");
00694         TProfile* gr_rdphiVz_Array[j];
00695         THStack* mgr_rdphiVz=new THStack();
00696         for ( int i = 0; i < j; i++) {
00697           data->Draw("r*dphi:z>>hprof_rdphiVz",Cut+zCut[i],"prof");       
00698           if (hprof_rdphiVz->GetEntries()>0){
00699             gr_rdphiVz_Array[i] = (TProfile*)hprof_rdphiVz->Clone() ; 
00700             gr_rdphiVz_Array[i]->SetMarkerColor(int(i/4)+i+1);    
00701             gr_rdphiVz_Array[i]->SetLineColor(int(i/4)+i+1);
00702             mgr_rdphiVz->Add(gr_rdphiVz_Array[i]);
00703           }
00704         }
00705         if ( (mgr_rdphiVz->GetMaximum("nostack")>0.00005)||(mgr_rdphiVz->GetMinimum("nostack")<-0.00005) ){
00706         mgr_rdphiVz->SetMaximum( 2.*mgr_rdphiVz->GetMaximum("nostack") );
00707         mgr_rdphiVz->SetMinimum( 2.*mgr_rdphiVz->GetMinimum("nostack") );
00708         }
00709         else{
00710         mgr_rdphiVz->SetMaximum( 100.*mgr_rdphiVz->GetMaximum("nostack") );
00711         mgr_rdphiVz->SetMinimum( 100.*mgr_rdphiVz->GetMinimum("nostack") );
00712         }
00713         //data->Project("hprof_dxVz", "dx:z",Cut,"prof");
00714         TProfile* gr_dxVz_Array[j];
00715         THStack* mgr_dxVz=new THStack();
00716         for ( int i = 0; i < j; i++) {
00717           data->Draw("dx:z>>hprof_dxVz",Cut+zCut[i],"prof");      
00718           if (hprof_dxVz->GetEntries()>0){
00719           gr_dxVz_Array[i] = (TProfile*)hprof_dxVz->Clone() ; 
00720                 gr_dxVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00721                 gr_dxVz_Array[i]->SetLineColor(int(i/4)+i+1);     
00722                 mgr_dxVz->Add(gr_dxVz_Array[i]);
00723           }
00724         }
00725         if ( (mgr_dxVz->GetMaximum("nostack")>0.00005)||(mgr_dxVz->GetMinimum("nostack")<-0.00005) ){
00726         mgr_dxVz->SetMaximum( 2.*mgr_dxVz->GetMaximum("nostack") );
00727         mgr_dxVz->SetMinimum( 2.*mgr_dxVz->GetMinimum("nostack") );
00728         }
00729         else{
00730           mgr_dxVz->SetMaximum( 100.*mgr_dxVz->GetMaximum("nostack") );
00731           mgr_dxVz->SetMinimum( 100.*mgr_dxVz->GetMinimum("nostack") );
00732         }
00733         
00734         //data->Project("hprof_dyVz", "dy:z",Cut,"prof");
00735         TProfile* gr_dyVz_Array[j];
00736         THStack* mgr_dyVz=new THStack();
00737         for ( int i = 0; i < j; i++) {
00738                 data->Draw("dy:z>>hprof_dyVz",Cut+zCut[i],"prof");
00739                 if (hprof_dyVz->GetEntries()>0){
00740                 gr_dyVz_Array[i] = (TProfile*)hprof_dyVz->Clone() ; 
00741                 gr_dyVz_Array[i]->SetMarkerColor(int(i/4)+i+1);   
00742                 gr_dyVz_Array[i]->SetLineColor(int(i/4)+i+1);     
00743                 mgr_dyVz->Add(gr_dyVz_Array[i],"p");
00744                 }
00745         }
00746         if ( (mgr_dyVz->GetMaximum("nostack")>0.00005)||(mgr_dyVz->GetMinimum("nostack")<-0.00005) ){
00747           mgr_dyVz->SetMaximum( 2.*mgr_dyVz->GetMaximum("nostack") );
00748           mgr_dyVz->SetMinimum( 2.*mgr_dyVz->GetMinimum("nostack") );
00749         }
00750         else{
00751           mgr_dyVz->SetMaximum( 100.*mgr_dyVz->GetMaximum("nostack") );
00752           mgr_dyVz->SetMinimum( 100.*mgr_dyVz->GetMinimum("nostack") );
00753         }
00754 
00755         //data->Project("hprof_drVphi", "dr:phi",Cut,"prof");
00756         TProfile* gr_drVphi_Array[j];
00757         THStack* mgr_drVphi=new THStack();
00758         for ( int i = 0; i < j; i++) {
00759                 data->Draw("dr:phi>>hprof_drVphi",Cut+zCut[i],"prof");    
00760                 if (hprof_drVphi->GetEntries()>0){
00761                 gr_drVphi_Array[i] = (TProfile*)hprof_drVphi->Clone() ; 
00762                 gr_drVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00763                 gr_drVphi_Array[i]->SetLineColor(int(i/4)+i+1);
00764                 mgr_drVphi->Add(gr_drVphi_Array[i],"p");
00765         }
00766         }
00767         if ( (mgr_drVphi->GetMaximum("nostack")>0.00005)||(mgr_drVphi->GetMinimum("nostack")<-0.00005) ){
00768         mgr_drVphi->SetMaximum( 2.*mgr_drVphi->GetMaximum("nostack") );
00769         mgr_drVphi->SetMinimum( 2.*mgr_drVphi->GetMinimum("nostack") );
00770         }
00771         else{
00772           mgr_drVphi->SetMaximum( 100.*mgr_drVphi->GetMaximum("nostack") );
00773           mgr_drVphi->SetMinimum( 100.*mgr_drVphi->GetMinimum("nostack") );
00774         }
00775         //data->Project("hprof_dzVphi", "dz:phi",Cut,"prof");
00776         TProfile* gr_dzVphi_Array[j];
00777         THStack* mgr_dzVphi=new THStack();
00778         for ( int i = 0; i < j; i++) {
00779                 data->Draw("dz:phi>>hprof_dzVphi",Cut+zCut[i],"prof");    
00780                 if (hprof_dzVphi->GetEntries()>0){
00781                 gr_dzVphi_Array[i] =  (TProfile*)hprof_dzVphi->Clone() ; 
00782                 gr_dzVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00783                 gr_dzVphi_Array[i]->SetLineColor(int(i/4)+i+1);
00784                 mgr_dzVphi->Add(gr_dzVphi_Array[i],"p");
00785         }
00786         }
00787         if ( (mgr_dzVphi->GetMaximum("nostack")>0.00005)||(mgr_dzVphi->GetMinimum("nostack")<-0.00005) ){
00788         mgr_dzVphi->SetMaximum( 2.*mgr_dzVphi->GetMaximum("nostack") );
00789         mgr_dzVphi->SetMinimum( 2.*mgr_dzVphi->GetMinimum("nostack") );
00790         }
00791         else{
00792         mgr_dzVphi->SetMaximum( 100.*mgr_dzVphi->GetMaximum("nostack") );
00793         mgr_dzVphi->SetMinimum( 100.*mgr_dzVphi->GetMinimum("nostack") );
00794         }
00795         //data->Project("hprof_rdphiVphi", "r*dphi:phi",Cut,"prof");
00796         TProfile* gr_rdphiVphi_Array[j];
00797         THStack* mgr_rdphiVphi=new THStack();
00798         for ( int i = 0; i < j; i++) {
00799                 data->Draw("r*dphi:phi>>hprof_rdphiVphi",Cut+zCut[i],"prof");     
00800                 if (hprof_rdphiVphi->GetEntries()>0){
00801                 gr_rdphiVphi_Array[i] =  (TProfile*)hprof_rdphiVphi->Clone() ; 
00802                 gr_rdphiVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);      
00803                 gr_rdphiVphi_Array[i]->SetLineColor(int(i/4)+i+1);        
00804                 mgr_rdphiVphi->Add(gr_rdphiVphi_Array[i],"p");
00805         }
00806         }
00807         if ( (mgr_rdphiVphi->GetMaximum("nostack")>0.00005)||(mgr_rdphiVphi->GetMinimum("nostack")<-0.00005) ){
00808         mgr_rdphiVphi->SetMaximum( 2.*mgr_rdphiVphi->GetMaximum("nostack") );
00809         mgr_rdphiVphi->SetMinimum( 2.*mgr_rdphiVphi->GetMinimum("nostack") );
00810         }
00811         else{
00812           mgr_rdphiVphi->SetMaximum( 100.*mgr_rdphiVphi->GetMaximum("nostack") );
00813           mgr_rdphiVphi->SetMinimum( 100.*mgr_rdphiVphi->GetMinimum("nostack") );
00814         }
00815         //data->Project("hprof_dxVphi", "dx:phi",Cut,"prof");
00816         TProfile* gr_dxVphi_Array[j];
00817         THStack* mgr_dxVphi=new THStack();
00818         for ( int i = 0; i < j; i++) {
00819                 data->Draw("dx:phi>>hprof_dxVphi",Cut+zCut[i],"prof");
00820                 if (hprof_dxVphi->GetEntries()>0){
00821                 gr_dxVphi_Array[i] =  (TProfile*)hprof_dxVphi->Clone() ; 
00822                 gr_dxVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00823                 gr_dxVphi_Array[i]->SetLineColor(int(i/4)+i+1);
00824                 mgr_dxVphi->Add(gr_dxVphi_Array[i],"p");
00825                 }
00826         }
00827         if ( (mgr_dxVphi->GetMaximum("nostack")>0.00005)||(mgr_dxVphi->GetMinimum("nostack")<-0.00005) ){
00828         mgr_dxVphi->SetMaximum( 2.*mgr_dxVphi->GetMaximum("nostack") );
00829         mgr_dxVphi->SetMinimum( 2.*mgr_dxVphi->GetMinimum("nostack") );
00830         }
00831         else{
00832         mgr_dxVphi->SetMaximum( 100.*mgr_dxVphi->GetMaximum("nostack") );
00833         mgr_dxVphi->SetMinimum( 100.*mgr_dxVphi->GetMinimum("nostack") );
00834         }
00835         //data->Project("hprof_dyVphi", "dy:phi",Cut,"prof");
00836         TProfile* gr_dyVphi_Array[j];
00837         THStack* mgr_dyVphi=new THStack();
00838         for ( int i = 0; i < j; i++) {
00839                 data->Draw("dy:phi>>hprof_dyVphi",Cut+zCut[i],"prof");    
00840                 if (hprof_dyVphi->GetEntries()>0){
00841                 gr_dyVphi_Array[i] =  (TProfile*)hprof_dyVphi->Clone() ; 
00842                 gr_dyVphi_Array[i]->SetMarkerColor(int(i/4)+i+1);         
00843                 gr_dyVphi_Array[i]->SetLineColor(int(i/4)+i+1);
00844                 mgr_dyVphi->Add(gr_dyVphi_Array[i],"p");
00845         }
00846         }
00847 if ( (mgr_dyVphi->GetMaximum("nostack")>0.00005)||(mgr_dyVphi->GetMinimum("nostack")<-0.00005) ){
00848         mgr_dyVphi->SetMaximum( 2.*mgr_dyVphi->GetMaximum("nostack") );
00849         mgr_dyVphi->SetMinimum( 2.*mgr_dyVphi->GetMinimum("nostack") );
00850  }
00851  else{
00852         mgr_dyVphi->SetMaximum( 100.*mgr_dyVphi->GetMaximum("nostack") );
00853         mgr_dyVphi->SetMinimum( 100.*mgr_dyVphi->GetMinimum("nostack") );
00854  }
00855         
00856         // ---------  draw histograms ---------
00857         /*TCanvas* c0 = new TCanvas("c0", "c0", 200, 10, 900, 300);
00858         c0->SetFillColor(0);
00859         c0->Divide(3,1);
00860         c0->cd(1);
00861         hprof_dr->Draw();
00862         c0->cd(2);
00863         hprof_dz->Draw();
00864         c0->cd(3);
00865         hprof_rdphi->Draw();
00866         if (savePlot) c0->Print((_outputDir+"plot3x1_Profile"+plotName).c_str());
00867         */
00868         mgr_drVr->SetTitle("#Delta r vs. r");           
00869         mgr_dzVr->SetTitle("#Delta z vs. r");           
00870         mgr_rdphiVr->SetTitle("r#Delta #phi vs. r");    
00871         mgr_dxVr->SetTitle("#Delta x vs. r");           
00872         mgr_dyVr->SetTitle("#Delta y vs. r");           
00873         mgr_drVz->SetTitle("#Delta r vs. z");           
00874         mgr_dzVz->SetTitle("#Delta z vs. z");           
00875         mgr_rdphiVz->SetTitle("r#Delta #phi vs. z");    
00876         mgr_dxVz->SetTitle("#Delta x vs. z");           
00877         mgr_dyVz->SetTitle("#Delta y vs. z");           
00878         mgr_drVphi->SetTitle("#Delta r vs. #phi");      
00879         mgr_dzVphi->SetTitle("#Delta z vs. #phi");      
00880         mgr_rdphiVphi->SetTitle("r#Delta #phi vs. #phi");
00881         mgr_dxVphi->SetTitle("#Delta x vs. #phi");      
00882         mgr_dyVphi->SetTitle("#Delta y vs. #phi");   
00883         
00884         // ---------  draw histograms ---------
00885         TCanvas* c = new TCanvas("c", "c", 200, 10, 1200, 700);
00886         c->SetFillColor(0);
00887         data->SetMarkerSize(0.5);
00888         data->SetMarkerStyle(6);
00889         c->Divide(5,3);
00890         c->cd(1);
00891         if (!autolimits) mgr_drVr->Draw("nostack");
00892         if (autolimits) mgr_drVr->Draw("nostack");
00893         c->Update();
00894         c->cd(2);
00895         if (!autolimits)  mgr_dzVr->Draw("nostack");
00896         if (autolimits) mgr_dzVr->Draw("nostack");
00897         c->Update();
00898         c->cd(3);
00899         if (!autolimits)  mgr_rdphiVr->Draw("nostack");
00900         if (autolimits) mgr_rdphiVr->Draw("nostack");
00901         c->cd(4);
00902         if (!autolimits) mgr_dxVr->Draw("nostack"); 
00903         if (autolimits) mgr_dxVr->Draw("nostack");
00904         c->cd(5);
00905         if (!autolimits) mgr_dyVr->Draw("nostack");
00906         if (autolimits) mgr_dyVr->Draw("nostack");
00907         c->cd(6);
00908         if (!autolimits) mgr_drVz->Draw("nostack");
00909         if (autolimits) mgr_drVz->Draw("nostack");
00910         c->cd(7);
00911         if (!autolimits)  mgr_dzVz->Draw("nostack");
00912         if (autolimits) mgr_dzVz->Draw("nostack");
00913         c->cd(8);
00914         if (!autolimits) mgr_rdphiVz->Draw("nostack");
00915         if (autolimits) mgr_rdphiVz->Draw("nostack");
00916         c->cd(9);
00917         if (!autolimits) mgr_dxVz->Draw("nostack");
00918         if (autolimits) mgr_dxVz->Draw("nostack");
00919         c->cd(10);
00920         if (!autolimits)  mgr_dyVz->Draw("nostack");
00921         if (autolimits) mgr_dyVz->Draw("nostack");
00922         c->cd(11);
00923         if (!autolimits) mgr_drVphi->Draw("nostack");
00924         if (autolimits) mgr_drVphi->Draw("nostack");
00925         c->cd(12);
00926         if (!autolimits) mgr_dzVphi->Draw("nostack");
00927         if (autolimits) mgr_dzVphi->Draw("nostack");
00928         c->cd(13);
00929         if (!autolimits) mgr_rdphiVphi->Draw("nostack");
00930         if (autolimits) mgr_rdphiVphi->Draw("nostack");
00931         c->cd(14);
00932         if (!autolimits) mgr_dxVphi->Draw("nostack");
00933         if (autolimits) mgr_dxVphi->Draw("nostack");
00934         c->cd(15);
00935         if (!autolimits)  mgr_dyVphi->Draw("nostack");
00936         if (autolimits) mgr_dyVphi->Draw("nostack");
00937         
00938         c->Update();
00939         
00940         // ---------  set output directory for histograms ---------
00941         plotDir->cd();
00942         
00943         hprof_drVr->Write(); hprof_dzVr->Write(); hprof_rdphiVr->Write(); hprof_dxVr->Write(); hprof_dyVr->Write();
00944         hprof_drVz->Write(); hprof_dzVz->Write(); hprof_rdphiVz->Write(); hprof_dxVz->Write(); hprof_dyVz->Write();
00945         hprof_drVphi->Write(); hprof_dzVphi->Write(); hprof_rdphiVphi->Write(); hprof_dxVphi->Write(); hprof_dyVphi->Write();
00946         
00947         /*
00948         // ---------  project tree onto histograms ---------
00949         data->Project("hprof_drVr", "dr:r",Cut ,"prof");
00950         data->Project("hprof_dzVr", "dz:r",Cut ,"prof");
00951         data->Project("hprof_rdphiVr", "r*dphi:r",Cut ,"prof");
00952         data->Project("hprof_dxVr", "dx:r",Cut ,"prof");
00953         data->Project("hprof_dyVr", "dy:r",Cut ,"prof");
00954         data->Project("hprof_drVz", "dr:z",Cut ,"prof");
00955         data->Project("hprof_dzVz", "dz:z",Cut ,"prof");
00956         data->Project("hprof_rdphiVz", "r*dphi:z",Cut ,"prof");
00957         data->Project("hprof_dxVz", "dx:z",Cut ,"prof");
00958         data->Project("hprof_dyVz", "dy:z",Cut ,"prof");
00959         data->Project("hprof_drVphi", "dr:phi",Cut ,"prof");
00960         data->Project("hprof_dzVphi", "dz:phi",Cut ,"prof");
00961         data->Project("hprof_rdphiVphi", "r*dphi:phi",Cut ,"prof");
00962         data->Project("hprof_dxVphi", "dx:phi",Cut ,"prof");
00963         data->Project("hprof_dyVphi", "dy:phi",Cut ,"prof");
00964         
00965         // ---------  draw histograms ---------
00966         TCanvas* cp = new TCanvas("cp", "cp", 200, 10, 1200, 700);
00967         cp->SetFillColor(0);
00968         data->SetMarkerSize(0.5);
00969         data->SetMarkerStyle(6);
00970         cp->Divide(5,3);
00971         cp->cd(1);
00972         hprof_drVr->Draw();
00973         cp->cd(2);
00974         hprof_dzVr->Draw();
00975         cp->cd(3);
00976         hprof_rdphiVr->Draw();
00977         cp->cd(4);
00978         hprof_dxVr->Draw();
00979         cp->cd(5);
00980         hprof_dyVr->Draw();
00981         cp->cd(6);
00982         hprof_drVz->Draw();
00983         cp->cd(7);
00984         hprof_dzVz->Draw();
00985         cp->cd(8);
00986         hprof_rdphiVz->Draw();
00987         cp->cd(9);
00988         hprof_dxVz->Draw();
00989         cp->cd(10);
00990         hprof_dyVz->Draw();
00991         cp->cd(11);
00992         hprof_drVphi->Draw();
00993         cp->cd(12);
00994         hprof_dzVphi->Draw();
00995         cp->cd(13);
00996         hprof_rdphiVphi->Draw();
00997         cp->cd(14);
00998         hprof_dxVphi->Draw();
00999         cp->cd(15);
01000         hprof_dyVphi->Draw();
01001         
01002         // ---------  set output directory for histograms ---------
01003         plotDir->cd();
01004         hprof_drVr->Write(); hprof_dzVr->Write(); hprof_rdphiVr->Write(); hprof_dxVr->Write(); hprof_dyVr->Write();
01005         hprof_drVz->Write(); hprof_dzVz->Write(); hprof_rdphiVz->Write(); hprof_dxVz->Write(); hprof_dyVz->Write();
01006         hprof_drVphi->Write(); hprof_dzVphi->Write(); hprof_rdphiVphi->Write(); hprof_dxVphi->Write(); hprof_dyVphi->Write();
01007         */
01008         if (savePlot) c->Print((_outputDir+"plot3x5Prof_"+plotName).c_str());
01009 }
01010 
01011 
01012 void comparisonPlots::getMaxMin(){
01013         
01014         data->GetEntry(0);
01015         minR = r_; maxR = r_;
01016         minZ = z_; maxZ = z_;
01017         minPhi = phi_; maxPhi = phi_;
01018         minDR = dr_; maxDR = dr_;
01019         minDZ = dz_; maxDZ = dz_;
01020         minRDPhi = r_*dphi_; maxRDPhi = r_*dphi_;
01021         minDX = dx_; maxDX = dx_;
01022         minDY = dy_; maxDY = dy_;
01023         
01024         int nEntries = data->GetEntries();
01025         for (int i = 1; i < nEntries; ++i){
01026                 data->GetEntry(i);
01027                 
01028                 if (r_ < minR) minR = r_;
01029                 if (r_ > maxR) maxR = r_;
01030                 if (z_ < minZ) minZ = z_;
01031                 if (z_ > maxZ) maxZ = z_;
01032                 if (phi_ < minPhi) minPhi = phi_;
01033                 if (phi_ > maxPhi) maxPhi = phi_;
01034                 if (dr_ < minDR) minDR = dr_;
01035                 if (dr_ > maxDR) maxDR = dr_;
01036                 if (dz_ < minDZ) minDZ = dz_;
01037                 if (dz_ > maxDZ) maxDZ = dz_;
01038                 if (r_*dphi_ < minRDPhi) minRDPhi = r_*dphi_;
01039                 if (r_*dphi_ > maxRDPhi) maxRDPhi = r_*dphi_;
01040                 if (dx_ < minDX) minDX = dx_;
01041                 if (dx_ > maxDX) maxDX = dx_;
01042                 if (dy_ < minDY) minDY = dy_;
01043                 if (dy_ > maxDY) maxDY = dy_;
01044         }
01045 }
01046 
01047 
01048 void comparisonPlots::getHistMaxMin(TH1* hist, double &max, double &min, int flag){
01049         
01050         int nBins = hist->GetNbinsX();
01051         for (int i = 0; i < nBins; ++i){
01052                 double binContent = hist->GetBinContent(i);
01053                 if (binContent > 0){
01054                         //double binWidth = hist->GetBinLowEdge(i) - hist->GetBinLowEdge(i-1);
01055                         //std::cout << "bin width1: " << hist->GetBinWidth(i) << ", bin width2: " << binWidth << std::endl;
01056                         if (flag == 0) max = hist->GetBinLowEdge(i) + 2.*hist->GetBinWidth(i) + 0.1*hist->GetBinLowEdge(i);
01057                         if (flag == 1) max = hist->GetBinLowEdge(i) + hist->GetBinWidth(i) + 0.1*hist->GetBinLowEdge(i);
01058                 }
01059         }
01060         for (int i = (nBins-1); i >= 0; i--){
01061                 double binContent = hist->GetBinContent(i);
01062                 if (binContent > 0) min = hist->GetBinLowEdge(i) - 0.1*hist->GetBinLowEdge(i);
01063         }
01064         //std::cout << "max: " << max << ", min: " << min << std::endl;
01065 }
01066 
01067 void comparisonPlots::Write()
01068 {
01069         output->Write();
01070 }
01071 
01072