00001 #include "CondFormats/EcalObjects/interface/EcalTPGPedestals.h"
00002
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 #include "CondCore/EcalPlugins/plugins/EcalPyWrapperFunctions.h"
00020
00021 namespace cond {
00022
00023 template<>
00024 class ValueExtractor<EcalTPGPedestals>: public BaseValueExtractor<EcalTPGPedestals> {
00025 public:
00026
00027 typedef EcalTPGPedestals Class;
00028 typedef ExtractWhat<Class> What;
00029 static What what() { return What();}
00030
00031 ValueExtractor(){}
00032 ValueExtractor(What const & what)
00033 {
00034
00035 }
00036 void compute(Class const & it){
00037 }
00038 private:
00039
00040 };
00041
00042 class EcalTPGPedestalsHelper: public EcalPyWrapperHelper<EcalTPGPedestal>{
00043 public:
00044 EcalTPGPedestalsHelper():EcalPyWrapperHelper<EcalObject>(3){}
00045 protected:
00046
00047
00048 typedef EcalTPGPedestal EcalObject;
00049
00050 type_vValues getValues( const std::vector<EcalObject> & vItems)
00051 {
00052 type_vValues vValues(total_values);
00053
00054
00055 vValues[0].first = "mean_x12";
00056 vValues[1].first = "mean_x6";
00057 vValues[2].first = "mean_x1";
00058
00059 vValues[0].second = .0;
00060 vValues[1].second = .0;
00061 vValues[2].second = .0;
00062
00063
00064 for(std::vector<EcalObject>::const_iterator iItems = vItems.begin(); iItems != vItems.end(); ++iItems){
00065
00066 vValues[0].second += iItems->mean_x12;
00067 vValues[1].second += iItems->mean_x6;
00068 vValues[2].second += iItems->mean_x1;
00069 }
00070 return vValues;
00071 }
00072 };
00073
00074 template<>
00075 std::string PayLoadInspector<EcalTPGPedestals>::summary() const {
00076 std::stringstream ss;
00077 EcalTPGPedestalsHelper helper;
00078 ss << helper.printBarrelsEndcaps(object().barrelItems(), object().endcapItems());
00079 return ss.str();
00080 }
00081
00082 template<>
00083 std::string PayLoadInspector<EcalTPGPedestals>::plot(std::string const & filename,
00084 std::string const &,
00085 std::vector<int> const&,
00086 std::vector<float> const& ) const {
00087 gStyle->SetPalette(1);
00088 const int TOTAL_IMAGES = 3;
00089 const int TOTAL_PADS = 3;
00090
00091
00092 const float IMG_SIZE = 1.3;
00093 TCanvas canvas("CC map","CC map",800*IMG_SIZE + 100, 200 * TOTAL_IMAGES*IMG_SIZE);
00094
00095 float xmi[3] = {0.0 , 0.22, 0.78};
00096 float xma[3] = {0.22, 0.78, 1.00};
00097
00098
00099 TPad*** pad = new TPad**[TOTAL_IMAGES];
00100 for (int gId = 0; gId < TOTAL_IMAGES; gId++) {
00101 pad[gId] = new TPad*[TOTAL_PADS];
00102 for (int obj = 0; obj < TOTAL_PADS; obj++) {
00103 float yma = 1. - (0.33 * gId);
00104 float ymi = yma - 0.33;
00105 pad[gId][obj] = new TPad(Form("p_%i_%i", obj, gId),Form("p_%i_%i", obj, gId),
00106 xmi[obj], ymi, xma[obj], yma);
00107 pad[gId][obj]->Draw();
00108 }
00109 }
00110
00111 const int kGains = 3;
00112 const int gainValues[3] = {12, 6, 1};
00113 const int kSides = 2;
00114 const int kBarlRings = EBDetId::MAX_IETA;
00115 const int kBarlWedges = EBDetId::MAX_IPHI;
00116 const int kEndcWedgesX = EEDetId::IX_MAX;
00117 const int kEndcWedgesY = EEDetId::IY_MAX;
00118
00119 TH2F** barrel_m = new TH2F*[3];
00120 TH2F** endc_p_m = new TH2F*[3];
00121 TH2F** endc_m_m = new TH2F*[3];
00122
00123
00124
00125 std::string variableName = "mean_x";
00126 for (int gainId = 0; gainId < kGains; gainId++) {
00127 barrel_m[gainId] = new TH2F(Form((variableName + "EBm%i").c_str(),gainId),Form((variableName + "%i EB").c_str(),gainValues[gainId]),360,0,360, 170, -85,85);
00128 endc_p_m[gainId] = new TH2F(Form((variableName + "EE+m%i").c_str(),gainId),Form((variableName + "%i EE+").c_str(),gainValues[gainId]),100,1,101,100,1,101);
00129 endc_m_m[gainId] = new TH2F(Form((variableName + "EE-m%i").c_str(),gainId),Form((variableName + "%i EE-").c_str(),gainValues[gainId]),100,1,101,100,1,101);
00130
00131
00132
00133 }
00134
00135 for (int sign=0; sign < kSides; sign++) {
00136 int thesign = sign==1 ? 1:-1;
00137
00138 for (int ieta=0; ieta<kBarlRings; ieta++) {
00139 for (int iphi=0; iphi<kBarlWedges; iphi++) {
00140 EBDetId id((ieta+1)*thesign, iphi+1);
00141 float y = -1 - ieta;
00142 if(sign == 1) y = ieta;
00143 barrel_m[0]->Fill(iphi, y, object()[id.rawId()].mean_x12);
00144 barrel_m[1]->Fill(iphi, y, object()[id.rawId()].mean_x6);
00145 barrel_m[2]->Fill(iphi, y, object()[id.rawId()].mean_x1);
00146
00147
00148
00149
00150
00151 }
00152 }
00153
00154 for (int ix=0; ix<kEndcWedgesX; ix++) {
00155 for (int iy=0; iy<kEndcWedgesY; iy++) {
00156 if (! EEDetId::validDetId(ix+1,iy+1,thesign)) continue;
00157 EEDetId id(ix+1,iy+1,thesign);
00158 if (thesign==1) {
00159 endc_p_m[0]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x12);
00160 endc_p_m[1]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x6);
00161 endc_p_m[2]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x1);
00162
00163
00164
00165
00166
00167 }
00168 else{
00169 endc_m_m[0]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x12);
00170 endc_m_m[1]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x6);
00171 endc_m_m[2]->Fill(ix+1,iy+1,object()[id.rawId()].mean_x1);
00172
00173
00174
00175
00176
00177 }
00178 }
00179 }
00180 }
00181
00182
00183
00184
00185
00186
00187 TLine* l = new TLine(0., 0., 0., 0.);
00188 l->SetLineWidth(1);
00189 int ixSectorsEE[202] = {
00190 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 56, 56, 46, 46, 44, 44, 43, 43, 42, 42,
00191 41, 41, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 46, 46, 56, 56, 58, 58, 59, 59,
00192 60, 60, 61, 61, 62, 62, 0,101,101, 98, 98, 96, 96, 93, 93, 88, 88, 86, 86, 81,
00193 81, 76, 76, 66, 66, 61, 61, 41, 41, 36, 36, 26, 26, 21, 21, 16, 16, 14, 14, 9,
00194 9, 6, 6, 4, 4, 1, 1, 4, 4, 6, 6, 9, 9, 14, 14, 16, 16, 21, 21, 26,
00195 26, 36, 36, 41, 41, 61, 61, 66, 66, 76, 76, 81, 81, 86, 86, 88, 88, 93, 93, 96,
00196 96, 98, 98,101,101, 0, 62, 66, 66, 71, 71, 81, 81, 91, 91, 93, 0, 62, 66, 66,
00197 91, 91, 98, 0, 58, 61, 61, 66, 66, 71, 71, 76, 76, 81, 81, 0, 51, 51, 0, 44,
00198 41, 41, 36, 36, 31, 31, 26, 26, 21, 21, 0, 40, 36, 36, 11, 11, 4, 0, 40, 36,
00199 36, 31, 31, 21, 21, 11, 11, 9, 0, 46, 46, 41, 41, 36, 36, 0, 56, 56, 61, 61, 66, 66};
00200
00201 int iySectorsEE[202] = {
00202 51, 56, 56, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 61, 61, 60, 60, 59, 59, 58,
00203 58, 56, 56, 46, 46, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 41, 41, 42, 42, 43,
00204 43, 44, 44, 46, 46, 51, 0, 51, 61, 61, 66, 66, 76, 76, 81, 81, 86, 86, 88, 88,
00205 93, 93, 96, 96, 98, 98,101,101, 98, 98, 96, 96, 93, 93, 88, 88, 86, 86, 81, 81,
00206 76, 76, 66, 66, 61, 61, 41, 41, 36, 36, 26, 26, 21, 21, 16, 16, 14, 14, 9, 9,
00207 6, 6, 4, 4, 1, 1, 4, 4, 6, 6, 9, 9, 14, 14, 16, 16, 21, 21, 26, 26,
00208 36, 36, 41, 41, 51, 0, 46, 46, 41, 41, 36, 36, 31, 31, 26, 26, 0, 51, 51, 56,
00209 56, 61, 61, 0, 61, 61, 66, 66, 71, 71, 76, 76, 86, 86, 88, 0, 62,101, 0, 61,
00210 61, 66, 66, 71, 71, 76, 76, 86, 86, 88, 0, 51, 51, 56, 56, 61, 61, 0, 46, 46,
00211 41, 41, 36, 36, 31, 31, 26, 26, 0, 40, 31, 31, 16, 16, 6, 0, 40, 31, 31, 16, 16, 6};
00212
00213 for (int gId = 0; gId < TOTAL_IMAGES; gId++) {
00214 pad[gId][0]->cd();
00215 endc_m_m[gId]->SetStats(0);
00216
00217
00218 endc_m_m[gId]->Draw("colz");
00219 for ( int i=0; i<201; i=i+1) {
00220 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00221 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00222 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00223 ixSectorsEE[i+1], iySectorsEE[i+1]);
00224 l->SetLineWidth(0.2);
00225 }
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 pad[gId][1]->cd();
00243 barrel_m[gId]->SetStats(0);
00244
00245
00246 barrel_m[gId]->Draw("colz");
00247 for(int i = 0; i <17; i++) {
00248 Double_t x = 20.+ (i *20);
00249 l = new TLine(x,-85.,x,86.);
00250 l->Draw();
00251 }
00252 l = new TLine(0.,0.,360.,0.);
00253 l->Draw();
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 pad[gId][2]->cd();
00270 endc_p_m[gId]->SetStats(0);
00271
00272
00273 endc_p_m[gId]->Draw("colz");
00274 for ( int i=0; i<201; i=i+1) {
00275 if ( (ixSectorsEE[i]!=0 || iySectorsEE[i]!=0) &&
00276 (ixSectorsEE[i+1]!=0 || iySectorsEE[i+1]!=0) ) {
00277 l->DrawLine(ixSectorsEE[i], iySectorsEE[i],
00278 ixSectorsEE[i+1], iySectorsEE[i+1]);
00279 }
00280 }
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 }
00295
00296 canvas.SaveAs(filename.c_str());
00297 return filename;
00298 }
00299
00300 }
00301
00302 PYTHON_WRAPPER(EcalTPGPedestals,EcalTPGPedestals);