Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-04-02 22:47:37

0001 #include "CondCore/Utilities/interface/PayloadInspectorModule.h"
0002 #include "CondCore/Utilities/interface/PayloadInspector.h"
0003 #include "CondCore/EcalPlugins/plugins/EcalDrawUtils.h"
0004 
0005 // the data format of the condition to be inspected
0006 #include "CondFormats/EcalObjects/interface/EcalSimComponentShape.h"
0007 
0008 #include "TProfile.h"
0009 #include "TCanvas.h"
0010 #include "TStyle.h"
0011 #include "TLine.h"
0012 #include "TLatex.h"
0013 #include "TMarker.h"
0014 
0015 #include <string>
0016 
0017 namespace {
0018   /********************************************
0019       profile of ECAL SimComponentShape for 1 IOV
0020   ********************************************/
0021   class EcalSimComponentShapeProfile : public cond::payloadInspector::PlotImage<EcalSimComponentShape> {
0022   public:
0023     EcalSimComponentShapeProfile()
0024         : cond::payloadInspector::PlotImage<EcalSimComponentShape>("ECAL SimComponentShape - Profile ") {
0025       setSingleIov(true);
0026     }
0027 
0028     bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash> > &iovs) override {
0029       auto iov = iovs.front();
0030       std::shared_ptr<EcalSimComponentShape> payload = fetchPayload(std::get<1>(iov));
0031       unsigned int run = std::get<0>(iov);
0032       std::vector<TProfile *> profiles;
0033       std::vector<int> EBnbins;
0034       std::vector<double> EBxmaxs;
0035       double EBth;
0036       int iShape = 0;
0037       if (payload.get()) {
0038         EBth = (*payload).barrel_thresh;
0039         double time = (*payload).time_interval;
0040         std::vector<std::vector<float> > EBshapes = (*payload).barrel_shapes;
0041         char nameBuffer[50];
0042         for (auto EBshape : EBshapes) {
0043           EBnbins.push_back(EBshape.size());
0044           EBxmaxs.push_back(EBnbins[iShape] * time);
0045           sprintf(nameBuffer, "EBComponentShape_%d", iShape);
0046           profiles.push_back(new TProfile(nameBuffer, "", EBnbins[iShape], 0, EBxmaxs[iShape]));
0047           for (int s = 0; s < EBnbins[iShape]; s++) {
0048             double val = EBshape[s];
0049             profiles[iShape]->Fill(s, val);
0050           }
0051           ++iShape;
0052         }
0053       }  // if payload.get()
0054       else
0055         return false;
0056 
0057       //      gStyle->SetPalette(1);
0058       gStyle->SetOptStat(0);
0059       gStyle->SetPalette(kThermometer);
0060       TCanvas canvas("ESPS", "ESPS", 1000, 500);
0061       TLatex t1;
0062       t1.SetNDC();
0063       t1.SetTextAlign(26);
0064       t1.SetTextSize(0.05);
0065       t1.DrawLatex(0.5, 0.96, Form("Sim Component Shapes, IOV %i", run));
0066 
0067       TPad *pad = new TPad("p_0", "p_0", 0.0, 0.0, 1.0, 0.95);
0068       pad->Draw();
0069       pad->cd();
0070       iShape = 0;
0071       for (auto profile : profiles) {
0072         if (iShape == 0) {
0073           profile->SetXTitle("time (ns)");
0074           profile->SetYTitle("normalized amplitude (ADC#)");
0075           profile->GetXaxis()->SetRangeUser(0., 275.);
0076           profile->GetYaxis()->SetRangeUser(0., 1.25);
0077         }
0078         profile->SetMarkerColor(TColor::GetPalette().At(10 * iShape));
0079         profile->SetLineColor(TColor::GetPalette().At(10 * iShape));
0080         profile->SetMarkerStyle(20);
0081         profile->SetMarkerSize(.25);
0082         if (iShape == 0) {
0083           profile->Draw("");
0084         } else {
0085           profile->Draw("SAME");
0086         }
0087         ++iShape;
0088       }
0089       pad->BuildLegend(.7, .225, .85, .8);
0090       t1.SetTextAlign(12);
0091       t1.DrawLatex(0.4, 0.85, Form("EB component shapes, threshold %f", EBth));
0092 
0093       std::string ImageName(m_imageFileName);
0094       canvas.SaveAs(ImageName.c_str());
0095       return true;
0096     }  // fill method
0097   };
0098 
0099 }  // namespace
0100 
0101 // Register the classes as boost python plugin
0102 PAYLOAD_INSPECTOR_MODULE(EcalSimComponentShape) { PAYLOAD_INSPECTOR_CLASS(EcalSimComponentShapeProfile); }