CMS 3D CMS Logo

Public Member Functions | Private Attributes

SimG4HcalHitJetFinder Class Reference

#include <SimG4HcalHitJetFinder.h>

List of all members.

Public Member Functions

std::vector
< SimG4HcalHitCluster > * 
getClusters (bool)
double rDist (const double, const double, const double, const double) const
double rDist (const SimG4HcalHitCluster *, const CaloHit *) const
void setCone (double)
void setInput (std::vector< CaloHit > *)
 SimG4HcalHitJetFinder (double cone=0.5)
virtual ~SimG4HcalHitJetFinder ()

Private Attributes

std::vector< SimG4HcalHitClusterclusvector
std::vector< CaloHitinput
double jetcone

Detailed Description

Definition at line 13 of file SimG4HcalHitJetFinder.h.


Constructor & Destructor Documentation

SimG4HcalHitJetFinder::SimG4HcalHitJetFinder ( double  cone = 0.5)

Definition at line 13 of file SimG4HcalHitJetFinder.cc.

: jetcone(cone) {}
SimG4HcalHitJetFinder::~SimG4HcalHitJetFinder ( ) [virtual]

Definition at line 15 of file SimG4HcalHitJetFinder.cc.

                                              {
  edm::LogInfo("ValidHcal") << "SimG4HcalHitJetFinder:: Deleting";
}

Member Function Documentation

std::vector< SimG4HcalHitCluster > * SimG4HcalHitJetFinder::getClusters ( bool  hcal_only)

Definition at line 27 of file SimG4HcalHitJetFinder.cc.

References clusvector, HcalBarrel, HcalEndcap, HcalForward, input, j, jetcone, LogDebug, rDist(), python::multivaluedict::sort(), and cond::rpcobtemp::temp.

Referenced by SimG4HcalValidation::jetAnalysis().

                                                                                {
  clusvector.erase(clusvector.begin(),clusvector.end()); 
  if (input.size() == 0) { 
    return &clusvector;
  }

  std::vector<CaloHit>::iterator itr;
  for (itr = input.begin(); itr != input.end(); itr++) {
    LogDebug("ValidHcal") << "HcalHitJetFinder::getClusters_1 - input :  e " 
                          << itr->e() << "  eta " << itr->eta() << "  phi " 
                          << itr->phi() << "  subdet " << itr->det();
  }

  sort(input.begin(),input.end()); // sort input in descending order
 
  for (itr = input.begin(); itr != input.end(); itr++) {
    LogDebug("ValidHcal") << "HcalHitJetFinder::getClusters_2 - input :  e " 
                          << itr->e() << "  eta " << itr->eta() << "  phi " 
                          << itr->phi() << "  subdet " << itr->det();
  }

  std::vector<SimG4HcalHitCluster> temp;   // dummy container for clusters

  //  first input hit -> first cluster

  CaloHit             hit;
  SimG4HcalHitCluster cluster;

  std::vector<CaloHit>::iterator itr_hits;

  int j, first_seed = 0;
  for (j=0, itr_hits = input.begin(); itr_hits != input.end();
       j++, itr_hits++) {
    int h_type = itr_hits->det(); //if desired HCAL hits (only) clusterfinding
    if (((h_type == static_cast<int>(HcalBarrel) ||
          h_type == static_cast<int>(HcalEndcap) ||
          h_type == static_cast<int>(HcalForward)) && hcal_only) || 
        (!hcal_only)) {
      cluster += input[j];
      LogDebug("ValidHcal") << "HcalHitJetFinder:: First seed hit "
                            << "..................\n" << (*itr_hits);
      first_seed = j;
      break;
    }
  }
  
  temp.push_back(cluster);
  
  std::vector<SimG4HcalHitCluster>::iterator itr_clus;

  for (j=0, itr_hits = input.begin(); itr_hits != input.end();
       j++, itr_hits++) {
    int h_type = itr_hits->det(); //if desired HCAL hits (only) clusterfinding
    if ((((h_type == static_cast<int>(HcalBarrel) ||
           h_type == static_cast<int>(HcalEndcap) ||
           h_type == static_cast<int>(HcalForward)) && hcal_only) || 
         (!hcal_only)) && (j != first_seed)) {
      LogDebug("ValidHcal") << "HcalHitJetFinder:: ........... Consider hit"
                            << " ..................\n" << (*itr_hits);
      
      int incl = 0; // if the hit is included in one of clusters
      
      int iclus;  
      for (itr_clus = temp.begin(), iclus = 0; itr_clus != temp.end();
           itr_clus++, iclus++) { 
        
        LogDebug("ValidHcal") << "HcalHitJetFinder::=======> Cluster " 
                              << iclus << "\n" << (*itr_clus);
        
        double d = rDist(&(*itr_clus), &(*itr_hits));
        if (d < jetcone) {
          LogDebug("ValidHcal") << "HcalHitJetFinder:: -> associated ... ";
          temp[iclus] += *itr_hits;
          incl = 1;
          break;  
        }
      }
      
      // to here jumps "break"
      if (incl == 0) {
        SimG4HcalHitCluster cl;
        cl += *itr_hits;
        temp.push_back(cl);
        LogDebug("ValidHcal") << "HcalHitJetFinder:: ************ NEW CLUSTER"
                              << " !\n" << cl;
      }
    }
  }

  clusvector = temp;
  return &clusvector;
}
double SimG4HcalHitJetFinder::rDist ( const double  etac,
const double  phic,
const double  etah,
const double  phih 
) const

