CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PFElectronTranslator Class Reference

#include <PFElectronTranslator.h>

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

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &run, const edm::EventSetup &c)
 PFElectronTranslator (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~PFElectronTranslator ()

Private Member Functions

const reco::PFCandidatecorrespondingDaughterCandidate (const reco::PFCandidate &cand, const reco::PFBlockElement &pfbe) const
void createBasicCluster (const reco::PFBlockElement &, reco::BasicClusterCollection &basicClusters, std::vector< const reco::PFCluster * > &, const reco::PFCandidate &coCandidate) const
void createBasicClusterPtrs (const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle)
void createPreshowerCluster (const reco::PFBlockElement &PFBE, reco::PreshowerClusterCollection &preshowerClusters, unsigned plane) const
void createPreshowerClusterPtrs (const edm::OrphanHandle< reco::PreshowerClusterCollection > &preshowerClustersHandle)
void createSuperClusterGsfMapRefs (const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle)
void createSuperClusters (const reco::PFCandidateCollection &, reco::SuperClusterCollection &superClusters) const
bool fetchCandidateCollection (edm::Handle< reco::PFCandidateCollection > &c, const edm::InputTag &tag, const edm::Event &iEvent) const
void fetchGsfCollection (edm::Handle< reco::GsfTrackCollection > &c, const edm::InputTag &tag, const edm::Event &iEvent) const
void fillMVAValueMap (edm::Event &iEvent, edm::ValueMap< float >::Filler &filler) const
void fillSCRefValueMap (edm::Event &iEvent, edm::ValueMap< reco::SuperClusterRef >::Filler &filler) const
void fillValueMap (edm::Event &iEvent, edm::ValueMap< float >::Filler &filler) const

Private Attributes

std::vector
< reco::CaloClusterPtrVector
basicClusterPtr_
std::vector
< reco::BasicClusterCollection
basicClusters_
std::map< reco::GsfTrackRef,
float > 
gsfMvaMap_
std::vector< int > gsfPFCandidateIndex_
std::vector< reco::GsfTrackRefGsfTrackRef_
edm::InputTag inputTagGSFTracks_
edm::InputTag inputTagPFCandidates_
double MVACut_
std::string PFBasicClusterCollection_
std::vector< std::vector
< const reco::PFCluster * > > 
pfClusters_
std::string PFMVAValueMap_
std::string PFPreshowerClusterCollection_
std::string PFSCValueMap_
std::string PFSuperClusterCollection_
std::vector
< reco::CaloClusterPtrVector
preshowerClusterPtr_
std::vector
< reco::PreshowerClusterCollection
preshowerClusters_
std::map< reco::GsfTrackRef,
reco::SuperClusterRef
scMap_
std::vector
< reco::SuperClusterCollection
superClusters_

Detailed Description

Definition at line 21 of file PFElectronTranslator.h.


Constructor & Destructor Documentation

PFElectronTranslator::PFElectronTranslator ( const edm::ParameterSet iConfig) [explicit]

Definition at line 17 of file PFElectronTranslator.cc.

References edm::ParameterSet::getParameter(), inputTagGSFTracks_, inputTagPFCandidates_, MVACut_, PFBasicClusterCollection_, PFMVAValueMap_, PFPreshowerClusterCollection_, PFSCValueMap_, and PFSuperClusterCollection_.

                                                                          {
  inputTagPFCandidates_ 
    = iConfig.getParameter<edm::InputTag>("PFCandidate");
  inputTagGSFTracks_
    = iConfig.getParameter<edm::InputTag>("GSFTracks");

  PFBasicClusterCollection_ = iConfig.getParameter<std::string>("PFBasicClusters");
  PFPreshowerClusterCollection_ = iConfig.getParameter<std::string>("PFPreshowerClusters");
  PFSuperClusterCollection_ = iConfig.getParameter<std::string>("PFSuperClusters");
  PFMVAValueMap_ = iConfig.getParameter<std::string>("ElectronMVA");
  PFSCValueMap_ = iConfig.getParameter<std::string>("ElectronSC");
  MVACut_ = (iConfig.getParameter<edm::ParameterSet>("MVACutBlock")).getParameter<double>("MVACut");

  produces<reco::BasicClusterCollection>(PFBasicClusterCollection_); 
  produces<reco::PreshowerClusterCollection>(PFPreshowerClusterCollection_); 
  produces<reco::SuperClusterCollection>(PFSuperClusterCollection_); 
  produces<edm::ValueMap<float> >(PFMVAValueMap_);
  produces<edm::ValueMap<reco::SuperClusterRef> >(PFSCValueMap_);
}
PFElectronTranslator::~PFElectronTranslator ( )

Definition at line 37 of file PFElectronTranslator.cc.

{}

Member Function Documentation

void PFElectronTranslator::beginRun ( edm::Run run,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 39 of file PFElectronTranslator.cc.

{}
const reco::PFCandidate & PFElectronTranslator::correspondingDaughterCandidate ( const reco::PFCandidate cand,
const reco::PFBlockElement pfbe 
) const [private]

Definition at line 437 of file PFElectronTranslator.cc.

References reco::CompositeCandidate::begin(), reco::PFCandidate::elementsInBlocks(), reco::CompositeCandidate::end(), and reco::PFBlockElement::index().

Referenced by produce().

{
  unsigned refindex=pfbe.index();
  //  std::cout << " N daughters " << cand.numberOfDaughters() << std::endl;
  reco::PFCandidate::const_iterator myDaughterCandidate=cand.begin();
  reco::PFCandidate::const_iterator itend=cand.end();

  for(;myDaughterCandidate!=itend;++myDaughterCandidate)
    {
      const reco::PFCandidate * myPFCandidate = (const reco::PFCandidate*)&*myDaughterCandidate;
      if(myPFCandidate->elementsInBlocks().size()!=1)
        {
          //      std::cout << " Daughter with " << myPFCandidate.elementsInBlocks().size()<< " element in block " << std::endl;
          return cand;
        }
      if(myPFCandidate->elementsInBlocks()[0].second==refindex) 
        {
          //      std::cout << " Found it " << cand << std::endl;
          return *myPFCandidate;
        }      
    }
  return cand;
}
void PFElectronTranslator::createBasicCluster ( const reco::PFBlockElement PFBE,
reco::BasicClusterCollection basicClusters,
std::vector< const reco::PFCluster * > &  pfClusters,
const reco::PFCandidate coCandidate 
) const [private]

Definition at line 213 of file PFElectronTranslator.cc.

References reco::CaloCluster::algo(), reco::CaloCluster::caloID(), reco::PFBlockElement::clusterRef(), reco::CaloCluster::hitsAndFractions(), edm::Ref< C, T, F >::isNull(), reco::CaloCluster::position(), reco::PFCandidate::rawEcalEnergy(), and reco::CaloCluster::seed().

Referenced by produce().

{
  reco::PFClusterRef myPFClusterRef= PFBE.clusterRef();
  if(myPFClusterRef.isNull()) return;  

  const reco::PFCluster & myPFCluster (*myPFClusterRef);
  pfClusters.push_back(&myPFCluster);
//  std::cout << " Creating BC " << myPFCluster.energy() << " " << coCandidate.ecalEnergy() <<" "<<  coCandidate.rawEcalEnergy() <<std::endl;
//  std::cout << " # hits " << myPFCluster.hitsAndFractions().size() << std::endl;

//  basicClusters.push_back(reco::CaloCluster(myPFCluster.energy(),
  basicClusters.push_back(reco::CaloCluster(coCandidate.rawEcalEnergy(),
                                            myPFCluster.position(),
                                            myPFCluster.caloID(),
                                            myPFCluster.hitsAndFractions(),
                                            myPFCluster.algo(),
                                            myPFCluster.seed()));
}
void PFElectronTranslator::createBasicClusterPtrs ( const edm::OrphanHandle< reco::BasicClusterCollection > &  basicClustersHandle) [private]

Definition at line 243 of file PFElectronTranslator.cc.

References basicClusterPtr_, basicClusters_, GsfTrackRef_, and findQualityFiles::size.

Referenced by produce().

{
  unsigned size=GsfTrackRef_.size();
  unsigned basicClusterCounter=0;
  basicClusterPtr_.resize(size);

  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
    {
      unsigned nbc=basicClusters_[iGSF].size();
      for(unsigned ibc=0;ibc<nbc;++ibc) // loop on basic clusters
        {
          //      std::cout <<  "Track "<< iGSF << " ref " << basicClusterCounter << std::endl;
          reco::CaloClusterPtr bcPtr(basicClustersHandle,basicClusterCounter);
          basicClusterPtr_[iGSF].push_back(bcPtr);
          ++basicClusterCounter;
        }
    }
}
void PFElectronTranslator::createPreshowerCluster ( const reco::PFBlockElement PFBE,
reco::PreshowerClusterCollection preshowerClusters,
unsigned  plane 
) const [private]

Definition at line 236 of file PFElectronTranslator.cc.

References reco::PFBlockElement::clusterRef().

Referenced by produce().

{
  reco::PFClusterRef  myPFClusterRef= PFBE.clusterRef();
  preshowerClusters.push_back(reco::PreshowerCluster(myPFClusterRef->energy(),myPFClusterRef->position(),
                                               myPFClusterRef->hitsAndFractions(),plane));
}
void PFElectronTranslator::createPreshowerClusterPtrs ( const edm::OrphanHandle< reco::PreshowerClusterCollection > &  preshowerClustersHandle) [private]

Definition at line 262 of file PFElectronTranslator.cc.

References GsfTrackRef_, preshowerClusterPtr_, preshowerClusters_, and findQualityFiles::size.

Referenced by produce().

{
  unsigned size=GsfTrackRef_.size();
  unsigned psClusterCounter=0;
  preshowerClusterPtr_.resize(size);

  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
    {
      unsigned nbc=preshowerClusters_[iGSF].size();
      for(unsigned ibc=0;ibc<nbc;++ibc) // loop on basic clusters
        {
          //      std::cout <<  "Track "<< iGSF << " ref " << basicClusterCounter << std::endl;
          reco::CaloClusterPtr psPtr(preshowerClustersHandle,psClusterCounter);
          preshowerClusterPtr_[iGSF].push_back(psPtr);
          ++psClusterCounter;
        }
    }
}
void PFElectronTranslator::createSuperClusterGsfMapRefs ( const edm::OrphanHandle< reco::SuperClusterCollection > &  superClustersHandle) [private]

Definition at line 281 of file PFElectronTranslator.cc.

References GsfTrackRef_, scMap_, and findQualityFiles::size.

Referenced by produce().

{
  unsigned size=GsfTrackRef_.size();

  for(unsigned iGSF=0;iGSF<size;++iGSF) // loop on tracks
    {
      edm::Ref<reco::SuperClusterCollection> scRef(superClustersHandle,iGSF);
      scMap_[GsfTrackRef_[iGSF]]=scRef;
    }
}
void PFElectronTranslator::createSuperClusters ( const reco::PFCandidateCollection pfCand,
reco::SuperClusterCollection superClusters 
) const [private]

Definition at line 347 of file PFElectronTranslator.cc.

References reco::SuperCluster::addCluster(), reco::CaloCluster::addHitAndFraction(), reco::SuperCluster::addPreshowerCluster(), basicClusterPtr_, basicClusters_, ExpressReco_HICollisions_FallBack::e, gsfPFCandidateIndex_, GsfTrackRef_, pfClusters_, PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), preshowerClusterPtr_, reco::SuperCluster::rawEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), reco::SuperCluster::setPreshowerEnergy(), and reco::SuperCluster::setSeed().

