CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PFSuperClusterAlgo Class Reference

#include <PFSuperClusterAlgo.h>

List of all members.

Public Member Functions

void doClustering (const edm::Handle< reco::PFClusterCollection > &pfclustersHandle, std::auto_ptr< reco::BasicClusterCollection > &basicClusters_p, boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_, int detector)
void findClustersOutsideMustacheArea ()
void matchSCtoESclusters (const edm::Handle< reco::PFClusterCollection > &pfclustersHandl, std::auto_ptr< reco::SuperClusterCollection > &pfSuperClustersWithES_p, boost::shared_ptr< PFEnergyCalibration > thePFEnergyCalibration_, int detector)
 PFSuperClusterAlgo ()
 constructor
void setCrackCorrections (bool applyCrackCorrections)
void setEtawidthSuperClusterBarrel (double etawidth)
void setEtawidthSuperClusterEndcap (double etawidth)
void setMustacheCut (bool doMustacheCut)
void setPhiwidthSuperClusterBarrel (double phiwidth)
void setPhiwidthSuperClusterEndcap (double phiwidth)
void setThreshPFClusterBarrel (double thresh)
void setThreshPFClusterEndcap (double thresh)
void setThreshPFClusterES (double thresh)
void setThreshPFClusterSeedBarrel (double thresh)
void setThreshPFClusterSeedEndcap (double thresh)
void setVerbosityLevel (bool verbose)
void storeSuperClusters (const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle, std::auto_ptr< reco::SuperClusterCollection > &pfSuperClusters_p)
virtual ~PFSuperClusterAlgo ()
 destructor

Private Member Functions

void createBasicCluster (const reco::PFClusterRef &myPFClusterRef, reco::BasicClusterCollection &basicClusters, std::vector< const reco::PFCluster * > &pfClusters) const
void createBasicClusterPtrs (const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle)
void createSuperClusters (reco::SuperClusterCollection &superClusters, bool doEEwithES) const

Private Attributes

std::vector< double > allPfClusterCalibratedEnergy_
bool applyCrackCorrections_
std::vector
< reco::CaloClusterPtrVector
basicClusterPtr_
std::vector
< reco::BasicClusterCollection
basicClusters_
bool doMustacheCut_
double etawidthSuperCluster_
double etawidthSuperClusterBarrel_
double etawidthSuperClusterEndcap_
std::vector< std::vector
< unsigned int > > 
insideMust_
int nSuperClusters
std::vector< reco::PFClusterRefpfClusterAboveThresholdCollection
std::vector< std::vector
< double > > 
pfClusterCalibratedEnergy_
std::vector< std::vector
< double > > 
pfClusterCalibratedEnergyWithES_
std::vector< int > pfClusterIndex_
std::vector< std::vector
< const reco::PFCluster * > > 
pfClusters_
double phiwidthSuperCluster_
double phiwidthSuperClusterBarrel_
double phiwidthSuperClusterEndcap_
std::vector< int > scPFseedIndex_
std::vector< reco::PFClusterRefseedCandidateCollection
std::vector< int > seedCandidateIndex_
reco::SuperClusterCollection superClusters_
double threshPFCluster_
double threshPFClusterBarrel_
double threshPFClusterEndcap_
double threshPFClusterES_
double threshPFClusterSeed_
double threshPFClusterSeedBarrel_
double threshPFClusterSeedEndcap_
bool verbose_

Detailed Description

Definition at line 41 of file PFSuperClusterAlgo.h.


Constructor & Destructor Documentation

PFSuperClusterAlgo::PFSuperClusterAlgo ( )

constructor

Definition at line 22 of file PFSuperClusterAlgo.cc.

{

}
virtual PFSuperClusterAlgo::~PFSuperClusterAlgo ( ) [inline, virtual]

destructor

Definition at line 49 of file PFSuperClusterAlgo.h.

{;}

Member Function Documentation

void PFSuperClusterAlgo::createBasicCluster ( const reco::PFClusterRef myPFClusterRef,
reco::BasicClusterCollection basicClusters,
std::vector< const reco::PFCluster * > &  pfClusters 
) const [private]

Definition at line 220 of file PFSuperClusterAlgo.cc.

References edm::Ref< C, T, F >::isNull().

