CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Validation/HcalHits/src/SimG4HcalHitCluster.cc

Go to the documentation of this file.
00001 
00002 // File: SimG4HcalHitCluster.cc
00003 // Description: Cluster class in SimG4HcalValidation
00005 #include "Validation/HcalHits/interface/SimG4HcalHitCluster.h"
00006 
00007 #include "CLHEP/Vector/LorentzVector.h"
00008 
00009 SimG4HcalHitCluster::SimG4HcalHitCluster(): ec(0), etac(0), phic(0) {}
00010 
00011 SimG4HcalHitCluster::~SimG4HcalHitCluster() {}
00012 
00013 bool SimG4HcalHitCluster::operator<(const SimG4HcalHitCluster& cluster) const {
00014   return (ec/cosh(etac) < cluster.e()/cosh(cluster.eta())) ? false : true ;
00015 }
00016 
00017 SimG4HcalHitCluster& SimG4HcalHitCluster::operator+=(const CaloHit& hit) {
00018 
00019   hitsc.push_back(hit);
00020  
00021   if (ec == 0. && etac == 0. && phic == 0.) {
00022     ec   = hit.e();
00023     etac = hit.eta();
00024     phic = hit.phi();
00025   } else {   
00026     // cluster px,py,pz
00027     double et = ec / my_cosh(etac);
00028     double px = et * cos(phic);
00029     double py = et * sin(phic);
00030     double pz = et * my_sinh(etac); 
00031 
00032     CLHEP::HepLorentzVector clusHLV(px,py,pz,ec);
00033       
00034     // hit px,py,pz
00035     double eh   = hit.e();
00036     double etah = hit.eta();
00037     double phih = hit.phi();
00038     et = eh / my_cosh(etah);
00039     px = et * cos(phih);
00040     py = et * sin(phih);
00041     pz = et * my_sinh(etah); 
00042       
00043     CLHEP::HepLorentzVector hitHLV(px,py,pz,eh);
00044       
00045     // clus + hit
00046     clusHLV += hitHLV;
00047       
00048     double theta  = clusHLV.theta();
00049     etac = -log(tan(theta/2.));
00050     phic = clusHLV.phi();
00051     ec   = clusHLV.t();
00052   }
00053 
00054   return *this;
00055 }
00056 
00057 double SimG4HcalHitCluster::collectEcalEnergyR() {
00058 
00059   double sum = 0.;
00060   std::vector<CaloHit>::iterator itr;
00061 
00062   for (itr = hitsc.begin(); itr < hitsc.end(); itr++) {
00063     if (itr->det() == 10 || itr->det() == 11 || itr->det() == 12) {
00064       sum += itr->e(); 
00065     }    
00066   }
00067   return sum;
00068 }
00069 
00070 std::ostream& operator<<(std::ostream& os, const SimG4HcalHitCluster& cluster){
00071   os << " SimG4HcalHitCluster:: E " << cluster.e() << "  eta " << cluster.eta()
00072      << "  phi " << cluster.phi();
00073   return os;
00074 }