00001 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00002 #include "CondTools/Ecal/interface/EcalGainRatiosXMLTranslator.h"
00003 #include "CondTools/Ecal/interface/EcalCondHeader.h"
00004 #include "TH2F.h"
00005 #include "TCanvas.h"
00006 #include "TLine.h"
00007 #include "TStyle.h"
00008 #include "TPave.h"
00009 #include "TPaveStats.h"
00010 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00011 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00012
00013 #include "CondCore/Utilities/interface/PayLoadInspector.h"
00014 #include "CondCore/Utilities/interface/InspectorPythonWrapper.h"
00015
00016 #include <string>
00017 #include <fstream>
00018
00019 namespace cond {
00020
00021 template<>
00022 class ValueExtractor<EcalGainRatios>: public BaseValueExtractor<EcalGainRatios> {
00023 public:
00024
00025 typedef EcalGainRatios Class;
00026 typedef ExtractWhat<Class> What;
00027 static What what() { return What();}
00028
00029 ValueExtractor(){}
00030 ValueExtractor(What const & what)
00031 {
00032
00033 }
00034 void compute(Class const & it){
00035 }
00036 private:
00037
00038 };
00039
00040
00041 template<>
00042 std::string
00043 PayLoadInspector<EcalGainRatios>::dump() const {
00044
00045
00046 std::stringstream ss;
00047 EcalCondHeader header;
00048 ss<<EcalGainRatiosXMLTranslator::dumpXML(header,object());
00049 return ss.str();
00050
00051 }
00052
00053 template<>
00054 std::string PayLoadInspector<EcalGainRatios>::summary() const {
00055
00056 std::stringstream ss;
00057 return ss.str();
00058 }
00059
00060
00061 template<>
00062 std::string PayLoadInspector<EcalGainRatios>::plot(std::string const & filename,
00063 std::string const &,
00064 std::vector<int> const&,
00065 std::vector<float> const& ) const {
00066 gStyle->SetPalette(1);
00067 TCanvas canvas("CC map","CC map",840,600);
00068 float xmi[3] = {0.0 , 0.22, 0.78};
00069 float xma[3] = {0.22, 0.78, 1.00};
00070 TPad*** pad = new TPad**[2];
00071 for (int gId = 0; gId < 2; gId++) {
00072 pad[gId] = new TPad*[3];
00073 for (int obj = 0; obj < 3; obj++) {
00074 float yma = 1.- (0.34 * gId);
00075 float ymi = yma - 0.32;
00076 pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId),Form("p_%i_%i", obj, gId),
00077 xmi[obj], ymi, xma[obj], yma);
00078 pad[gId][obj]->Draw();
00079 }
00080 }
00081 TPad** pad1 = new TPad*[4];
00082 for (int obj = 0; obj < 4; obj++) {
00083 float xmi = 0.26 * obj;
00084 float xma = xmi + 0.22;
00085 pad1[obj] = new TPad(Form("p1_%i", obj),Form("p1_%i", obj),
00086 xmi, 0.0, xma, 0.32);
00087 pad1[obj]->Draw();
00088 }
00089 const int kSides = 2;
00090 const int kBarlRings = EBDetId::MAX_IETA;
00091 const int kBarlWedges = EBDetId::MAX_IPHI;
00092 const int kEndcWedgesX = EEDetId::IX_MAX;
00093 const int kEndcWedgesY = EEDetId::IY_MAX;
00094
00095 TH2F* barrel_12O6 = new TH2F("EB_12O6","EB gain 12/6",360,0,360, 170, -85,85);
00096 TH2F* endc_p_12O6 = new TH2F("EE+_12O6","EE+ gain 12/6",100,1,101,100,1,101);
00097 TH2F* endc_m_12O6 = new TH2F("EE-_12O6","EE- gain 12/6",100,1,101,100,1,101);
00098 TH2F* barrel_6O1 = new TH2F("EB_6O1","EB gain 6/1",360,0,360, 170, -85,85);
00099 TH2F* endc_p_6O1 = new TH2F("EE+_6O1","EE+ gain 6/1",100,1,101,100,1,101);
00100 TH2F* endc_m_6O1 = new TH2F("EE-_6O1","EE- gain 6/1",100,1,101,100,1,101);
00101 TH1F* b_12O6 = new TH1F("b_12O6","EB gain 12/6", 50, 1.8, 2.1);
00102 TH1F* e_12O6 = new TH1F("e_12O6","EE gain 12/6", 50, 1.8, 2.1);
00103 TH1F* b_6O1 = new TH1F("b_6O1","EB gain 6/1", 50, 5.35, 5.85);
00104 TH1F* e_6O1 = new TH1F("e_6O1","EE gain 6/1", 50, 5.35, 5.85);
00105
00106 for (int sign=0; sign < kSides; sign++) {
00107 int thesign = sign==1 ? 1:-1;
00108
00109 for (int ieta=0; ieta<kBarlRings; ieta++) {
00110 for (int iphi=0; iphi<kBarlWedges; iphi++) {
00111 EBDetId id((ieta+1)*thesign, iphi+1);
00112 float y = -1 - ieta;
00113 if(sign == 1) y = ieta;
00114 barrel_12O6->Fill(iphi, y, object()[id.rawId()].gain12Over6());
00115 barrel_6O1->Fill(iphi, y, object()[id.rawId()].gain6Over1());
00116 b_12O6->Fill(object()[id.rawId()].gain12Over6());
00117 b_6O1->Fill(object()[id.rawId()].gain6Over1());
00118 }
00119 }
00120
00121 for (int ix=0; ix<kEndcWedgesX; ix++) {
00122 for (int iy=0; iy<kEndcWedgesY; iy++) {
00123 if (! EEDetId::validDetId(ix+1,iy+1,thesign)) continue;
00124 EEDetId id(ix+1,iy+1,thesign);
00125 if (thesign==1) {
00126 endc_p_12O6->Fill(ix+1,iy+1,object()[id.rawId()].gain12Over6());
00127 endc_p_6O1->Fill(ix+1,iy+1,object()[id.rawId()].gain6Over1());
00128 }
00129 else{
00130 endc_m_12O6->Fill(ix+1,iy+1,object()[id.rawId()].gain12Over6());
00131 endc_m_6O1->Fill(ix+1,iy+1,object()[id.rawId()].gain6Over1());
00132 }
00133 e_12O6->Fill(object()[id.rawId()].gain12Over6());
00134 e_6O1->Fill(object()[id.rawId()].gain6Over1());
00135 }
00136 }
00137 }
00138
00139 TLine* l = new TLine(0., 0., 0., 0.);
00140 l->SetLineWidth(1);
00141 int ixSectorsEE[202] = {
00142 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 56, 56, 46, 46, 44, 44, 43, 43, 42, 42,
00143 41, 41, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 46, 46, 56, 56, 58, 58, 59, 59,
00144 60, 60, 61, 61, 62, 62, 0,101,101, 98, 98, 96, 96, 93, 93, 88, 88, 86, 86, 81,
00145 81, 76, 76, 66, 66, 61, 61, 41, 41, 36, 36, 26, 26, 21, 21, 16, 16, 14, 14, 9,
00146 9, 6, 6, 4, 4, 1, 1, 4, 4, 6, 6, 9, 9, 14, 14, 16, 16, 21, 21, 26,
00147 26, 36, 36, 41, 41, 61, 61, 66, 66, 76, 76, 81, 81, 86, 86, 88, 88, 93, 93, 96,
00148 96, 98, 98,101,101, 0, 62, 66, 66, 71, 71, 81, 81, 91, 91, 93, 0, 62, 66, 66,
00149 91, 91, 98, 0, 58, 61, 61, 66, 66, 71, 71, 76, 76, 81, 81, 0, 51, 51, 0, 44,
00150 41, 41, 36, 36, 31, 31, 26, 26, 21, 21, 0, 40, 36, 36, 11, 11, 4, 0, 40, 36,
00151 36, 31, 31, 21, 21, 11, 11, 9, 0, 46, 46, 41, 41, 36, 36, 0, 56, 56, 61, 61, 66, 66};
00152
00153 int iySectorsEE[202] = {
00154 51, 56, 56, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 61, 61, 60, 60, 59, 59, 58,
00155 58, 56, 56, 46, 46, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 41, 41, 42, 42, 43,
00156 43, 44, 44, 46, 46, 51, 0, 51, 61, 61, 66, 66, 76, 76, 81, 81, 86, 86, 88, 88,
00157 93, 93, 96, 96, 98, 98,101,101, 98, 98, 96, 96, 93, 93, 88, 88, 86, 86, 81, 81,
00158 76, 76, 66, 66, 61, 61, 41, 41, 36, 36, 26, 26, 21, 21, 16, 16, 14, 14, 9, 9,
00159 6, 6, 4, 4, 1, 1, 4, 4, 6, 6, 9, 9, 14, 14, 16, 16, 21, 21, 26, 26,
00160 36, 36, 41, 41, 51, 0, 46, 46, 41, 41, 36, 36, 31, 31, 26, 26, 0, 51, 51, 56,
00161 56, 61, 61, 0, 61, 61, 66, 66, 71, 71, 76, 76, 86, 86, 88, 0, 62,101, 0, 61,
00162 61, 66, 66, 71, 71, 76, 76, 86, 86, 88, 0, 51, 51, 56, 56, 61, 61, 0, 46, 46,
00163 41, 41, 36, 36, 31, 31, 26, 26, 0, 40, 31, 31, 16, 16, 6, 0, 40, 31, 31, 16, 16, 6};
00164
00165 float min12O6 = 1.9, max12O6 = 2.0, min6O1 = 5.4, max6O1 = 5.8;
00166 pad[0][0]->cd();
00167 endc_m_12O6->SetStats(0);
00168 endc_m_12O6->SetMaximum(max12O6);
00169 endc_m_12O6->SetMinimum(min12O6);
00170 endc_m_12O6->Draw("colz");
00171 for ( int i=0; i<201; i=i+1) {
00172 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00173 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00174 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00175 ixSectorsEE[i+1], iySectorsEE[i+1]);
00176 l->SetLineWidth(0.2);
00177 }
00178 }
00179 pad[0][1]->cd();
00180 barrel_12O6->SetStats(0);
00181 barrel_12O6->SetMaximum(max12O6);
00182 barrel_12O6->SetMinimum(min12O6);
00183 barrel_12O6->Draw("colz");
00184 for(int i = 0; i <17; i++) {
00185 Double_t x = 20.+ (i *20);
00186 l = new TLine(x,-85.,x,86.);
00187 l->Draw();
00188 }
00189 l = new TLine(0.,0.,360.,0.);
00190 l->Draw();
00191 pad[0][2]->cd();
00192 endc_p_12O6->SetStats(0);
00193 endc_p_12O6->SetMaximum(max12O6);
00194 endc_p_12O6->SetMinimum(min12O6);
00195 endc_p_12O6->Draw("colz");
00196 for ( int i=0; i<201; i=i+1) {
00197 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00198 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00199 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00200 ixSectorsEE[i+1], iySectorsEE[i+1]);
00201 l->SetLineWidth(0.2);
00202 }
00203 }
00204 pad[1][0]->cd();
00205 endc_m_6O1->SetStats(0);
00206 endc_m_6O1->SetMaximum(max6O1);
00207 endc_m_6O1->SetMinimum(min6O1);
00208 endc_m_6O1->Draw("colz");
00209 for ( int i=0; i<201; i=i+1) {
00210 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00211 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00212 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00213 ixSectorsEE[i+1], iySectorsEE[i+1]);
00214 l->SetLineWidth(0.2);
00215 }
00216 }
00217 pad[1][1]->cd();
00218 barrel_6O1->SetStats(0);
00219 barrel_6O1->SetMaximum(max6O1);
00220 barrel_6O1->SetMinimum(min6O1);
00221 barrel_6O1->Draw("colz");
00222 for(int i = 0; i <17; i++) {
00223 Double_t x = 20.+ (i *20);
00224 l = new TLine(x,-85.,x,86.);
00225 l->Draw();
00226 }
00227 l = new TLine(0.,0.,360.,0.);
00228 l->Draw();
00229 pad[1][2]->cd();
00230 endc_p_6O1->SetStats(0);
00231 endc_p_6O1->SetMaximum(max6O1);
00232 endc_p_6O1->SetMinimum(min6O1);
00233 endc_p_6O1->Draw("colz");
00234 for ( int i=0; i<201; i=i+1) {
00235 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00236 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00237 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00238 ixSectorsEE[i+1], iySectorsEE[i+1]);
00239 l->SetLineWidth(0.2);
00240 }
00241 }
00242
00243 gStyle->SetOptStat(111110);
00244 pad1[0]->cd();
00245 b_12O6->Draw();
00246 pad1[0]->Update();
00247 TPaveStats *st = (TPaveStats*)b_12O6->FindObject("stats");
00248 st->SetX1NDC(0.6);
00249 st->SetY1NDC(0.75);
00250 pad1[1]->cd();
00251 e_12O6->Draw();
00252 pad1[0]->Update();
00253 st = (TPaveStats*)e_12O6->FindObject("stats");
00254 st->SetX1NDC(0.6);
00255 st->SetY1NDC(0.75);
00256 pad1[2]->cd();
00257 b_6O1->Draw();
00258 pad1[0]->Update();
00259 st = (TPaveStats*)b_6O1->FindObject("stats");
00260 st->SetX1NDC(0.6);
00261 st->SetY1NDC(0.75);
00262 pad1[3]->cd();
00263 e_6O1->Draw();
00264 pad1[0]->Update();
00265 st = (TPaveStats*)e_6O1->FindObject("stats");
00266 st->SetX1NDC(0.6);
00267 st->SetY1NDC(0.75);
00268
00269 canvas.SaveAs(filename.c_str());
00270 return filename;
00271 }
00272
00273
00274 }
00275
00276 PYTHON_WRAPPER(EcalGainRatios,EcalGainRatios);