45 #include "HepMC/GenParticle.h" 46 #include "HepMC/SimpleVector.h" 47 #include "CLHEP/Units/GlobalPhysicalConstants.h" 59 beamSpot_(conf.getParameter<
edm::InputTag>(
"beamSpot"))
62 histfile_ =
new TFile(
"electronpixelseeds.root",
"RECREATE");
68 tree_ =
new TTree(
"ElectronSeeds",
"ElectronSeed validation ntuple");
73 tree_->Branch(
"mcQ",
mcQ,
"mcQ[10]/F");
97 histeMC_ =
new TH1F(
"eMC",
"MC particle energy",100,0.,100.);
98 histeMCmatched_ =
new TH1F(
"eMCmatched",
"matched MC particle energy",100,0.,100.);
101 histp_ =
new TH1F(
"p",
"seed p",100,0.,100.);
102 histeclu_ =
new TH1F(
"clus energy",
"supercluster energy",100,0.,100.);
103 histpt_ =
new TH1F(
"pt",
"seed pt",100,0.,100.);
104 histptMC_ =
new TH1F(
"ptMC",
"MC particle pt",100,0.,100.);
105 histptMCmatched_ =
new TH1F(
"ptMCmatched",
"matched MC particle pt",100,0.,100.);
108 histetclu_ =
new TH1F(
"Et",
"supercluster Et",100,0.,100.);
109 histeffpt_ =
new TH1F(
"pt eff",
"seed effciency vs pt",100,0.,100.);
110 histeta_ =
new TH1F(
"seed eta",
"seed eta",100,-2.5,2.5);
111 histetaMC_ =
new TH1F(
"etaMC",
"MC particle eta",100,-2.5,2.5);
112 histetaMCmatched_ =
new TH1F(
"etaMCmatched",
"matched MC particle eta",100,-2.5,2.5);
115 histetaclu_ =
new TH1F(
"clus eta",
"supercluster eta",100,-2.5,2.5);
116 histeffeta_ =
new TH1F(
"eta eff",
"seed effciency vs eta",100,-2.5,2.5);
117 histq_ =
new TH1F(
"q",
"seed charge",100,-2.5,2.5);
118 histeoverp_ =
new TH1F(
"E/p",
"seed E/p",100,0.,10.);
119 histnbseeds_ =
new TH1I(
"nrs",
"Nr of seeds ",50,0.,25.);
120 histnbclus_ =
new TH1I(
"nrclus",
"Nr of superclusters ",50,0.,25.);
121 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");
198 typedef recHitContainer::const_iterator const_iterator;
199 typedef std::pair<const_iterator,const_iterator> range;
210 edm::LogInfo(
"")<<
"\n\n =================> Treating event "<<e.
id()<<
" Number of seeds "<<elSeeds.
product()->size();
217 float dphi1=0., dphi2=0., drz1=0., drz2=0.;
218 float phi1=0., phi2=0., rz1=0., rz2=0.;
220 for( ElectronSeedCollection::const_iterator MyS= (*elSeeds).begin(); MyS != (*elSeeds).end(); ++MyS) {
222 LogDebug(
"") <<
"\nSeed nr "<<is<<
": ";
223 range
r=(*MyS).recHits();
224 LogDebug(
"")<<
" Number of RecHits= "<<(*MyS).nHits();
230 LogDebug(
"") <<
" First hit local x,y,z "<<(*it).localPosition()<<
" det "<<id1.
det()<<
" subdet "<<id1.
subdetId();
237 LogDebug(
"") <<
" Second hit local x,y,z "<<(*it).localPosition()<<
" det "<<id2.
det()<<
" subdet "<<id2.
subdetId();
238 LogDebug(
"") <<
" Second hit global "<<det2->
toGlobal((*it).localPosition());
244 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
252 if (caloCluster.
isNull())
continue;
254 LogDebug(
"")<<
" ElectronSeed superCluster energy: "<<theClus->energy()<<
", position: "<<theClus->position();
256 LogDebug(
"")<<
" ElectronSeed supercluster Et: "<<theClus->energy()*
sin(2.*atan(
exp(-theClus->position().eta())));
258 LogDebug(
"")<<
" ElectronSeed supercluster eta: "<<theClus->position().eta();
259 LogDebug(
"")<<
" ElectronSeed seed charge: "<<(*MyS).getCharge();
267 GlobalPoint xmeas(theClus->position().x(),theClus->position().y(),theClus->position().z());
269 float energy = theClus->energy();
283 DetId id=(*it).geographicalId();
294 float SCl_phi = xmeas.phi();
295 float localDphi = SCl_phi-hitPos.
phi();
298 if(
std::abs(localDphi)>2.5)
continue;
304 if (
id.subdetId()%2==1) {
311 DetId id2=(*it).geographicalId();
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());
321 double r2diff = (xmeas.x()-pxHit1x)*(xmeas.x()-pxHit1x) + (xmeas.y()-pxHit1y)*(xmeas.y()-pxHit1y);
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();
348 histetclu_->Fill(theClus->energy()*
sin(2.*atan(
exp(-theClus->position().eta()))));
351 histq_->Fill((*MyS).getCharge());
363 seedQ[is] = (*MyS).getCharge();
390 e.
getByLabel(
"correctedHybridSuperClusters", clusters);
399 e.
getByLabel(
"generatorSmeared",
"", HepMCEvt);
403 HepMC::FourVector pAssSim;
405 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin();
406 partIter != MCEvt->particles_end(); ++partIter) {
408 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin();
409 vertIter != MCEvt->vertices_end(); ++vertIter) {
412 HepMC::GenVertex * creation = (*partIter)->production_vertex();
414 HepMC::FourVector momentum = (*partIter)->momentum();
416 int id = (*partIter)->pdg_id();
417 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum " << momentum.rho() <<
" GeV/c" << std::endl;
419 if (
id == 11 ||
id == -11) {
423 if ( (*partIter)->production_vertex() ) {
424 if ( (*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
426 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
428 if ( ((mother ==
nullptr) || ((mother !=
nullptr) && (mother->pdg_id() == 23))
429 || ((mother !=
nullptr) && (mother->pdg_id() == 32))
430 || ((mother !=
nullptr) && (
std::abs(mother->pdg_id()) == 24)))) {
432 pAssSim = genPc->momentum();
439 if (
std::abs(pAssSim.eta())> 2.5)
continue;
446 bool okSeedFound =
false;
447 double seedOkRatio = 999999.;
451 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
453 range
r=gsfIter->recHits();
455 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
461 double dphi = phi-pAssSim.phi();
463 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
465 if ( deltaR < 0.15 ){
469 double tmpSeedRatio = p/pAssSim.t();
471 seedOkRatio = tmpSeedRatio;
472 bestElectronSeed=*gsfIter;
487 mcEta[ip] = pAssSim.eta();
488 mcPhi[ip] = pAssSim.phi();
489 mcPt[ip] = pAssSim.perp();
490 mcQ[ip] = ((
id == 11) ? -1.: +1.);
496 seedOkRatio = 999999.;
499 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
501 range
r=gsfIter->recHits();
503 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
509 double dphi = phi-pAssSim.phi();
511 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
513 if (gsfIter->isEcalDriven()) {
514 if ( deltaR < 0.15 ){
518 double tmpSeedRatio = p/pAssSim.t();
520 seedOkRatio = tmpSeedRatio;
521 bestElectronSeed=*gsfIter;
539 seedOkRatio = 999999.;
542 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
544 range
r=gsfIter->recHits();
546 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
552 double dphi = phi-pAssSim.phi();
554 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
556 if (gsfIter->isTrackerDriven()) {
557 if ( deltaR < 0.15 ){
561 double tmpSeedRatio = p/pAssSim.t();
563 seedOkRatio = tmpSeedRatio;
564 bestElectronSeed=*gsfIter;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
static FreeTrajectoryState get(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
float superclusterEnergy[10]
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Sin< T >::type sin(const T &t)
float superclusterPhi[10]
Geom::Phi< T > phi() const
unsigned int side(const DetId &id) const
GlobalPoint globalPosition() const
TH1F * histtrackerdrivenetaMCmatched_
const Plane & surface() const
The nominal surface of the GeomDet.
edm::InputTag inputCollection_
recHitContainer::const_iterator const_iterator
TH1F * histecaldrivenptMCmatched_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
~ElectronSeedAnalyzer() override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
GlobalVector momentum() const
TH1F * histecaldriveneMCmatched_
GlobalPoint position() const
float superclusterEta[10]
const HepMC::GenEvent * GetEvent() const
TH1F * histecaldrivenetaMCmatched_
T const * product() const
void analyze(const edm::Event &, const edm::EventSetup &) override
bool isNull() const
Checks for null.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
TH1F * histtrackerdriveneMCmatched_
unsigned int layer(const DetId &id) const
GlobalVector globalMomentum() const
const TrackerGeomDet * idToDet(DetId) const override
const Point & position() const
position
ElectronSeedAnalyzer(const edm::ParameterSet &conf)
Power< A, B >::type pow(const A &a, const B &b)
TH1F * histtrackerdrivenptMCmatched_
constexpr Detector det() const
get the detector field from this detid