Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /DQM/DTMonitorModule/test/plotEfficiency.r is written in an unsupported language. File is not indexed.

0001 
0002 /*
0003  * Produces 1D plots of chamber efficiency starting from the DQM output files
0004  * of the DTChamberEfficiency and DTChamberEfficiencyTest modules.
0005  * 
0006  * 
0007  * G. Cerminara 2009
0008  */
0009 #if !defined(__CINT) || defined(__MAKECINT__)
0010 #include "TH2F.h"
0011 #include "TCanvas.h"
0012 #include "TGraphErrors.h"
0013 #include "TStyle.h"
0014 #include "TFile.h"
0015 // #include "macros.C"
0016 #include <vector>
0017 #endif
0018 
0019 using namespace std;
0020 
0021 vector<TGraphErrors *> plotEffwh(const TH2F *hEffDQM) {
0022   vector<TGraphErrors *> ret;
0023   if(hEffDQM != 0) {
0024     TCanvas *c = newCanvas(hEffDQM->GetName(), hEffDQM->GetName());
0025     hEffDQM->Draw("COLZ");
0026     double sector[12];
0027     double sectErr[12];    
0028 
0029     double effiency[4][12];
0030     double efficiencyErr[4][12];
0031     cout << "D-1" << endl;
0032     for(int station = 1; station != 5; ++station) { //loop over stations
0033       for(int sect = 1; sect != 13; ++sect) { // loop over sectors
0034         sector[sect-1] = sect;
0035         effiency[station-1][sect-1] = hEffDQM->GetBinContent(sect,station);
0036         efficiencyErr[station-1][sect-1] = hEffDQM->GetBinError(sect,station);
0037         sectErr[sect-1] = 0.5;
0038       }
0039     }
0040     cout << "D-0.5" << endl;
0041 
0042     ret.push_back(new TGraphErrors(12, sector, effiency[0], sectErr, efficiencyErr[0]));
0043     ret.push_back(new TGraphErrors(12, sector, effiency[1], sectErr, efficiencyErr[1]));
0044     ret.push_back(new TGraphErrors(12, sector, effiency[2], sectErr, efficiencyErr[2]));
0045     ret.push_back(new TGraphErrors(12, sector, effiency[3], sectErr, efficiencyErr[3]));
0046     cout << "D0" << endl;
0047     cout << " ret.size() : " << ret.size() << endl;
0048     return ret;
0049   } else return ret;
0050 }
0051 
0052 
0053 void plotEfficiency(){
0054   // Load needed macros and files
0055   gROOT->LoadMacro("macros.C");     // Load service macros
0056 
0057   // Get the style
0058   TStyle * style = getStyle("tdr");
0059   style->cd();
0060   
0061   // retrieve the last open file
0062   TFile *file = (TFile *)(gROOT->GetListOfFiles()->Last());
0063   if(file == 0) {
0064     cout << "No file loaded!Exiting." << endl;
0065     return;
0066   }
0067   cout << "Loading file: " << file->GetName() << endl;
0068   
0069   // retrieve the original histos from the file
0070   TH2F *histoEff_Whm2 = (TH2F *) file->Get("DQMData/Run 109459/DT/Run summary/05-ChamberEff/EfficiencyMap_All_W-2");
0071 
0072   
0073 
0074 //   if(histoEff_Whm2 != 0) {
0075 //     TCanvas *c = newCanvas(histoEff_Whm2->GetName(), histoEff_Whm2->GetName());
0076 //     histoEff_Whm2->Draw("COLZ");
0077 //     double sector[12];
0078 //     double sectErr[12];    
0079 
0080 //     double effiency[4][12];
0081 //     double efficiencyErr[4][12];
0082 
0083 //     for(int station = 1; station != 5; ++station) { //loop over stations
0084 //       for(int sect = 1; sect != 13; ++sect) { // loop over sectors
0085 //      sector[sect-1] = sect;
0086 //      effiency[station-1][sect-1] = histoEff_Whm2->GetBinContent(sect,station);
0087 //      efficiencyErr[station-1][sect-1] = histoEff_Whm2->GetBinError(sect,station);
0088 //      sectErr[sect-1] = 0.5;
0089 //       }
0090 //     }
0091 
0092 
0093 //     TGraphErrors *mb1Eff_Whm2 = new TGraphErrors(12, sector, effiency[0], sectErr, efficiencyErr[0]);
0094 //     TGraphErrors *mb2Eff_Whm2 = new TGraphErrors(12, sector, effiency[1], sectErr, efficiencyErr[1]);
0095 //     TGraphErrors *mb3Eff_Whm2 = new TGraphErrors(12, sector, effiency[2], sectErr, efficiencyErr[2]);
0096 //     TGraphErrors *mb4Eff_Whm2 = new TGraphErrors(12, sector, effiency[3], sectErr, efficiencyErr[3]);
0097 
0098 
0099     vector<TGraphErrors *> graphsWhM2 = plotEffwh(histoEff_Whm2);
0100     cout << "DD" << endl;
0101     cout << " size: " << graphsWhM2.size() << endl;
0102     cout << " " << (int)  graphsWhM2[0] << " "
0103          << (int)  graphsWhM2[1] << " "
0104          << (int)  graphsWhM2[2] << " "
0105          << (int)  graphsWhM2[3] << " " << endl;
0106 
0107     TGraphErrors *mb1Eff_Whm2 = graphsWhM2[0];
0108     TGraphErrors *mb2Eff_Whm2 = graphsWhM2[1];
0109     TGraphErrors *mb3Eff_Whm2 = graphsWhM2[2];
0110     TGraphErrors *mb4Eff_Whm2 = graphsWhM2[3];
0111 
0112     cout << "D1" << endl;
0113 
0114     TCanvas *c1 = newCanvas("Efficiency_Whm2", "Efficiency_Whm2");
0115     mb1Eff_Whm2->Draw("AP");
0116     mb1Eff_Whm2->SetMarkerColor(1);
0117 
0118     mb2Eff_Whm2->Draw("P");
0119     mb2Eff_Whm2->SetMarkerColor(2);
0120     mb3Eff_Whm2->Draw("P");
0121     mb3Eff_Whm2->SetMarkerColor(3);
0122     mb4Eff_Whm2->Draw("P");
0123     mb4Eff_Whm2->SetMarkerColor(4);
0124 
0125     
0126 //   }
0127 
0128 }
0129