1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// -*- C++ -*-
//
// Package: miscalibExample
// Class: miscalibExample
//
/**\class miscalibExample miscalibExample.cc Calibration/EcalCalibAlgos/src/miscalibExample.cc
Description: Perform single electron calibration (tested on TB data only).
Implementation:
<Notes on implementation>
*/
//
// Original Author: Lorenzo AGOSTINO
// Created: Tue Jul 18 12:17:01 CEST 2006
//
//
// system include files
// user include files
#include "Calibration/EcalCalibAlgos/interface/miscalibExample.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>
#include <stdexcept>
#include <vector>
miscalibExample::miscalibExample(const edm::ParameterSet& iConfig)
: rootfile_{iConfig.getUntrackedParameter<std::string>("rootfile", "ecalSimpleTBanalysis.root")},
correctedHybridSuperClusterProducer_{iConfig.getParameter<std::string>("correctedHybridSuperClusterProducer")},
correctedHybridSuperClusterCollection_{
iConfig.getParameter<std::string>("correctedHybridSuperClusterCollection")},
correctedHybridSuperClusterToken_{consumes<reco::SuperClusterCollection>(
edm::InputTag(correctedHybridSuperClusterProducer_, correctedHybridSuperClusterCollection_))} {}
miscalibExample::~miscalibExample() {}
//========================================================================
void miscalibExample::beginJob() {
//========================================================================
// Book histograms
scEnergy = new TH1F("scEnergy", "SuperCluster energy", 100, 20., 80.);
read_events = 0;
}
//========================================================================
void miscalibExample::endJob() {
//========================================================================
std::cout << "************* STATISTICS **************" << std::endl;
std::cout << "Read Events: " << read_events << std::endl;
/////////////////////////////////////////////////////////////////////////////
TFile f(rootfile_.c_str(), "RECREATE");
scEnergy->Write();
f.Close();
delete scEnergy;
}
//=================================================================================
void miscalibExample::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
//=================================================================================
using namespace edm;
using namespace std;
read_events++;
// Get hybrid super clusters after energy correction
Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
iEvent.getByToken(correctedHybridSuperClusterToken_, pCorrectedHybridSuperClusters);
if (!pCorrectedHybridSuperClusters.isValid()) {
LogError("EgammaSimpleAnalyzer") << "Error! can't get collection with label "
<< correctedHybridSuperClusterCollection_.c_str();
}
const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
reco::SuperClusterCollection::const_iterator superClusterIt;
for (superClusterIt = correctedHybridSuperClusters->begin(); superClusterIt != correctedHybridSuperClusters->end();
superClusterIt++) {
scEnergy->Fill(superClusterIt->energy());
}
}
|