40 #include "CLHEP/Units/GlobalPhysicalConstants.h" 41 #include "HepMC/GenParticle.h" 42 #include "HepMC/SimpleVector.h" 112 using namespace reco;
118 beamSpot_(conf.getParameter<
edm::
InputTag>(
"beamSpot")) {
120 histfile_ =
new TFile(
"electronpixelseeds.root",
"RECREATE");
125 tree_ =
new TTree(
"ElectronSeeds",
"ElectronSeed validation ntuple");
129 tree_->Branch(
"mcPt",
mcPt,
"mcPt[10]/F");
130 tree_->Branch(
"mcQ",
mcQ,
"mcQ[10]/F");
154 histeMC_ =
new TH1F(
"eMC",
"MC particle energy", 100, 0., 100.);
155 histeMCmatched_ =
new TH1F(
"eMCmatched",
"matched MC particle energy", 100, 0., 100.);
157 new TH1F(
"ecaldriveneMCmatched",
"matched MC particle energy, ecal driven", 100, 0., 100.);
159 new TH1F(
"trackerdriveneMCmatched",
"matched MC particle energy, tracker driven", 100, 0., 100.);
160 histp_ =
new TH1F(
"p",
"seed p", 100, 0., 100.);
161 histeclu_ =
new TH1F(
"clus energy",
"supercluster energy", 100, 0., 100.);
162 histpt_ =
new TH1F(
"pt",
"seed pt", 100, 0., 100.);
163 histptMC_ =
new TH1F(
"ptMC",
"MC particle pt", 100, 0., 100.);
164 histptMCmatched_ =
new TH1F(
"ptMCmatched",
"matched MC particle pt", 100, 0., 100.);
167 new TH1F(
"trackerdrivenptMCmatched",
"matched MC particle pt, tracker driven", 100, 0., 100.);
168 histetclu_ =
new TH1F(
"Et",
"supercluster Et", 100, 0., 100.);
169 histeffpt_ =
new TH1F(
"pt eff",
"seed effciency vs pt", 100, 0., 100.);
170 histeta_ =
new TH1F(
"seed eta",
"seed eta", 100, -2.5, 2.5);
171 histetaMC_ =
new TH1F(
"etaMC",
"MC particle eta", 100, -2.5, 2.5);
172 histetaMCmatched_ =
new TH1F(
"etaMCmatched",
"matched MC particle eta", 100, -2.5, 2.5);
174 new TH1F(
"ecaldrivenetaMCmatched",
"matched MC particle eta, ecal driven", 100, -2.5, 2.5);
176 new TH1F(
"trackerdrivenetaMCmatched",
"matched MC particle eta, tracker driven", 100, -2.5, 2.5);
177 histetaclu_ =
new TH1F(
"clus eta",
"supercluster eta", 100, -2.5, 2.5);
178 histeffeta_ =
new TH1F(
"eta eff",
"seed effciency vs eta", 100, -2.5, 2.5);
179 histq_ =
new TH1F(
"q",
"seed charge", 100, -2.5, 2.5);
180 histeoverp_ =
new TH1F(
"E/p",
"seed E/p", 100, 0., 10.);
181 histnbseeds_ =
new TH1I(
"nrs",
"Nr of seeds ", 50, 0., 25.);
182 histnbclus_ =
new TH1I(
"nrclus",
"Nr of superclusters ", 50, 0., 25.);
183 histnrseeds_ =
new TH1I(
"ns",
"Nr of seeds if clusters", 50, 0., 25.);
196 histetaEff->GetXaxis()->SetTitle(
"#eta");
197 histetaEff->GetYaxis()->SetTitle(
"Efficiency");
204 histptEff->GetXaxis()->SetTitle(
"p_{T}");
205 histptEff->GetYaxis()->SetTitle(
"Efficiency");
258 edm::LogInfo(
"") <<
"\n\n =================> Treating event " <<
e.id() <<
" Number of seeds " 262 float mass = .000511;
266 float dphi1 = 0., dphi2 = 0., drz1 = 0., drz2 = 0.;
267 float phi1 = 0., phi2 = 0., rz1 = 0., rz2 = 0.;
269 for (ElectronSeedCollection::const_iterator MyS = (*elSeeds).begin(); MyS != (*elSeeds).end(); ++MyS) {
270 LogDebug(
"") <<
"\nSeed nr " << is <<
": ";
272 LogDebug(
"") <<
" Number of RecHits= " << (*MyS).nHits();
279 LogDebug(
"") <<
" First hit local x,y,z " << (*it).localPosition() <<
" det " <<
id1.det() <<
" subdet " 281 LogDebug(
"") <<
" First hit global " << det1->
toGlobal((*it).localPosition());
287 LogDebug(
"") <<
" Second hit local x,y,z " << (*it).localPosition() <<
" det " <<
id2.det() <<
" subdet " 289 LogDebug(
"") <<
" Second hit global " << det2->
toGlobal((*it).localPosition());
303 LogDebug(
"") <<
" ElectronSeed outermost state position: " <<
t.globalPosition();
304 LogDebug(
"") <<
" ElectronSeed outermost state momentum: " <<
t.globalMomentum();
309 LogDebug(
"") <<
" ElectronSeed superCluster energy: " << theClus->energy() <<
", position: " << theClus->position();
310 LogDebug(
"") <<
" ElectronSeed outermost state Pt: " <<
t.globalMomentum().perp();
311 LogDebug(
"") <<
" ElectronSeed supercluster Et: " 312 << theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta())));
313 LogDebug(
"") <<
" ElectronSeed outermost momentum direction eta: " <<
t.globalMomentum().eta();
314 LogDebug(
"") <<
" ElectronSeed supercluster eta: " << theClus->position().eta();
315 LogDebug(
"") <<
" ElectronSeed seed charge: " << (*MyS).getCharge();
316 LogDebug(
"") <<
" ElectronSeed E/p: " << theClus->energy() /
t.globalMomentum().mag();
323 GlobalPoint xmeas(theClus->position().x(), theClus->position().y(), theClus->position().z());
325 float energy = theClus->energy();
339 DetId id = (*it).geographicalId();
349 float SCl_phi = xmeas.phi();
350 float localDphi = SCl_phi - hitPos.
phi();
362 if (
id.subdetId() % 2 == 1) {
374 double pxHit1z = hitPos.
z();
375 double pxHit1x = hitPos.
x();
376 double pxHit1y = hitPos.
y();
377 double r1diff = (pxHit1x - vprim.x()) * (pxHit1x - vprim.x()) + (pxHit1y - vprim.y()) * (pxHit1y - vprim.y());
378 r1diff =
sqrt(r1diff);
379 double r2diff = (xmeas.x() - pxHit1x) * (xmeas.x() - pxHit1x) + (xmeas.y() - pxHit1y) * (xmeas.y() - pxHit1y);
380 r2diff =
sqrt(r2diff);
381 double zVertexPred = pxHit1z - r1diff * (xmeas.z() - pxHit1z) / r2diff;
383 GlobalPoint vertexPred(vprim.x(), vprim.y(), zVertexPred);
391 phi2 = hitPos2.
phi();
393 rz2 = hitPos2.
perp();
395 if (
id2.subdetId() % 2 == 1) {
404 histpt_->Fill(
t.globalMomentum().perp());
405 histetclu_->Fill(theClus->energy() *
sin(2. * atan(
exp(-theClus->position().eta()))));
406 histeta_->Fill(
t.globalMomentum().eta());
408 histq_->Fill((*MyS).getCharge());
409 histeoverp_->Fill(theClus->energy() /
t.globalMomentum().mag());
417 seedEta[is] =
t.globalMomentum().eta();
418 seedPhi[is] =
t.globalMomentum().phi();
419 seedPt[is] =
t.globalMomentum().perp();
420 seedQ[is] = (*MyS).getCharge();
446 e.getByLabel(
"correctedHybridSuperClusters",
clusters);
456 e.getByLabel(
"generatorSmeared",
"", HepMCEvt);
460 HepMC::FourVector pAssSim;
462 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin(); partIter != MCEvt->particles_end();
464 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin(); vertIter != MCEvt->vertices_end();
467 HepMC::GenVertex *creation = (*partIter)->production_vertex();
469 HepMC::FourVector momentum = (*partIter)->momentum();
471 int id = (*partIter)->pdg_id();
472 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum " 473 << momentum.rho() <<
" GeV/c" << std::endl;
475 if (
id == 11 ||
id == -11) {
478 if ((*partIter)->production_vertex()) {
479 if ((*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
481 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
483 if (((mother ==
nullptr) || ((mother !=
nullptr) && (mother->pdg_id() == 23)) ||
484 ((mother !=
nullptr) && (mother->pdg_id() == 32)) ||
485 ((mother !=
nullptr) && (
std::abs(mother->pdg_id()) == 24)))) {
487 pAssSim = genPc->momentum();
502 bool okSeedFound =
false;
503 double seedOkRatio = 999999.;
507 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
510 for (
auto const &
recHit : gsfIter->recHits()) {
516 float eta =
t.globalMomentum().eta();
517 float phi =
t.globalMomentum().phi();
518 float p =
t.globalMomentum().mag();
519 double dphi =
phi - pAssSim.phi();
521 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
527 double tmpSeedRatio =
p / pAssSim.t();
529 seedOkRatio = tmpSeedRatio;
530 bestElectronSeed = *gsfIter;
544 mcEta[ip] = pAssSim.eta();
545 mcPhi[ip] = pAssSim.phi();
546 mcPt[ip] = pAssSim.perp();
547 mcQ[ip] = ((
id == 11) ? -1. : +1.);
553 seedOkRatio = 999999.;
556 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
559 for (
auto const &
recHit : gsfIter->recHits()) {
565 float eta =
t.globalMomentum().eta();
566 float phi =
t.globalMomentum().phi();
567 float p =
t.globalMomentum().mag();
568 double dphi =
phi - pAssSim.phi();
570 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
572 if (gsfIter->isEcalDriven()) {
577 double tmpSeedRatio =
p / pAssSim.t();
579 seedOkRatio = tmpSeedRatio;
580 bestElectronSeed = *gsfIter;
597 seedOkRatio = 999999.;
600 for (ElectronSeedCollection::const_iterator gsfIter = (*elSeeds).begin(); gsfIter != (*elSeeds).end();
603 for (
auto const &
recHit : gsfIter->recHits()) {
609 float eta =
t.globalMomentum().eta();
610 float phi =
t.globalMomentum().phi();
611 float p =
t.globalMomentum().mag();
612 double dphi =
phi - pAssSim.phi();
614 dphi = dphi < 0 ? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
616 if (gsfIter->isTrackerDriven()) {
621 double tmpSeedRatio =
p / pAssSim.t();
623 seedOkRatio = tmpSeedRatio;
624 bestElectronSeed = *gsfIter;
T getParameter(std::string const &) const
float superclusterEnergy[10]
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
const Point & position() const
position
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
Sin< T >::type sin(const T &t)
float superclusterPhi[10]
T const * product() const
TH1F * histtrackerdrivenetaMCmatched_
unsigned int side(const DetId &id) const
unsigned int layer(const DetId &id) const
edm::InputTag inputCollection_
GlobalPoint globalPosition() const
TH1F * histecaldrivenptMCmatched_
Abs< T >::type abs(const T &t)
bool isNull() const
Checks for null.
~ElectronSeedAnalyzer() override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
const TrackerGeomDet * idToDet(DetId) const override
TH1F * histecaldriveneMCmatched_
const HepMC::GenEvent * GetEvent() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
float superclusterEta[10]
TH1F * histecaldrivenetaMCmatched_
void analyze(const edm::Event &, const edm::EventSetup &) override
TH1F * histtrackerdriveneMCmatched_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
TrajectoryStateTransform transformer_
ElectronSeedAnalyzer(const edm::ParameterSet &conf)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken_
Power< A, B >::type pow(const A &a, const B &b)
TH1F * histtrackerdrivenptMCmatched_