34 #include "HepMC/GenParticle.h"
35 #include "HepMC/GenVertex.h"
50 tok_jets_ = consumes<reco::CaloJetCollection>(
edm::InputTag(nameProd_,
55 tok_egamma_ = consumes<reco::SuperClusterCollection>(
edm::InputTag(nameProd_,
60 tok_ecal_ = consumes<EcalRecHitCollection>(
edm::InputTag(nameProd_, ecalInput_) );
64 tok_hbhe_ = consumes<HBHERecHitCollection>(
edm::InputTag(nameProd_,hbheInput_));
68 tok_ho_ = consumes<HORecHitCollection>(
edm::InputTag(nameProd_,hoInput_));
72 tok_hf_ = consumes<HFRecHitCollection>(
edm::InputTag(nameProd_,hfInput_));
75 CutOnEgammaEnergy_ = iConfig.
getParameter<
double>(
"CutOnEgammaEnergy");
100 GammaJetAnalysis::~GammaJetAnalysis()
110 hOutputFile =
new TFile( fOutputFileName.c_str(),
"RECREATE" ) ;
111 myTree =
new TTree(
"GammaJet",
"GammaJet Tree");
112 myTree->Branch(
"run", &
run,
"run/I");
113 myTree->Branch(
"event", &
event,
"event/I");
121 myTree->Branch(
"NumRecoJets", &NumRecoJets,
"NumRecoJets/I");
122 myTree->Branch(
"JetRecoEt", JetRecoEt,
"JetRecoEt[10]/F");
123 myTree->Branch(
"JetRecoEta", JetRecoEta,
"JetRecoEta[10]/F");
124 myTree->Branch(
"JetRecoPhi", JetRecoPhi,
"JetRecoPhi[10]/F");
125 myTree->Branch(
"JetRecoType", JetRecoType,
"JetRecoType[10]/F");
128 myTree->Branch(
"NumRecoGamma", &NumRecoGamma,
"NumRecoGamma/I");
129 myTree->Branch(
"EcalClusDet", &EcalClusDet,
"EcalClusDet[20]/I");
130 myTree->Branch(
"GammaRecoEt", GammaRecoEt,
"GammaRecoEt[20]/F");
131 myTree->Branch(
"GammaRecoEta", GammaRecoEta,
"GammaRecoEta[20]/F");
132 myTree->Branch(
"GammaRecoPhi", GammaRecoPhi,
"GammaRecoPhi[20]/F");
133 myTree->Branch(
"GammaIsoEcal", GammaIsoEcal,
"GammaIsoEcal[9][20]/F");
136 myTree->Branch(
"NumRecoTrack", &NumRecoTrack,
"NumRecoTrack/I");
137 myTree->Branch(
"TrackRecoEt", TrackRecoEt,
"TrackRecoEt[200]/F");
138 myTree->Branch(
"TrackRecoEta", TrackRecoEta,
"TrackRecoEta[200]/F");
139 myTree->Branch(
"TrackRecoPhi", TrackRecoPhi,
"TrackRecoPhi[200]/F");
147 myout_part =
new std::ofstream((myName+
"_part.dat").c_str());
148 if(!myout_part)
cout <<
" Output file not open!!! "<<endl;
149 myout_hcal =
new std::ofstream((myName+
"_hcal.dat").c_str());
150 if(!myout_hcal)
cout <<
" Output file not open!!! "<<endl;
151 myout_ecal =
new std::ofstream((myName+
"_ecal.dat").c_str());
152 if(!myout_ecal)
cout <<
" Output file not open!!! "<<endl;
154 myout_jet =
new std::ofstream((myName+
"_jet.dat").c_str());
155 if(!myout_jet)
cout <<
" Output file not open!!! "<<endl;
156 myout_photon =
new std::ofstream((myName+
"_photon.dat").c_str());
157 if(!myout_photon)
cout <<
" Output file not open!!! "<<endl;
162 void GammaJetAnalysis::endJob()
165 cout <<
"===== Start writing user histograms =====" << endl;
166 hOutputFile->SetCompressionLevel(2);
169 hOutputFile->Close() ;
170 cout <<
"===== End writing user histograms =======" << endl;
189 std::vector<Provenance const*> theProvenance;
201 (*myout_part)<<
"Event "<<iEvent.
id().
run()<<
" "<<iEvent.
id().
event()<<endl;
202 (*myout_jet)<<
"Event "<<iEvent.
id().
run()<<
" "<<iEvent.
id().
event()<<endl;
203 (*myout_hcal)<<
"Event "<<iEvent.
id().
run()<<
" "<<iEvent.
id().
event()<<endl;
204 (*myout_ecal)<<
"Event "<<iEvent.
id().
run()<<
" "<<iEvent.
id().
event()<<endl;
205 (*myout_photon)<<
"Event "<<iEvent.
id().
run()<<
" "<<iEvent.
id().
event()<<endl;
208 std::vector<edm::InputTag>::const_iterator ic;
212 double etlost = -100.1;
220 reco::CaloJetCollection::const_iterator
jet = jets->begin ();
221 cout<<
" Size of Calo jets "<<jets->size()<<endl;
224 if(jets->size() > 0 )
227 for (; jet != jets->end (); jet++)
229 cout<<
" Jet et "<<(*jet).et()<<
" "<<(*jet).eta()<<
" "<<(*jet).phi()<<endl;
231 if(ij<4) (*myout_jet)<<jettype<<
" "<<
reco<<
" "<<ij<<
" "<<(*jet).et()<<
" "<<(*jet).eta()<<
" "<<(*jet).phi()
232 <<
" "<<iEvent.
id().
event()<<endl;
234 if( NumRecoJets < 8 )
236 JetRecoEt[NumRecoJets] = (*jet).et();
237 JetRecoEta[NumRecoJets] = (*jet).eta();
238 JetRecoPhi[NumRecoJets] = (*jet).phi();
239 JetRecoType[NumRecoJets] = jettype;
245 if (!allowMissingInputs_) {
246 cout<<
" Calojets are missed "<<endl;
251 cout<<
" We filled CaloJet part "<<jetexist<<endl;
253 if( jetexist < 0 ) (*myout_jet)<<jetexist<<
" "<<
reco<<
" "<<etlost
254 <<
" "<<etlost<<
" "<<etlost
255 <<
" "<<iEvent.
id().
event()<<endl;
258 std::vector<edm::InputTag>::const_iterator
i;
259 vector<std::pair<DetId, double> > theRecHits;
267 recHit != (*ec).end(); ++recHit)
271 GlobalPoint pos = geo->getPosition(recHit->detid());
272 theRecHits.push_back(std::pair<DetId, double>(recHit->detid(), recHit->energy()));
274 if( (*recHit).energy()> ecut[recHit->detid().subdetId()-1][0] )
275 (*myout_ecal)<<recHit->detid().subdetId()<<
" "<<(*recHit).energy()<<
" "<<pos.
phi()<<
" "<<pos.
eta()
276 <<
" "<<iEvent.
id().
event()<<endl;
281 if (!allowMissingInputs_) {
282 cout<<
" Ecal collection is missed "<<endl;
287 cout<<
" Fill EcalRecHits "<<endl;
297 hbheItr != (*hbhe).end(); ++hbheItr)
300 GlobalPoint pos = geo->getPosition(hbheItr->detid());
301 (*myout_hcal)<<
id.subdetId()<<
" "<<(*hbheItr).energy()<<
" "<<pos.
phi()<<
302 " "<<pos.
eta()<<
" "<<iEvent.
id().
event()<<endl;
303 theRecHits.push_back(std::pair<DetId, double>(hbheItr->detid(), hbheItr->energy()));
307 if (!allowMissingInputs_) {
308 cout<<
" HBHE collection is missed "<<endl;
314 for(
int i = 0;
i<9;
i++)
316 for(
int j= 0;
j<10;
j++) GammaIsoEcal[
i][
j] = 0.;
331 for(reco::SuperClusterCollection::const_iterator aClus = correctedSuperClusters->begin();
332 aClus != correctedSuperClusters->end(); aClus++) {
333 double vet = aClus->energy()/cosh(aClus->eta());
334 cout<<
" Supercluster " << ij<<
" Et "<< vet <<
" energy "<<aClus->energy()<<
" eta "<<aClus->eta()<<
" Cut "<<CutOnEgammaEnergy_<<endl;
336 if(vet>CutOnEgammaEnergy_) {
338 float gammaiso_ecal[9] = {0.,0.,0.,0.,0.,0.,0.,0.,0.};
339 for(vector<std::pair<DetId, double> >::const_iterator it = theRecHits.begin(); it != theRecHits.end(); it++)
344 double deta = fabs(eta-aClus->eta());
345 double dphi = fabs(phi-aClus->phi());
346 if(dphi>4.*atan(1.)) dphi = 8.*atan(1.)-dphi;
347 double dr =
sqrt(deta*deta+dphi*dphi);
350 if( fabs(aClus->eta()) > 1.47 ) rmin = 0.07*(fabs(aClus->eta())-.47)*1.2;
351 if( fabs(aClus->eta()) > 2.2 ) rmin = 0.07*(fabs(aClus->eta())-.47)*1.4;
355 for (
int i = 0;
i<3;
i++)
357 for (
int j = 0;
j<3;
j++)
362 if(it->first.subdetId() == 1) ecutn = ecut[0][
j];
363 if(it->first.subdetId() == 2) ecutn = ecut[1][
j];
364 if( dr>rmin && dr<risol[
i])
366 if((*it).second > ecutn) gammaiso_ecal[itype_ecal] = gammaiso_ecal[itype_ecal]+(*it).second/cosh(eta);
373 if( dr>rmin && dr<risol[
i])
375 if((*it).first > ecutn)
377 gammaiso_ecal[itype_ecal] = gammaiso_ecal[itype_ecal]+(*it).second/cosh(eta);
390 if( NumRecoGamma < 10 )
392 for (
int ii = 0;
ii<9 ;
ii++)
394 GammaIsoEcal[
ii][NumRecoGamma] = gammaiso_ecal[
ii];
396 EcalClusDet[NumRecoGamma] = 1;
397 GammaRecoEt[NumRecoGamma] = vet;
398 GammaRecoEta[NumRecoGamma] = aClus->eta();
399 GammaRecoPhi[NumRecoGamma] = aClus->phi();
402 (*myout_photon)<<ij<<
" "<<
barrel<<
" "<<vet<<
" "<<aClus->eta()<<
" "<<aClus->phi()<<
" "<<iEvent.
id().
event()<<endl;
403 (*myout_photon)<<ij<<
" "<<gammaiso_ecal[0]<<
" "<<gammaiso_ecal[1] <<
" "<<gammaiso_ecal[2]<<
" "<<gammaiso_ecal[3]
404 <<
" "<<gammaiso_ecal[4]<<
" "<<gammaiso_ecal[5]<<
" "<<gammaiso_ecal[6]<<
" "<<gammaiso_ecal[7]<<
" "<<gammaiso_ecal[8]<<endl;
410 if (!allowMissingInputs_) {
411 cout<<
" Ecal barrel clusters are missed "<<endl;
416 cout<<
" After iso cuts "<<jetexist<<endl;
418 double ecluslost = -100.1;
419 if(jetexist<0) (*myout_photon)<<jetexist<<
" "<<
barrel<<
" "<<ecluslost<<
" "<<ecluslost
420 <<
" "<<ecluslost<<
" "<<iEvent.
id().
event()<<endl;
422 cout<<
" Event is ready "<<endl;
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void getAllProvenance(std::vector< Provenance const * > &provenances) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Geom::Phi< T > phi() const
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
T const * product() const
T const * product() const