Referenced by produce().

{
  unsigned nGSF=GsfTrackRef_.size();
  for(unsigned iGSF=0;iGSF<nGSF;++iGSF)
    {

      // Computes energy position a la e/gamma 
      double sclusterE=0;
      double posX=0.;
      double posY=0.;
      double posZ=0.;
      
      unsigned nbasics=basicClusters_[iGSF].size();
      for(unsigned ibc=0;ibc<nbasics;++ibc)
        {
          double e = basicClusters_[iGSF][ibc].energy();
          sclusterE += e;
          posX += e * basicClusters_[iGSF][ibc].position().X();
          posY += e * basicClusters_[iGSF][ibc].position().Y();
          posZ += e * basicClusters_[iGSF][ibc].position().Z();   
        }
      posX /=sclusterE;
      posY /=sclusterE;
      posZ /=sclusterE;
      
      if(pfCand[gsfPFCandidateIndex_[iGSF]].gsfTrackRef()!=GsfTrackRef_[iGSF])
        {
          edm::LogError("PFElectronTranslator") << " Major problem in PFElectron Translator" << std::endl;
        }
      
      // compute the width
      PFClusterWidthAlgo pfwidth(pfClusters_[iGSF]);
      
      double correctedEnergy=pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
      reco::SuperCluster mySuperCluster(correctedEnergy,math::XYZPoint(posX,posY,posZ));
      // protection against empty basic cluster collection ; the value is -2 in this case
      if(nbasics)
        {
//        std::cout << "SuperCluster creation; energy " << pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
//        std::cout << " " <<   pfCand[gsfPFCandidateIndex_[iGSF]].rawEcalEnergy() << std::endl;
//        std::cout << "Seed energy from basic " << basicClusters_[iGSF][0].energy() << std::endl;
          mySuperCluster.setSeed(basicClusterPtr_[iGSF][0]);
        }
      else
        {
          //      std::cout << "SuperCluster creation ; seed energy " << 0 << std::endl;
//        std::cout << "SuperCluster creation ; energy " << pfCand[gsfPFCandidateIndex_[iGSF]].ecalEnergy();
//        std::cout << " " <<   pfCand[gsfPFCandidateIndex_[iGSF]].rawEcalEnergy() << std::endl;
//        std::cout << " No seed found " << 0 << std::endl;       
//        std::cout << " MVA " << pfCand[gsfPFCandidateIndex_[iGSF]].mva_e_pi() << std::endl;
          mySuperCluster.setSeed(reco::CaloClusterPtr());
        }
      // the seed should be the first basic cluster

      for(unsigned ibc=0;ibc<nbasics;++ibc)
        {
          mySuperCluster.addCluster(basicClusterPtr_[iGSF][ibc]);
          //      std::cout <<"Adding Ref to SC " << basicClusterPtr_[iGSF][ibc].index() << std::endl;
          const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iGSF][ibc].hitsAndFractions();
          //      std::cout << " Number of cells " << v1.size() << std::endl;
          for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
               diIt != v1.end();
               ++diIt ) {
            //      std::cout << " Adding DetId " << (diIt->first).rawId() << " " << diIt->second << std::endl;
            mySuperCluster.addHitAndFraction(diIt->first,diIt->second);
          } // loop over rechits      
        }      

      unsigned nps=preshowerClusterPtr_[iGSF].size();
      for(unsigned ips=0;ips<nps;++ips)
        {
          mySuperCluster.addPreshowerCluster(preshowerClusterPtr_[iGSF][ips]);
        }
      

      // Set the preshower energy
      mySuperCluster.setPreshowerEnergy(pfCand[gsfPFCandidateIndex_[iGSF]].pS1Energy()+
                                        pfCand[gsfPFCandidateIndex_[iGSF]].pS2Energy());

      // Set the cluster width
      mySuperCluster.setEtaWidth(pfwidth.pflowEtaWidth());
      mySuperCluster.setPhiWidth(pfwidth.pflowPhiWidth());
      // Force the computation of rawEnergy_ of the reco::SuperCluster
      mySuperCluster.rawEnergy();
      superClusters.push_back(mySuperCluster);
   }
}
bool PFElectronTranslator::fetchCandidateCollection ( edm::Handle< reco::PFCandidateCollection > &  c,
const edm::InputTag tag,
const edm::Event iEvent 
) const [private]

