Go to the documentation of this file.00001 #ifndef CALIBRATABLETEST_H_
00002 #define CALIBRATABLETEST_H_
00003
00004
00005 #include <memory>
00006 #include <vector>
00007
00008 #include "FWCore/Framework/interface/Frameworkfwd.h"
00009 #include "FWCore/Framework/interface/EDAnalyzer.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "FWCore/Framework/interface/MakerMacros.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00015
00016 #include "DataFormats/ParticleFlowReco/interface/Calibratable.h"
00017
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00019 #include "DataFormats/ParticleFlowReco/interface/PFSimParticleFwd.h"
00020 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
00021 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00022 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00023
00024 #include <TTree.h>
00025
00026
00057 class CalibratableTest : public edm::EDAnalyzer {
00058 public:
00059 explicit CalibratableTest(const edm::ParameterSet&);
00060 ~CalibratableTest();
00061
00062
00063
00064
00065 template<class T> void getCollection(edm::Handle<T>& c,
00066 const edm::InputTag& tag, const edm::Event& event) const;
00067
00068 private:
00069
00070
00071
00072 virtual void beginJob();
00073 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00074 virtual void endJob();
00075
00076
00077
00078
00079
00080 virtual void fillTreeAndReset();
00081
00082
00083
00084
00085 std::vector<unsigned> findPrimarySimParticles(
00086 const std::vector<reco::PFSimParticle>& sims);
00087
00088
00089
00090
00091 std::vector<unsigned> findCandidatesInDeltaR(const reco::PFSimParticle& pft,
00092 const std::vector<reco::PFCandidate>& cands, const double& deltaR);
00093
00094
00095
00096
00097 void extractCandidate(const reco::PFCandidate& cand);
00098
00099
00100
00101
00102 double deltaR(const double& eta1, const double& eta2, const double& phi1,
00103 const double& phi2);
00104
00105
00106 TTree* tree_;
00107
00108
00109 edm::Service<TFileService> fileservice_;
00110
00111
00112 int debug_;
00113
00114
00115
00116 bool thisEventPasses_;
00117
00118
00119
00120 bool thisParticlePasses_;
00121
00122
00123 pftools::Calibratable* calib_;
00124
00125
00126
00127 unsigned nParticleWrites_, nParticleFails_;
00128 unsigned nEventWrites_, nEventFails_;
00129
00130
00131 double deltaRCandToSim_;
00132
00133
00134 edm::InputTag inputTagCandidates_;
00135 edm::InputTag inputTagSimParticles_;
00136 edm::InputTag inputTagClustersEcal_;
00137 edm::InputTag inputTagClustersHcal_;
00138
00139
00140 edm::Handle<reco::PFCandidateCollection>* pfCandidates_;
00141 edm::Handle<reco::PFSimParticleCollection>* simParticles_;
00142 edm::Handle<reco::PFClusterCollection>* clustersEcal_;
00143 edm::Handle<reco::PFClusterCollection>* clustersHcal_;
00144
00145 };
00146
00147 template<class T> void CalibratableTest::getCollection(edm::Handle<T>& c,
00148 const edm::InputTag& tag, const edm::Event& event) const {
00149
00150 try {
00151 event.getByLabel(tag, c);
00152 if(!c.isValid()) {
00153 std::cout << "Warning! Collection for label " << tag << " is not valid!" << std::endl;
00154 }
00155 }
00156 catch (cms::Exception& err) {
00157 std::cout << "Couldn't get collection\n";
00158
00159
00160 }
00161 }
00162
00163 #endif