CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonsWithConversionsAnalyzer Class Reference

#include <PhotonsWithConversionsAnalyzer.h>

Inheritance diagram for PhotonsWithConversionsAnalyzer:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 PhotonsWithConversionsAnalyzer (const edm::ParameterSet &)
 
virtual ~PhotonsWithConversionsAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

float etaTransformation (float a, float b)
 

Private Attributes

TFile * fOutputFile_
 
std::string fOutputFileName_
 
TH2F * h2_tk_inPtVsR_
 
TH2F * h2_tk_nHitsVsR_
 
TH1F * h_deltaEta_
 
TH1F * h_deltaPhi_
 
TH1F * h_ErecoEMC_
 
TH1F * h_MCConvE_
 
TH1F * h_MCConvEta_
 
TH1F * h_MCConvPt_
 
TH1F * h_MCphoE_
 
TH1F * h_MCphoEta_
 
TH1F * h_MCphoPhi_
 
TH1F * h_phoE_
 
TH1F * h_phoEta_
 
TH1F * h_phoPhi_
 
TH1F * h_scE_
 
TH1F * h_scEt_
 
TH1F * h_scEta_
 
TH1F * h_scPhi_
 
std::string HepMCLabel
 
int nEvt_
 
int nMatched_
 
int nMCPho_
 
std::string photonCollection_
 
std::string photonCollectionProducer_
 
std::string SimHitLabel
 
std::string SimTkLabel
 
std::string SimVtxLabel
 
PhotonMCTruthFinderthePhotonMCTruthFinder_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 23 of file PhotonsWithConversionsAnalyzer.h.

Constructor & Destructor Documentation

PhotonsWithConversionsAnalyzer::PhotonsWithConversionsAnalyzer ( const edm::ParameterSet pset)
explicit

Definition at line 51 of file PhotonsWithConversionsAnalyzer.cc.

References edm::ParameterSet::getParameter().

52  {
53 
54  photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
55  photonCollection_ = pset.getParameter<std::string>("photonCollection");
56  //
57 
58 
59 }
T getParameter(std::string const &) const
PhotonsWithConversionsAnalyzer::~PhotonsWithConversionsAnalyzer ( )
virtual

Definition at line 63 of file PhotonsWithConversionsAnalyzer.cc.

63  {
64 
65 
67 
68 }

Member Function Documentation

void PhotonsWithConversionsAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup  
)
virtual

Loop over recontructed photons

End loop over Reco particles

End loop over MC particles

Implements edm::EDAnalyzer.

Definition at line 162 of file PhotonsWithConversionsAnalyzer.cc.

References conversions_cfi::conversions, gather_cfg::cout, delta, Geom::deltaPhi(), HcalObjRepresent::Fill(), edm::Event::getByLabel(), i, edm::EventBase::id(), Geom::pi(), funct::pow(), edm::RefVector< C, T, F >::size(), mathSSE::sqrt(), testEve_cfg::tracks, and Geom::twoPi().