Definition at line 180 of file PFElectronTranslator.cc.

References newFWLiteAna::found, and edm::Event::getByLabel().

Referenced by produce().

                                                                            {  
  bool found = iEvent.getByLabel(tag, c);

  if(!found)
    {
      std::ostringstream  err;
      err<<" cannot get PFCandidates: "
         <<tag<<std::endl;
      edm::LogError("PFElectronTranslator")<<err.str();
    }
  return found;
      
}
void PFElectronTranslator::fetchGsfCollection ( edm::Handle< reco::GsfTrackCollection > &  c,
const edm::InputTag tag,
const edm::Event iEvent 
) const [private]

Definition at line 196 of file PFElectronTranslator.cc.

References Exception, newFWLiteAna::found, and edm::Event::getByLabel().

Referenced by fillMVAValueMap(), and fillSCRefValueMap().

                                                                            {  
  bool found = iEvent.getByLabel(tag, c);
  
  if(!found ) {
    std::ostringstream  err;
    err<<" cannot get GSFTracks: "
       <<tag<<std::endl;
    edm::LogError("PFElectronTranslator")<<err.str();
    throw cms::Exception( "MissingProduct", err.str());
  }  
}
void PFElectronTranslator::fillMVAValueMap ( edm::Event iEvent,
edm::ValueMap< float >::Filler &  filler 
) const [private]

