CMS 3D CMS Logo

EcalTPInputAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: EcalTPInputAnalyzer
4 //
10 //
11 //
12 // Original Author: Ursula Berthon
13 // Created: Thu Jul 4 11:38:38 CEST 2005
14 //
15 //
16 
17 // system include files
18 #include <memory>
19 #include <utility>
20 
21 // user include files
24 
27 
30 
33 #include "EcalTPInputAnalyzer.h"
34 
35 using namespace edm;
36 
38 
39 {
40  histfile_ = new TFile("histos.root", "UPDATE");
41  histEndc = new TH1I("AdcE", "Adc-s for Endcap", 100, 0., 5000.);
42  histBar = new TH1I("AdcB", "Adc-s for Barrel", 100, 0., 5000.);
43  ecal_parts_.push_back("Barrel");
44  ecal_parts_.push_back("Endcap");
45 
46  // for (unsigned int i=0;i<2;++i) {
47  // ecal_et_[i]=new TH1I(ecal_parts_[i].c_str(),"Et",255,0,255);
48  // char title[30];
49  // sprintf(title,"%s_ttf",ecal_parts_[i].c_str());
50  // ecal_tt_[i]=new TH1I(title,"TTF",10,0,10);
51  // sprintf(title,"%s_fgvb",ecal_parts_[i].c_str());
52  // ecal_fgvb_[i]=new TH1I(title,"FGVB",10,0,10);
53  // }
54  producer_ = iConfig.getParameter<std::string>("Producer");
55  ebLabel_ = iConfig.getParameter<std::string>("EBLabel");
56  eeLabel_ = iConfig.getParameter<std::string>("EELabel");
57 }
58 
60 
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 
64  histfile_->Write();
65  histfile_->Close();
66 }
67 
68 //
69 // member functions
70 //
71 
72 // ------------ method called to analyze the data ------------
74  const edm::EventSetup &iSetup) {
75  using namespace edm;
76  using namespace std;
77 
78  bool barrel = true;
81  if (!iEvent.getByLabel(producer_, ebLabel_, ebDigis)) {
82  barrel = false;
83  edm::LogWarning("EcalTPG")
84  << " Couldnt find Barrel dataframes with Producer:" << producer_
85  << " and label: " << ebLabel_;
86  }
87  bool endcap = true;
88  if (!iEvent.getByLabel(producer_, eeLabel_, eeDigis)) {
89  endcap = false;
90  edm::LogWarning("EcalTPG")
91  << " Couldnt find Endcap dataframes with Producer:" << producer_
92  << " and label: " << eeLabel_;
93  }
94  // barrel
95  if (barrel) {
96  const EBDigiCollection *ebdb = ebDigis.product();
97  for (unsigned int i = 0; i < ebDigis->size(); ++i) {
98  EBDataFrame ebdf = (*ebdb)[i];
99  int nrSamples = ebdf.size();
100  // unsigned int nrSamples=(ebDigis.product())[i].size();
101  for (int is = 0; is < nrSamples; ++is) {
102  // EcalMGPASample sam=((ebDigis.product())[i])[is];
103  EcalMGPASample sam = ebdf[is];
104  histBar->Fill(sam.adc());
105  }
106  }
107  }
108  // endcap
109  if (endcap) {
110  const EEDigiCollection *eedb = eeDigis.product();
111  for (unsigned int i = 0; i < eeDigis->size(); ++i) {
112  EEDataFrame eedf = (*eedb)[i];
113  int nrSamples = eedf.size();
114  for (int is = 0; is < nrSamples; ++is) {
115  EcalMGPASample sam = eedf[is];
116  histEndc->Fill(sam.adc());
117  }
118  }
119  }
120  // // Get input
121  // edm::Handle<EcalTrigPrimDigiCollection> tp;
122  // iEvent.getByLabel(label_,producer_,tp);
123  // for (unsigned int i=0;i<tp.product()->size();i++) {
124  // EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
125  // int subdet=d.id().subDet()-1;
126  // ecal_et_[subdet]->Fill(d.compressedEt());
127  // ecal_tt_[subdet]->Fill(d.ttFlag());
128  // ecal_fgvb_[subdet]->Fill(d.fineGrain());
129  // }
130 }
131 
133  histEndc->Write();
134  histBar->Write();
135 }
T getParameter(std::string const &) const
void analyze(const edm::Event &, const edm::EventSetup &) override
int size() const
Definition: EcalDataFrame.h:26
int iEvent
Definition: GenABIO.cc:224
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
T const * product() const
Definition: Handle.h:74
HLT enums.
EcalTPInputAnalyzer(const edm::ParameterSet &)
int adc() const
get the ADC sample (12 bits)