163 {
164 
165 
166  using namespace edm;
167  const float etaPhiDistance=0.01;
168  // Fiducial region
169  //UNUSED const float TRK_BARL =0.9;
170  //UNUSED const float BARL = 1.4442; // DAQ TDR p.290
171  //UNUSED const float END_LO = 1.566;
172  //UNUSED const float END_HI = 2.5;
173  // Electron mass
174  //UNUSED const Float_t mElec= 0.000511;
175 
176 
177  nEvt_++;
178  LogInfo("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
179  // LogDebug("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
180  std::cout << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
181 
182 
184  Handle<reco::PhotonCollection> photonHandle;
186  const reco::PhotonCollection photonCollection = *(photonHandle.product());
187  std::cout << "ConvertedPhotonAnalyzer Photons with conversions collection size " << photonCollection.size() << "\n";
188 
189 
191  std::cout << " ConvertedPhotonAnalyzer Looking for MC truth " << "\n";
192 
193  //get simtrack info
194  std::vector<SimTrack> theSimTracks;
195  std::vector<SimVertex> theSimVertices;
196 
199  e.getByLabel("g4SimHits",SimTk);
200  e.getByLabel("g4SimHits",SimVtx);
201 
202  theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
203  theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
204 
205  std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices);
206  std::cout << " ConvertedPhotonAnalyzer mcPhotons size " << mcPhotons.size() << std::endl;
207 
208 
209 
210  // Loop over simulated photons
211  //UNUSED int iDet=0;
212  //UNUSED int iRadius=-1;
213  //UNUSED int indPho=0;
214 
215  for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
216  float mcPhi= (*mcPho).fourMomentum().phi();
217  float mcEta= (*mcPho).fourMomentum().pseudoRapidity();
218  mcEta = etaTransformation(mcEta, (*mcPho).primaryVertex().z() );
219 
220  if ( (*mcPho).fourMomentum().et() < 20 ) continue;
221  // if ( ! ( fabs(mcEta) <= BARL || ( fabs(mcEta) >= END_LO && fabs(mcEta) <=END_HI ) ) ) {
222  // continue;
223  //} // all ecal fiducial region
224 
225 
226 
227  h_MCphoE_->Fill( (*mcPho).fourMomentum().e());
228  h_MCphoEta_->Fill( (*mcPho).fourMomentum().eta());
229  h_MCphoPhi_->Fill( (*mcPho).fourMomentum().phi());
230 
231 
232 
233  // keep only visible conversions
234  if ( (*mcPho).isAConversion() == 0 ) continue;
235 
236 
237  nMCPho_++;
238 
239  h_MCConvEta_ ->Fill ( fabs( (*mcPho).fourMomentum().pseudoRapidity()) - 0.001);
240 
241 
242  bool REJECTED;
243 
244 
246  //std::cout << " ConvertedPhotonAnalyzer Starting loop over photon candidates " << "\n";
247  for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) {
248  REJECTED=false;
249 
250  // std::cout << " ConvertedPhotonAnalyzer Reco SC energy " << (*iPho).superCluster()->energy() << "\n";
251 
252  float phiClu=(*iPho).superCluster()->phi();
253  float etaClu=(*iPho).superCluster()->eta();
254  float deltaPhi = phiClu-mcPhi;
255  float deltaEta = etaClu-mcEta;
256 
257 
258  if ( deltaPhi > Geom::pi() ) deltaPhi -= Geom::twoPi();
259  if ( deltaPhi < -Geom::pi() ) deltaPhi += Geom::twoPi();
260  deltaPhi=pow(deltaPhi,2);
261  deltaEta=pow(deltaEta,2);
262  float delta = deltaPhi+deltaEta ;
263  if ( delta >= etaPhiDistance ) REJECTED=true;
264 
265 
266  // if ( ! ( fabs(etaClu) <= BARL || ( fabs(etaClu) >= END_LO && fabs(etaClu) <=END_HI ) ) ) REJECTED=true;
267 
268  if ( REJECTED ) continue;
269  std::cout << " MATCHED " << std::endl;
270  nMatched_++;
271 
272 
273  // std::cout << " ConvertedPhotonAnalyzer Matching candidate " << std::endl;
274 
275  // std::cout << " ConvertedPhotonAnalyzer Photons isAconversion " << (*mcPho).isAConversion() << " mcMatchingPhoton energy " << (*mcPho).fourMomentum().e() << " ConvertedPhotonAnalyzer conversion vertex R " << (*mcPho).vertex().perp() << " Z " << (*mcPho).vertex().z() << std::endl;
276 
277 
278  h_ErecoEMC_->Fill( (*iPho).superCluster()->energy()/(*mcPho).fourMomentum().e());
279  h_deltaPhi_-> Fill ( (*iPho).superCluster()->position().phi()- mcPhi);
280  h_deltaEta_-> Fill ( (*iPho).superCluster()->position().eta()- mcEta);
281 
282  h_scE_->Fill( (*iPho).superCluster()->energy() );
283  h_scEt_->Fill( (*iPho).superCluster()->energy()/cosh( (*iPho).superCluster()->position().eta()) );
284  h_scEta_->Fill( (*iPho).superCluster()->position().eta() );
285  h_scPhi_->Fill( (*iPho).superCluster()->position().phi() );
286 
287 
288  h_phoE_->Fill( (*iPho).energy() );
289  h_phoEta_->Fill( (*iPho).eta() );
290  h_phoPhi_->Fill( (*iPho).phi() );
291 
292  if ( !(*iPho).hasConversionTracks() ) continue;
293  // std::cout << " This photons has " << (*iPho).conversions().size() << " conversions candidates " << std::endl;
294  reco::ConversionRefVector conversions = (*iPho).conversions();
295  //std::vector<reco::ConversionRef> conversions = (*iPho).conversions();
296 
297 
298  for (unsigned int i=0; i<conversions.size(); i++) {
299  //std::cout << " Conversion candidate Energy " << (*iPho).energy() << " number of tracks " << conversions[i]->nTracks() << std::endl;
300  std::vector< edm::RefToBase<reco::Track> > tracks = conversions[i]->tracks();
301 
302  for (unsigned int i=0; i<tracks.size(); i++) {
303 
304  // std::cout << " ConvertedPhotonAnalyzer Reco Track charge " << tracks[i]->charge() << " Num of RecHits " << tracks[i]->recHitsSize() << " inner momentum " << sqrt ( tracks[i]->innerMomentum().Mag2() ) << "\n";
305 
306 
307  h2_tk_nHitsVsR_ -> Fill ( (*mcPho).vertex().perp(), tracks[i]->recHitsSize() );
308  h2_tk_inPtVsR_->Fill ( (*mcPho).vertex().perp(), sqrt( tracks[i]->innerMomentum().Mag2() ) );
309  }
310 
311  }
312 
313 
314  }
315 
316  }
317 
318 
319 }
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:28
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::vector< PhotonMCTruth > find(std::vector< SimTrack > simTracks, std::vector< SimVertex > simVertices)
tuple tracks
Definition: testEve_cfg.py:39
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
edm::EventID id() const
Definition: EventBase.h:56
double pi()
Definition: Pi.h:31
double twoPi()
Definition: Pi.h:32
size_type size() const
Size of the RefVector.
Definition: RefVector.h:84
tuple cout
Definition: gather_cfg.py:41
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void PhotonsWithConversionsAnalyzer::beginJob ( void  )
virtual