Definition at line 293 of file PFElectronTranslator.cc.

References fetchGsfCollection(), gsfMvaMap_, inputTagGSFTracks_, edm::helper::Filler< Map >::insert(), and makeHLTPrescaleTable::values.

Referenced by produce().

{
  edm::Handle<reco::GsfTrackCollection> gsfTracks;
  fetchGsfCollection(gsfTracks,
                     inputTagGSFTracks_,
                     iEvent);
  unsigned ngsf=gsfTracks->size();
  std::vector<float> values;
  for(unsigned igsf=0;igsf<ngsf;++igsf)
    {
      reco::GsfTrackRef theTrackRef(gsfTracks, igsf);
      std::map<reco::GsfTrackRef,float>::const_iterator itcheck=gsfMvaMap_.find(theTrackRef);
      if(itcheck==gsfMvaMap_.end())
        {
          //      edm::LogWarning("PFElectronTranslator") << "MVA Map, missing GSF track ref " << std::endl;
          values.push_back(-99.);
          //      std::cout << " Push_back -99. " << std::endl;
        }
      else
        {
          values.push_back(itcheck->second);      
        }
    }
  filler.insert(gsfTracks,values.begin(),values.end());
}
void PFElectronTranslator::fillSCRefValueMap ( edm::Event iEvent,
edm::ValueMap< reco::SuperClusterRef >::Filler &  filler 
) const [private]

