Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:37

0001 
0002 #ifndef VECTOR
0003 #define VECTOR
0004 #include <vector>
0005 #endif
0006 
0007 #ifndef IOSTREAM
0008 #define  IOSTREAM
0009 #include <iostream>
0010 #endif
0011 
0012 #ifndef IOMANIP
0013 #define IOMANIP
0014 #include <iomanip>
0015 #endif
0016 
0017 {
0018 
0019   gStyle->SetTitleFillColor(0);
0020   gStyle->SetFrameFillColor(0);
0021   
0022   string MyDirectory = "/uscms/home/stoyan/work/csc_ana/CSCEff/dev/CMSSW_2_2_1/src/test/merged/";
0023   string MySubDirectory;
0024   string MyFileName;// = "efficiencies.root";
0025  
0026   string MyFullPath;
0027   char *file_name;
0028 
0029   MySubDirectory = "./";
0030   MyFileName = "efficiencies.root";
0031   MyFullPath =  MyDirectory +  MySubDirectory + MyFileName;
0032   file_name = MyFullPath.c_str();
0033   TFile *f1=
0034     (TFile*)gROOT->GetListOfFiles()->FindObject(file_name);
0035   if (!f1){
0036     TFile *f1 = new TFile(file_name);
0037   }
0038 
0039   
0040   std::vector < TFile * > DataFiles;
0041   DataFiles.push_back(f1);
0042 
0043   Int_t nx = 36;
0044   const Int_t ny = 16;
0045   
0046   char *chambers[nx]  = {"01","02","03","04","05","06","07","08","09","10",
0047             "11","12","13","14","15","16","17","18","19","20",
0048              "21","22","23","24","25","26","27","28","29","30",
0049              "31","32","33","34","35","36"};
0050   char *types[ny] = {"ME-41","ME-32","ME-31","ME-22","ME-21","ME-13","ME-12","ME-11",
0051              "ME+11","ME+12","ME+13","ME+21","ME+22","ME+31","ME+32","ME+41"};
0052   
0053   
0054   TH2F * data_p2;
0055   string histo = Form("h_rhEfficiency");
0056 
0057   //string histo = Form("h_segEfficiency");
0058 
0059   //string histo = Form("h_stripEfficiency");
0060 
0061   //string histo = Form("h_wireEfficiency");
0062 
0063   //string histo = Form("h_clctEfficiency");
0064 
0065   //string histo = Form("h_alctEfficiency");
0066 
0067   char *histo_full = histo.c_str();
0068   data_p2=(TH2F*)(*(DataFiles[0]))->Get(histo_full);
0069   
0070   TH2F *hold = (TH2F*)data_p2->Clone("old");
0071   
0072   int nbinsX = hold->GetNbinsX();
0073   int nbinsY = hold->GetNbinsY();
0074   
0075 
0076   TH2F *h2 = new TH2F("h2","RecHit efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0077   //TH2F *h2 = new TH2F("h2","Segment efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0078   //TH2F *h2 = new TH2F("h2","Strip efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0079   //TH2F *h2 = new TH2F("h2","WireGroup efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0080   //TH2F *h2 = new TH2F("h2","CLCT efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0081   //TH2F *h2 = new TH2F("h2","ALCT efficiency (in %), errors represented by text; chamber number",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0082 
0083 
0084   TH2F *h3 = new TH2F("h2","RecHit efficiency (in %)",nbinsX,0.,float(nbinsX), nbinsY,0.,float(nbinsY));
0085 
0086   
0087   TCanvas *eff1 = new TCanvas("eff1","Efficiency",10,10,1200,800);
0088   gPad->SetFillColor(0);
0089   std::cout<<" Processing..."<<std::endl;  
0090   ofstream myfile;
0091   myfile.open ("efficiencies.txt");
0092   myfile<<"         "<<setw(7)<<"ME-41 "<<setw(7)<<"ME-32 "<<setw(7)<<"ME-31 "<<setw(7)<<"ME-22 "<<
0093     setw(7)<<"ME-21 "<<setw(7)<<"ME-13 "<<setw(7)<<"ME-12 "<<setw(7)<<"ME-11 "<<setw(7)<<
0094     "ME+11 "<<setw(7)<<"ME+12 "<<setw(7)<<"ME+13 "<<setw(7)<<"ME+21 "<<setw(7)<<
0095     "ME+22 "<<setw(7)<<"ME+31 "<<setw(7)<<"ME+32 "<<setw(7)<<"ME+41 "<<std::endl;
0096   for (int ibinX = 1 ; ibinX <= nbinsX ;  ibinX++ )  {
0097     myfile<<std::endl;
0098     myfile<<"CH"<<chambers[ibinX-1]<<"    ";
0099     for (int ibinY = 1 ; ibinY <= nbinsY ;  ibinY++ )  {
0100       Int_t ibin = hold->GetBin(ibinX,ibinY);
0101       double binCont = hold->GetBinContent(ibin) ;
0102       double binErr = hold->GetBinError(ibin) ;
0103       myfile<<" "<<setw(6)<<std::setprecision(4) <<binCont;
0104       int tmpCont = int(binCont*1000. + 0.5);
0105       int tmpErr = int(binErr*1000. + 0.5);
0106       double newCont = double(tmpCont)/10.;
0107       double newErr = double(tmpErr)/10.;
0108       h2->Fill(chambers[ibinX-1],types[ibinY-1],newCont);
0109       h3->Fill(chambers[ibinX-1],types[ibinY-1],newErr);
0110     }    
0111   }
0112   myfile.close();
0113   
0114   h2->SetStats(0);
0115   eff1->SetGrid();
0116   
0117   gStyle->SetPalette(1);
0118   h2->Draw("colz");  
0119   h3->Draw("sametext45"); 
0120   //gPad->GetFrame()->SetBorderMode(0);
0121   //eff1->GetFrame()->SetBorderMode(0);
0122 }