CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProducerAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <string>
4 #include <iostream>
5 
6 // user include files
7 
14 // collections
24 
33 
37 
40 
41 namespace cms {
42 
43  //
44  // class declaration
45  //
46 
48  public:
49  explicit ProducerAnalyzer(const edm::ParameterSet&);
50  ~ProducerAnalyzer() override = default;
51 
52  void analyze(const edm::Event&, const edm::EventSetup&) override;
53  void beginJob() override {}
54  void endJob() override {}
55  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
56 
57  private:
58  // ----------member data ---------------------------
67 
72 
74 
80 
83 
85  };
86 } // end namespace cms
87 
88 using namespace reco;
89 
90 namespace cms {
91 
92  //
93  // constructors and destructor
94  //
95  ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig) {
96  // get name of output file with histogramms
97 
98  nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
99  jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo", "GammaJetJetBackToBackCollection");
100  gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus");
101  ecalInput_ = iConfig.getUntrackedParameter<std::string>("ecalInput");
102  hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
103  hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
104  hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
105  tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks");
106 
107  tok_hovar_ = consumes<HOCalibVariableCollection>(edm::InputTag(nameProd_, hoInput_));
108  tok_horeco_ = consumes<HORecHitCollection>(edm::InputTag("horeco"));
109  tok_ho_ = consumes<HORecHitCollection>(edm::InputTag(hoInput_));
110  tok_hoProd_ = consumes<HORecHitCollection>(edm::InputTag(nameProd_, hoInput_));
111 
112  tok_hf_ = consumes<HFRecHitCollection>(edm::InputTag(hfInput_));
113 
114  tok_jets_ = consumes<reco::CaloJetCollection>(edm::InputTag(nameProd_, jetCalo_));
115  tok_gamma_ = consumes<reco::SuperClusterCollection>(edm::InputTag(nameProd_, gammaClus_));
116  tok_muons_ = consumes<reco::MuonCollection>(edm::InputTag(nameProd_, "SelectedMuons"));
117  tok_ecal_ = consumes<EcalRecHitCollection>(edm::InputTag(nameProd_, ecalInput_));
118  tok_tracks_ = consumes<reco::TrackCollection>(edm::InputTag(nameProd_, tracks_));
119 
120  tok_hbheProd_ = consumes<HBHERecHitCollection>(edm::InputTag(nameProd_, hbheInput_));
121  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag(hbheInput_));
122 
123  tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
124  }
125 
126  //
127  // member functions
128  //
129 
130  // ------------ method called to produce the data ------------
132  using namespace edm;
133 
134  const CaloGeometry* geo = &(iSetup.getData(tok_geom_));
135 
136  std::vector<StableProvenance const*> theProvenance;
137  iEvent.getAllStableProvenance(theProvenance);
138  for (auto const& provenance : theProvenance) {
139  edm::LogVerbatim("HcalAlCa") << " Print all module/label names " << provenance->moduleName() << " "
140  << provenance->moduleLabel() << " " << provenance->productInstanceName();
141  }
142 
143  if (nameProd_ == "hoCalibProducer") {
144  auto const& ho = iEvent.getHandle(tok_hovar_);
145  const HOCalibVariableCollection Hitho = *(ho.product());
146  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
147  }
148 
149  if (nameProd_ == "ALCARECOMuAlZMuMu") {
150  auto const& ho = iEvent.getHandle(tok_horeco_);
151  const HORecHitCollection Hitho = *(ho.product());
152  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
153  auto const& mucand = iEvent.getHandle(tok_muons_);
154  edm::LogVerbatim("HcalAlCa") << " Size of muon collection " << mucand->size();
155  for (const auto& it : *(mucand.product())) {
156  TrackRef mu = it.combinedMuon();
157  edm::LogVerbatim("HcalAlCa") << " Pt muon " << mu->innerMomentum();
158  }
159  }
160 
161  if (nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") {
162  auto const& hbhe = iEvent.getHandle(tok_hbhe_);
163  const HBHERecHitCollection Hithbhe = *(hbhe.product());
164  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
165 
166  auto const& ho = iEvent.getHandle(tok_ho_);
167  const HORecHitCollection Hitho = *(ho.product());
168  edm::LogVerbatim("HcalAlCa") << " Size of HO " << (Hitho).size();
169 
170  auto const& hf = iEvent.getHandle(tok_hf_);
171  const HFRecHitCollection Hithf = *(hf.product());
172  edm::LogVerbatim("HcalAlCa") << " Size of HF " << (Hithf).size();
173  }
174  if (nameProd_ == "IsoProd") {
175  edm::LogVerbatim("HcalAlCa") << " We are here ";
176  auto const& tracks = iEvent.getHandle(tok_tracks_);
177 
178  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
179  for (const auto& track : *(tracks.product())) {
180  edm::LogVerbatim("HcalAlCa") << " P track " << track.p() << " eta " << track.eta() << " phi " << track.phi()
181  << " Outer " << track.outerMomentum() << " " << track.outerPosition();
182  const TrackExtraRef& myextra = track.extra();
183  edm::LogVerbatim("HcalAlCa") << " Track extra " << myextra->outerMomentum() << " " << myextra->outerPosition();
184  }
185 
186  auto const& ecal = iEvent.getHandle(tok_ecal_);
187  const EcalRecHitCollection Hitecal = *(ecal.product());
188  edm::LogVerbatim("HcalAlCa") << " Size of Ecal " << (Hitecal).size();
189 
190  double energyECAL = 0.;
191  double energyHCAL = 0.;
192 
193  for (const auto& hite : *(ecal.product())) {
194  const GlobalPoint& posE = geo->getPosition(hite.detid());
195 
196  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << hite.energy() << " eta " << posE.eta() << " phi "
197  << posE.phi();
198 
199  energyECAL = energyECAL + hite.energy();
200  }
201 
202  auto const& hbhe = iEvent.getHandle(tok_hbheProd_);
203  const HBHERecHitCollection Hithbhe = *(hbhe.product());
204  edm::LogVerbatim("HcalAlCa") << " Size of HBHE " << (Hithbhe).size();
205 
206  for (const auto& hith : *(hbhe.product())) {
207  GlobalPoint posH =
208  (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid());
209 
210  edm::LogVerbatim("HcalAlCa") << " Energy HCAL " << hith.energy() << " eta " << posH.eta() << " phi "
211  << posH.phi();
212 
213  energyHCAL = energyHCAL + hith.energy();
214  }
215 
216  edm::LogVerbatim("HcalAlCa") << " Energy ECAL " << energyECAL << " Energy HCAL " << energyHCAL;
217  }
218 
219  if (nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd") {
220  edm::LogVerbatim("HcalAlCa") << " we are in GammaJetProd area ";
221  auto const& ecal = iEvent.getHandle(tok_ecal_);
222  edm::LogVerbatim("HcalAlCa") << " Size of ECAL " << (*ecal).size();
223 
224  auto const& jets = iEvent.getHandle(tok_jets_);
225  edm::LogVerbatim("HcalAlCa") << " Jet size " << (*jets).size();
226 
227  for (const auto& jet : *(jets.product())) {
228  edm::LogVerbatim("HcalAlCa") << " Et jet " << jet.et() << " eta " << jet.eta() << " phi " << jet.phi();
229  }
230 
231  auto const& tracks = iEvent.getHandle(tok_tracks_);
232  edm::LogVerbatim("HcalAlCa") << " Tracks size " << (*tracks).size();
233  }
234  if (nameProd_ == "GammaJetProd") {
235  auto const& eclus = iEvent.getHandle(tok_gamma_);
236  edm::LogVerbatim("HcalAlCa") << " GammaClus size " << (*eclus).size();
237  for (const auto& iclus : *(eclus.product())) {
238  edm::LogVerbatim("HcalAlCa") << " Et gamma " << iclus.energy() / cosh(iclus.eta()) << " eta " << iclus.eta()
239  << " phi " << iclus.phi();
240  }
241  }
242  }
243 
246  desc.addUntracked<std::string>("nameProd", "hoCalibProducer");
247  desc.addUntracked<std::string>("jetCalo", "GammaJetJetBackToBackCollection");
248  desc.addUntracked<std::string>("gammaClus", "GammaJetGammaBackToBackCollection");
249  desc.addUntracked<std::string>("ecalInput", "GammaJetEcalRecHitCollection");
250  desc.addUntracked<std::string>("hbheInput", "hbhereco");
251  desc.addUntracked<std::string>("hoInput", "horeco");
252  desc.addUntracked<std::string>("hfInput", "hfreco");
253  desc.addUntracked<std::string>("Tracks", "GammaJetTracksCollection");
254  descriptions.add("alcaHcalProducerAnalyzer", desc);
255  }
256 
257 } // namespace cms
258 
261 
Log< level::Info, true > LogVerbatim
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)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void beginJob() override
edm::EDGetTokenT< reco::TrackCollection > tok_tracks_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
edm::EDGetTokenT< reco::MuonCollection > tok_muons_
auto const & tracks
cannot be loose
edm::EDGetTokenT< reco::SuperClusterCollection > tok_gamma_
edm::EDGetTokenT< HORecHitCollection > tok_hoProd_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< HBHERecHitCollection > tok_hbheProd_
ProducerAnalyzer(const edm::ParameterSet &)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
void endJob() override
vector< PseudoJet > jets
edm::EDGetTokenT< HORecHitCollection > tok_horeco_
edm::EDGetTokenT< HOCalibVariableCollection > tok_hovar_
edm::EDGetTokenT< EcalRecHitCollection > tok_ecal_
const int mu
Definition: Constants.h:22
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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)
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T eta() const
Definition: PV3DBase.h:73
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
~ProducerAnalyzer() override=default
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::CaloJetCollection > tok_jets_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
tuple size
Write out results.
tok_geom_(esConsumes< CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun >())
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
Definition: Event.cc:136