Definition at line 320 of file PFElectronTranslator.cc.

References fetchGsfCollection(), inputTagGSFTracks_, edm::helper::Filler< Map >::insert(), scMap_, and makeHLTPrescaleTable::values.

Referenced by produce().

{
  edm::Handle<reco::GsfTrackCollection> gsfTracks;
  fetchGsfCollection(gsfTracks,
                     inputTagGSFTracks_,
                     iEvent);
  unsigned ngsf=gsfTracks->size();
  std::vector<reco::SuperClusterRef> values;
  for(unsigned igsf=0;igsf<ngsf;++igsf)
    {
      reco::GsfTrackRef theTrackRef(gsfTracks, igsf);
      std::map<reco::GsfTrackRef,reco::SuperClusterRef>::const_iterator itcheck=scMap_.find(theTrackRef);
      if(itcheck==scMap_.end())
        {
          //      edm::LogWarning("PFElectronTranslator") << "SCRef Map, missing GSF track ref" << std::endl;
          values.push_back(reco::SuperClusterRef());
        }
      else
        {
          values.push_back(itcheck->second);      
        }
    }
  filler.insert(gsfTracks,values.begin(),values.end());
}
void PFElectronTranslator::fillValueMap ( edm::Event iEvent,
edm::ValueMap< float >::Filler &  filler 
) const [private]
void PFElectronTranslator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 41 of file PFElectronTranslator.cc.

