CMS 3D CMS Logo

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