{

  //cout << "Inside PFSuperClusterAlgo::createBasicCluster"<<endl;

  if(myPFClusterRef.isNull()) return;  

  const reco::PFCluster & myPFCluster (*myPFClusterRef);
  pfClusters.push_back(&myPFCluster);



  basicClusters.push_back(myPFCluster);
  /*
    reco::CaloCluster(//coCandidate.rawEcalEnergy(),
    myPFCluster.energy(),
    myPFCluster.position(),
    myPFCluster.caloID(),
    myPFCluster.hitsAndFractions(),
    myPFCluster.algo(),
    myPFCluster.seed()));
  */

}
void PFSuperClusterAlgo::createBasicClusterPtrs ( const edm::OrphanHandle< reco::BasicClusterCollection > &  basicClustersHandle) [private]

Definition at line 247 of file PFSuperClusterAlgo.cc.

References findQualityFiles::size.

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

  for(unsigned is=0;is<size;++is) // loop on superclusters
    {
      unsigned nbc=basicClusters_[is].size();
      for(unsigned ibc=0;ibc<nbc;++ibc) // loop on basic clusters
        {
          reco::CaloClusterPtr bcPtr(basicClustersHandle,basicClusterCounter);
          basicClusterPtr_[is].push_back(bcPtr);
          ++basicClusterCounter;
        }
    }
}
void PFSuperClusterAlgo::createSuperClusters ( reco::SuperClusterCollection superClusters,
bool  doEEwithES 
) const [private]

Definition at line 266 of file PFSuperClusterAlgo.cc.

References reco::SuperCluster::addCluster(), reco::CaloCluster::addHitAndFraction(), gather_cfg::cout, reco::CaloCluster::eta(), PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), reco::CaloCluster::phi(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), reco::SuperCluster::setPreshowerEnergy(), and reco::SuperCluster::setSeed().

                                                                                                            {

  unsigned ns=nSuperClusters;
  for(unsigned is=0;is<ns;++is)
    {

      // Computes energy position a la e/gamma 
      double sclusterE=0;
      double posX=0.;
      double posY=0.;
      double posZ=0.;
      
      double correctedEnergy = 0;
      double correctedEnergyWithES = 0;

      unsigned nbasics=basicClusters_[is].size();
      for(unsigned ibc=0;ibc<nbasics;++ibc)
        {

          if (doMustacheCut_ && insideMust_[is][ibc] == 0) continue; //Cleaning of PU clusters outside Mustache area
          
          double BCenergy = basicClusters_[is][ibc].energy();
          sclusterE += BCenergy;

          //Use PFCluster calibrated energy
          correctedEnergy += pfClusterCalibratedEnergy_[is][ibc];
          if (doEEwithES) correctedEnergyWithES += pfClusterCalibratedEnergyWithES_[is][ibc];

          posX += BCenergy * basicClusters_[is][ibc].position().X();
          posY += BCenergy * basicClusters_[is][ibc].position().Y();
          posZ += BCenergy * basicClusters_[is][ibc].position().Z();      
        }
      posX /=sclusterE;
      posY /=sclusterE;
      posZ /=sclusterE;
          

      // compute the width
      PFClusterWidthAlgo pfwidth(pfClusters_[is]);
      
      //create the supercluster
      double corrEnergy = correctedEnergy;
      if (doEEwithES) corrEnergy = correctedEnergyWithES;
      reco::SuperCluster mySuperCluster(corrEnergy,math::XYZPoint(posX,posY,posZ));

      if (verbose_) {
        if (!doEEwithES) cout << "Supercluster "<<is<< " eta="<< mySuperCluster.eta() <<" phi="<< mySuperCluster.phi()<< " rawEnergy="<<sclusterE<<" correctedEnergy="<<correctedEnergy <<endl;
        if (doEEwithES) cout << "Supercluster "<<is<< " eta="<< mySuperCluster.eta() <<" phi="<< mySuperCluster.phi()<< " rawEnergy="<<sclusterE<<" correctedEnergy="<<correctedEnergy <<" correctedEnergyWithES="<<correctedEnergyWithES<<endl;
      }

      
      if(nbasics)
        {
          if (verbose_) std::cout << "Seed cluster energy=" << basicClusters_[is][scPFseedIndex_[is]].energy() << std::endl;
          mySuperCluster.setSeed(basicClusterPtr_[is][scPFseedIndex_[is]]);
        }
      else
        {
          mySuperCluster.setSeed(reco::CaloClusterPtr());
        }
      // the seed should be the first basic cluster


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

      /*
      //Could consider adding the preshower clusters
      unsigned nps=preshowerClusterPtr_[is].size();
      for(unsigned ips=0;ips<nps;++ips)
        {
          mySuperCluster.addPreshowerCluster(preshowerClusterPtr_[is][ips]);
        }
      */

      // Set the preshower energy
      if (doEEwithES) mySuperCluster.setPreshowerEnergy(correctedEnergyWithES-correctedEnergy);
      else mySuperCluster.setPreshowerEnergy(0.);

      // 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);
      
    }
}
void PFSuperClusterAlgo::doClustering ( const edm::Handle< reco::PFClusterCollection > &  pfclustersHandle,
std::auto_ptr< reco::BasicClusterCollection > &  basicClusters_p,
boost::shared_ptr< PFEnergyCalibration thePFEnergyCalibration_,
int  detector 
)

