CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes

PFJetAlgorithm Class Reference

#include <PFJetAlgorithm.h>

List of all members.

Classes

class  Jet

Public Types

typedef std::map< double,
PFJetAlgorithm::Jet,
std::greater< double >
>::iterator 
IJ
typedef std::map< double, int,
std::greater< double >
>::const_iterator 
IV

Public Member Functions

void CleanUp ()
void Clear ()
const std::vector
< PFJetAlgorithm::Jet > & 
FindJets (const std::vector< TLorentzVector > *vecs)
double GetConeAngle () const
const std::vector
< PFJetAlgorithm::Jet > & 
GetJets () const
void MergeJets (std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &etjets)
 PFJetAlgorithm (double cone, double et, double conemerge)
 PFJetAlgorithm ()
void SetConeAngle (double coneAngle)
void SetConeMerge (double coneMerge)
void SetSeedEt (double et)
void Update ()
virtual ~PFJetAlgorithm ()

Static Public Member Functions

static double DeltaR (double eta1, double phi1, double eta2, double phi2)

Private Attributes

const std::vector
< TLorentzVector > * 
fAllVecs
std::vector< int > fAssignedVecs
double fConeAngle
double fConeMerge
std::map< double, int,
std::greater< double > > 
fEtOrderedSeeds
std::vector< PFJetAlgorithm::JetfJets
double fSeedEt

Detailed Description

Definition at line 11 of file PFJetAlgorithm.h.


Member Typedef Documentation

typedef std::map< double, PFJetAlgorithm::Jet, std::greater<double> >::iterator PFJetAlgorithm::IJ

Definition at line 66 of file PFJetAlgorithm.h.

typedef std::map<double, int, std::greater<double> >::const_iterator PFJetAlgorithm::IV

Definition at line 67 of file PFJetAlgorithm.h.


Constructor & Destructor Documentation

PFJetAlgorithm::PFJetAlgorithm ( ) [inline]

Definition at line 69 of file PFJetAlgorithm.h.

: fConeAngle(0.5), fSeedEt(2),  fConeMerge(0.5) {}
PFJetAlgorithm::PFJetAlgorithm ( double  cone,
double  et,
double  conemerge 
) [inline]

Definition at line 71 of file PFJetAlgorithm.h.

                                                           : 
    fConeAngle(cone), 
    fSeedEt(et),
    fConeMerge(conemerge)
    {}
virtual PFJetAlgorithm::~PFJetAlgorithm ( ) [inline, virtual]

Definition at line 77 of file PFJetAlgorithm.h.

{}

Member Function Documentation

void PFJetAlgorithm::CleanUp ( )

Definition at line 125 of file BlockFormatter.cc.

References gather_cfg::cout, FEDRawData::data(), L1Comparator_cfi::FEDid, spr::find(), FEDNumbering::MINECALFEDID, lumiPlot::rawdata, FEDRawData::resize(), and FEDRawData::size().

                                                                    {


 for (int id=0; id < 36 + 18; id++) {
        if ( (! doBarrel_) && (id >= 9 && id <= 44)) continue;
        if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue;

        int FEDid = FEDNumbering::MINECALFEDID + id +1;
        FEDRawData& rawdata = productRawData -> FEDData(FEDid);

        // ---- if raw need not be made for a given fed, set its size to empty and return 
        if ( find( (*plistDCCId_).begin(), (*plistDCCId_).end(), (id+1) ) == (*plistDCCId_).end() )
        {
            rawdata.resize( 0 );
            continue;
        }

        // ---- Add the trailer word
        int lastline = rawdata.size();
        rawdata.resize( lastline + 8);
        unsigned char * pData = rawdata.data(); 
        int event_length = (lastline + 8) / 8;   // in 64 bits words

        pData[lastline+7] = 0xa0;
        // pData[lastline+4] = event_length & 0xFFFFFF;
        pData[lastline+4] = event_length & 0xFF;
        pData[lastline+5] = (event_length >> 8) & 0xFF;
        pData[lastline+6] = (event_length >> 16) & 0xFF;
        int event_status = 0;
        pData[lastline+1] = event_status & 0x0F;
        int tts = 0 <<4;
        pData[lastline] = tts & 0xF0;

        // ---- Write the event length in the DCC header
        // pData[8] = event_length & 0xFFFFFF;
        pData[8] = event_length & 0xFF;
        pData[9] = (event_length >> 8) & 0xFF;
        pData[10] = (event_length >> 16) & 0xFF;
        
        // cout << " in BlockFormatter::CleanUp. FEDid = " << FEDid << " event_length*8 " << dec << event_length*8 << endl;

        map<int, map<int,int> >::iterator fen = FEDorder -> find(FEDid);

        bool FED_has_data = true;
        if (fen == FEDorder->end()) FED_has_data = false;
        if (debug_ && (! FED_has_data)) cout << " FEDid is not in FEDorder ! " << endl;
        if ( ! FED_has_data) {
                int ch_status = 7;
                for (int iFE=1; iFE <= 68; iFE++) {
                        int irow = (iFE-1) / 14;
                        int kval = ( (iFE-1) % 14) / 2;
                        if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
                        else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);
                }
        }

        if (FED_has_data) {
        map<int, int>& FEorder = (*fen).second;

        for (int iFE=1; iFE <= 68; iFE++) {
          map<int,int>::iterator fe = FEorder.find(iFE);
          int ch_status = 0;
          if (fe == FEorder.end())      // FE not present due to SRP, update CH_status
                ch_status = 7;          // CH_SUPPRESS
          int irow = (iFE-1) / 14;
          int kval = ( (iFE-1) % 14) / 2;
          if (iFE % 2 ==1) pData[32 + 8*irow + kval] |= ch_status & 0xFF;
          else pData[32 + 8*irow + kval] |= ((ch_status <<4) & 0xFF);

        }
        }
        
 }
}
void PFJetAlgorithm::Clear ( ) [inline]

