41 #include "CLHEP/Units/GlobalPhysicalConstants.h"
42 #include "HepMC/GenParticle.h"
43 #include "HepMC/SimpleVector.h"
109 using namespace reco;
112 : beamSpot_(conf.getParameter<
edm::
InputTag>(
"beamSpot")) {
114 histfile_ =
new TFile(
"electronpixelseeds.root",
"RECREATE");
119 tree_ =
new TTree(
"ElectronSeeds",
"ElectronSeed validation ntuple");
123 tree_->Branch(
"mcPt",
mcPt,
"mcPt[10]/F");
124 tree_->Branch(
"mcQ",
mcQ,
"mcQ[10]/F");
148 histeMC_ =
new TH1F(
"eMC",
"MC particle energy", 100, 0., 100.);
149 histeMCmatched_ =
new TH1F(
"eMCmatched",
"matched MC particle energy", 100, 0., 100.);
151 new TH1F(
"ecaldriveneMCmatched",
"matched MC particle energy, ecal driven", 100, 0., 100.);
153 new TH1F(
"trackerdriveneMCmatched",
"matched MC particle energy, tracker driven", 100, 0., 100.);
154 histp_ =
new TH1F(
"p",
"seed p", 100, 0., 100.);
155 histeclu_ =
new TH1F(
"clus energy",
"supercluster energy", 100, 0., 100.);
156 histpt_ =
new TH1F(
"pt",
"seed pt", 100, 0., 100.);
157 histptMC_ =
new TH1F(
"ptMC",
"MC particle pt", 100, 0., 100.);
158 histptMCmatched_ =
new TH1F(
"ptMCmatched",
"matched MC particle pt", 100, 0., 100.);
161 new TH1F(
"trackerdrivenptMCmatched",
"matched MC particle pt, tracker driven", 100, 0., 100.);
162 histetclu_ =
new TH1F(
"Et",
"supercluster Et", 100, 0., 100.);
163 histeffpt_ =
new TH1F(
"pt eff",
"seed effciency vs pt", 100, 0., 100.);
164 histeta_ =
new TH1F(
"seed eta",
"seed eta", 100, -2.5, 2.5);
165 histetaMC_ =
new TH1F(
"etaMC",
"MC particle eta", 100, -2.5, 2.5);
166 histetaMCmatched_ =
new TH1F(
"etaMCmatched",
"matched MC particle eta", 100, -2.5, 2.5);
168 new TH1F(
"ecaldrivenetaMCmatched",
"matched MC particle eta, ecal driven", 100, -2.5, 2.5);
170 new TH1F(
"trackerdrivenetaMCmatched",
"matched MC particle eta, tracker driven", 100, -2.5, 2.5);
171 histetaclu_ =
new TH1F(
"clus eta",
"supercluster eta", 100, -2.5, 2.5);
172 histeffeta_ =
new TH1F(
"eta eff",
"seed effciency vs eta", 100, -2.5, 2.5);
173 histq_ =
new TH1F(
"q",
"seed charge", 100, -2.5, 2.5);
174 histeoverp_ =
new TH1F(
"E/p",
"seed E/p", 100, 0., 10.);
175 histnbseeds_ =
new TH1I(
"nrs",
"Nr of seeds ", 50, 0., 25.);
176 histnbclus_ =
new TH1I(
"nrclus",
"Nr of superclusters ", 50, 0., 25.);
177 histnrseeds_ =
new TH1I(
"ns",
"Nr of seeds if clusters", 50, 0., 25.);
190 histetaEff->GetXaxis()->SetTitle(
"#eta");
191 histetaEff->GetYaxis()->SetTitle(
"Efficiency");
198 histptEff->GetXaxis()->SetTitle(
"p_{T}");
199 histptEff->GetYaxis()->SetTitle(
"Efficiency");
255 edm::LogInfo(
"") <<
"\n\n =================> Treating event " <<
e.id() <<
" Number of seeds "
259 float mass = .000511;
263 float dphi1 = 0., dphi2 = 0., drz1 = 0., drz2 = 0.;
264 float phi1 = 0., phi2 = 0., rz1 = 0., rz2 = 0.;
266 for (ElectronSeedCollection::const_iterator MyS = (*elSeeds).begin(); MyS != (*elSeeds).end(); ++MyS) {
267 LogDebug(
"") <<
"\nSeed nr " << is <<
": ";
269 LogDebug(
"") <<
" Number of RecHits= " << (*MyS).nHits();
276 LogDebug(
"") <<
" First hit local x,y,z " << (*it).localPosition() <<
" det " <<
id1.det() <<
" subdet "
278 LogDebug(
"") <<
" First hit global " << det1->
toGlobal((*it).localPosition());
284 LogDebug(
"") <<
" Second hit local x,y,z " << (*it).localPosition() <<
" det " <<
id2.det() <<
" subdet "
286 LogDebug(
"") <<
" Second hit global " << det2->
toGlobal((*it).localPosition());
300 LogDebug(
"") <<
" ElectronSeed outermost state position: " <<
t.globalPosition();
301 LogDebug(
"") <<
" ElectronSeed outermost state momentum: " <<
t.globalMomentum();
306 LogDebug(
"") <<
" ElectronSeed superCluster energy: " << theClus->energy() <<
", position: " << theClus->position();
307 LogDebug(
"") <<
" ElectronSeed outermost state Pt: " <<
t.globalMomentum().perp();
308 LogDebug(
"") <<
" ElectronSeed supercluster Et: "
309 << theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta())));
310 LogDebug(
"") <<
" ElectronSeed outermost momentum direction eta: " <<
t.globalMomentum().eta();
311 LogDebug(
"") <<
" ElectronSeed supercluster eta: " << theClus->position().eta();
312 LogDebug(
"") <<
" ElectronSeed seed charge: " << (*MyS).getCharge();
313 LogDebug(
"") <<
" ElectronSeed E/p: " << theClus->energy() /
t.globalMomentum().mag();
320 GlobalPoint xmeas(theClus->position().x(), theClus->position().y(), theClus->position().z());
322 float energy = theClus->energy();
336 DetId id = (*it).geographicalId();
346 float SCl_phi = xmeas.phi();
347 float localDphi = SCl_phi - hitPos.
phi();
359 if (
id.subdetId() % 2 == 1) {
371 double pxHit1z = hitPos.
z();
372 double pxHit1x = hitPos.
x();
373 double pxHit1y = hitPos.
y();
374 double r1diff = (pxHit1x - vprim.x()) * (pxHit1x - vprim.x()) + (pxHit1y - vprim.y()) * (pxHit1y - vprim.y());
375 r1diff =
sqrt(r1diff);
376 double r2diff = (xmeas.x() - pxHit1x) * (xmeas.x() - pxHit1x) + (xmeas.y() - pxHit1y) * (xmeas.y() - pxHit1y);
377 r2diff =
sqrt(r2diff);
378 double zVertexPred = pxHit1z - r1diff * (xmeas.z() - pxHit1z) / r2diff;
380 GlobalPoint vertexPred(vprim.x(), vprim.y(), zVertexPred);
388 phi2 = hitPos2.
phi();
390 rz2 = hitPos2.
perp();
392 if (
id2.subdetId() % 2 == 1) {
401 histpt_->Fill(
t.globalMomentum().perp());
402 histetclu_->Fill(theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta()))));
403 histeta_->Fill(
t.globalMomentum().eta());
405 histq_->Fill((*MyS).getCharge());
406 histeoverp_->Fill(theClus->energy() /
t.globalMomentum().mag());
414 seedEta[is] =
t.globalMomentum().eta();
415 seedPhi[is] =
t.globalMomentum().phi();
416 seedPt[is] =
t.globalMomentum().perp();
417 seedQ[is] = (*MyS).getCharge();
443 e.getByLabel(
"correctedHybridSuperClusters",
clusters);
453 e.getByLabel(
"generatorSmeared",
"", HepMCEvt);
457 HepMC::FourVector pAssSim;
459 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin(); partIter != MCEvt->particles_end();
461 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin(); vertIter != MCEvt->vertices_end();
464 HepMC::GenVertex *creation = (*partIter)->production_vertex();
466 HepMC::FourVector momentum = (*partIter)->momentum();
468 int id = (*partIter)->pdg_id();
469 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum "
470 << momentum.rho() <<
" GeV/c" << std::endl;
472 if (
id == 11 ||
id == -11) {
475 if ((*partIter)->production_vertex()) {
476 if ((*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
478 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
480 if (((mother ==
nullptr) || ((mother !=
nullptr) && (mother->pdg_id() == 23)) ||
481 ((mother !=
nullptr) && (mother->pdg_id() == 32)) ||
482 ((mother !=
nullptr) && (
std::abs(mother->pdg_id()) == 24)))) {
484 pAssSim = genPc->momentum();
499 bool okSeedFound =
false;
500 double seedOkRatio = 999999.;
504 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
507 for (
auto const &
recHit : gsfIter->recHits()) {
513 float eta =
t.globalMomentum().eta();
514 float phi =
t.globalMomentum().phi();
515 float p =
t.globalMomentum().mag();
516 double dphi =
phi - pAssSim.phi();
518 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
524 double tmpSeedRatio =
p / pAssSim.t();
526 seedOkRatio = tmpSeedRatio;
527 bestElectronSeed = *gsfIter;
541 mcEta[ip] = pAssSim.eta();
542 mcPhi[ip] = pAssSim.phi();
543 mcPt[ip] = pAssSim.perp();
544 mcQ[ip] = ((
id == 11) ? -1. : +1.);
550 seedOkRatio = 999999.;
553 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
556 for (
auto const &
recHit : gsfIter->recHits()) {
562 float eta =
t.globalMomentum().eta();
563 float phi =
t.globalMomentum().phi();
564 float p =
t.globalMomentum().mag();
565 double dphi =
phi - pAssSim.phi();
567 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
569 if (gsfIter->isEcalDriven()) {
574 double tmpSeedRatio =
p / pAssSim.t();
576 seedOkRatio = tmpSeedRatio;
577 bestElectronSeed = *gsfIter;
594 seedOkRatio = 999999.;
597 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
600 for (
auto const &
recHit : gsfIter->recHits()) {
606 float eta =
t.globalMomentum().eta();
607 float phi =
t.globalMomentum().phi();
608 float p =
t.globalMomentum().mag();
609 double dphi =
phi - pAssSim.phi();
611 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
613 if (gsfIter->isTrackerDriven()) {
618 double tmpSeedRatio =
p / pAssSim.t();
620 seedOkRatio = tmpSeedRatio;
621 bestElectronSeed = *gsfIter;