CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SoftElectronProducer Class Reference

#include <SoftElectronProducer.h>

Inheritance diagram for SoftElectronProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 SoftElectronProducer (const edm::ParameterSet &iConf)
 ~SoftElectronProducer ()

Private Member Functions

virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)

Private Attributes

edm::InputTag barrelRecHitCollection_
edm::InputTag endcapRecHitCollection_
edm::InputTag theBasicClusterTag
edm::ParameterSet theConf
double theDiscriminatorCut
ElectronIdMLPtheElecNN
edm::InputTag theHBHERecHitTag
double theHOverEConeSize
edm::InputTag thePrimaryVertexTag
TrackDetectorAssociatortheTrackAssociator
TrackAssociatorParameterstheTrackAssociatorParameters
edm::InputTag theTrackTag

Detailed Description

Id:
SoftElectronProducer.h,v 1.3 2009/05/04 19:02:13 fwyzard Exp
Date:
2009/05/04 19:02:13
Revision:
1.3
Author:
P. Demin - UCL, Louvain-la-Neuve - Belgium

Definition at line 24 of file SoftElectronProducer.h.


Constructor & Destructor Documentation

SoftElectronProducer::SoftElectronProducer ( const edm::ParameterSet iConf)

Definition at line 44 of file SoftElectronProducer.cc.

References barrelRecHitCollection_, endcapRecHitCollection_, edm::ParameterSet::getParameter(), Parameters::parameters, theBasicClusterTag, theConf, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, and example_cfg::TrackAssociatorParameters.

                                                                       :
  theConf(iConf), theTrackAssociator(0), theElecNN(0)
{
  theTrackTag             = theConf.getParameter<InputTag>("TrackTag");

  theHBHERecHitTag        = theConf.getParameter<InputTag>("HBHERecHitTag");
  theBasicClusterTag      = theConf.getParameter<InputTag>("BasicClusterTag");
 // theBasicClusterShapeTag = theConf.getParameter<InputTag>("BasicClusterShapeTag");

  theHOverEConeSize = theConf.getParameter<double>("HOverEConeSize");

  barrelRecHitCollection_ = theConf.getParameter<edm::InputTag>("BarrelRecHitCollection");
  endcapRecHitCollection_ = theConf.getParameter<edm::InputTag>("EndcapRecHitCollection");

  // TrackAssociator and its parameters
  theTrackAssociator = new TrackDetectorAssociator();
  theTrackAssociator->useDefaultPropagator();
  edm::ParameterSet parameters = iConf.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
  theTrackAssociatorParameters = new TrackAssociatorParameters( parameters );

  theDiscriminatorCut = theConf.getParameter<double>("DiscriminatorCut");

  theElecNN = new ElectronIdMLP;

  // register the product
  produces<reco::ElectronCollection>();
}
SoftElectronProducer::~SoftElectronProducer ( )

Member Function Documentation

void SoftElectronProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 83 of file SoftElectronProducer.cc.

References abs, TrackDetectorAssociator::associate(), barrelRecHitCollection_, dtNoiseDBValidation_cfg::cerr, EcalClusterLazyTools::covariances(), alignCSCRings::e, EcalClusterLazyTools::e2x2(), EcalClusterLazyTools::e3x3(), EcalClusterLazyTools::e5x5(), EcalClusterLazyTools::eMax(), jptDQMConfig_cff::eMax, endcapRecHitCollection_, reco::TrackBase::eta(), edm::EventSetup::get(), edm::Event::getByLabel(), TrackDetectorAssociator::getFreeTrajectoryState(), DetId::Hcal, info, TrackDetMatchInfo::isGoodEcal, reco::TrackBase::numberOfValidHits(), reco::TrackBase::p(), p4, position, edm::ESHandle< T >::product(), reco::TrackBase::pt(), edm::Event::put(), reco::Electron::setTrack(), theBasicClusterTag, theDiscriminatorCut, theElecNN, theHBHERecHitTag, theHOverEConeSize, theTrackAssociator, theTrackAssociatorParameters, theTrackTag, TrackDetMatchInfo::trkGlobPosAtEcal, ElectronIdMLP::value(), relativeConstraints::value, cms::Exception::what(), x, detailsBasic3DVector::y, and z.

