CMS 3D CMS Logo

SimG4HcalHitJetFinder.cc
Go to the documentation of this file.
1 // File: SimG4HcalHitJetFinder.cc
3 // Description: Jet finder class for SimG4HcalValidation
8 
9 #include <algorithm>
10 #include <cmath>
11 #include <iostream>
12 
13 SimG4HcalHitJetFinder::SimG4HcalHitJetFinder(double cone) : jetcone(cone) {}
14 
15 SimG4HcalHitJetFinder::~SimG4HcalHitJetFinder() { edm::LogInfo("ValidHcal") << "SimG4HcalHitJetFinder:: Deleting"; }
16 
17 void SimG4HcalHitJetFinder::setCone(double cone) { jetcone = cone; }
18 
19 void SimG4HcalHitJetFinder::setInput(std::vector<CaloHit> *hhit) { input = *hhit; }
20 
21 std::vector<SimG4HcalHitCluster> *SimG4HcalHitJetFinder::getClusters(bool hcal_only) {
22  clusvector.erase(clusvector.begin(), clusvector.end());
23  if (input.empty()) {
24  return &clusvector;
25  }
26 
27  std::vector<CaloHit>::iterator itr;
28  for (itr = input.begin(); itr != input.end(); itr++) {
29  LogDebug("ValidHcal") << "HcalHitJetFinder::getClusters_1 - input : e " << itr->e() << " eta " << itr->eta()
30  << " phi " << itr->phi() << " subdet " << itr->det();
31  }
32 
33  sort(input.begin(), input.end()); // sort input in descending order
34 
35  for (itr = input.begin(); itr != input.end(); itr++) {
36  LogDebug("ValidHcal") << "HcalHitJetFinder::getClusters_2 - input : e " << itr->e() << " eta " << itr->eta()
37  << " phi " << itr->phi() << " subdet " << itr->det();
38  }
39 
40  std::vector<SimG4HcalHitCluster> temp; // dummy container for clusters
41 
42  // first input hit -> first cluster
43 
44  CaloHit hit;
45  SimG4HcalHitCluster cluster;
46 
47  std::vector<CaloHit>::iterator itr_hits;
48 
49  int j, first_seed = 0;
50  for (j = 0, itr_hits = input.begin(); itr_hits != input.end(); j++, itr_hits++) {
51  int h_type = itr_hits->det(); // if desired HCAL hits (only) clusterfinding
52  if (((h_type == static_cast<int>(HcalBarrel) || h_type == static_cast<int>(HcalEndcap) ||
53  h_type == static_cast<int>(HcalForward)) &&
54  hcal_only) ||
55  (!hcal_only)) {
56  cluster += input[j];
57  LogDebug("ValidHcal") << "HcalHitJetFinder:: First seed hit "
58  << "..................\n"
59  << (*itr_hits);
60  first_seed = j;
61  break;
62  }
63  }
64 
65  temp.push_back(cluster);
66 
67  std::vector<SimG4HcalHitCluster>::iterator itr_clus;
68 
69  for (j = 0, itr_hits = input.begin(); itr_hits != input.end(); j++, itr_hits++) {
70  int h_type = itr_hits->det(); // if desired HCAL hits (only) clusterfinding
71  if ((((h_type == static_cast<int>(HcalBarrel) || h_type == static_cast<int>(HcalEndcap) ||
72  h_type == static_cast<int>(HcalForward)) &&
73  hcal_only) ||
74  (!hcal_only)) &&
75  (j != first_seed)) {
76  LogDebug("ValidHcal") << "HcalHitJetFinder:: ........... Consider hit"
77  << " ..................\n"
78  << (*itr_hits);
79 
80  int incl = 0; // if the hit is included in one of clusters
81 
82  int iclus;
83  for (itr_clus = temp.begin(), iclus = 0; itr_clus != temp.end(); itr_clus++, iclus++) {
84  LogDebug("ValidHcal") << "HcalHitJetFinder::=======> Cluster " << iclus << "\n" << (*itr_clus);
85 
86  double d = rDist(&(*itr_clus), &(*itr_hits));
87  if (d < jetcone) {
88  LogDebug("ValidHcal") << "HcalHitJetFinder:: -> associated ... ";
89  temp[iclus] += *itr_hits;
90  incl = 1;
91  break;
92  }
93  }
94 
95  // to here jumps "break"
96  if (incl == 0) {
98  cl += *itr_hits;
99  temp.push_back(cl);
100  LogDebug("ValidHcal") << "HcalHitJetFinder:: ************ NEW CLUSTER"
101  << " !\n"
102  << cl;
103  }
104  }
105  }
106 
107  clusvector = temp;
108  return &clusvector;
109 }
110 
111 double SimG4HcalHitJetFinder::rDist(const SimG4HcalHitCluster *cluster, const CaloHit *hit) const {
112  double etac = cluster->eta();
113  double phic = cluster->phi();
114 
115  double etah = hit->eta();
116  double phih = hit->phi();
117 
118  return rDist(etac, phic, etah, phih);
119 }
120 
121 double SimG4HcalHitJetFinder::rDist(const double etac, const double phic, const double etah, const double phih) const {
122  double delta_eta = etac - etah;
123  double delta_phi = phic - phih;
124 
125  if (phic < phih)
126  delta_phi = phih - phic;
127  if (delta_phi > M_PI)
128  delta_phi = 2 * M_PI - delta_phi;
129 
130  double tmp = sqrt(delta_eta * delta_eta + delta_phi * delta_phi);
131 
132  LogDebug("ValidHcal") << "HcalHitJetFinder::rDist:\n"
133  << " Clus. eta, phi = " << etac << " " << phic << "\n"
134  << " hit eta, phi = " << etah << " " << phih << " rDist = " << tmp;
135 
136  return tmp;
137 }
HLT_2018_cff.delta_phi
delta_phi
Definition: HLT_2018_cff.py:10311
MessageLogger.h
SimG4HcalHitJetFinder::getClusters
std::vector< SimG4HcalHitCluster > * getClusters(bool)
Definition: SimG4HcalHitJetFinder.cc:21
edm::LogInfo
Definition: MessageLogger.h:254
SimG4HcalHitJetFinder::clusvector
std::vector< SimG4HcalHitCluster > clusvector
Definition: SimG4HcalHitJetFinder.h:27
SimG4HcalHitJetFinder::~SimG4HcalHitJetFinder
virtual ~SimG4HcalHitJetFinder()
Definition: SimG4HcalHitJetFinder.cc:15
HcalBarrel
Definition: HcalAssistant.h:33
SimG4HcalHitJetFinder.h
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
SimG4HcalHitJetFinder::SimG4HcalHitJetFinder
SimG4HcalHitJetFinder(double cone=0.5)
Definition: SimG4HcalHitJetFinder.cc:13
SimG4HcalHitCluster::eta
double eta() const
Definition: SimG4HcalHitCluster.h:18
SimG4HcalHitJetFinder::input
std::vector< CaloHit > input
Definition: SimG4HcalHitJetFinder.h:26
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SimG4HcalHitCluster::phi
double phi() const
Definition: SimG4HcalHitCluster.h:19
SimG4HcalHitJetFinder::jetcone
double jetcone
Definition: SimG4HcalHitJetFinder.h:25
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
SimG4HcalHitJetFinder::setInput
void setInput(std::vector< CaloHit > *)
Definition: SimG4HcalHitJetFinder.cc:19
SimG4HcalHitJetFinder::setCone
void setCone(double)
Definition: SimG4HcalHitJetFinder.cc:17
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
CaloHit
Definition: CaloHit.h:12
HcalSubdetector.h
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
HcalForward
Definition: HcalAssistant.h:36
SimG4HcalHitJetFinder::rDist
double rDist(const SimG4HcalHitCluster *, const CaloHit *) const
Definition: SimG4HcalHitJetFinder.cc:111
HLT_2018_cff.delta_eta
delta_eta
Definition: HLT_2018_cff.py:10310
HcalEndcap
Definition: HcalAssistant.h:34
SimG4HcalHitCluster
Definition: SimG4HcalHitCluster.h:12
ztail.d
d
Definition: ztail.py:151
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hit
Definition: SiStripHitEffFromCalibTree.cc:88