CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: EcalTPInputAnalyzer.cc,v 1.5 2008/01/17 13:40:52 uberthon Exp $
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 #include <utility>
22 
23 // user include files
26 
29 
32 
33 #include "EcalTPInputAnalyzer.h"
36 
37 using namespace edm;
38 
40 
41 {
42  histfile_=new TFile("histos.root","UPDATE");
43  histEndc = new TH1I("AdcE","Adc-s for Endcap",100,0.,5000.);
44  histBar = new TH1I("AdcB","Adc-s for Barrel",100,0.,5000.);
45  ecal_parts_.push_back("Barrel");
46  ecal_parts_.push_back("Endcap");
47 
48 // for (unsigned int i=0;i<2;++i) {
49 // ecal_et_[i]=new TH1I(ecal_parts_[i].c_str(),"Et",255,0,255);
50 // char title[30];
51 // sprintf(title,"%s_ttf",ecal_parts_[i].c_str());
52 // ecal_tt_[i]=new TH1I(title,"TTF",10,0,10);
53 // sprintf(title,"%s_fgvb",ecal_parts_[i].c_str());
54 // ecal_fgvb_[i]=new TH1I(title,"FGVB",10,0,10);
55 // }
56  producer_= iConfig.getParameter<std::string>("Producer");
57  ebLabel_= iConfig.getParameter<std::string>("EBLabel");
58  eeLabel_= iConfig.getParameter<std::string>("EELabel");
59 }
60 
61 
63 {
64 
65  // do anything here that needs to be done at desctruction time
66  // (e.g. close files, deallocate resources etc.)
67 
68  histfile_->Write();
69  histfile_->Close();
70 
71 }
72 
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to analyze the data ------------
79 void
81 {
82  using namespace edm;
83  using namespace std;
84 
85  bool barrel=true;
88  if (!iEvent.getByLabel(producer_,ebLabel_,ebDigis)) {
89  barrel=false;
90  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel dataframes with Producer:"<<producer_<<" and label: "<<ebLabel_;
91  }
92  bool endcap=true;
93  if (!iEvent.getByLabel(producer_,eeLabel_,eeDigis)) {
94  endcap=false;
95  edm::LogWarning("EcalTPG") <<" Couldnt find Endcap dataframes with Producer:"<<producer_<<" and label: "<<eeLabel_;
96  }
97  //barrel
98  if (barrel) {
99  const EBDigiCollection *ebdb=ebDigis.product();
100  for (unsigned int i=0;i<ebDigis->size();++i) {
101  EBDataFrame ebdf=(*ebdb)[i];
102  int nrSamples=ebdf.size();
103  //unsigned int nrSamples=(ebDigis.product())[i].size();
104  for (int is=0;is<nrSamples;++is) {
105  // EcalMGPASample sam=((ebDigis.product())[i])[is];
106  EcalMGPASample sam=ebdf[is];
107  histBar->Fill(sam.adc());
108  }
109  }
110  }
111  //endcap
112  if (endcap) {
113  const EEDigiCollection *eedb=eeDigis.product();
114  for (unsigned int i=0;i<eeDigis->size();++i) {
115  EEDataFrame eedf=(*eedb)[i];
116  int nrSamples=eedf.size();
117  for (int is=0;is<nrSamples;++is) {
118  EcalMGPASample sam=eedf[is];
119  histEndc->Fill(sam.adc());
120  }
121  }
122  }
123 // // Get input
124 // edm::Handle<EcalTrigPrimDigiCollection> tp;
125 // iEvent.getByLabel(label_,producer_,tp);
126 // for (unsigned int i=0;i<tp.product()->size();i++) {
127 // EcalTriggerPrimitiveDigi d=(*(tp.product()))[i];
128 // int subdet=d.id().subDet()-1;
129 // ecal_et_[subdet]->Fill(d.compressedEt());
130 // ecal_tt_[subdet]->Fill(d.ttFlag());
131 // ecal_fgvb_[subdet]->Fill(d.fineGrain());
132 // }
133 }
134 
135 void
137  histEndc ->Write();
138  histBar ->Write();
139 }
140 
141 
142 
143 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
int size() const
Definition: EcalDataFrame.h:27
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
EcalTPInputAnalyzer(const edm::ParameterSet &)
int adc() const
get the ADC sample (12 bits)