Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:42

0001 // -*- C++ -*-
0002 //
0003 // Package:    miscalibExample
0004 // Class:      miscalibExample
0005 //
0006 /**\class miscalibExample miscalibExample.cc Calibration/EcalCalibAlgos/src/miscalibExample.cc
0007 
0008  Description: Perform single electron calibration (tested on TB data only).
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Lorenzo AGOSTINO
0015 //         Created:  Tue Jul 18 12:17:01 CEST 2006
0016 //
0017 //
0018 
0019 // system include files
0020 
0021 // user include files
0022 #include "Calibration/EcalCalibAlgos/interface/miscalibExample.h"
0023 
0024 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0025 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027 
0028 #include <iostream>
0029 #include <stdexcept>
0030 #include <vector>
0031 
0032 miscalibExample::miscalibExample(const edm::ParameterSet& iConfig)
0033     : rootfile_{iConfig.getUntrackedParameter<std::string>("rootfile", "ecalSimpleTBanalysis.root")},
0034       correctedHybridSuperClusterProducer_{iConfig.getParameter<std::string>("correctedHybridSuperClusterProducer")},
0035       correctedHybridSuperClusterCollection_{
0036           iConfig.getParameter<std::string>("correctedHybridSuperClusterCollection")},
0037       correctedHybridSuperClusterToken_{consumes<reco::SuperClusterCollection>(
0038           edm::InputTag(correctedHybridSuperClusterProducer_, correctedHybridSuperClusterCollection_))} {}
0039 
0040 miscalibExample::~miscalibExample() {}
0041 
0042 //========================================================================
0043 void miscalibExample::beginJob() {
0044   //========================================================================
0045 
0046   // Book histograms
0047   scEnergy = new TH1F("scEnergy", "SuperCluster energy", 100, 20., 80.);
0048   read_events = 0;
0049 }
0050 
0051 //========================================================================
0052 void miscalibExample::endJob() {
0053   //========================================================================
0054 
0055   std::cout << "************* STATISTICS **************" << std::endl;
0056   std::cout << "Read Events: " << read_events << std::endl;
0057 
0058   /////////////////////////////////////////////////////////////////////////////
0059 
0060   TFile f(rootfile_.c_str(), "RECREATE");
0061 
0062   scEnergy->Write();
0063   f.Close();
0064   delete scEnergy;
0065 }
0066 
0067 //=================================================================================
0068 void miscalibExample::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069   //=================================================================================
0070   using namespace edm;
0071   using namespace std;
0072 
0073   read_events++;
0074 
0075   // Get hybrid super clusters after energy correction
0076 
0077   Handle<reco::SuperClusterCollection> pCorrectedHybridSuperClusters;
0078 
0079   iEvent.getByToken(correctedHybridSuperClusterToken_, pCorrectedHybridSuperClusters);
0080 
0081   if (!pCorrectedHybridSuperClusters.isValid()) {
0082     LogError("EgammaSimpleAnalyzer") << "Error! can't get collection with label "
0083                                      << correctedHybridSuperClusterCollection_.c_str();
0084   }
0085   const reco::SuperClusterCollection* correctedHybridSuperClusters = pCorrectedHybridSuperClusters.product();
0086 
0087   reco::SuperClusterCollection::const_iterator superClusterIt;
0088   for (superClusterIt = correctedHybridSuperClusters->begin(); superClusterIt != correctedHybridSuperClusters->end();
0089        superClusterIt++) {
0090     scEnergy->Fill(superClusterIt->energy());
0091   }
0092 }