CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
19 // system include files
20 #include <memory>
21 
22 // user include files
28 
31 
32 #include <vector>
33 #include <string>
34 
35 #include "TH1I.h"
36 #include "TFile.h"
37 
38 using namespace edm;
39 using namespace std;
40 
41 //
42 // class declaration
43 //
44 
45 class TPGCheck : public edm::EDAnalyzer {
46  public:
47  explicit TPGCheck(const edm::ParameterSet&);
48  ~TPGCheck();
49 
50 
51  private:
52  virtual void beginJob() override ;
53  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
54  virtual void endJob() override ;
55 
56  // ----------member data ---------------------------
57  TH1I *ecal_et_[2];
58  TH1I *ecal_tt_[2];
59  TH1I * ecal_fgvb_[2];
60 
61  TFile *histFile_;
64  std::vector<std::string> ecal_parts_;
65  // fix for consumes
67 };
68 
69 //
70 // constructors and destructor
71 //
73 {
74  //now do what ever initialization is needed
75 
76  ecal_parts_.push_back("Barrel");
77  ecal_parts_.push_back("Endcap");
78 
79  histFile_=new TFile("histos.root","RECREATE");
80  for (unsigned int i=0;i<2;++i) {
81  // Energy
82  char t[30];
83  sprintf(t,"%s_energy",ecal_parts_[i].c_str());
84  ecal_et_[i]=new TH1I(t,"Et",255,0,255);
85 
86  // Trigger Tower flag
87  char titleTTF[30];
88  sprintf(titleTTF,"%s_ttf",ecal_parts_[i].c_str());
89  ecal_tt_[i]=new TH1I(titleTTF,"TTF",10,0,10);
90 
91  // Fain Grain
92  char titleFG[30];
93  sprintf(titleFG,"%s_fgvb",ecal_parts_[i].c_str());
94  ecal_fgvb_[i]=new TH1I(titleFG,"FGVB",10,0,10);
95  }
96 
97  label_= iConfig.getParameter<std::string>("Label");
98  producer_= iConfig.getParameter<std::string>("Producer");
99  ecal_tp_token_ = consumes<EcalTrigPrimDigiCollection> (edm::InputTag(label_,producer_));
100 }
101 
102 
104 {
105 
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 
109  histFile_->Write();
110  histFile_->Close();
111 
112 }
113 
114 
115 //
116 // member functions
117 //
118 
119 // ------------ method called to for each event ------------
120 void
122 {
123 
124  // Get input
126  iEvent.getByToken(ecal_tp_token_,tp);
127  for (unsigned int i=0;i<tp.product()->size();i++) {
128  EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
129  int subdet=d.id().subDet()-1;
130  // for endcap, regroup double TP-s that are generated for the 2 interior rings
131  if (subdet==0) {
132  ecal_et_[subdet]->Fill(d.compressedEt());
133  }
134  else {
135  if (d.id().ietaAbs()==27 || d.id().ietaAbs()==28) {
136  if (i%2) ecal_et_[subdet]->Fill(d.compressedEt()*2.);
137  }
138  else ecal_et_[subdet]->Fill(d.compressedEt());
139  }
140  ecal_tt_[subdet]->Fill(d.ttFlag());
141  ecal_fgvb_[subdet]->Fill(d.fineGrain());
142  }
143 }
144 
145 
146 // ------------ method called once each job just before starting event loop ------------
147 void
149 {
150 }
151 
152 // ------------ method called once each job just after ending the event loop ------------
153 void
155  for (unsigned int i=0;i<2;++i) {
156  ecal_et_[i]->Write();
157  ecal_tt_[i]->Write();
158  ecal_fgvb_[i]->Write();
159  }
160 }
161 
162 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::string label_
Definition: TPGCheck.cc:62
TFile * histFile_
Definition: TPGCheck.cc:61
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TPGCheck.cc:121
void beginJob()
Definition: Breakpoints.cc:15
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecal_tp_token_
Definition: TPGCheck.cc:66
tuple d
Definition: ztail.py:151
~TPGCheck()
Definition: TPGCheck.cc:103
int compressedEt() const
get the encoded/compressed Et of interesting sample
int iEvent
Definition: GenABIO.cc:230
virtual void beginJob() override
Definition: TPGCheck.cc:148
int ietaAbs() const
get the absolute value of the tower ieta
const EcalTrigTowerDetId & id() const
T const * product() const
Definition: Handle.h:81
TPGCheck(const edm::ParameterSet &)
Definition: TPGCheck.cc:72
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
virtual void endJob() override
Definition: TPGCheck.cc:154
bool fineGrain() const
get the fine-grain bit of interesting sample
std::vector< std::string > ecal_parts_
Definition: TPGCheck.cc:64
std::string producer_
Definition: TPGCheck.cc:63
int ttFlag() const
get the Trigger tower Flag of interesting sample