48 : fOutputFileName_( pset.getUntrackedParameter<string>(
"HistOutFile",std::string(
"TestConversions.root")) ),
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);
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.);
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);
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);
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);
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.);
119 const float PI = 3.1415927;
123 const float R_ECAL = 136.5;
130 float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
132 if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
133 if(Theta<0.0) Theta = Theta+
PI ;
136 if( fabs(ETA) > etaBarrelEndcap )
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));
161 const float etaPhiDistance=0.01;
164 const float BARL = 1.4442;
165 const float END_LO = 1.566;
166 const float END_HI = 2.5;
172 LogInfo(
"ConvertedPhotonAnalyzer") <<
"ConvertedPhotonAnalyzer Analyzing event number: " << e.
id() <<
" Global Counter " <<
nEvt_ <<
"\n";
174 std::cout <<
"ConvertedPhotonAnalyzer Analyzing event number: " << e.
id() <<
" Global Counter " <<
nEvt_ <<
"\n";
181 std::cout <<
"ConvertedPhotonAnalyzer Converted photon collection size " << phoCollection.size() <<
"\n";
185 std::cout <<
" ConvertedPhotonAnalyzer Looking for MC truth " <<
"\n";
188 std::vector<SimTrack> theSimTracks;
189 std::vector<SimVertex> theSimVertices;
196 theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
197 theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
200 std::cout <<
" ConvertedPhotonAnalyzer mcPhotons size " << mcPhotons.size() << std::endl;
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();
214 if ( ! ( fabs(mcEta) <= BARL || ( fabs(mcEta) >= END_LO && fabs(mcEta) <=END_HI ) ) ) {
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;
224 h_MCphoE_->Fill( (*mcPho).fourMomentum().e());
231 if ( (*mcPho).isAConversion() == 0 )
continue;
236 h_MCConvEta_ ->Fill ( fabs( (*mcPho).fourMomentum().pseudoRapidity()) - 0.001);
243 std::cout <<
" ConvertedPhotonAnalyzer Starting loop over photon candidates " <<
"\n";
244 for( reco::ConversionCollection::const_iterator iPho = phoCollection.begin(); iPho != phoCollection.end(); iPho++) {
247 std::cout <<
" ConvertedPhotonAnalyzer Reco SC energy " << (*iPho).caloCluster()[0]->energy() <<
"\n";
251 float phiClu=(*iPho).caloCluster()[0]->phi();
252 float etaClu=(*iPho).caloCluster()[0]->eta();
254 float deltaEta = etaClu-mcEta;
261 float delta = deltaPhi+deltaEta ;
262 if ( delta >= etaPhiDistance ) REJECTED=
true;
267 if ( REJECTED )
continue;
272 std::cout <<
" ConvertedPhotonAnalyzer Matching candidate " << std::endl;
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;
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);
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() );
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";
291 h2_tk_inPtVsR_->Fill ( (*mcPho).vertex().perp(),
sqrt( (*iPho).tracks()[
i]->innerMomentum().Mag2() ) );
325 std::cout <<
"ConvertedPhotonAnalyzer::endJob Analyzed " <<
nEvt_ <<
" events " <<
"\n";
T getParameter(std::string const &) const
std::string convertedPhotonCollection_
double deltaPhi(float phi1, float phi2)
virtual ~SimpleConvertedPhotonAnalyzer()
PhotonMCTruthFinder * thePhotonMCTruthFinder_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
SimpleConvertedPhotonAnalyzer(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Tan< T >::type tan(const T &t)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Log< T >::type log(const T &t)
std::vector< PhotonMCTruth > find(std::vector< SimTrack > simTracks, std::vector< SimVertex > simVertices)
static const float etaBarrelEndcap
static const float Z_Endcap
float etaTransformation(float a, float b)
std::string convertedPhotonCollectionProducer_
static const float R_ECAL
std::string fOutputFileName_
Power< A, B >::type pow(const A &a, const B &b)