Definition at line 29 of file PFSuperClusterAlgo.cc.

References gather_cfg::cout, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, reco::PFCluster::energy(), relval_parameters_module::energy, reco::CaloCluster::eta(), i, j, edm::Ref< C, T, F >::key(), combine::key, reco::PFCluster::layer(), reco::CaloCluster::phi(), edm::Handle< T >::product(), findQualityFiles::size, and python::multivaluedict::sort().

                                                                                                                                                                                                                                         {

  //Similar to hybrid e/gamma, algorithm but same in barrel and endcap
  //0- Calibrate PFCluster energies
  //1- first look for the seed pfclusters
  //2- around the seed, open the (etawidth, phiwidth) window
  //3- take all the pfclusters passing the threshold in this window and remove them from the list of available pfclusters
  //4- go to next seed if not already clustered
  
  const reco::PFClusterCollection& pfclusters = *pfclustersHandle.product();
  //Setting parameters
  if (detector==0) {
    threshPFClusterSeed_ = threshPFClusterSeedBarrel_;
    threshPFCluster_ = threshPFClusterBarrel_;
    etawidthSuperCluster_ = etawidthSuperClusterBarrel_;
    phiwidthSuperCluster_ = phiwidthSuperClusterBarrel_;
  }
  if (detector==1) {
    threshPFClusterSeed_ = threshPFClusterSeedEndcap_;
    threshPFCluster_ = threshPFClusterEndcap_;
    etawidthSuperCluster_ = etawidthSuperClusterEndcap_;
    phiwidthSuperCluster_ = phiwidthSuperClusterEndcap_;
  }

  if (verbose_) {
    if (detector==0) cout << "PFSuperClusterAlgo::doClustering in EB" << endl;
    if (detector==1) cout << "PFSuperClusterAlgo::doClustering in EE" << endl;
  }

  //cleaning vectors
  pfClusters_.clear();
  basicClusters_.clear();

  basicClusterPtr_.clear();

  scPFseedIndex_.clear();
  seedCandidateIndex_.clear();
  pfClusterIndex_.clear();

  unsigned int nClusters = pfclusters.size();
  allPfClusterCalibratedEnergy_.resize(nClusters);
  allPfClusterCalibratedEnergy_.assign(nClusters, 0.0);

  pfClusterCalibratedEnergy_.clear();

  seedCandidateCollection.clear();
  pfClusterAboveThresholdCollection.clear();


  int layer;
  if (detector==0) layer = PFLayer::ECAL_BARREL;
  if (detector==1) layer = PFLayer::ECAL_ENDCAP;

  //Select PF clusters available for the clustering
  for (unsigned int i=0; i<pfclusters.size(); i++){
    const reco::PFCluster & myPFCluster = pfclusters[i];
    if (verbose_) cout << "PFCluster i="<<i<<" energy="<<myPFCluster.energy()<<endl;
    
    if (myPFCluster.layer()==layer){

      double PFClusterCalibratedEnergy = thePFEnergyCalibration_->energyEm(myPFCluster,0.0,0.0,applyCrackCorrections_);

      allPfClusterCalibratedEnergy_[i]= PFClusterCalibratedEnergy;

      //select PFClusters seeds
      if (PFClusterCalibratedEnergy > threshPFClusterSeed_){
        const reco::PFClusterRef seedCandidate = reco::PFClusterRef(pfclustersHandle, i);
        seedCandidateCollection.push_back(seedCandidate);
      }

      //select PFClusters above thresholds
      if (PFClusterCalibratedEnergy > threshPFCluster_){
        const reco::PFClusterRef pfClusterAboveThreshold = reco::PFClusterRef(pfclustersHandle, i);
        pfClusterAboveThresholdCollection.push_back(pfClusterAboveThreshold);
        pfClusterIndex_.push_back(i);
      }

    }

  }

  //Sort seeds by energy
  sort(seedCandidateCollection.begin(), seedCandidateCollection.end(), less_magPF());
 
  if (verbose_) cout << "After sorting"<<endl;
  for (unsigned int is=0; is<seedCandidateCollection.size(); is++) {
    if (verbose_) cout << "SeedPFCluster "<<is<< " energy="<<seedCandidateCollection[is]->energy()<<endl;

    for (unsigned int i=0; i<pfclusters.size(); i++){
      if (seedCandidateCollection[is].key()==i) {
        seedCandidateIndex_.push_back(i);
        if (verbose_) cout << "seedCandidateIndex_[is]="<<seedCandidateIndex_[is]<<endl;
      }
    }
  }


  //Keep pfclusters within etawidth-phiwidth window around seeds

  std::vector<int> isSeedUsed(seedCandidateCollection.size(),0);

  std::vector<int> isPFclusterUsed(pfClusterAboveThresholdCollection.size(), 0);

  std::vector<bool> isClusterized(pfclusters.size(), false);

  nSuperClusters = 0;

  //run over the seed candidates
  for (unsigned int is=0; is<seedCandidateCollection.size(); is++){

    if (verbose_) cout << "is="<<is<<" seedCandidate Energy="<<seedCandidateCollection[is]->energy() <<" eta="<< seedCandidateCollection[is]->eta()<< " phi="<< seedCandidateCollection[is]->phi()<< endl;

    if (isClusterized[seedCandidateIndex_[is]]==true) {
     if (verbose_) cout << "This seed cluster (energy="<<(*pfclustersHandle)[seedCandidateIndex_[is]].energy() <<") is already used, switching to next one"  << endl;
      continue;
    }
    isSeedUsed[is]=0;

    double seedEta = seedCandidateCollection[is]->eta();
    double seedPhi = seedCandidateCollection[is]->phi();
    //check if the pfclusters can belong to the seeded supercluster
    for (unsigned int j=0; j<pfClusterAboveThresholdCollection.size(); j++){
      
      reco::PFClusterRef myPFClusterRef = pfClusterAboveThresholdCollection[j];
      const reco::PFCluster & myPFCluster (*myPFClusterRef);
      if (isPFclusterUsed[j]==1) {
        if (verbose_) cout << "This PFCluster (energy="<<myPFCluster.energy() <<") is already used" << endl;
        continue;
      }
      
      //checking if the pfcluster is inside the eta/phi box around the seed
      if (fabs(seedEta-myPFCluster.eta())<etawidthSuperCluster_
          && fabs(seedPhi-myPFCluster.phi())<phiwidthSuperCluster_ //FIXME wraparound
                  ){

        isSeedUsed[is]++;
        if (isSeedUsed[is]==1){
          pfClusters_.push_back(std::vector<const reco::PFCluster *>());
          basicClusters_.push_back(reco::BasicClusterCollection());
          pfClusterCalibratedEnergy_.push_back(std::vector<double>());
        }

        isPFclusterUsed[j]=1;
        
        //add pfcluster to collection of basicclusters
        createBasicCluster(myPFClusterRef, basicClusters_[nSuperClusters], pfClusters_[nSuperClusters]);

        double PFClusterCalibratedEnergy = allPfClusterCalibratedEnergy_[myPFClusterRef.key()];
          //thePFEnergyCalibration_->energyEm(myPFCluster,0.0,0.0,applyCrackCorrections_);
        pfClusterCalibratedEnergy_[nSuperClusters].push_back(PFClusterCalibratedEnergy);

        if (myPFClusterRef==seedCandidateCollection[is]) {
          scPFseedIndex_.push_back(basicClusters_[nSuperClusters].size()-1);
        }

        if (verbose_) cout << "Use PFCluster "<<j<<" eta="<< myPFCluster.eta()
                           << "phi="<< myPFCluster.phi()
                           <<" energy="<< myPFCluster.energy()
                           <<" calibEnergy="<< pfClusterCalibratedEnergy_[nSuperClusters][basicClusters_[nSuperClusters].size()-1]<<endl;
        
        isClusterized[pfClusterIndex_[j]] = true;
        
      }
    }
    
    
    //If the seed was used, store the basic clusters
    if (isSeedUsed[is]>0) {

      if (verbose_) cout << "New supercluster, number "<<nSuperClusters<<" having "<< basicClusters_[nSuperClusters].size()<< " basicclusters"<<endl;
      if (verbose_) for (unsigned int i=0; i<basicClusters_[nSuperClusters].size(); i++) cout << "BC "<<i<<" energy="<<basicClusters_[nSuperClusters][i].energy()<<endl;

      basicClusters_p->insert(basicClusters_p->end(),basicClusters_[nSuperClusters].begin(), basicClusters_[nSuperClusters].end());

      if (verbose_) cout << "basicClusters_p filled" << endl;

      nSuperClusters++;
    }
    
  }

  if (verbose_) {
    if (detector==0) cout << "Leaving doClustering in EB (nothing more to clusterize)"<<endl;
    if (detector==1) cout << "Leaving doClustering in EE (nothing more to clusterize)"<<endl;
  }


  return;
}
void PFSuperClusterAlgo::findClustersOutsideMustacheArea ( )