References basicClusterPtr_, basicClusters_, correspondingDaughterCandidate(), createBasicCluster(), createBasicClusterPtrs(), createPreshowerCluster(), createPreshowerClusterPtrs(), createSuperClusterGsfMapRefs(), createSuperClusters(), ExpressReco_HICollisions_FallBack::e, ECAL, asciidump::elements, reco::PFCandidate::elementsInBlocks(), fetchCandidateCollection(), edm::helper::Filler< Map >::fill(), fillMVAValueMap(), fillSCRefValueMap(), gsfMvaMap_, gsfPFCandidateIndex_, reco::PFCandidate::gsfTrackRef(), GsfTrackRef_, i, inputTagPFCandidates_, edm::Ref< C, T, F >::isNull(), reco::PFCandidate::mva_e_pi(), MVACut_, reco::PFCandidate::particleId(), PFBasicClusterCollection_, reco::tau::pfCandidates(), pfClusters_, PFMVAValueMap_, PFPreshowerClusterCollection_, PFSCValueMap_, PFSuperClusterCollection_, preshowerClusterPtr_, preshowerClusters_, reco::PFBlockElement::PS1, reco::PFBlockElement::PS2, edm::Event::put(), scMap_, ntuplemaker::status, superClusters_, and reco::PFBlockElement::type().

                                                                 { 
  
  std::auto_ptr<reco::SuperClusterCollection> 
    superClusters_p(new reco::SuperClusterCollection);

  std::auto_ptr<reco::BasicClusterCollection> 
    basicClusters_p(new reco::BasicClusterCollection);

  std::auto_ptr<reco::PreshowerClusterCollection>
    psClusters_p(new reco::PreshowerClusterCollection);
  
  std::auto_ptr<edm::ValueMap<float> > mvaMap_p(new edm::ValueMap<float>());
  edm::ValueMap<float>::Filler mvaFiller(*mvaMap_p);

  std::auto_ptr<edm::ValueMap<reco::SuperClusterRef> > 
    scMap_p(new edm::ValueMap<reco::SuperClusterRef>());
  edm::ValueMap<reco::SuperClusterRef>::Filler scRefFiller(*scMap_p);
  

  edm::Handle<reco::PFCandidateCollection> pfCandidates;
  bool status=fetchCandidateCollection(pfCandidates, 
                                       inputTagPFCandidates_, 
                                       iEvent );
  
  // clear the vectors
  GsfTrackRef_.clear();
  basicClusters_.clear();
  pfClusters_.clear();
  preshowerClusters_.clear();
  superClusters_.clear();
  basicClusterPtr_.clear();
  preshowerClusterPtr_.clear();
  gsfPFCandidateIndex_.clear();
  scMap_.clear();
  gsfMvaMap_.clear();
 
  // loop on the candidates 
  //CC@@
  // we need first to create AND put the SuperCluster, 
  // basic clusters and presh clusters collection 
  // in order to get a working Handle
  unsigned ncand=(status)?pfCandidates->size():0;
  unsigned iGSF=0;
  for( unsigned i=0; i<ncand; ++i ) {

    const reco::PFCandidate& cand = (*pfCandidates)[i];    
    if(cand.particleId()!=reco::PFCandidate::e) continue; 
    if(cand.gsfTrackRef().isNull()) continue;
    // Note that -1 will still cut some total garbage candidates 
    // Fill the MVA map
    gsfMvaMap_[cand.gsfTrackRef()]=cand.mva_e_pi();       
    if(cand.mva_e_pi()<MVACut_) continue;

    GsfTrackRef_.push_back(cand.gsfTrackRef());
    gsfPFCandidateIndex_.push_back(i);
    
    basicClusters_.push_back(reco::BasicClusterCollection());
    pfClusters_.push_back(std::vector<const reco::PFCluster *>());
    preshowerClusters_.push_back(reco::PreshowerClusterCollection());

    for(unsigned iele=0; iele<cand.elementsInBlocks().size(); ++iele) {
      // first get the block 
      reco::PFBlockRef blockRef = cand.elementsInBlocks()[iele].first;
      //
      unsigned elementIndex = cand.elementsInBlocks()[iele].second;
      // check it actually exists 
      if(blockRef.isNull()) continue;
      
      // then get the elements of the block
      const edm::OwnVector< reco::PFBlockElement >&  elements = (*blockRef).elements();
      
      const reco::PFBlockElement & pfbe (elements[elementIndex]); 
      // The first ECAL element should be the cluster associated to the GSF; defined as the seed
      if(pfbe.type()==reco::PFBlockElement::ECAL)
        {         
          //      const reco::PFCandidate * coCandidate = &cand;
          // the Brem photons are saved as daughter PFCandidate; this 
          // is convenient to access the corrected energy
          //      std::cout << " Found candidate "  << correspondingDaughterCandidate(coCandidate,pfbe) << " " << coCandidate << std::endl;
          createBasicCluster(pfbe,basicClusters_[iGSF],pfClusters_[iGSF],correspondingDaughterCandidate(cand,pfbe));
        }
      if(pfbe.type()==reco::PFBlockElement::PS1)
        {
          createPreshowerCluster(pfbe,preshowerClusters_[iGSF],1);
        }
      if(pfbe.type()==reco::PFBlockElement::PS2)
        {
          createPreshowerCluster(pfbe,preshowerClusters_[iGSF],2);
        }      
          
    }   // loop on the elements

    // save the basic clusters
    basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iGSF].begin(), basicClusters_[iGSF].end());
    // save the preshower clusters
    psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iGSF].begin(),preshowerClusters_[iGSF].end());

    ++iGSF;
  } // loop on PFCandidates

  
   //Save the basic clusters and get an handle as to be able to create valid Refs (thanks to Claude)
  //  std::cout << " Number of basic clusters " << basicClusters_p->size() << std::endl;
  const edm::OrphanHandle<reco::BasicClusterCollection> bcRefProd = 
    iEvent.put(basicClusters_p,PFBasicClusterCollection_);

  //preshower clusters
  const edm::OrphanHandle<reco::PreshowerClusterCollection> psRefProd = 
    iEvent.put(psClusters_p,PFPreshowerClusterCollection_);

  // now that the Basic clusters are in the event, the Ref can be created
  createBasicClusterPtrs(bcRefProd);
  // now that the preshower clusters are in the event, the Ref can be created
  createPreshowerClusterPtrs(psRefProd);
  
  // and now the Super cluster can be created with valid references  
  if(status) createSuperClusters(*pfCandidates,*superClusters_p);
  
  // Let's put the super clusters in the event
  const edm::OrphanHandle<reco::SuperClusterCollection> scRefProd = iEvent.put(superClusters_p,PFSuperClusterCollection_); 
  // create the super cluster Ref
  createSuperClusterGsfMapRefs(scRefProd);
  
  
  fillMVAValueMap(iEvent,mvaFiller);
  mvaFiller.fill();

  fillSCRefValueMap(iEvent,scRefFiller);
  scRefFiller.fill();

  // MVA map
  iEvent.put(mvaMap_p,PFMVAValueMap_);
  // Gsf-SC map
  iEvent.put(scMap_p,PFSCValueMap_);
}

