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
SimpleConvertedPhotonAnalyzer Class Reference

#include <SimpleConvertedPhotonAnalyzer.h>

Inheritance diagram for SimpleConvertedPhotonAnalyzer:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 SimpleConvertedPhotonAnalyzer (const edm::ParameterSet &)
 
virtual ~SimpleConvertedPhotonAnalyzer ()
 
- 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

std::string convertedPhotonCollection_
 
std::string convertedPhotonCollectionProducer_
 
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_scEta_
 
TH1F * h_scPhi_
 
std::string HepMCLabel
 
int nEvt_
 
int nMatched_
 
int nMCPho_
 
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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 23 of file SimpleConvertedPhotonAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file SimpleConvertedPhotonAnalyzer.cc.

References convertedPhotonCollection_, convertedPhotonCollectionProducer_, and edm::ParameterSet::getParameter().

48  : fOutputFileName_( pset.getUntrackedParameter<string>("HistOutFile",std::string("TestConversions.root")) ),
49  fOutputFile_(0)
50 {
51 
52  convertedPhotonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
53  convertedPhotonCollection_ = pset.getParameter<std::string>("convertedPhotonCollection");
54  //
55 
56 
57 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
SimpleConvertedPhotonAnalyzer::~SimpleConvertedPhotonAnalyzer ( )
virtual

Definition at line 61 of file SimpleConvertedPhotonAnalyzer.cc.

References thePhotonMCTruthFinder_.

61  {
62 
63 
65 
66 }

Member Function Documentation

void SimpleConvertedPhotonAnalyzer::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 156 of file SimpleConvertedPhotonAnalyzer.cc.

References convertedPhotonCollection_, convertedPhotonCollectionProducer_, gather_cfg::cout, delta, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, etaTransformation(), HcalObjRepresent::Fill(), PhotonMCTruthFinder::find(), edm::Event::getByLabel(), h2_tk_inPtVsR_, h2_tk_nHitsVsR_, h_deltaEta_, h_deltaPhi_, h_ErecoEMC_, h_MCConvEta_, h_MCphoE_, h_MCphoEta_, h_MCphoPhi_, h_scE_, h_scEta_, h_scPhi_, i, edm::EventBase::id(), nEvt_, nMatched_, nMCPho_, Geom::pi(), funct::pow(), mathSSE::sqrt(), thePhotonMCTruthFinder_, and Geom::twoPi().

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

Reco - MC

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file SimpleConvertedPhotonAnalyzer.cc.

References fOutputFile_, fOutputFileName_, h2_tk_inPtVsR_, h2_tk_nHitsVsR_, h_deltaEta_, h_deltaPhi_, h_ErecoEMC_, h_MCConvE_, h_MCConvEta_, h_MCConvPt_, h_MCphoE_, h_MCphoEta_, h_MCphoPhi_, h_phoE_, h_phoEta_, h_phoPhi_, h_scE_, h_scEta_, h_scPhi_, nEvt_, nMatched_, nMCPho_, hitfit::return, and thePhotonMCTruthFinder_.

70 {
71 
72 
73  nEvt_=0;
74  nMCPho_=0;
75  nMatched_=0;
76 
77 
79 
80  fOutputFile_ = new TFile( fOutputFileName_.c_str(), "RECREATE" ) ;
81 
83  h_ErecoEMC_ = new TH1F("deltaE"," delta(reco-mc) energy",100,0.,2.);
84  h_deltaPhi_ = new TH1F("deltaPhi"," delta(reco-mc) phi",100,-0.1, 0.1);
85  h_deltaEta_ = new TH1F("deltaEta"," delta(reco-mc) eta",100,-0.05, 0.05);
86 
88  h_MCphoE_ = new TH1F("MCphoE","MC photon energy",100,0.,100.);
89  h_MCphoPhi_ = new TH1F("MCphoPhi","MC photon phi",40,-3.14, 3.14);
90  h_MCphoEta_ = new TH1F("MCphoEta","MC photon eta",40,-3., 3.);
91 
92 
94  h_MCConvE_ = new TH1F("MCConvE","MC converted photon energy",100,0.,100.);
95  h_MCConvPt_ = new TH1F("MCConvPt","MC converted photon pt",100,0.,100.);
96  h_MCConvEta_ = new TH1F("MCConvEta","MC converted photon eta",50, 0., 2.5);
97 
99  h_scE_ = new TH1F("scE","Uncorrected converted photons : SC Energy ",100,0., 200.);
100  h_scEta_ = new TH1F("scEta","Uncorrected converted photons: SC Eta ",40,-3., 3.);
101  h_scPhi_ = new TH1F("scPhi","Uncorrected converted photons: SC Phi ",40, -3.14, 3.14);
102  //
103  h_phoE_ = new TH1F("phoE","Uncorrected converted photons : Energy ",100,0., 200.);
104  h_phoEta_ = new TH1F("phoEta","Uncorrected converted photons: Eta ",40,-3., 3.);
105  h_phoPhi_ = new TH1F("phoPhi","Uncorrected converted photons: Phi ",40, -3.14, 3.14);
106 
107  // Recontructed tracks from converted photon candidates
108  h2_tk_nHitsVsR_ = new TH2F("tknHitsVsR","Tracks Hits vs R ", 12,0.,120.,20,0.5, 20.5);
109  h2_tk_inPtVsR_ = new TH2F("tkInPtvsR","Tracks inner Pt vs R ", 12,0.,120.,100,0., 100.);
110 
111 
112  return ;
113 }
void SimpleConvertedPhotonAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 314 of file SimpleConvertedPhotonAnalyzer.cc.

References gather_cfg::cout, fOutputFile_, nEvt_, and hitfit::return.

315 {
316 
317 
318 
319 
320  fOutputFile_->Write() ;
321  fOutputFile_->Close() ;
322 
323  edm::LogInfo("ConvertedPhotonAnalyzer") << "Analyzed " << nEvt_ << "\n";
324  // std::cout << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
325  std::cout << "ConvertedPhotonAnalyzer::endJob Analyzed " << nEvt_ << " events " << "\n";
326 
327  return ;
328 }
tuple cout
Definition: gather_cfg.py:121
float SimpleConvertedPhotonAnalyzer::etaTransformation ( float  a,
float  b 
)
private

Definition at line 116 of file SimpleConvertedPhotonAnalyzer.cc.

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

Referenced by analyze().

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

Member Data Documentation

std::string SimpleConvertedPhotonAnalyzer::convertedPhotonCollection_
private

Definition at line 60 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and SimpleConvertedPhotonAnalyzer().

std::string SimpleConvertedPhotonAnalyzer::convertedPhotonCollectionProducer_
private

Definition at line 59 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and SimpleConvertedPhotonAnalyzer().

TFile* SimpleConvertedPhotonAnalyzer::fOutputFile_
private

Definition at line 46 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob(), and endJob().

std::string SimpleConvertedPhotonAnalyzer::fOutputFileName_
private

Definition at line 45 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH2F* SimpleConvertedPhotonAnalyzer::h2_tk_inPtVsR_
private

Definition at line 92 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH2F* SimpleConvertedPhotonAnalyzer::h2_tk_nHitsVsR_
private

Definition at line 90 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_deltaEta_
private

Definition at line 64 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_deltaPhi_
private

Definition at line 63 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_ErecoEMC_
private

Definition at line 62 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvE_
private

Definition at line 75 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvEta_
private

Definition at line 77 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvPt_
private

Definition at line 76 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoE_
private

Definition at line 68 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoEta_
private

Definition at line 70 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoPhi_
private

Definition at line 69 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoE_
private

Definition at line 85 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoEta_
private

Definition at line 86 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoPhi_
private

Definition at line 87 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scE_
private

Definition at line 81 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scEta_
private

Definition at line 82 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scPhi_
private

Definition at line 83 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

std::string SimpleConvertedPhotonAnalyzer::HepMCLabel
private

Definition at line 53 of file SimpleConvertedPhotonAnalyzer.h.

int SimpleConvertedPhotonAnalyzer::nEvt_
private

Definition at line 49 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

int SimpleConvertedPhotonAnalyzer::nMatched_
private

Definition at line 51 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

int SimpleConvertedPhotonAnalyzer::nMCPho_
private

Definition at line 50 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

std::string SimpleConvertedPhotonAnalyzer::SimHitLabel
private

Definition at line 56 of file SimpleConvertedPhotonAnalyzer.h.

std::string SimpleConvertedPhotonAnalyzer::SimTkLabel
private

Definition at line 54 of file SimpleConvertedPhotonAnalyzer.h.

std::string SimpleConvertedPhotonAnalyzer::SimVtxLabel
private

Definition at line 55 of file SimpleConvertedPhotonAnalyzer.h.

PhotonMCTruthFinder* SimpleConvertedPhotonAnalyzer::thePhotonMCTruthFinder_
private