Definition at line 538 of file PFSuperClusterAlgo.cc.

References gather_cfg::cout, and reco::Mustache::MustacheClust().

                                                        {

  //Find PF cluster outside the Mustache area

  if (!doMustacheCut_) return;

  //if (verbose_) cout << "findClustersOutsideMustacheArea" << endl;

  insideMust_.clear();
  //outsideMust_.clear();

  reco::Mustache PFSCMustache;
  
  //if (verbose_) cout << "Mustache object created" << endl;

  std::vector<unsigned int> insideMustList;
  std::vector<unsigned int> outsideMustList;

  for (unsigned int isc=0; isc<basicClusters_.size(); isc++){
    
    //if (verbose_) cout << "isc="<<isc<<endl;
 
    insideMust_.push_back(std::vector<unsigned int>());
    //outsideMust_.push_back(std::vector<unsigned int>());

    insideMustList.clear();
    outsideMustList.clear();

    //Find the pfclusters inside/outside the mustache
    PFSCMustache.MustacheClust(basicClusters_[isc],
                               insideMustList, 
                               outsideMustList);

    for (unsigned int ibc=0; ibc<basicClusters_[isc].size(); ibc++) insideMust_[isc].push_back(1);
      
    for (unsigned int iclus=0; iclus<outsideMustList.size(); iclus++) {
      if (verbose_) cout << "isc="<<isc<<" outsideMustList[iclus]="<<outsideMustList[iclus]<<" outside mustache, energy="<< basicClusters_[isc][outsideMustList[iclus]]<<endl;
      insideMust_[isc][outsideMustList[iclus]] = 0;
    }
    
  }



  return;
}
void PFSuperClusterAlgo::matchSCtoESclusters ( const edm::Handle< reco::PFClusterCollection > &  pfclustersHandl,
std::auto_ptr< reco::SuperClusterCollection > &  pfSuperClustersWithES_p,
boost::shared_ptr< PFEnergyCalibration thePFEnergyCalibration_,
int  detector 
)

