CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProducerAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 
3 // user include files
4 
25 
26 #include <map>
27 
28 using namespace std;
29 using namespace reco;
30 
31 namespace cms
32 {
33 
34 //
35 // constructors and destructor
36 //
37 ProducerAnalyzer::ProducerAnalyzer(const edm::ParameterSet& iConfig)
38 {
39  // get name of output file with histogramms
40 
41  nameProd_ = iConfig.getUntrackedParameter<std::string>("nameProd");
42  jetCalo_ = iConfig.getUntrackedParameter<std::string>("jetCalo","GammaJetJetBackToBackCollection");
43  gammaClus_ = iConfig.getUntrackedParameter<std::string>("gammaClus","GammaJetGammaBackToBackCollection");
44  ecalInput_=iConfig.getUntrackedParameter<std::string>("ecalInput","GammaJetEcalRecHitCollection");
45  hbheInput_ = iConfig.getUntrackedParameter<std::string>("hbheInput");
46  hoInput_ = iConfig.getUntrackedParameter<std::string>("hoInput");
47  hfInput_ = iConfig.getUntrackedParameter<std::string>("hfInput");
48  Tracks_ = iConfig.getUntrackedParameter<std::string>("Tracks","GammaJetTracksCollection");
49 
50 }
51 
52 ProducerAnalyzer::~ProducerAnalyzer()
53 {
54 
55  // do anything here that needs to be done at desctruction time
56  // (e.g. close files, deallocate resources etc.)
57 
58 }
59 
61 {
62 }
63 
64 void ProducerAnalyzer::endJob()
65 {
66 }
67 
68 
69 //
70 // member functions
71 //
72 
73 // ------------ method called to produce the data ------------
74 void
76 {
77 
78  using namespace edm;
79 
80  const CaloGeometry* geo;
82  iSetup.get<CaloGeometryRecord>().get(pG);
83  geo = pG.product();
84 
85 
86  std::vector<Provenance const*> theProvenance;
87  iEvent.getAllProvenance(theProvenance);
88  for( std::vector<Provenance const*>::const_iterator ip = theProvenance.begin();
89  ip != theProvenance.end(); ip++)
90  {
91  cout<<" Print all module/label names "<<(**ip).moduleName()<<" "<<(**ip).moduleLabel()<<
92  " "<<(**ip).productInstanceName()<<endl;
93  }
94 
95 
96  if(nameProd_ == "hoCalibProducer")
97  {
99  iEvent.getByLabel(nameProd_,hoInput_, ho);
100  const HOCalibVariableCollection Hitho = *(ho.product());
101  std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
102  }
103 
104  if(nameProd_ == "ALCARECOMuAlZMuMu" )
105  {
106 
108  iEvent.getByLabel("horeco", ho);
109  const HORecHitCollection Hitho = *(ho.product());
110  std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
112  iEvent.getByLabel(nameProd_,"SelectedMuons", mucand);
113  std::cout<<" Size of muon collection "<<mucand->size()<<std::endl;
114  for(MuonCollection::const_iterator it = mucand->begin(); it != mucand->end(); it++)
115  {
116  TrackRef mu = (*it).combinedMuon();
117  std::cout<<" Pt muon "<<mu->innerMomentum()<<std::endl;
118  }
119 
120  }
121 
122  if(nameProd_ != "IsoProd" && nameProd_ != "ALCARECOMuAlZMuMu" && nameProd_ != "hoCalibProducer")
123  {
125  iEvent.getByLabel(hbheInput_, hbhe);
126  const HBHERecHitCollection Hithbhe = *(hbhe.product());
127  std::cout<<" Size of HBHE "<<(Hithbhe).size()<<std::endl;
128 
129 
131  iEvent.getByLabel(hoInput_, ho);
132  const HORecHitCollection Hitho = *(ho.product());
133  std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
134 
135 
137  iEvent.getByLabel(hfInput_, hf);
138  const HFRecHitCollection Hithf = *(hf.product());
139  std::cout<<" Size of HF "<<(Hithf).size()<<std::endl;
140  }
141  if(nameProd_ == "IsoProd")
142  {
143  cout<<" We are here "<<endl;
145  iEvent.getByLabel(nameProd_,Tracks_,tracks);
146 
147 
148  std::cout<<" Tracks size "<<(*tracks).size()<<std::endl;
149  reco::TrackCollection::const_iterator track = tracks->begin ();
150 
151  for (; track != tracks->end (); track++)
152  {
153  cout<<" P track "<<(*track).p()<<" eta "<<(*track).eta()<<" phi "<<(*track).phi()<<" Outer "<<(*track).outerMomentum()<<" "<<
154  (*track).outerPosition()<<endl;
155  TrackExtraRef myextra = (*track).extra();
156  cout<<" Track extra "<<myextra->outerMomentum()<<" "<<myextra->outerPosition()<<endl;
157  }
158 
160  iEvent.getByLabel(nameProd_,ecalInput_,ecal);
161  const EcalRecHitCollection Hitecal = *(ecal.product());
162  std::cout<<" Size of Ecal "<<(Hitecal).size()<<std::endl;
164 
165  double energyECAL = 0.;
166  double energyHCAL = 0.;
167 
168  for (; hite != (ecal.product())->end (); hite++)
169  {
170 
171 // cout<<" Energy ECAL "<<(*hite).energy()<<endl;
172 
173 
174 // " eta "<<(*hite).detid()<<" phi "<<(*hite).detid().getPosition().phi()<<endl;
175 
176  GlobalPoint posE = geo->getPosition((*hite).detid());
177 
178  cout<<" Energy ECAL "<<(*hite).energy()<<
179  " eta "<<posE.eta()<<" phi "<<posE.phi()<<endl;
180 
181  energyECAL = energyECAL + (*hite).energy();
182 
183  }
184 
186  iEvent.getByLabel(nameProd_,hbheInput_,hbhe);
187  const HBHERecHitCollection Hithbhe = *(hbhe.product());
188  std::cout<<" Size of HBHE "<<(Hithbhe).size()<<std::endl;
190 
191  for (; hith != (hbhe.product())->end (); hith++)
192  {
193 
194  GlobalPoint posH = geo->getPosition((*hith).detid());
195 
196  cout<<" Energy HCAL "<<(*hith).energy()<<
197  " eta "<<posH.eta()<<" phi "<<posH.phi()<<endl;
198 
199  energyHCAL = energyHCAL + (*hith).energy();
200 
201  }
202 
203  cout<<" Energy ECAL "<< energyECAL<<" Energy HCAL "<< energyHCAL<<endl;
204 
206  iEvent.getByLabel(nameProd_,hoInput_,ho);
207  const HORecHitCollection Hitho = *(ho.product());
208  std::cout<<" Size of HO "<<(Hitho).size()<<std::endl;
210 
211  for (; hito != (ho.product())->end (); hito++)
212  {
213 // cout<<" Energy HO "<<(*hito).energy()<<endl;
214 // " eta "<<(*hite).eta()<<" phi "<<(*hite).phi()<<endl;
215  }
216 
217  }
218 
219 
220  if(nameProd_ == "GammaJetProd" || nameProd_ == "DiJProd")
221  {
222  cout<<" we are in GammaJetProd area "<<endl;
224  iEvent.getByLabel(nameProd_,ecalInput_, ecal);
225  std::cout<<" Size of ECAL "<<(*ecal).size()<<std::endl;
226 
228  iEvent.getByLabel(nameProd_,jetCalo_, jets);
229  std::cout<<" Jet size "<<(*jets).size()<<std::endl;
230  reco::CaloJetCollection::const_iterator jet = jets->begin ();
231  for (; jet != jets->end (); jet++)
232  {
233  cout<<" Et jet "<<(*jet).et()<<" eta "<<(*jet).eta()<<" phi "<<(*jet).phi()<<endl;
234  }
235 
237  iEvent.getByLabel(nameProd_,Tracks_, tracks);
238  std::cout<<" Tracks size "<<(*tracks).size()<<std::endl;
239  }
240  if( nameProd_ == "GammaJetProd")
241  {
243  iEvent.getByLabel(nameProd_,gammaClus_, eclus);
244  std::cout<<" GammaClus size "<<(*eclus).size()<<std::endl;
245  reco::SuperClusterCollection::const_iterator iclus = eclus->begin ();
246  for (; iclus != eclus->end (); iclus++)
247  {
248  cout<<" Et gamma "<<(*iclus).energy()/cosh((*iclus).eta())<<" eta "<<(*iclus).eta()<<" phi "<<(*iclus).phi()<<endl;
249  }
250  }
251 
252 }
253 //define this as a plug-in
254 //DEFINE_FWK_MODULE(ProducerAnalyzer)
255 }
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 debug=false)
T getUntrackedParameter(std::string const &, T const &) const
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:70
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)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
std::vector< EcalRecHit >::const_iterator const_iterator
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
vector< PseudoJet > jets
const int mu
Definition: Constants.h:23
#define end
Definition: vmac.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
std::vector< HOCalibVariables > HOCalibVariableCollection
collection of HOcalibration variabale
T const * product() const
Definition: Handle.h:74
T eta() const
Definition: PV3DBase.h:75
#define begin
Definition: vmac.h:31
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.