Definition at line 92 of file PFJetAlgorithm.h.

References fAssignedVecs, fEtOrderedSeeds, and fJets.

Referenced by PFRootEventManager::tauBenchmark().

               { 
    fJets.clear(); 
    fAssignedVecs.clear(); 
    fEtOrderedSeeds.clear();
  } 
double PFJetAlgorithm::DeltaR ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
) [static]

Definition at line 78 of file PFJetAlgorithm.cc.

References Phi_mpi_pi(), and mathSSE::sqrt().

                                                                                {
  double deta = eta1 - eta2;
  double dphi = TVector2::Phi_mpi_pi(phi1 - phi2);
  return sqrt(deta*deta + dphi*dphi);
}
const vector< PFJetAlgorithm::Jet > & PFJetAlgorithm::FindJets ( const std::vector< TLorentzVector > *  vecs)

Definition at line 18 of file PFJetAlgorithm.cc.

References PFJetAlgorithm::Jet::Add(), reco::tau::disc::Eta(), PFJetAlgorithm::Jet::GetMomentum(), i, and colinearityKinematic::Phi.

Referenced by PFRootEventManager::tauBenchmark().

                                                            {


  fAllVecs = vecs;

  fAssignedVecs.clear(); 
  fAssignedVecs.reserve( vecs->size() );
  
  fEtOrderedSeeds.clear();
  
  for(unsigned i = 0; i<vecs->size(); i++) {
    // cout<<"i = "<<i<<endl;
    double et = (*vecs)[i].Et();
    
    int assigned = -1;
    if( et >= fSeedEt) {
      fJets.push_back( Jet(i, fAllVecs) );
      fEtOrderedSeeds.insert( make_pair(et, fJets.size()-1) );
      assigned = i;
    }
    fAssignedVecs.push_back(assigned);
  }

  
  // loop on seeds 
  for(IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
    
    Jet& currentjet = fJets[iv->second];

    double etaseed = currentjet.GetMomentum().Eta();
    double phiseed = currentjet.GetMomentum().Phi();
    
    
    // adding particles
    for(unsigned i = 0; i<fAllVecs->size(); i++) {
      
      if( fAssignedVecs[i] > -1 ) continue;

      double dr = DeltaR(etaseed, phiseed, 
                         (*fAllVecs)[i].Eta(), (*fAllVecs)[i].Phi());
      // cout<<"\t\tparticle "<<i<<" "<<dr<<" "<<(*fAllVecs)[i].Et()<<endl; 
                         
      if( dr < fConeAngle) {
        // cout<<"\t\tadding"<<endl;
        currentjet.Add(i);
        fAssignedVecs[i] = iv->second;
      }
    }
    
    // cout<<"\t seed processed"<<endl;
  }
  // cout<<"end find jets"<<endl;

  Update();
  CleanUp();

  return fJets;
}
double PFJetAlgorithm::GetConeAngle ( ) const [inline]

Definition at line 103 of file PFJetAlgorithm.h.

References fConeAngle.

{ return fConeAngle;}
const std::vector< PFJetAlgorithm::Jet >& PFJetAlgorithm::GetJets ( ) const [inline]

Definition at line 104 of file PFJetAlgorithm.h.

References fJets.

{ return fJets;}
void PFJetAlgorithm::MergeJets ( std::map< double, PFJetAlgorithm::Jet, std::greater< double > > &  etjets)

Definition at line 257 of file PFJetAlgorithm.cc.