Definition at line 384 of file PFSuperClusterAlgo.cc.

References gather_cfg::cout, PFLayer::ECAL_ENDCAP, reco::PFCluster::energy(), reco::CaloCluster::eta(), i, reco::PFCluster::layer(), reco_skim_cfg_mod::maxSize, reco::CaloCluster::phi(), Pi, edm::Handle< T >::product(), PFLayer::PS1, PFLayer::PS2, findQualityFiles::size, LinkByRecHit::testECALAndPSByRecHit(), and TwoPi.

{

  if (verbose_) cout << "matchSCtoESclusters" << endl;


  if (detector==0) return;

  const reco::PFClusterCollection& pfclusters = *pfclustersHandle.product();
  std::vector<const reco::PFCluster*> pfESClusterAboveThresholdCollection;
  pfClusterCalibratedEnergyWithES_.clear();
  //  pfESClusterAboveThresholdCollection.clear();

  //Select the preshower pfclusters above thresholds
  typedef reco::PFClusterCollection::const_iterator PFCI;
  unsigned int i=0;
  for (PFCI cluster = pfclusters.begin(), cEnd = pfclusters.end(); cluster!=cEnd; ++cluster,++i){
    
    if (cluster->layer()==PFLayer::PS1 || cluster->layer()==PFLayer::PS2){
      
      if (verbose_) cout << "ES PFCluster i="<<i<<" energy="<<cluster->energy()<<endl;
      
      if (cluster->energy()>threshPFClusterES_){
        pfESClusterAboveThresholdCollection.push_back(&*cluster);
      }

    }

  }

  unsigned int nESaboveThreshold = pfESClusterAboveThresholdCollection.size();


  //for each preshower pfcluster get the associated EE pfcluster if existing

  double dist = -1;
  double distmin = 1000;
  int iscsel = -1;
  int ibcsel = -1;

  unsigned int nSCs = pfClusters_.size();
 
  //These vectors will relate the EE clusters in the SC to the ES clusters (needed for calibration)
  unsigned int maxSize = 0;
  for (unsigned int isc=0; isc<nSCs; isc++) {
    unsigned int iscSize = pfClusters_[isc].size();
    if (maxSize < iscSize) maxSize = iscSize;
  }

  //cache some values instead of recomputing ntimes
  std::vector<double > SCBCtoESenergyPS1(nSCs*maxSize, 0);
  std::vector<double > SCBCtoESenergyPS2(nSCs*maxSize, 0);

  std::vector<double> bcEtas(nSCs*maxSize,0);
  std::vector<double> bcPhis(nSCs*maxSize,0);
  for (unsigned int isc=0; isc<nSCs; isc++) {
    for (unsigned int ibc=0, nBCs = pfClusters_[isc].size(); ibc<nBCs; ibc++){
      unsigned int indBC = isc*maxSize + ibc;
      bcEtas[indBC] = pfClusters_[isc][ibc]->eta();
      bcPhis[indBC] = pfClusters_[isc][ibc]->phi();
    }
  }
  for (unsigned int ies=0;  ies<nESaboveThreshold; ies++){ //loop over the ES pfclusters above the threshold

    distmin = 1000;
    iscsel = -1;
    ibcsel = -1;
    
    const reco::PFCluster* pfes(pfESClusterAboveThresholdCollection[ies]);
    double pfesEta = pfes->eta();
    double pfesPhi = pfes->phi();
    for (unsigned int isc=0; isc<nSCs; isc++){ //loop over the superclusters
      for (unsigned int ibc=0, nBCs = pfClusters_[isc].size(); ibc<nBCs; ibc++){ //loop over the basic clusters inside the SC
        unsigned int indBC = isc*maxSize + ibc;
        const reco::PFCluster* bcPtr = pfClusters_[isc][ibc];

        if (bcPtr->layer()!=PFLayer::ECAL_ENDCAP) continue;
        double bcEta = bcEtas[indBC];
        double deta=fabs(bcEta-pfesEta);
        if (bcEta*pfesEta<0 || fabs(deta)>0.3) continue; //same side of the EE
        
        double bcPhi = bcPhis[indBC];
        double dphi= fabs(bcPhi-pfesPhi); 
        if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
        //if (fabs(deta)>0.4 || fabs(dphi)>1.0) continue;
        if (fabs(dphi)>0.6) continue; //geometrical matching to speed up the timing
        
        dist = LinkByRecHit::testECALAndPSByRecHit( *(bcPtr), *(pfes), false); //matches EE and ES cluster
      
        if (dist!=-1){
          if (verbose_) cout << "isc="<<isc<<" ibc="<<ibc<< " ies="<<ies<< " ESenergy="<< pfes->energy()<<" dist="<<dist<<endl;
          
          if (dist<distmin){
            distmin = dist;
            iscsel = isc;
            ibcsel = ibc;
          }
        }
        
      }
    }


    //Store energies of the ES clusters associated to BC of the SC
    if (iscsel!=-1 && ibcsel!=-1){
      if (verbose_) cout << "Associate ESpfcluster ies="<<ies<<" to BC "<<ibcsel<<" in SC"<<iscsel<<endl;
      unsigned int indBCsel = iscsel*maxSize + ibcsel;
      if (pfes->layer()==PFLayer::PS1) {
        SCBCtoESenergyPS1[indBCsel]+=pfes->energy();
      }
      if (pfes->layer()==PFLayer::PS2) {
        SCBCtoESenergyPS2[indBCsel]+=pfes->energy();
      }
    }

  }


  //Compute the calibrated pfcluster energy, including EE+ES calibration. 
   for (unsigned int isc=0; isc<nSCs; isc++){
      pfClusterCalibratedEnergyWithES_.push_back(std::vector<double>());
      for (unsigned int ibc=0; ibc<pfClusters_[isc].size(); ibc++){
        const reco::PFCluster & myPFCluster (*(pfClusters_[isc][ibc]));
        if (myPFCluster.layer()!=PFLayer::ECAL_ENDCAP) continue;

        unsigned int indBC = isc*maxSize + ibc;
        double PFClusterCalibratedEnergy = 
          thePFEnergyCalibration_->energyEm(myPFCluster,SCBCtoESenergyPS1[indBC],SCBCtoESenergyPS2[indBC],applyCrackCorrections_);
        if (verbose_) cout << "isc="<<isc<<" ibc="<<ibc<<" EEenergy="<<myPFCluster.energy()
                           <<" calibEnergyWithoutES="<< pfClusterCalibratedEnergy_[isc][ibc] 
                           << " calibEnergyWithES="<<PFClusterCalibratedEnergy <<endl;
        pfClusterCalibratedEnergyWithES_[isc].push_back(PFClusterCalibratedEnergy);
        
        if (verbose_){
          cout << "isc="<<isc<<" ibc="<<ibc<<" EEenergy="<<myPFCluster.energy()
               <<" PS1energy="<< SCBCtoESenergyPS1[indBC]<<" PS2energy="<<SCBCtoESenergyPS2[indBC]
               <<" calibEnergyWithoutES="<< pfClusterCalibratedEnergy_[isc][ibc] << " calibEnergyWithES="<<PFClusterCalibratedEnergy <<endl;
        }
        
      }
   }

   
   //Store EE+preshower superclusters
   if (verbose_) cout << "Store EE+preshower superclusters" << endl;
   superClusters_.clear();

   createSuperClusters(superClusters_, true);

   pfSuperClustersWithES_p->insert(pfSuperClustersWithES_p->end(), superClusters_.begin(), superClusters_.end());
   
  return;
}
void PFSuperClusterAlgo::setCrackCorrections ( bool  applyCrackCorrections) [inline]