Member Data Documentation

Definition at line 92 of file PFElectronTranslator.h.

Referenced by createBasicClusterPtrs(), createSuperClusters(), and produce().

Definition at line 84 of file PFElectronTranslator.h.

Referenced by createBasicClusterPtrs(), createSuperClusters(), and produce().

Definition at line 99 of file PFElectronTranslator.h.

Referenced by fillMVAValueMap(), and produce().

std::vector<int> PFElectronTranslator::gsfPFCandidateIndex_ [private]

Definition at line 96 of file PFElectronTranslator.h.

Referenced by createSuperClusters(), and produce().

Definition at line 72 of file PFElectronTranslator.h.

Referenced by fillMVAValueMap(), fillSCRefValueMap(), and PFElectronTranslator().

Definition at line 71 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

Definition at line 78 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

Definition at line 73 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

std::vector<std::vector<const reco::PFCluster *> > PFElectronTranslator::pfClusters_ [private]

Definition at line 86 of file PFElectronTranslator.h.

Referenced by createSuperClusters(), and produce().

std::string PFElectronTranslator::PFMVAValueMap_ [private]

Definition at line 76 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

Definition at line 74 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

std::string PFElectronTranslator::PFSCValueMap_ [private]

Definition at line 77 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

Definition at line 75 of file PFElectronTranslator.h.

Referenced by PFElectronTranslator(), and produce().

Definition at line 94 of file PFElectronTranslator.h.

Referenced by createPreshowerClusterPtrs(), createSuperClusters(), and produce().

Definition at line 88 of file PFElectronTranslator.h.

Referenced by createPreshowerClusterPtrs(), and produce().

Definition at line 98 of file PFElectronTranslator.h.

Referenced by createSuperClusterGsfMapRefs(), fillSCRefValueMap(), and produce().

Definition at line 90 of file PFElectronTranslator.h.

Referenced by produce().