Reco - MC

Reimplemented from edm::EDAnalyzer.

Definition at line 71 of file PhotonsWithConversionsAnalyzer.cc.

References TFileDirectory::make(), and mathSSE::return().

72 {
73 
74 
75  nEvt_=0;
76  nMCPho_=0;
77  nMatched_=0;
78 
79 
81 
82 
83 
85 
86 
88  h_ErecoEMC_ = fs->make<TH1F>("deltaE"," delta(reco-mc) energy",100,0.,2.);
89  h_deltaPhi_ = fs->make<TH1F>("deltaPhi"," delta(reco-mc) phi",100,-0.1, 0.1);
90  h_deltaEta_ = fs->make<TH1F>("deltaEta"," delta(reco-mc) eta",100,-0.05, 0.05);
91 
93  h_MCphoE_ = fs->make<TH1F>("MCphoE","MC photon energy",100,0.,100.);
94  h_MCphoPhi_ = fs->make<TH1F>("MCphoPhi","MC photon phi",40,-3.14, 3.14);
95  h_MCphoEta_ = fs->make<TH1F>("MCphoEta","MC photon eta",40,-3., 3.);
96 
97 
99  h_MCConvE_ = fs->make<TH1F>("MCConvE","MC converted photon energy",100,0.,100.);
100  h_MCConvPt_ = fs->make<TH1F>("MCConvPt","MC converted photon pt",100,0.,100.);
101  h_MCConvEta_ = fs->make<TH1F>("MCConvEta","MC converted photon eta",50, 0., 2.5);
102 
104  h_scE_ = fs->make<TH1F>("scE","SC Energy ",100,0., 200.);
105  h_scEt_ = fs->make<TH1F>("scEt","SC Et ",100,0., 200.);
106  h_scEta_ = fs->make<TH1F>("scEta","SC Eta ",40,-3., 3.);
107  h_scPhi_ = fs->make<TH1F>("scPhi","SC Phi ",40, -3.14, 3.14);
108  //
109  h_phoE_ = fs->make<TH1F>("phoE","Photon Energy ",100,0., 200.);
110  h_phoEta_ = fs->make<TH1F>("phoEta","Photon Eta ",40,-3., 3.);
111  h_phoPhi_ = fs->make<TH1F>("phoPhi","Photon Phi ",40, -3.14, 3.14);
112 
113  // Recontructed tracks from converted photon candidates
114  h2_tk_nHitsVsR_ = fs->make<TH2F>("tknHitsVsR","Tracks Hits vs R ", 12,0.,120.,20,0.5, 20.5);
115  h2_tk_inPtVsR_ = fs->make<TH2F>("tkInPtvsR","Tracks inner Pt vs R ", 12,0.,120.,100,0., 100.);
116 
117 
118  return ;
119 }
return((rh^lh)&mask)
T * make() const
make new ROOT object
void PhotonsWithConversionsAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 324 of file PhotonsWithConversionsAnalyzer.cc.

References gather_cfg::cout, and mathSSE::return().

