CMS 3D CMS Logo

TPGCheck.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TPGCheck
4 // Class: TPGCheck
5 //
13 //
14 // Original Author: Muriel Cerutti
15 // Created: Thu Oct 26 10:47:17 CEST 2006
16 //
17 
18 // system include files
19 #include <memory>
20 
21 // user include files
27 
30 
31 #include <string>
32 #include <vector>
33 
34 #include "TFile.h"
35 #include "TH1I.h"
36 
37 using namespace edm;
38 using namespace std;
39 
40 //
41 // class declaration
42 //
43 
44 class TPGCheck : public edm::one::EDAnalyzer<> {
45 public:
46  explicit TPGCheck(const edm::ParameterSet &);
47  ~TPGCheck() override;
48 
49 private:
50  void beginJob() override;
51  void analyze(const edm::Event &, const edm::EventSetup &) override;
52  void endJob() override;
53 
54  // ----------member data ---------------------------
55  TH1I *ecal_et_[2];
56  TH1I *ecal_tt_[2];
57  TH1I *ecal_fgvb_[2];
58 
59  TFile *histFile_;
62  std::vector<std::string> ecal_parts_;
63  // fix for consumes
65 };
66 
67 //
68 // constructors and destructor
69 //
71  // now do what ever initialization is needed
72 
73  ecal_parts_.push_back("Barrel");
74  ecal_parts_.push_back("Endcap");
75 
76  histFile_ = new TFile("histos.root", "RECREATE");
77  for (unsigned int i = 0; i < 2; ++i) {
78  // Energy
79  char t[30];
80  sprintf(t, "%s_energy", ecal_parts_[i].c_str());
81  ecal_et_[i] = new TH1I(t, "Et", 255, 0, 255);
82 
83  // Trigger Tower flag
84  char titleTTF[30];
85  sprintf(titleTTF, "%s_ttf", ecal_parts_[i].c_str());
86  ecal_tt_[i] = new TH1I(titleTTF, "TTF", 10, 0, 10);
87 
88  // Fain Grain
89  char titleFG[30];
90  sprintf(titleFG, "%s_fgvb", ecal_parts_[i].c_str());
91  ecal_fgvb_[i] = new TH1I(titleFG, "FGVB", 10, 0, 10);
92  }
93 
94  label_ = iConfig.getParameter<std::string>("Label");
95  producer_ = iConfig.getParameter<std::string>("Producer");
96  ecal_tp_token_ = consumes<EcalTrigPrimDigiCollection>(edm::InputTag(label_, producer_));
97 }
98 
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 
103  histFile_->Write();
104  histFile_->Close();
105 }
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to for each event ------------
112 void TPGCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
113  // Get input
115  iEvent.getByToken(ecal_tp_token_, tp);
116  for (unsigned int i = 0; i < tp.product()->size(); i++) {
117  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
118  int subdet = d.id().subDet() - 1;
119  // for endcap, regroup double TP-s that are generated for the 2 interior
120  // rings
121  if (subdet == 0) {
122  ecal_et_[subdet]->Fill(d.compressedEt());
123  } else {
124  if (d.id().ietaAbs() == 27 || d.id().ietaAbs() == 28) {
125  if (i % 2)
126  ecal_et_[subdet]->Fill(d.compressedEt() * 2.);
127  } else
128  ecal_et_[subdet]->Fill(d.compressedEt());
129  }
130  ecal_tt_[subdet]->Fill(d.ttFlag());
131  ecal_fgvb_[subdet]->Fill(d.fineGrain());
132  }
133 }
134 
135 // ------------ method called once each job just before starting event loop
136 // ------------
138 
139 // ------------ method called once each job just after ending the event loop
140 // ------------
142  for (unsigned int i = 0; i < 2; ++i) {
143  ecal_et_[i]->Write();
144  ecal_tt_[i]->Write();
145  ecal_fgvb_[i]->Write();
146  }
147 }
148 
149 // define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string label_
Definition: TPGCheck.cc:60
TFile * histFile_
Definition: TPGCheck.cc:59
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TPGCheck.cc:112
void beginJob()
Definition: Breakpoints.cc:14
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecal_tp_token_
Definition: TPGCheck.cc:64
int iEvent
Definition: GenABIO.cc:224
void beginJob() override
Definition: TPGCheck.cc:137
~TPGCheck() override
Definition: TPGCheck.cc:99
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
d
Definition: ztail.py:151
TPGCheck(const edm::ParameterSet &)
Definition: TPGCheck.cc:70
void endJob() override
Definition: TPGCheck.cc:141
HLT enums.
std::vector< std::string > ecal_parts_
Definition: TPGCheck.cc:62
std::string producer_
Definition: TPGCheck.cc:61