43 #include "HepMC/GenParticle.h"
44 #include "HepMC/SimpleVector.h"
45 #include "CLHEP/Units/GlobalPhysicalConstants.h"
57 : beamSpot_(conf.getParameter<
edm::
InputTag>(
"beamSpot")) {
59 histfile_ =
new TFile(
"electronpixelseeds.root",
"RECREATE");
64 tree_ =
new TTree(
"ElectronSeeds",
"ElectronSeed validation ntuple");
68 tree_->Branch(
"mcPt",
mcPt,
"mcPt[10]/F");
69 tree_->Branch(
"mcQ",
mcQ,
"mcQ[10]/F");
93 histeMC_ =
new TH1F(
"eMC",
"MC particle energy", 100, 0., 100.);
94 histeMCmatched_ =
new TH1F(
"eMCmatched",
"matched MC particle energy", 100, 0., 100.);
96 new TH1F(
"ecaldriveneMCmatched",
"matched MC particle energy, ecal driven", 100, 0., 100.);
98 new TH1F(
"trackerdriveneMCmatched",
"matched MC particle energy, tracker driven", 100, 0., 100.);
99 histp_ =
new TH1F(
"p",
"seed p", 100, 0., 100.);
100 histeclu_ =
new TH1F(
"clus energy",
"supercluster energy", 100, 0., 100.);
101 histpt_ =
new TH1F(
"pt",
"seed pt", 100, 0., 100.);
102 histptMC_ =
new TH1F(
"ptMC",
"MC particle pt", 100, 0., 100.);
103 histptMCmatched_ =
new TH1F(
"ptMCmatched",
"matched MC particle pt", 100, 0., 100.);
106 new TH1F(
"trackerdrivenptMCmatched",
"matched MC particle pt, tracker driven", 100, 0., 100.);
107 histetclu_ =
new TH1F(
"Et",
"supercluster Et", 100, 0., 100.);
108 histeffpt_ =
new TH1F(
"pt eff",
"seed effciency vs pt", 100, 0., 100.);
109 histeta_ =
new TH1F(
"seed eta",
"seed eta", 100, -2.5, 2.5);
110 histetaMC_ =
new TH1F(
"etaMC",
"MC particle eta", 100, -2.5, 2.5);
111 histetaMCmatched_ =
new TH1F(
"etaMCmatched",
"matched MC particle eta", 100, -2.5, 2.5);
113 new TH1F(
"ecaldrivenetaMCmatched",
"matched MC particle eta, ecal driven", 100, -2.5, 2.5);
115 new TH1F(
"trackerdrivenetaMCmatched",
"matched MC particle eta, tracker driven", 100, -2.5, 2.5);
116 histetaclu_ =
new TH1F(
"clus eta",
"supercluster eta", 100, -2.5, 2.5);
117 histeffeta_ =
new TH1F(
"eta eff",
"seed effciency vs eta", 100, -2.5, 2.5);
118 histq_ =
new TH1F(
"q",
"seed charge", 100, -2.5, 2.5);
119 histeoverp_ =
new TH1F(
"E/p",
"seed E/p", 100, 0., 10.);
120 histnbseeds_ =
new TH1I(
"nrs",
"Nr of seeds ", 50, 0., 25.);
121 histnbclus_ =
new TH1I(
"nrclus",
"Nr of superclusters ", 50, 0., 25.);
122 histnrseeds_ =
new TH1I(
"ns",
"Nr of seeds if clusters", 50, 0., 25.);
135 histetaEff->GetXaxis()->SetTitle(
"#eta");
136 histetaEff->GetYaxis()->SetTitle(
"Efficiency");
143 histptEff->GetXaxis()->SetTitle(
"p_{T}");
144 histptEff->GetYaxis()->SetTitle(
"Efficiency");
200 edm::LogInfo(
"") <<
"\n\n =================> Treating event " <<
e.id() <<
" Number of seeds "
204 float mass = .000511;
208 float dphi1 = 0., dphi2 = 0., drz1 = 0., drz2 = 0.;
209 float phi1 = 0., phi2 = 0., rz1 = 0., rz2 = 0.;
211 for (ElectronSeedCollection::const_iterator MyS = (*elSeeds).begin(); MyS != (*elSeeds).end(); ++MyS) {
212 LogDebug(
"") <<
"\nSeed nr " << is <<
": ";
214 LogDebug(
"") <<
" Number of RecHits= " << (*MyS).nHits();
221 LogDebug(
"") <<
" First hit local x,y,z " << (*it).localPosition() <<
" det " <<
id1.det() <<
" subdet "
223 LogDebug(
"") <<
" First hit global " << det1->
toGlobal((*it).localPosition());
229 LogDebug(
"") <<
" Second hit local x,y,z " << (*it).localPosition() <<
" det " <<
id2.det() <<
" subdet "
231 LogDebug(
"") <<
" Second hit global " << det2->
toGlobal((*it).localPosition());
245 LogDebug(
"") <<
" ElectronSeed outermost state position: " <<
t.globalPosition();
246 LogDebug(
"") <<
" ElectronSeed outermost state momentum: " <<
t.globalMomentum();
251 LogDebug(
"") <<
" ElectronSeed superCluster energy: " << theClus->energy() <<
", position: " << theClus->position();
252 LogDebug(
"") <<
" ElectronSeed outermost state Pt: " <<
t.globalMomentum().perp();
253 LogDebug(
"") <<
" ElectronSeed supercluster Et: "
254 << theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta())));
255 LogDebug(
"") <<
" ElectronSeed outermost momentum direction eta: " <<
t.globalMomentum().eta();
256 LogDebug(
"") <<
" ElectronSeed supercluster eta: " << theClus->position().eta();
257 LogDebug(
"") <<
" ElectronSeed seed charge: " << (*MyS).getCharge();
258 LogDebug(
"") <<
" ElectronSeed E/p: " << theClus->energy() /
t.globalMomentum().mag();
265 GlobalPoint xmeas(theClus->position().x(), theClus->position().y(), theClus->position().z());
267 float energy = theClus->energy();
281 DetId id = (*it).geographicalId();
291 float SCl_phi = xmeas.phi();
292 float localDphi = SCl_phi - hitPos.
phi();
304 if (
id.subdetId() % 2 == 1) {
316 double pxHit1z = hitPos.
z();
317 double pxHit1x = hitPos.
x();
318 double pxHit1y = hitPos.
y();
319 double r1diff = (pxHit1x - vprim.x()) * (pxHit1x - vprim.x()) + (pxHit1y - vprim.y()) * (pxHit1y - vprim.y());
320 r1diff =
sqrt(r1diff);
321 double r2diff = (xmeas.x() - pxHit1x) * (xmeas.x() - pxHit1x) + (xmeas.y() - pxHit1y) * (xmeas.y() - pxHit1y);
322 r2diff =
sqrt(r2diff);
323 double zVertexPred = pxHit1z - r1diff * (xmeas.z() - pxHit1z) / r2diff;
325 GlobalPoint vertexPred(vprim.x(), vprim.y(), zVertexPred);
333 phi2 = hitPos2.
phi();
335 rz2 = hitPos2.
perp();
337 if (
id2.subdetId() % 2 == 1) {
346 histpt_->Fill(
t.globalMomentum().perp());
347 histetclu_->Fill(theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta()))));
348 histeta_->Fill(
t.globalMomentum().eta());
350 histq_->Fill((*MyS).getCharge());
351 histeoverp_->Fill(theClus->energy() /
t.globalMomentum().mag());
359 seedEta[is] =
t.globalMomentum().eta();
360 seedPhi[is] =
t.globalMomentum().phi();
361 seedPt[is] =
t.globalMomentum().perp();
362 seedQ[is] = (*MyS).getCharge();
388 e.getByLabel(
"correctedHybridSuperClusters",
clusters);
398 e.getByLabel(
"generatorSmeared",
"", HepMCEvt);
402 HepMC::FourVector pAssSim;
404 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin(); partIter != MCEvt->particles_end();
406 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin(); vertIter != MCEvt->vertices_end();
409 HepMC::GenVertex *creation = (*partIter)->production_vertex();
411 HepMC::FourVector momentum = (*partIter)->momentum();
413 int id = (*partIter)->pdg_id();
414 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum "
415 << momentum.rho() <<
" GeV/c" << std::endl;
417 if (
id == 11 ||
id == -11) {
420 if ((*partIter)->production_vertex()) {
421 if ((*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
423 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
425 if (((mother ==
nullptr) || ((mother !=
nullptr) && (mother->pdg_id() == 23)) ||
426 ((mother !=
nullptr) && (mother->pdg_id() == 32)) ||
427 ((mother !=
nullptr) && (
std::abs(mother->pdg_id()) == 24)))) {
429 pAssSim = genPc->momentum();
444 bool okSeedFound =
false;
445 double seedOkRatio = 999999.;
449 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
452 for (
auto const &
recHit : gsfIter->recHits()) {
458 float eta =
t.globalMomentum().eta();
459 float phi =
t.globalMomentum().phi();
460 float p =
t.globalMomentum().mag();
461 double dphi =
phi - pAssSim.phi();
463 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
469 double tmpSeedRatio =
p / pAssSim.t();
471 seedOkRatio = tmpSeedRatio;
472 bestElectronSeed = *gsfIter;
486 mcEta[ip] = pAssSim.eta();
487 mcPhi[ip] = pAssSim.phi();
488 mcPt[ip] = pAssSim.perp();
489 mcQ[ip] = ((
id == 11) ? -1. : +1.);
495 seedOkRatio = 999999.;
498 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
501 for (
auto const &
recHit : gsfIter->recHits()) {
507 float eta =
t.globalMomentum().eta();
508 float phi =
t.globalMomentum().phi();
509 float p =
t.globalMomentum().mag();
510 double dphi =
phi - pAssSim.phi();
512 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
514 if (gsfIter->isEcalDriven()) {
519 double tmpSeedRatio =
p / pAssSim.t();
521 seedOkRatio = tmpSeedRatio;
522 bestElectronSeed = *gsfIter;
539 seedOkRatio = 999999.;
542 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
545 for (
auto const &
recHit : gsfIter->recHits()) {
551 float eta =
t.globalMomentum().eta();
552 float phi =
t.globalMomentum().phi();
553 float p =
t.globalMomentum().mag();
554 double dphi =
phi - pAssSim.phi();
556 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
558 if (gsfIter->isTrackerDriven()) {
563 double tmpSeedRatio =
p / pAssSim.t();
565 seedOkRatio = tmpSeedRatio;
566 bestElectronSeed = *gsfIter;