Definition at line 69 of file PFSuperClusterAlgo.h.

References applyCrackCorrections_.

{ applyCrackCorrections_ = applyCrackCorrections;}
void PFSuperClusterAlgo::setEtawidthSuperClusterBarrel ( double  etawidth) [inline]

Definition at line 59 of file PFSuperClusterAlgo.h.

References etawidthSuperClusterBarrel_.

void PFSuperClusterAlgo::setEtawidthSuperClusterEndcap ( double  etawidth) [inline]

Definition at line 61 of file PFSuperClusterAlgo.h.

References etawidthSuperClusterEndcap_.

void PFSuperClusterAlgo::setMustacheCut ( bool  doMustacheCut) [inline]

Definition at line 65 of file PFSuperClusterAlgo.h.

References doMustacheCut_.

{ doMustacheCut_ = doMustacheCut;}
void PFSuperClusterAlgo::setPhiwidthSuperClusterBarrel ( double  phiwidth) [inline]

Definition at line 58 of file PFSuperClusterAlgo.h.

References phiwidthSuperClusterBarrel_.

void PFSuperClusterAlgo::setPhiwidthSuperClusterEndcap ( double  phiwidth) [inline]

Definition at line 60 of file PFSuperClusterAlgo.h.

References phiwidthSuperClusterEndcap_.

