102 : fOutputFileName_(
pset.getUntrackedParameter<
string>(
"HistOutFile",
std::
string(
"TestConversions.root"))),
103 fOutputFile_(nullptr) {
121 h_ErecoEMC_ =
new TH1F(
"deltaE",
" delta(reco-mc) energy", 100, 0., 2.);
122 h_deltaPhi_ =
new TH1F(
"deltaPhi",
" delta(reco-mc) phi", 100, -0.1, 0.1);
123 h_deltaEta_ =
new TH1F(
"deltaEta",
" delta(reco-mc) eta", 100, -0.05, 0.05);
126 h_MCphoE_ =
new TH1F(
"MCphoE",
"MC photon energy", 100, 0., 100.);
127 h_MCphoPhi_ =
new TH1F(
"MCphoPhi",
"MC photon phi", 40, -3.14, 3.14);
128 h_MCphoEta_ =
new TH1F(
"MCphoEta",
"MC photon eta", 40, -3., 3.);
131 h_MCConvE_ =
new TH1F(
"MCConvE",
"MC converted photon energy", 100, 0., 100.);
132 h_MCConvPt_ =
new TH1F(
"MCConvPt",
"MC converted photon pt", 100, 0., 100.);
133 h_MCConvEta_ =
new TH1F(
"MCConvEta",
"MC converted photon eta", 50, 0., 2.5);
136 h_scE_ =
new TH1F(
"scE",
"Uncorrected converted photons : SC Energy ", 100, 0., 200.);
137 h_scEta_ =
new TH1F(
"scEta",
"Uncorrected converted photons: SC Eta ", 40, -3., 3.);
138 h_scPhi_ =
new TH1F(
"scPhi",
"Uncorrected converted photons: SC Phi ", 40, -3.14, 3.14);
140 h_phoE_ =
new TH1F(
"phoE",
"Uncorrected converted photons : Energy ", 100, 0., 200.);
141 h_phoEta_ =
new TH1F(
"phoEta",
"Uncorrected converted photons: Eta ", 40, -3., 3.);
142 h_phoPhi_ =
new TH1F(
"phoPhi",
"Uncorrected converted photons: Phi ", 40, -3.14, 3.14);
145 h2_tk_nHitsVsR_ =
new TH2F(
"tknHitsVsR",
"Tracks Hits vs R ", 12, 0., 120., 20, 0.5, 20.5);
146 h2_tk_inPtVsR_ =
new TH2F(
"tkInPtvsR",
"Tracks inner Pt vs R ", 12, 0., 120., 100, 0., 100.);
153 const float PI = 3.1415927;
157 const float R_ECAL = 136.5;
164 float ZEcal =
R_ECAL * sinh(EtaParticle) + Zvertex;
174 if (EtaParticle < 0.0)
176 float Zlen = Zend - Zvertex;
177 float RR = Zlen / sinh(EtaParticle);
178 Theta = atan(RR / Zend);
190 const float etaPhiDistance = 0.01;
193 const float BARL = 1.4442;
194 const float END_LO = 1.566;
195 const float END_HI = 2.5;
200 LogInfo(
"ConvertedPhotonAnalyzer") <<
"ConvertedPhotonAnalyzer Analyzing event number: " <<
e.id()
201 <<
" Global Counter " <<
nEvt_ <<
"\n";
203 std::cout <<
"ConvertedPhotonAnalyzer Analyzing event number: " <<
e.id() <<
" Global Counter " <<
nEvt_ <<
"\n";
209 std::cout <<
"ConvertedPhotonAnalyzer Converted photon collection size " << phoCollection.size() <<
"\n";
212 std::cout <<
" ConvertedPhotonAnalyzer Looking for MC truth " 216 std::vector<SimTrack> theSimTracks;
217 std::vector<SimVertex> theSimVertices;
221 e.getByLabel(
"g4SimHits", SimTk);
222 e.getByLabel(
"g4SimHits", SimVtx);
224 theSimTracks.insert(theSimTracks.end(), SimTk->begin(), SimTk->end());
225 theSimVertices.insert(theSimVertices.end(), SimVtx->begin(), SimVtx->end());
228 std::cout <<
" ConvertedPhotonAnalyzer mcPhotons size " << mcPhotons.size() << std::endl;
235 for (std::vector<PhotonMCTruth>::const_iterator mcPho = mcPhotons.begin(); mcPho != mcPhotons.end(); mcPho++) {
236 float mcPhi = (*mcPho).fourMomentum().phi();
237 float mcEta = (*mcPho).fourMomentum().pseudoRapidity();
240 if (!(fabs(mcEta) <= BARL || (fabs(mcEta) >= END_LO && fabs(mcEta) <= END_HI))) {
244 std::cout <<
" ConvertedPhotonAnalyzer MC Photons before matching " << std::endl;
245 std::cout <<
" ConvertedPhotonAnalyzer Photons isAconversion " << (*mcPho).isAConversion()
246 <<
" mcMatchingPhoton energy " << (*mcPho).fourMomentum().e() <<
" conversion vertex R " 247 << (*mcPho).vertex().perp() <<
" Z " << (*mcPho).vertex().z() <<
" x " << (*mcPho).vertex().x() <<
" y " 248 << (*mcPho).vertex().y() <<
" z " << (*mcPho).vertex().z() << std::endl;
249 std::cout <<
" ConvertedPhotonAnalyzer mcEta " << mcEta <<
" mcPhi " << mcPhi << std::endl;
251 h_MCphoE_->Fill((*mcPho).fourMomentum().e());
256 if ((*mcPho).isAConversion() == 0)
261 h_MCConvEta_->Fill(fabs((*mcPho).fourMomentum().pseudoRapidity()) - 0.001);
266 std::cout <<
" ConvertedPhotonAnalyzer Starting loop over photon candidates " 268 for (reco::ConversionCollection::const_iterator iPho = phoCollection.begin(); iPho != phoCollection.end(); iPho++) {
271 std::cout <<
" ConvertedPhotonAnalyzer Reco SC energy " << (*iPho).caloCluster()[0]->energy() <<
"\n";
273 float phiClu = (*iPho).caloCluster()[0]->phi();
274 float etaClu = (*iPho).caloCluster()[0]->eta();
285 if (
delta >= etaPhiDistance)
295 std::cout <<
" ConvertedPhotonAnalyzer Matching candidate " << std::endl;
297 std::cout <<
" ConvertedPhotonAnalyzer Photons isAconversion " << (*mcPho).isAConversion()
298 <<
" mcMatchingPhoton energy " << (*mcPho).fourMomentum().e()
299 <<
" ConvertedPhotonAnalyzer conversion vertex R " << (*mcPho).vertex().perp() <<
" Z " 300 << (*mcPho).vertex().z() << std::endl;
302 h_ErecoEMC_->Fill((*iPho).caloCluster()[0]->energy() / (*mcPho).fourMomentum().e());
303 h_deltaPhi_->Fill((*iPho).caloCluster()[0]->position().phi() - mcPhi);
304 h_deltaEta_->Fill((*iPho).caloCluster()[0]->position().eta() - mcEta);
306 h_scE_->Fill((*iPho).caloCluster()[0]->energy());
307 h_scEta_->Fill((*iPho).caloCluster()[0]->position().eta());
308 h_scPhi_->Fill((*iPho).caloCluster()[0]->position().phi());
310 for (
unsigned int i = 0;
i < (*iPho).tracks().size();
i++) {
311 std::cout <<
" ConvertedPhotonAnalyzer Reco Track charge " << (*iPho).tracks()[
i]->charge()
312 <<
" Num of RecHits " << (*iPho).tracks()[
i]->recHitsSize() <<
" inner momentum " 313 <<
sqrt((*iPho).tracks()[
i]->innerMomentum().Mag2()) <<
"\n";
315 h2_tk_nHitsVsR_->Fill((*mcPho).vertex().perp(), (*iPho).tracks()[
i]->recHitsSize());
316 h2_tk_inPtVsR_->Fill((*mcPho).vertex().perp(),
sqrt((*iPho).tracks()[
i]->innerMomentum().Mag2()));
330 std::cout <<
"ConvertedPhotonAnalyzer::endJob Analyzed " <<
nEvt_ <<
" events "
std::string convertedPhotonCollection_
#define DEFINE_FWK_MODULE(type)
PhotonMCTruthFinder * thePhotonMCTruthFinder_
T const * product() const
static constexpr float R_ECAL
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
static const double deltaEta
~SimpleConvertedPhotonAnalyzer() override
SimpleConvertedPhotonAnalyzer(const edm::ParameterSet &)
Tan< T >::type tan(const T &t)
static constexpr float etaBarrelEndcap
Log< level::Info, false > LogInfo
std::vector< PhotonMCTruth > find(const std::vector< SimTrack > &simTracks, const std::vector< SimVertex > &simVertices)
float etaTransformation(float a, float b)
std::string convertedPhotonCollectionProducer_
static constexpr float ZEcal
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string fOutputFileName_
Power< A, B >::type pow(const A &a, const B &b)
static constexpr float Z_Endcap