Definition at line 133 of file SimG4HcalHitJetFinder.cc.

References kinem::delta_eta(), kinem::delta_phi(), LogDebug, M_PI, mathSSE::sqrt(), and tmp.

                                                                              {

  double delta_eta = etac - etah;
  double delta_phi = phic - phih;

  if (phic < phih)      delta_phi = phih - phic;
  if (delta_phi > M_PI) delta_phi = 2*M_PI - delta_phi;

  double tmp = sqrt(delta_eta * delta_eta + delta_phi * delta_phi);

  LogDebug("ValidHcal") << "HcalHitJetFinder::rDist:\n"
                        << " Clus. eta, phi = " << etac << " " << phic << "\n"
                        << " hit   eta, phi = " << etah << " " << phih 
                        << " rDist = " << tmp;

  return tmp;
}
double SimG4HcalHitJetFinder::rDist ( const SimG4HcalHitCluster cluster,
const CaloHit hit 
) const

Definition at line 120 of file SimG4HcalHitJetFinder.cc.

References SimG4HcalHitCluster::eta(), CaloHit::eta(), CaloHit::phi(), and SimG4HcalHitCluster::phi().

Referenced by SimG4HcalValidation::collectEnergyRdir(), getClusters(), and SimG4HcalValidation::jetAnalysis().

                                                              {

  double etac = cluster->eta();
  double phic = cluster->phi();
  
  double etah = hit->eta();
  double phih = hit->phi();

  return rDist(etac, phic, etah, phih);
}
void SimG4HcalHitJetFinder::setCone ( double  cone)

Definition at line 19 of file SimG4HcalHitJetFinder.cc.

References jetcone.

                                               { 
  jetcone = cone;
}   
void SimG4HcalHitJetFinder::setInput ( std::vector< CaloHit > *  hhit)

Definition at line 23 of file SimG4HcalHitJetFinder.cc.

References input.

Referenced by SimG4HcalValidation::jetAnalysis().

                                                             { 
  input   = * hhit;
}

Member Data Documentation

Definition at line 30 of file SimG4HcalHitJetFinder.h.

Referenced by getClusters().

std::vector<CaloHit> SimG4HcalHitJetFinder::input [private]

Definition at line 29 of file SimG4HcalHitJetFinder.h.

Referenced by getClusters(), and setInput().

Definition at line 28 of file SimG4HcalHitJetFinder.h.

Referenced by getClusters(), and setCone().