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 
26 #include "EcalTPInputAnalyzer.h"
27 
29  : producer_(iConfig.getParameter<std::string>("Producer")),
30  ebLabel_(iConfig.getParameter<std::string>("EBLabel")),
31  eeLabel_(iConfig.getParameter<std::string>("EELabel")),
32  ebToken_(consumes<EBDigiCollection>(edm::InputTag(producer_, ebLabel_))),
33  eeToken_(consumes<EEDigiCollection>(edm::InputTag(producer_, eeLabel_))) {
34  usesResource(TFileService::kSharedResource);
35 
37  histEndc = fs->make<TH1I>("AdcE", "Adc-s for Endcap", 100, 0., 5000.);
38  histBar = fs->make<TH1I>("AdcB", "Adc-s for Barrel", 100, 0., 5000.);
39  ecal_parts_.push_back("Barrel");
40  ecal_parts_.push_back("Endcap");
41 
42  // for (unsigned int i=0;i<2;++i) {
43  // ecal_et_[i] = fs->make<TH1I>(ecal_parts_[i].c_str(),"Et",255,0,255);
44  // char title[30];
45  // sprintf(title,"%s_ttf",ecal_parts_[i].c_str());
46  // ecal_tt_[i] = fs->make<TH1I>(title,"TTF",10,0,10);
47  // sprintf(title,"%s_fgvb",ecal_parts_[i].c_str());
48  // ecal_fgvb_[i] = fs->make<TH1I>(title,"FGVB",10,0,10);
49  // }
50 }
51 
52 //
53 // member functions
54 //
55 
56 // ------------ method called to analyze the data ------------
58  bool barrel = true;
59  const edm::Handle<EBDigiCollection> &ebDigis = iEvent.getHandle(ebToken_);
60  if (!ebDigis.isValid()) {
61  barrel = false;
62  edm::LogWarning("EcalTPG") << " Couldnt find Barrel dataframes with Producer:" << producer_
63  << " and label: " << ebLabel_;
64  }
65  bool endcap = true;
67  if (!eeDigis.isValid()) {
68  endcap = false;
69  edm::LogWarning("EcalTPG") << " Couldnt find Endcap dataframes with Producer:" << producer_
70  << " and label: " << eeLabel_;
71  }
72  // barrel
73  if (barrel) {
74  const EBDigiCollection *ebdb = ebDigis.product();
75  for (unsigned int i = 0; i < ebDigis->size(); ++i) {
76  EBDataFrame ebdf = (*ebdb)[i];
77  int nrSamples = ebdf.size();
78  // unsigned int nrSamples=(ebDigis.product())[i].size();
79  for (int is = 0; is < nrSamples; ++is) {
80  // EcalMGPASample sam=((ebDigis.product())[i])[is];
81  EcalMGPASample sam = ebdf[is];
82  histBar->Fill(sam.adc());
83  }
84  }
85  }
86  // endcap
87  if (endcap) {
88  const EEDigiCollection *eedb = eeDigis.product();
89  for (unsigned int i = 0; i < eeDigis->size(); ++i) {
90  EEDataFrame eedf = (*eedb)[i];
91  int nrSamples = eedf.size();
92  for (int is = 0; is < nrSamples; ++is) {
93  EcalMGPASample sam = eedf[is];
94  histEndc->Fill(sam.adc());
95  }
96  }
97  }
98  // // Get input
99  // const edm::Handle<EcalTrigPrimDigiCollection>& tp = iEvent.getHandle(tpToken_);
100  // for (unsigned int i=0;i<tp.product()->size();i++) {
101  // EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
102  // int subdet=d.id().subDet()-1;
103  // ecal_et_[subdet]->Fill(d.compressedEt());
104  // ecal_tt_[subdet]->Fill(d.ttFlag());
105  // ecal_fgvb_[subdet]->Fill(d.fineGrain());
106  // }
107 }
static const std::string kSharedResource
Definition: TFileService.h:76
void analyze(const edm::Event &, const edm::EventSetup &) override
T const * product() const
Definition: Handle.h:70
const std::string eeLabel_
const edm::EDGetTokenT< EBDigiCollection > ebToken_
int size() const
Definition: EcalDataFrame.h:26
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > ecal_parts_
const std::string producer_
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
int adc() const
get the ADC sample (12 bits)
const std::string ebLabel_
Log< level::Warning, false > LogWarning
const edm::EDGetTokenT< EEDigiCollection > eeToken_
EcalTPInputAnalyzer(const edm::ParameterSet &)