void PFSuperClusterAlgo::setThreshPFClusterBarrel ( double  thresh) [inline]
void PFSuperClusterAlgo::setThreshPFClusterEndcap ( double  thresh) [inline]
void PFSuperClusterAlgo::setThreshPFClusterES ( double  thresh) [inline]
void PFSuperClusterAlgo::setThreshPFClusterSeedBarrel ( double  thresh) [inline]
void PFSuperClusterAlgo::setThreshPFClusterSeedEndcap ( double  thresh) [inline]
void PFSuperClusterAlgo::setVerbosityLevel ( bool  verbose) [inline]

Definition at line 51 of file PFSuperClusterAlgo.h.

References validate_alignment_devdb10_cfg::verbose, and verbose_.

void PFSuperClusterAlgo::storeSuperClusters ( const edm::OrphanHandle< reco::BasicClusterCollection > &  basicClustersHandle,
std::auto_ptr< reco::SuperClusterCollection > &  pfSuperClusters_p 
)

Definition at line 365 of file PFSuperClusterAlgo.cc.

References gather_cfg::cout.

{

  //Find PU clusters lying outside Mustache area
  findClustersOutsideMustacheArea();

  //Create basic clusters and superclusters
  createBasicClusterPtrs(basicClustersHandle);
  superClusters_.clear();
  createSuperClusters(superClusters_, false);

  if (verbose_) cout << "Created "<<superClusters_.size()<< " pfSuperClusters"<<endl;

  //storing superclusters
  pfSuperClusters_p->insert(pfSuperClusters_p->end(), superClusters_.begin(), superClusters_.end());

  return;
}

