CMS 3D CMS Logo

CherenkovAnalysis.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CherenkovAnalysis
4 // Class: CherenkovAnalysis
5 //
14 //
15 // Original Author: Frederic Ronga
16 // Created: Wed Mar 12 17:39:55 CET 2008
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
27 
30 
33 
36 
39 #include <TH1F.h>
40 
41 #define EDM_ML_DEBUG
42 
44 public:
45  explicit CherenkovAnalysis(const edm::ParameterSet &);
46  ~CherenkovAnalysis() override {}
47 
48 private:
50  TH1F *hEnergy_;
51  double maxEnergy_;
53 
55 
56  void beginJob() override {}
57  void analyze(const edm::Event &, const edm::EventSetup &) override;
58  void endJob() override {}
59 };
60 
61 //__________________________________________________________________________________________________
63  : maxEnergy_(iConfig.getParameter<double>("maxEnergy")),
64  nBinsEnergy_(iConfig.getParameter<unsigned>("nBinsEnergy")) {
65  tok_calo_ = consumes<edm::PCaloHitContainer>(iConfig.getParameter<edm::InputTag>("caloHitSource"));
66 
67  // Book histograms
69 
70  if (!tfile.isAvailable())
71  throw cms::Exception("BadConfig") << "TFileService unavailable: "
72  << "please add it to config file";
73 
74  hEnergy_ = tfile->make<TH1F>("hEnergy", "Total energy deposit [GeV]", nBinsEnergy_, 0, maxEnergy_);
75  hTimeStructure_ = tfile->make<TH1F>("hTimeStructure", "Time structure [ns]", 100, 0, 0.3);
76 }
77 
78 //__________________________________________________________________________________________________
81  iEvent.getByToken(tok_calo_, pCaloHits);
82 
83  double totalEnergy = 0;
84 
85  // Loop on all hits and calculate total energy loss
86  edm::PCaloHitContainer::const_iterator it = pCaloHits.product()->begin();
87  edm::PCaloHitContainer::const_iterator itend = pCaloHits.product()->end();
88  for (; it != itend; ++it) {
89  totalEnergy += (*it).energy();
90  hTimeStructure_->Fill((*it).time(),
91  (*it).energy()); // Time weighted by energy...
92  // edm::LogInfo("CherenkovAnalysis") << "Time = " << (*it).time() <<
93  // std::endl;
94  }
95 #ifdef EDM_ML_DEBUG
96  edm::LogVerbatim("CherenkovAnalysis") << "CherenkovAnalysis::Total energy = " << totalEnergy;
97 #endif
98  hEnergy_->Fill(totalEnergy);
99 }
100 
MessageLogger.h
CherenkovAnalysis::hTimeStructure_
TH1F * hTimeStructure_
Definition: CherenkovAnalysis.cc:54
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CherenkovAnalysis
Definition: CherenkovAnalysis.cc:43
edm::EDGetTokenT< edm::PCaloHitContainer >
CherenkovAnalysis::~CherenkovAnalysis
~CherenkovAnalysis() override
Definition: CherenkovAnalysis.cc:46
CherenkovAnalysis::maxEnergy_
double maxEnergy_
Definition: CherenkovAnalysis.cc:51
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
CherenkovAnalysis::hEnergy_
TH1F * hEnergy_
Definition: CherenkovAnalysis.cc:50
MakerMacros.h
CherenkovAnalysis::beginJob
void beginJob() override
Definition: CherenkovAnalysis.cc:56
CherenkovAnalysis::endJob
void endJob() override
Definition: CherenkovAnalysis.cc:58
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
tfile
Definition: tfile.py:1
CherenkovAnalysis::CherenkovAnalysis
CherenkovAnalysis(const edm::ParameterSet &)
Definition: CherenkovAnalysis.cc:62
TFileService.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PCaloHit.h
CherenkovAnalysis::nBinsEnergy_
int nBinsEnergy_
Definition: CherenkovAnalysis.cc:52
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
CherenkovAnalysis::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: CherenkovAnalysis.cc:79
InputTag.h
compare.tfile
tfile
Definition: compare.py:325
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CherenkovAnalysis::tok_calo_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_calo_
Definition: CherenkovAnalysis.cc:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PCaloHitContainer.h
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15