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  // do anything here that needs to be done at desctruction time
61  // (e.g. close files, deallocate resources etc.)
62 
63  histfile_->Write();
64  histfile_->Close();
65 }
66 
67 //
68 // member functions
69 //
70 
71 // ------------ method called to analyze the data ------------
73  using namespace edm;
74  using namespace std;
75 
76  bool barrel = true;
79  if (!iEvent.getByLabel(producer_, ebLabel_, ebDigis)) {
80  barrel = false;
81  edm::LogWarning("EcalTPG") << " Couldnt find Barrel dataframes with Producer:" << producer_
82  << " and label: " << ebLabel_;
83  }
84  bool endcap = true;
85  if (!iEvent.getByLabel(producer_, eeLabel_, eeDigis)) {
86  endcap = false;
87  edm::LogWarning("EcalTPG") << " Couldnt find Endcap dataframes with Producer:" << producer_
88  << " and label: " << eeLabel_;
89  }
90  // barrel
91  if (barrel) {
92  const EBDigiCollection *ebdb = ebDigis.product();
93  for (unsigned int i = 0; i < ebDigis->size(); ++i) {
94  EBDataFrame ebdf = (*ebdb)[i];
95  int nrSamples = ebdf.size();
96  // unsigned int nrSamples=(ebDigis.product())[i].size();
97  for (int is = 0; is < nrSamples; ++is) {
98  // EcalMGPASample sam=((ebDigis.product())[i])[is];
99  EcalMGPASample sam = ebdf[is];
100  histBar->Fill(sam.adc());
101  }
102  }
103  }
104  // endcap
105  if (endcap) {
106  const EEDigiCollection *eedb = eeDigis.product();
107  for (unsigned int i = 0; i < eeDigis->size(); ++i) {
108  EEDataFrame eedf = (*eedb)[i];
109  int nrSamples = eedf.size();
110  for (int is = 0; is < nrSamples; ++is) {
111  EcalMGPASample sam = eedf[is];
112  histEndc->Fill(sam.adc());
113  }
114  }
115  }
116  // // Get input
117  // edm::Handle<EcalTrigPrimDigiCollection> tp;
118  // iEvent.getByLabel(label_,producer_,tp);
119  // for (unsigned int i=0;i<tp.product()->size();i++) {
120  // EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
121  // int subdet=d.id().subDet()-1;
122  // ecal_et_[subdet]->Fill(d.compressedEt());
123  // ecal_tt_[subdet]->Fill(d.ttFlag());
124  // ecal_fgvb_[subdet]->Fill(d.fineGrain());
125  // }
126 }
127 
129  histEndc->Write();
130  histBar->Write();
131 }
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:488
T const * product() const
Definition: Handle.h:69
HLT enums.
EcalTPInputAnalyzer(const edm::ParameterSet &)
int adc() const
get the ADC sample (12 bits)