Member Data Documentation

Definition at line 117 of file PFSuperClusterAlgo.h.

Definition at line 104 of file PFSuperClusterAlgo.h.

Referenced by setCrackCorrections().

Definition at line 115 of file PFSuperClusterAlgo.h.

Definition at line 113 of file PFSuperClusterAlgo.h.

Definition at line 100 of file PFSuperClusterAlgo.h.

Referenced by setMustacheCut().

Definition at line 86 of file PFSuperClusterAlgo.h.

Definition at line 96 of file PFSuperClusterAlgo.h.

Referenced by setEtawidthSuperClusterBarrel().

Definition at line 98 of file PFSuperClusterAlgo.h.

Referenced by setEtawidthSuperClusterEndcap().

std::vector<std::vector<unsigned int> > PFSuperClusterAlgo::insideMust_ [private]

Definition at line 132 of file PFSuperClusterAlgo.h.

Definition at line 106 of file PFSuperClusterAlgo.h.

Definition at line 122 of file PFSuperClusterAlgo.h.

std::vector<std::vector<double> > PFSuperClusterAlgo::pfClusterCalibratedEnergy_ [private]

Definition at line 118 of file PFSuperClusterAlgo.h.

std::vector<std::vector<double> > PFSuperClusterAlgo::pfClusterCalibratedEnergyWithES_ [private]

Definition at line 119 of file PFSuperClusterAlgo.h.

std::vector<int> PFSuperClusterAlgo::pfClusterIndex_ [private]

Definition at line 110 of file PFSuperClusterAlgo.h.

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

Definition at line 112 of file PFSuperClusterAlgo.h.

Definition at line 87 of file PFSuperClusterAlgo.h.

Definition at line 95 of file PFSuperClusterAlgo.h.

Referenced by setPhiwidthSuperClusterBarrel().

Definition at line 97 of file PFSuperClusterAlgo.h.

Referenced by setPhiwidthSuperClusterEndcap().

std::vector<int> PFSuperClusterAlgo::scPFseedIndex_ [private]

Definition at line 108 of file PFSuperClusterAlgo.h.

Definition at line 121 of file PFSuperClusterAlgo.h.

std::vector<int> PFSuperClusterAlgo::seedCandidateIndex_ [private]

Definition at line 109 of file PFSuperClusterAlgo.h.

Definition at line 144 of file PFSuperClusterAlgo.h.

Definition at line 85 of file PFSuperClusterAlgo.h.

Definition at line 90 of file PFSuperClusterAlgo.h.

Referenced by setThreshPFClusterBarrel().

Definition at line 92 of file PFSuperClusterAlgo.h.

Referenced by setThreshPFClusterEndcap().

Definition at line 93 of file PFSuperClusterAlgo.h.

Referenced by setThreshPFClusterES().

Definition at line 84 of file PFSuperClusterAlgo.h.

Definition at line 89 of file PFSuperClusterAlgo.h.

Referenced by setThreshPFClusterSeedBarrel().

Definition at line 91 of file PFSuperClusterAlgo.h.

Referenced by setThreshPFClusterSeedEndcap().

Definition at line 82 of file PFSuperClusterAlgo.h.

Referenced by setVerbosityLevel().