References findQualityFiles::jj.

                                                                                        {

  // look for smallest distance between 2 jets : 
  
  IJ j1 = etjets.end();
  IJ j2 = etjets.end();
  double smallestdistance = 999999;

  for(IJ ij = etjets.begin(); ij != etjets.end(); ij++) {
    
    const TLorentzVector& mom1 = ij->second.GetMomentum();
    
    double eta1 = mom1.Eta();
    double phi1 = mom1.Phi();
    
    for(IJ jj = etjets.begin(); jj != etjets.end(); jj++) {
   
      if( jj == ij ) continue;  
      
      const TLorentzVector& mom2 = jj->second.GetMomentum();
      
      double eta2 = mom2.Eta();
      double phi2 = mom2.Phi();

      double dr = DeltaR(eta1, phi1, eta2, phi2);
      
      if(dr<smallestdistance) {
        smallestdistance = dr; 
        j1 = ij;
        j2 = jj;
      }
    }
  } 

  //   cout<<"smallest distance is between : "<<endl;
  //   cout<<j1->second<<endl;
  //   cout<<j2->second<<endl;

  if( smallestdistance < fConeMerge ) {
    j1->second += j2->second;
    etjets.erase(j2);
    
    MergeJets( etjets ); 
  }
}
void PFJetAlgorithm::SetConeAngle ( double  coneAngle) [inline]

Definition at line 83 of file PFJetAlgorithm.h.

References fConeAngle.

Referenced by PFRootEventManager::readOptions().

{fConeAngle = coneAngle;}
void PFJetAlgorithm::SetConeMerge ( double  coneMerge) [inline]

Definition at line 85 of file PFJetAlgorithm.h.

References fConeMerge.

Referenced by PFRootEventManager::readOptions().

{fConeMerge = coneMerge;}
void PFJetAlgorithm::SetSeedEt ( double  et) [inline]

Definition at line 84 of file PFJetAlgorithm.h.

References fSeedEt.

Referenced by PFRootEventManager::readOptions().

{fSeedEt = et;}
void PFJetAlgorithm::Update ( )

Definition at line 85 of file PFJetAlgorithm.cc.

References PFJetAlgorithm::Jet::Add(), PFJetAlgorithm::Jet::Clear(), reco::tau::disc::Eta(), PFJetAlgorithm::Jet::GetMomentum(), i, and colinearityKinematic::Phi.

                            {
  // use existing jets as seeds 
  //   cout<<"clearing seeds"<<endl;
  fEtOrderedSeeds.clear();
  for(unsigned ij = 0; ij<fJets.size(); ij++ ) {
    double et = fJets[ij].GetMomentum().Et();
    if(et >= fSeedEt)
      fEtOrderedSeeds.insert( make_pair(et, ij) );
  }

  // loop on seeds and add particles 
  //   cout<<"clearing assigned"<<endl;
  for(unsigned i = 0; i<fAssignedVecs.size(); i++) {
    fAssignedVecs[i] = -1;
  }

  //   cout<<"loop on seeds"<<endl;
  bool needupdate = false;
  for(IV iv = fEtOrderedSeeds.begin(); iv != fEtOrderedSeeds.end(); iv++ ) {
    
    Jet& currentjet = fJets[iv->second];

    TLorentzVector seedmom = currentjet.GetMomentum();

    double etaseed = seedmom.Eta();
    double phiseed = seedmom.Phi();
    //     cout<<"SEED\t"<<etaseed<<" "<<phiseed<<endl;

    currentjet.Clear();

    // adding particles
    for(unsigned i = 0; i<fAllVecs->size(); i++) {
      
      if( fAssignedVecs[i] > -1 ) continue;

      double dr = DeltaR(etaseed, phiseed, 
                         (*fAllVecs)[i].Eta(), (*fAllVecs)[i].Phi());
      // cout<<"\t\tparticle "<<i<<" "<<dr<<" "<<(*fAllVecs)[i].Et()<<endl; 
                         
      if( dr < fConeAngle) {
        // cout<<"\t\tadding"<<endl;
        currentjet.Add(i);
        fAssignedVecs[i] = iv->second;
      }
    }
    
    TLorentzVector deltav = currentjet.GetMomentum();
    deltav -= seedmom;
    if(deltav.M() > 0.001) needupdate = true;
  }
  
  if(needupdate) Update();
}

Member Data Documentation

const std::vector<TLorentzVector>* PFJetAlgorithm::fAllVecs [private]

Definition at line 52 of file PFJetAlgorithm.h.

std::vector< int > PFJetAlgorithm::fAssignedVecs [private]

Definition at line 54 of file PFJetAlgorithm.h.

Referenced by Clear().

double PFJetAlgorithm::fConeAngle [private]

Definition at line 58 of file PFJetAlgorithm.h.

Referenced by GetConeAngle(), and SetConeAngle().

double PFJetAlgorithm::fConeMerge [private]

Definition at line 60 of file PFJetAlgorithm.h.

Referenced by SetConeMerge().

std::map<double, int, std::greater<double> > PFJetAlgorithm::fEtOrderedSeeds [private]

Definition at line 55 of file PFJetAlgorithm.h.

Referenced by Clear().

std::vector< PFJetAlgorithm::Jet > PFJetAlgorithm::fJets [private]

Definition at line 53 of file PFJetAlgorithm.h.

Referenced by Clear(), and GetJets().

double PFJetAlgorithm::fSeedEt [private]

Definition at line 59 of file PFJetAlgorithm.h.

Referenced by SetSeedEt().