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 //
25 // constructors and destructor
26 //
27 ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig)
28 {
29  // get name of output file with histogramms
30 
31  nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
32  jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo","GammaJetJetBackToBackCollection");
33  gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus","GammaJetGammaBackToBackCollection");
34  ecalInput_=iConfig.getUntrackedParameter<std::string>("ecalInput","GammaJetEcalRecHitCollection");
35  hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
36  hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
37  hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
38  Tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks","GammaJetTracksCollection");
39 
40  tok_hovar_ = consumes<HOCalibVariableCollection>( edm::InputTag(nameProd_,hoInput_) );
41  tok_horeco_ = consumes<HORecHitCollection>( edm::InputTag("horeco") );
42  tok_ho_ = consumes<HORecHitCollection>( edm::InputTag(hoInput_) );
43  tok_hoProd_ = consumes<HORecHitCollection>( edm::InputTag(nameProd_,hoInput_) );
44 
45  tok_hf_ = consumes<HFRecHitCollection>( edm::InputTag(hfInput_) );
46 
47  tok_jets_ = consumes<reco::CaloJetCollection>( edm::InputTag(nameProd_,jetCalo_) );
48  tok_gamma_ = consumes<reco::SuperClusterCollection>( edm::InputTag(nameProd_,gammaClus_) );
49  tok_muons_ = consumes<reco::MuonCollection>(edm::InputTag(nameProd_,"SelectedMuons"));
50  tok_ecal_ = consumes<EcalRecHitCollection>( edm::InputTag(nameProd_,ecalInput_) );
51  tok_tracks_ = consumes<reco::TrackCollection>( edm::InputTag(nameProd_,Tracks_) );
52 
53  tok_hbheProd_ = consumes<HBHERecHitCollection>( edm::InputTag(nameProd_,hbheInput_) );
54  tok_hbhe_ = consumes<HBHERecHitCollection>( edm::InputTag(hbheInput_) );
55 
56 }
57 
58 ProducerAnalyzer::~ProducerAnalyzer()
59 {
60 
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 
64 }
65 
67 {
68 }
69 
70 void ProducerAnalyzer::endJob()
71 {
72 }
73 
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
80 void
82 {
83 
84  using namespace edm;
85 
87  iSetup.get<CaloGeometryRecord>().get(pG);
88  const CaloGeometry* geo = pG.product();
89 
90 
91  std::vector<StableProvenance const*> theProvenance;
92  iEvent.getAllStableProvenance(theProvenance);
93  for(auto const& provenance : theProvenance) {
94  edm::LogVerbatim("HcalAlCa")<<" Print all module/label names "
95  <<provenance->moduleName()
96  <<" "<<provenance->moduleLabel()
97  <<" "<<provenance->productInstanceName();
98  }
99 
100 
101  if(nameProd_ == "hoCalibProducer") {
103  iEvent.getByToken(tok_hovar_, ho);
104  const HOCalibVariableCollection Hitho = *(ho.product());
105  edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size();
106  }
107 
108  if(nameProd_ == "ALCARECOMuAlZMuMu" ) {
109 
111  iEvent.getByToken(tok_horeco_, ho);
112  const HORecHitCollection Hitho = *(ho.product());
113  edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size();
115  iEvent.getByToken(tok_muons_, mucand);
116  edm::LogVerbatim("HcalAlCa")<<" Size of muon collection "<<mucand->size();
117  for(const auto & it : *(mucand.product())) {
118  TrackRef mu = it.combinedMuon();
119  edm::LogVerbatim("HcalAlCa")<<" Pt muon "<<mu->innerMomentum();
120  }
121 
122  }
123 
124  if(nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer") {
126  iEvent.getByToken(tok_hbhe_, hbhe);
127  const HBHERecHitCollection Hithbhe = *(hbhe.product());
128  edm::LogVerbatim("HcalAlCa")<<" Size of HBHE "<<(Hithbhe).size();
129 
130 
132  iEvent.getByToken(tok_ho_, ho);
133  const HORecHitCollection Hitho = *(ho.product());
134  edm::LogVerbatim("HcalAlCa")<<" Size of HO "<<(Hitho).size();
135 
136 
138  iEvent.getByToken(tok_hf_, hf);
139  const HFRecHitCollection Hithf = *(hf.product());
140  edm::LogVerbatim("HcalAlCa")<<" Size of HF "<<(Hithf).size();
141  }
142  if(nameProd_ == "IsoProd") {
143  edm::LogVerbatim("HcalAlCa")<<" We are here ";
145  iEvent.getByToken(tok_tracks_,tracks);
146 
147 
148  edm::LogVerbatim("HcalAlCa")<<" Tracks size "<<(*tracks).size();
149  for (const auto & track : *(tracks.product())) {
150  edm::LogVerbatim("HcalAlCa")<<" P track "<<track.p()<<" eta "
151  <<track.eta()<<" phi "<<track.phi()
152  <<" Outer "<<track.outerMomentum()
153  <<" "<<track.outerPosition();
154  TrackExtraRef myextra = track.extra();
155  edm::LogVerbatim("HcalAlCa")<<" Track extra "
156  <<myextra->outerMomentum()<<" "
157  <<myextra->outerPosition();
158  }
159 
161  iEvent.getByToken(tok_ecal_,ecal);
162  const EcalRecHitCollection Hitecal = *(ecal.product());
163  edm::LogVerbatim("HcalAlCa")<<" Size of Ecal "<<(Hitecal).size();
164 
165  double energyECAL = 0.;
166  double energyHCAL = 0.;
167 
168  for (const auto & hite : *(ecal.product())) {
169 
170  const GlobalPoint& posE = geo->getPosition(hite.detid());
171 
172  edm::LogVerbatim("HcalAlCa")<<" Energy ECAL "<<hite.energy()
173  <<" eta "<<posE.eta()<<" phi "<<posE.phi();
174 
175  energyECAL = energyECAL + hite.energy();
176 
177  }
178 
180  iEvent.getByToken(tok_hbheProd_,hbhe);
181  const HBHERecHitCollection Hithbhe = *(hbhe.product());
182  edm::LogVerbatim("HcalAlCa")<<" Size of HBHE "<<(Hithbhe).size();
183 
184  for (const auto & hith : *(hbhe.product())) {
185 
186  GlobalPoint posH = (static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(hith.detid())))->getPosition(hith.detid());
187 
188  edm::LogVerbatim("HcalAlCa")<<" Energy HCAL "<<hith.energy()
189  <<" eta "<<posH.eta()<<" phi "<<posH.phi();
190 
191  energyHCAL = energyHCAL + hith.energy();
192 
193  }
194 
195  edm::LogVerbatim("HcalAlCa")<<" Energy ECAL "<< energyECAL
196  <<" Energy HCAL "<< energyHCAL;
197  }
198 
199 
200  if(nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd") {
201  edm::LogVerbatim("HcalAlCa")<<" we are in GammaJetProd area ";
203  iEvent.getByToken(tok_ecal_, ecal);
204  edm::LogVerbatim("HcalAlCa")<<" Size of ECAL "<<(*ecal).size();
205 
207  iEvent.getByToken(tok_jets_, jets);
208  edm::LogVerbatim("HcalAlCa")<<" Jet size "<<(*jets).size();
209 
210  for (const auto & jet : *(jets.product())) {
211  edm::LogVerbatim("HcalAlCa")<<" Et jet "<<jet.et()<<" eta "<<jet.eta()
212  <<" phi "<<jet.phi();
213  }
214 
216  iEvent.getByToken(tok_tracks_, tracks);
217  edm::LogVerbatim("HcalAlCa")<<" Tracks size "<<(*tracks).size();
218  }
219  if( nameProd_ == "GammaJetProd") {
221  iEvent.getByToken(tok_gamma_, eclus);
222  edm::LogVerbatim("HcalAlCa")<<" GammaClus size "<<(*eclus).size();
223  for (const auto & iclus : *(eclus.product())) {
224  edm::LogVerbatim("HcalAlCa")<<" Et gamma "
225  <<iclus.energy()/cosh(iclus.eta())<<" eta "
226  <<iclus.eta()<<" phi "<<iclus.phi();
227  }
228  }
229 
230 }
231 //define this as a plug-in
232 //DEFINE_FWK_MODULE(ProducerAnalyzer)
233 }
size
Write out results.
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
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:519
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:230
vector< PseudoJet > jets
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
const int mu
Definition: Constants.h:22
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, bool useRaw=false, bool debug=false)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:58
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
T eta() const
Definition: PV3DBase.h:76
fixed size matrix
HLT enums.
T const * product() const
Definition: ESHandle.h:86
void getAllStableProvenance(std::vector< StableProvenance const * > &provenances) const
Definition: Event.cc:144