Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:28

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: SimG4HcalHitCluster.cc
0003 // Description: Cluster class in SimG4HcalValidation
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #include "Validation/HcalHits/interface/SimG4HcalHitCluster.h"
0006 
0007 #include "CLHEP/Vector/LorentzVector.h"
0008 
0009 SimG4HcalHitCluster::SimG4HcalHitCluster() : ec(0), etac(0), phic(0) {}
0010 
0011 bool SimG4HcalHitCluster::operator<(const SimG4HcalHitCluster &cluster) const {
0012   return (ec / cosh(etac) < cluster.e() / cosh(cluster.eta())) ? false : true;
0013 }
0014 
0015 SimG4HcalHitCluster &SimG4HcalHitCluster::operator+=(const CaloHit &hit) {
0016   hitsc.push_back(hit);
0017 
0018   if (ec == 0. && etac == 0. && phic == 0.) {
0019     ec = hit.e();
0020     etac = hit.eta();
0021     phic = hit.phi();
0022   } else {
0023     // cluster px,py,pz
0024     double et = ec / my_cosh(etac);
0025     double px = et * cos(phic);
0026     double py = et * sin(phic);
0027     double pz = et * my_sinh(etac);
0028 
0029     CLHEP::HepLorentzVector clusHLV(px, py, pz, ec);
0030 
0031     // hit px,py,pz
0032     double eh = hit.e();
0033     double etah = hit.eta();
0034     double phih = hit.phi();
0035     et = eh / my_cosh(etah);
0036     px = et * cos(phih);
0037     py = et * sin(phih);
0038     pz = et * my_sinh(etah);
0039 
0040     CLHEP::HepLorentzVector hitHLV(px, py, pz, eh);
0041 
0042     // clus + hit
0043     clusHLV += hitHLV;
0044 
0045     double theta = clusHLV.theta();
0046     etac = -log(tan(theta / 2.));
0047     phic = clusHLV.phi();
0048     ec = clusHLV.t();
0049   }
0050 
0051   return *this;
0052 }
0053 
0054 double SimG4HcalHitCluster::collectEcalEnergyR() {
0055   double sum = 0.;
0056   std::vector<CaloHit>::iterator itr;
0057 
0058   for (itr = hitsc.begin(); itr < hitsc.end(); itr++) {
0059     if (itr->det() == 10 || itr->det() == 11 || itr->det() == 12) {
0060       sum += itr->e();
0061     }
0062   }
0063   return sum;
0064 }
0065 
0066 std::ostream &operator<<(std::ostream &os, const SimG4HcalHitCluster &cluster) {
0067   os << " SimG4HcalHitCluster:: E " << cluster.e() << "  eta " << cluster.eta() << "  phi " << cluster.phi();
0068   return os;
0069 }