{

  auto_ptr<reco::ElectronCollection> candidates(new reco::ElectronCollection());

  Handle<reco::TrackCollection> handleTrack;
  reco::TrackCollection::const_iterator itTrack;

  Handle<reco::BasicClusterCollection> handleCluster;
  reco::BasicClusterCollection::const_iterator itCluster;

  //Handle<reco::ClusterShapeCollection> handleShape;
  //reco::ClusterShapeCollection::const_iterator itShape;

  Handle<HBHERecHitCollection> handleRecHit;
  CaloRecHitMetaCollectionV::const_iterator itRecHit;

  ESHandle<CaloGeometry> handleCaloGeom;
  

  double hcalEnergy, clusEnergy, trkP;
  double x[2], y[2], z[2];
  double covEtaEta, covEtaPhi, covPhiPhi, emFraction, deltaE;
  double eMax, e2x2, e3x3, e5x5, v1, v2, v3, v4;
  double value, dist, distMin;

  const reco::BasicCluster *matchedCluster;
  //const reco::ClusterShape *matchedShape;
  const reco::Track *track;

  // get basic clusters
  iEvent.getByLabel(theBasicClusterTag, handleCluster);

  // get basic cluster shapes
  //iEvent.getByLabel(theBasicClusterShapeTag, handleShape);

  // get rec. hits
  iEvent.getByLabel(theHBHERecHitTag, handleRecHit);
  HBHERecHitMetaCollection metaRecHit(*handleRecHit);

  //only barrel is used, giving twice the same inputag..


  EcalClusterLazyTools ecalTool(iEvent, iSetup, barrelRecHitCollection_, endcapRecHitCollection_ );

  // get calorimeter geometry
  iSetup.get<CaloGeometryRecord>().get(handleCaloGeom);

  CaloConeSelector selectorRecHit(theHOverEConeSize, handleCaloGeom.product(), DetId::Hcal);

  // get tracks
  iEvent.getByLabel(theTrackTag, handleTrack);

  FreeTrajectoryState tmpFTS;
  TrackDetMatchInfo info;
  unsigned int counterTrack;

  // loop over tracks
  for(itTrack = handleTrack->begin(), counterTrack = 0;
      itTrack != handleTrack->end();
      ++itTrack, ++counterTrack)
  {
    track = &(*itTrack);

    try {
      tmpFTS = theTrackAssociator->getFreeTrajectoryState(iSetup, *track);
      info = theTrackAssociator->associate(iEvent, iSetup, tmpFTS, *theTrackAssociatorParameters);
    } catch (cms::Exception e) {
      // extrapolation failed, skip this track
      std::cerr << "Caught exception during track extrapolation: " << e.what() << ". Skipping track" << endl;
      continue;
    }

    x[0] = info.trkGlobPosAtEcal.x();
    y[0] = info.trkGlobPosAtEcal.y();
    z[0] = info.trkGlobPosAtEcal.z();

    // analyse only tracks passing quality cuts
    if(track->numberOfValidHits() >= 8 && track->pt() > 2.0 &&
       abs(track->eta()) < 1.2 && info.isGoodEcal)
    {
      distMin = 1.0e6;
      matchedCluster = 0;
//      matchedShape = 0;

      // loop over basic clusters
      for(itCluster = handleCluster->begin(); itCluster != handleCluster->end();++itCluster)
      {
        x[1] = itCluster->x();
        y[1] = itCluster->y();
        z[1] = itCluster->z();

        dist = hypot(x[0] - x[1], y[0] - y[1]);
        dist = hypot(dist, z[0] - z[1]);

        if(dist < distMin)
        {
          distMin = dist;
          matchedCluster = &(*itCluster);
        }
      }

      // identify electrons based on cluster properties
      if(matchedCluster  && distMin < 10.0)
      {
        GlobalPoint position(matchedCluster->x(), matchedCluster->y(), matchedCluster->z());
        auto_ptr<CaloRecHitMetaCollectionV> chosen = selectorRecHit.select(position, metaRecHit);
        hcalEnergy = 0.0;
        for(itRecHit = chosen->begin(); itRecHit != chosen->end(); ++itRecHit)
        {
          hcalEnergy += itRecHit->energy();
        }

        clusEnergy = matchedCluster->energy();
        trkP = track->p();

        deltaE = (clusEnergy - trkP)/(clusEnergy + trkP);
        emFraction =  clusEnergy/(clusEnergy + hcalEnergy);

        eMax = ecalTool.eMax(*matchedCluster);
        e2x2 = ecalTool.e2x2(*matchedCluster);
        e3x3 = ecalTool.e3x3(*matchedCluster);
        e5x5 = ecalTool.e5x5(*matchedCluster);
        v1 = eMax/e3x3;
        v2 = eMax/e2x2;
        v3 = e2x2/e5x5;
        v4 = ((e5x5 - eMax) < 0.001) ? 1.0 : (e3x3 - eMax)/(e5x5 - eMax);
        std::vector<float> cov = ecalTool.covariances(*matchedCluster); 
        covEtaEta = cov[0];
        covEtaPhi = cov[1];
        covPhiPhi = cov[2];

        value = theElecNN->value(0, covEtaEta, covEtaPhi, covPhiPhi,
                                 v1, v2, v3, v4, emFraction, deltaE);
        if (value > theDiscriminatorCut)
        {
          const reco::Particle::LorentzVector  p4(0.0, 0.0, 0.0, clusEnergy);
          const reco::Particle::Point vtx(0.0, 0.0, 0.0);
          reco::Electron newCandidate(0, p4, vtx);
          reco::TrackRef refTrack(handleTrack, counterTrack);
          newCandidate.setTrack(refTrack);
          candidates->push_back(newCandidate);
        }
      }
    }
  }
  
  // put the product in the event
  iEvent.put(candidates);

}

Member Data Documentation

Definition at line 42 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 43 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 40 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 36 of file SoftElectronProducer.h.

Referenced by SoftElectronProducer().

Definition at line 46 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 51 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

Definition at line 39 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 45 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().

Definition at line 41 of file SoftElectronProducer.h.

Definition at line 48 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

Definition at line 49 of file SoftElectronProducer.h.

Referenced by produce(), SoftElectronProducer(), and ~SoftElectronProducer().

Definition at line 38 of file SoftElectronProducer.h.

Referenced by produce(), and SoftElectronProducer().