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();
293 std::pair<bool,double> est;
296 float SCl_phi = xmeas.phi();
297 float localDphi = SCl_phi-hitPos.
phi();
300 if(
std::abs(localDphi)>2.5)
continue;
306 if (
id.subdetId()%2==1) {
313 DetId id2=(*it).geographicalId();
318 double pxHit1z = hitPos.
z();
319 double pxHit1x = hitPos.
x();
320 double pxHit1y = hitPos.
y();
321 double r1diff = (pxHit1x-vprim.x())*(pxHit1x-vprim.x()) + (pxHit1y-vprim.y())*(pxHit1y-vprim.y());
323 double r2diff = (xmeas.x()-pxHit1x)*(xmeas.x()-pxHit1x) + (xmeas.y()-pxHit1y)*(xmeas.y()-pxHit1y);
325 double zVertexPred = pxHit1z - r1diff*(xmeas.z()-pxHit1z)/r2diff;
327 GlobalPoint vertexPred(vprim.x(),vprim.y(),zVertexPred);
335 phi2 = hitPos2.
phi();
337 rz2 = hitPos2.
perp();
350 histetclu_->Fill(theClus->energy()*
sin(2.*atan(
exp(-theClus->position().eta()))));
353 histq_->Fill((*MyS).getCharge());
365 seedQ[is] = (*MyS).getCharge();
392 e.
getByLabel(
"correctedHybridSuperClusters", clusters);
401 e.
getByLabel(
"generatorSmeared",
"", HepMCEvt);
403 const HepMC::GenEvent* MCEvt = HepMCEvt->
GetEvent();
405 HepMC::FourVector pAssSim;
407 for (HepMC::GenEvent::particle_const_iterator partIter = MCEvt->particles_begin();
408 partIter != MCEvt->particles_end(); ++partIter) {
410 for (HepMC::GenEvent::vertex_const_iterator vertIter = MCEvt->vertices_begin();
411 vertIter != MCEvt->vertices_end(); ++vertIter) {
414 HepMC::GenVertex * creation = (*partIter)->production_vertex();
416 HepMC::FourVector momentum = (*partIter)->momentum();
418 int id = (*partIter)->pdg_id();
419 LogDebug(
"") <<
"MC particle id " <<
id <<
", creationVertex " << (*creation) <<
" cm, initialMomentum " << momentum.rho() <<
" GeV/c" << std::endl;
421 if (
id == 11 ||
id == -11) {
425 if ( (*partIter)->production_vertex() ) {
426 if ( (*partIter)->production_vertex()->particles_begin(
HepMC::parents) !=
428 mother = *((*partIter)->production_vertex()->particles_begin(
HepMC::parents));
430 if ( ((mother ==
nullptr) || ((mother !=
nullptr) && (mother->pdg_id() == 23))
431 || ((mother !=
nullptr) && (mother->pdg_id() == 32))
432 || ((mother !=
nullptr) && (
std::abs(mother->pdg_id()) == 24)))) {
434 pAssSim = genPc->momentum();
441 if (
std::abs(pAssSim.eta())> 2.5)
continue;
448 bool okSeedFound =
false;
449 double seedOkRatio = 999999.;
453 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
457 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
463 double dphi = phi-pAssSim.phi();
465 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
467 if ( deltaR < 0.15 ){
471 double tmpSeedRatio = p/pAssSim.t();
473 seedOkRatio = tmpSeedRatio;
474 bestElectronSeed=*gsfIter;
489 mcEta[ip] = pAssSim.eta();
490 mcPhi[ip] = pAssSim.phi();
491 mcPt[ip] = pAssSim.perp();
492 mcQ[ip] = ((
id == 11) ? -1.: +1.);
498 seedOkRatio = 999999.;
501 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
503 range r=gsfIter->recHits();
505 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
511 double dphi = phi-pAssSim.phi();
513 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
515 if (gsfIter->isEcalDriven()) {
516 if ( deltaR < 0.15 ){
520 double tmpSeedRatio = p/pAssSim.t();
522 seedOkRatio = tmpSeedRatio;
523 bestElectronSeed=*gsfIter;
541 seedOkRatio = 999999.;
544 for( ElectronSeedCollection::const_iterator gsfIter= (*elSeeds).begin(); gsfIter != (*elSeeds).end(); ++gsfIter) {
546 range r=gsfIter->recHits();
548 for (TrackingRecHitCollection::const_iterator rhits=r.first; rhits!=r.second; rhits++) det = pDD->
idToDet(((*rhits)).geographicalId());
554 double dphi = phi-pAssSim.phi();
556 dphi = dphi < 0? (CLHEP::twopi) + dphi : dphi - CLHEP::twopi;
558 if (gsfIter->isTrackerDriven()) {
559 if ( deltaR < 0.15 ){
563 double tmpSeedRatio = p/pAssSim.t();
565 seedOkRatio = tmpSeedRatio;
566 bestElectronSeed=*gsfIter;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) 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_
Abs< T >::type abs(const T &t)
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]
const HepMC::GenEvent * GetEvent() const
TH1F * histecaldrivenetaMCmatched_
T const * product() const
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
Detector det() const
get the detector field from this detid
Power< A, B >::type pow(const A &a, const B &b)
TH1F * histtrackerdrivenptMCmatched_