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();
218 float dphi1=0., dphi2=0., drz1=0., drz2=0.;
219 float phi1=0., phi2=0., rz1=0., rz2=0.;
221 for( ElectronSeedCollection::const_iterator MyS= (*elSeeds).begin(); MyS != (*elSeeds).end(); ++MyS) {
223 LogDebug(
"") <<
"\nSeed nr "<<is<<
": ";
224 range
r=(*MyS).recHits();
225 LogDebug(
"")<<
" Number of RecHits= "<<(*MyS).nHits();
229 DetId id1 = (*it).geographicalId();
230 det1 = pDD->idToDet(id1);
231 LogDebug(
"") <<
" First hit local x,y,z "<<(*it).localPosition()<<
" det "<<id1.
det()<<
" subdet "<<id1.
subdetId();
236 DetId id2 = (*it).geographicalId();
237 det2 = pDD->idToDet(id2);
238 LogDebug(
"") <<
" Second hit local x,y,z "<<(*it).localPosition()<<
" det "<<id2.
det()<<
" subdet "<<id2.
subdetId();
239 LogDebug(
"") <<
" Second hit global "<<det2->
toGlobal((*it).localPosition());
245 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->idToDet(((*rhits)).geographicalId());
253 if (caloCluster.
isNull())
continue;
255 LogDebug(
"")<<
" ElectronSeed superCluster energy: "<<theClus->energy()<<
", position: "<<theClus->position();
257 LogDebug(
"")<<
" ElectronSeed supercluster Et: "<<theClus->energy()*
sin(2.*atan(
exp(-theClus->position().eta())));
259 LogDebug(
"")<<
" ElectronSeed supercluster eta: "<<theClus->position().eta();
260 LogDebug(
"")<<
" ElectronSeed seed charge: "<<(*MyS).getCharge();
267 int charge = int((*MyS).getCharge());
268 GlobalPoint xmeas(theClus->position().x(),theClus->position().y(),theClus->position().z());
269 GlobalPoint vprim(theBeamSpot->position().x(),theBeamSpot->position().y(),theBeamSpot->position().z());
270 float energy = theClus->energy();
285 DetId id=(*it).geographicalId();
286 const GeomDet *geomdet=pDD->idToDet((*it).geographicalId());
291 tsos1 = prop1stLayer->propagate(tsos,geomdet->
surface()) ;
295 std::pair<bool,double> est;
298 float SCl_phi = xmeas.phi();
299 float localDphi = SCl_phi-hitPos.
phi();
302 if(
std::abs(localDphi)>2.5)
continue;
308 if (
id.subdetId()%2==1) {
315 DetId id2=(*it).geographicalId();
316 const GeomDet *geomdet2=pDD->idToDet((*it).geographicalId());
320 double pxHit1z = hitPos.
z();
321 double pxHit1x = hitPos.
x();
322 double pxHit1y = hitPos.
y();
323 double r1diff = (pxHit1x-vprim.x())*(pxHit1x-vprim.x()) + (pxHit1y-vprim.y())*(pxHit1y-vprim.y());
325 double r2diff = (xmeas.x()-pxHit1x)*(xmeas.x()-pxHit1x) + (xmeas.y()-pxHit1y)*(xmeas.y()-pxHit1y);
327 double zVertexPred = pxHit1z - r1diff*(xmeas.z()-pxHit1z)/r2diff;
329 GlobalPoint vertexPred(vprim.x(),vprim.y(),zVertexPred);
332 tsos2 = prop2ndLayer->propagate(fts2,geomdet2->
surface()) ;
337 phi2 = hitPos2.
phi();
339 rz2 = hitPos2.
perp();
352 histetclu_->Fill(theClus->energy()*
sin(2.*atan(
exp(-theClus->position().eta()))));
355 histq_->Fill((*MyS).getCharge());
367 seedQ[is] = (*MyS).getCharge();
478 e.
getByLabel(
"correctedHybridSuperClusters", clusters);
489 const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
491 HepMC::FourVector pAssSim;
493 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin();
494 partIter != MCEvt->particles_end(); ++partIter) {
496 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin();
497 vertIter != MCEvt->vertices_end(); ++vertIter) {
500 HepMC::GenVertex * creation = (*partIter)->production_vertex();
502 HepMC::FourVector momentum = (*partIter)->momentum();
504 int id = (*partIter)->pdg_id();
505 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum " << momentum.rho() <<
" GeV/c" << std::endl;
507 if (
id == 11 ||
id == -11) {
511 if ( (*partIter)->production_vertex() ) {
512 if ( (*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
514 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
516 if ( ((mother == 0) || ((mother != 0) && (mother->pdg_id() == 23))
517 || ((mother != 0) && (mother->pdg_id() == 32))
518 || ((mother != 0) && (
std::abs(mother->pdg_id()) == 24)))) {
520 pAssSim = genPc->momentum();
527 if (
std::abs(pAssSim.eta())> 2.5)
continue;
534 bool okSeedFound =
false;
535 double seedOkRatio = 999999.;
539 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
541 range
r=gsfIter->recHits();
543 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->idToDet(((*rhits)).geographicalId());
549 double dphi = phi-pAssSim.phi();
551 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
553 if ( deltaR < 0.15 ){
557 double tmpSeedRatio = p/pAssSim.t();
559 seedOkRatio = tmpSeedRatio;
560 bestElectronSeed=*gsfIter;
575 mcEta[ip] = pAssSim.eta();
576 mcPhi[ip] = pAssSim.phi();
577 mcPt[ip] = pAssSim.perp();
578 mcQ[ip] = ((
id == 11) ? -1.: +1.);
584 seedOkRatio = 999999.;
587 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
589 range
r=gsfIter->recHits();
591 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->idToDet(((*rhits)).geographicalId());
597 double dphi = phi-pAssSim.phi();
599 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
601 if (gsfIter->isEcalDriven()) {
602 if ( deltaR < 0.15 ){
606 double tmpSeedRatio = p/pAssSim.t();
608 seedOkRatio = tmpSeedRatio;
609 bestElectronSeed=*gsfIter;
627 seedOkRatio = 999999.;
630 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
632 range
r=gsfIter->recHits();
634 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->idToDet(((*rhits)).geographicalId());
640 double dphi = phi-pAssSim.phi();
642 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
644 if (gsfIter->isTrackerDriven()) {
645 if ( deltaR < 0.15 ){
649 double tmpSeedRatio = p/pAssSim.t();
651 seedOkRatio = tmpSeedRatio;
652 bestElectronSeed=*gsfIter;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
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
bool isNull() const
Checks for null.
GlobalPoint globalPosition() const
TH1F * histtrackerdrivenetaMCmatched_
virtual ~ElectronSeedAnalyzer()
const Plane & surface() const
The nominal surface of the GeomDet.
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::InputTag inputCollection_
recHitContainer::const_iterator const_iterator
TH1F * histecaldrivenptMCmatched_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
GlobalVector momentum() const
TH1F * histecaldriveneMCmatched_
double deltaR(double eta1, double eta2, double phi1, double phi2)
GlobalPoint position() const
float superclusterEta[10]
TH1F * histecaldrivenetaMCmatched_
REF castTo() const
cast to a concrete type
T const * product() const
TH1F * histtrackerdriveneMCmatched_
GlobalVector globalMomentum() const
Detector det() const
get the detector field from this detid
ElectronSeedAnalyzer(const edm::ParameterSet &conf)
Power< A, B >::type pow(const A &a, const B &b)
TH1F * histtrackerdrivenptMCmatched_