CMS 3D CMS Logo

ProducerAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 
3 // user include files
4 
18 
19 using namespace reco;
20 
21 namespace cms {
22 
23  //
24  // constructors and destructor
25  //
26  ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig) {
27  // get name of output file with histogramms
28 
29  nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
30  jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo", "GammaJetJetBackToBackCollection");
31  gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus", "GammaJetGammaBackToBackCollection");
32  ecalInput_ = iConfig.getUntrackedParameter<std::string>("ecalInput", "GammaJetEcalRecHitCollection");
33  hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
34  hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
35  hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
36  Tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks", "GammaJetTracksCollection");
37 
38  tok_hovar_ = consumes<HOCalibVariableCollection>(edm::InputTag(nameProd_, hoInput_));
39  tok_horeco_ = consumes<HORecHitCollection>(edm::InputTag("horeco"));
40  tok_ho_ = consumes<HORecHitCollection>(edm::InputTag(hoInput_));
41  tok_hoProd_ = consumes<HORecHitCollection>(edm::InputTag(nameProd_, hoInput_));
42 
43  tok_hf_ = consumes<HFRecHitCollection>(edm::InputTag(hfInput_));
44 
45  tok_jets_ = consumes<reco::CaloJetCollection>(edm::InputTag(nameProd_, jetCalo_));
46  tok_gamma_ = consumes<reco::SuperClusterCollection>(edm::InputTag(nameProd_, gammaClus_));
47  tok_muons_ = consumes<reco::MuonCollection>(edm::InputTag(nameProd_, "SelectedMuons"));
48  tok_ecal_ = consumes<EcalRecHitCollection>(edm::InputTag(nameProd_, ecalInput_));
49  tok_tracks_ = consumes<reco::TrackCollection>(edm::InputTag(nameProd_, Tracks_));
50 
51  tok_hbheProd_ = consumes<HBHERecHitCollection>(edm::InputTag(nameProd_, hbheInput_));
52  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag(hbheInput_));
53  }
54 
55  ProducerAnalyzer::~ProducerAnalyzer() {
56  // do anything here that needs to be done at desctruction time
57  // (e.g. close files, deallocate resources etc.)
58  }
59 
61 
62  void ProducerAnalyzer::endJob() {}
63 
64  //
65  // member functions
66  //
67 
68  // ------------ method called to produce the data ------------
70  using namespace edm;
71 
73  iSetup.get<CaloGeometryRecord>().get(pG);
74  const CaloGeometry* geo = pG.product();
75 
76  std::vector<StableProvenance const*> theProvenance;
77  iEvent.getAllStableProvenance(theProvenance);
78  for (auto const& provenance : theProvenance) {
79  edm::LogVerbatim("HcalAlCa") << " Print all module/label names " << provenance->moduleName() << " "
80  << provenance->moduleLabel() << " " << provenance->productInstanceName();
81  }
82 
83  if (nameProd_ == "hoCalibProducer") {
85  iEvent.getByToken(tok_hovar_, ho);
86  const HOCalibVariableCollection Hitho = *(ho.product());
87  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
88  }
89 
90  if (nameProd_ == "ALCARECOMuAlZMuMu") {
92  iEvent.getByToken(tok_horeco_, ho);
93  const HORecHitCollection Hitho = *(ho.product());
94  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
96  iEvent.getByToken(tok_muons_, mucand);
97  edm::LogVerbatim("HcalAlCa") << " Size of muon collection " << mucand->size();
98  for (const auto& it : *(mucand.product())) {
99  TrackRef mu = it.combinedMuon();
100  edm::LogVerbatim("HcalAlCa") << " Pt muon " << mu->innerMomentum();
101  }
102  }
103 
104  if (nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") {
106  iEvent.getByToken(tok_hbhe_, hbhe);
107  const HBHERecHitCollection Hithbhe = *(hbhe.product());
108  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
109 
111  iEvent.getByToken(tok_ho_, ho);
112  const HORecHitCollection Hitho = *(ho.product());
113  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
114 
116  iEvent.getByToken(tok_hf_, hf);
117  const HFRecHitCollection Hithf = *(hf.product());
118  edm::LogVerbatim("HcalAlCa") << " Size of HF " << (Hithf).size();
119  }
120  if (nameProd_ == "IsoProd") {
121  edm::LogVerbatim("HcalAlCa") << " We are here ";
123  iEvent.getByToken(tok_tracks_, tracks);
124 
125  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
126  for (const auto& track : *(tracks.product())) {
127  edm::LogVerbatim("HcalAlCa") << " P track " << track.p() << " eta " << track.eta() << " phi " << track.phi()
128  << " Outer " << track.outerMomentum() << " " << track.outerPosition();
129  const TrackExtraRef & myextra = track.extra();
130  edm::LogVerbatim("HcalAlCa") << " Track extra " << myextra->outerMomentum() << " " << myextra->outerPosition();
131  }
132 
134  iEvent.getByToken(tok_ecal_, ecal);
135  const EcalRecHitCollection Hitecal = *(ecal.product());
136  edm::LogVerbatim("HcalAlCa") << " Size of Ecal " << (Hitecal).size();
137 
138  double energyECAL = 0.;
139  double energyHCAL = 0.;
140 
141  for (const auto& hite : *(ecal.product())) {
142  const GlobalPoint& posE = geo->getPosition(hite.detid());
143 
144  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << hite.energy() << " eta " << posE.eta() << " phi "
145  << posE.phi();
146 
147  energyECAL = energyECAL + hite.energy();
148  }
149 
151  iEvent.getByToken(tok_hbheProd_, hbhe);
152  const HBHERecHitCollection Hithbhe = *(hbhe.product());
153  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
154 
155  for (const auto& hith : *(hbhe.product())) {
156  GlobalPoint posH =
157  (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid());
158 
159  edm::LogVerbatim("HcalAlCa") << " Energy HCAL " << hith.energy() << " eta " << posH.eta() << " phi "
160  << posH.phi();
161 
162  energyHCAL = energyHCAL + hith.energy();
163  }
164 
165  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << energyECAL << " Energy HCAL " << energyHCAL;
166  }
167 
168  if (nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd") {
169  edm::LogVerbatim("HcalAlCa") << " we are in GammaJetProd area ";
171  iEvent.getByToken(tok_ecal_, ecal);
172  edm::LogVerbatim("HcalAlCa") << " Size of ECAL " << (*ecal).size();
173 
175  iEvent.getByToken(tok_jets_, jets);
176  edm::LogVerbatim("HcalAlCa") << " Jet size " << (*jets).size();
177 
178  for (const auto& jet : *(jets.product())) {
179  edm::LogVerbatim("HcalAlCa") << " Et jet " << jet.et() << " eta " << jet.eta() << " phi " << jet.phi();
180  }
181 
183  iEvent.getByToken(tok_tracks_, tracks);
184  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
185  }
186  if (nameProd_ == "GammaJetProd") {
188  iEvent.getByToken(tok_gamma_, eclus);
189  edm::LogVerbatim("HcalAlCa") << " GammaClus size " << (*eclus).size();
190  for (const auto& iclus : *(eclus.product())) {
191  edm::LogVerbatim("HcalAlCa") << " Et gamma " << iclus.energy() / cosh(iclus.eta()) << " eta " << iclus.eta()
192  << " phi " << iclus.phi();
193  }
194  }
195  }
196  //define this as a plug-in
197  //DEFINE_FWK_MODULE(ProducerAnalyzer)
198 } // namespace cms
size
Write out results.
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
T getUntrackedParameter(std::string const &, T const &) const
double energyECAL(std::vector< DetId > &vdets, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:14
int iEvent
Definition: GenABIO.cc:224
vector< PseudoJet > jets
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:74
const int mu
Definition: Constants.h:22
Namespace of DDCMS conversion namespace.
double energyHCAL(std::vector< DetId > &vdets, edm::Handle< T > &hits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int useRaw=0, bool debug=false)
T const * product() const
Definition: Handle.h:74
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
T eta() const
Definition: PV3DBase.h:76
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
Definition: Event.cc:117