325 {
326 
327 
328 
329 
330  // fOutputFile_->Write() ;
331  // fOutputFile_->Close() ;
332 
333  edm::LogInfo("ConvertedPhotonAnalyzer") << "Analyzed " << nEvt_ << "\n";
334  // std::cout << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
335  std::cout << "ConvertedPhotonAnalyzer::endJob Analyzed " << nEvt_ << " events " << "\n";
336 
337  return ;
338 }
return((rh^lh)&mask)
tuple cout
Definition: gather_cfg.py:41
float PhotonsWithConversionsAnalyzer::etaTransformation ( float  a,
float  b 
)
private

Definition at line 122 of file PhotonsWithConversionsAnalyzer.cc.

References ETA, etaBarrelEndcap, funct::log(), PI, R_ECAL, funct::tan(), and Z_Endcap.

122  {
123 
124 //---Definitions
125  const float PI = 3.1415927;
126  //UNUSED const float TWOPI = 2.0*PI;
127 
128 //---Definitions for ECAL
129  const float R_ECAL = 136.5;
130  const float Z_Endcap = 328.0;
131  const float etaBarrelEndcap = 1.479;
132 
133 //---ETA correction
134 
135  float Theta = 0.0 ;
136  float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
137 
138  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
139  if(Theta<0.0) Theta = Theta+PI ;
140  float ETA = - log(tan(0.5*Theta));
141 
142  if( fabs(ETA) > etaBarrelEndcap )
143  {
144  float Zend = Z_Endcap ;
145  if(EtaParticle<0.0 ) Zend = -Zend ;
146  float Zlen = Zend - Zvertex ;
147  float RR = Zlen/sinh(EtaParticle);
148  Theta = atan(RR/Zend);
149  if(Theta<0.0) Theta = Theta+PI ;
150  ETA = - log(tan(0.5*Theta));
151  }
152 //---Return the result
153  return ETA;
154 //---end
155 }
#define PI
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Log< T >::type log(const T &t)
Definition: Log.h:22
static const float etaBarrelEndcap
static const float Z_Endcap
static const float R_ECAL

Member Data Documentation

TFile* PhotonsWithConversionsAnalyzer::fOutputFile_
private

Definition at line 46 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::fOutputFileName_
private

Definition at line 45 of file PhotonsWithConversionsAnalyzer.h.

TH2F* PhotonsWithConversionsAnalyzer::h2_tk_inPtVsR_
private

Definition at line 93 of file PhotonsWithConversionsAnalyzer.h.

TH2F* PhotonsWithConversionsAnalyzer::h2_tk_nHitsVsR_
private

Definition at line 91 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_deltaEta_
private

Definition at line 64 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_deltaPhi_
private

Definition at line 63 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_ErecoEMC_
private

Definition at line 62 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCConvE_
private

Definition at line 75 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCConvEta_
private

Definition at line 77 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCConvPt_
private

Definition at line 76 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCphoE_
private

Definition at line 68 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCphoEta_
private

Definition at line 70 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_MCphoPhi_
private

Definition at line 69 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_phoE_
private

Definition at line 86 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_phoEta_
private

Definition at line 87 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_phoPhi_
private

Definition at line 88 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_scE_
private

Definition at line 81 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_scEt_
private

Definition at line 82 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_scEta_
private

Definition at line 83 of file PhotonsWithConversionsAnalyzer.h.

TH1F* PhotonsWithConversionsAnalyzer::h_scPhi_
private

Definition at line 84 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::HepMCLabel
private

Definition at line 53 of file PhotonsWithConversionsAnalyzer.h.

int PhotonsWithConversionsAnalyzer::nEvt_
private

Definition at line 49 of file PhotonsWithConversionsAnalyzer.h.

int PhotonsWithConversionsAnalyzer::nMatched_
private

Definition at line 51 of file PhotonsWithConversionsAnalyzer.h.

int PhotonsWithConversionsAnalyzer::nMCPho_
private

Definition at line 50 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::photonCollection_
private

Definition at line 60 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::photonCollectionProducer_
private

Definition at line 59 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::SimHitLabel
private

Definition at line 56 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::SimTkLabel
private

Definition at line 54 of file PhotonsWithConversionsAnalyzer.h.

std::string PhotonsWithConversionsAnalyzer::SimVtxLabel
private

Definition at line 55 of file PhotonsWithConversionsAnalyzer.h.

PhotonMCTruthFinder* PhotonsWithConversionsAnalyzer::thePhotonMCTruthFinder_
private

Definition at line 43 of file PhotonsWithConversionsAnalyzer.h.