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