CMS 3D CMS Logo

NominalEfficiencyThresholds.cc
Go to the documentation of this file.
2 
3 #include <cmath>
4 #include <iostream>
5 #include <cstring>
6 #include <cstdlib>
7 #include <cstdio>
8 using namespace muonisolation;
9 using namespace std;
10 
12  float BaseEtaBin = 0.087;
13  theBounds[0] = 0.0;
14  for (int it = 1; it <= 20; it++)
15  theBounds[it] = it * BaseEtaBin;
16  theBounds[21] = 1.83;
17  theBounds[22] = 1.93;
18  theBounds[23] = 2.043;
19  theBounds[24] = 2.172;
20  theBounds[25] = 2.322;
21  theBounds[26] = 2.5;
22  theBounds[27] = 2.65;
23  theBounds[28] = 3.0;
24  theBounds[29] = 3.13;
25  theBounds[30] = 3.305;
26  theBounds[31] = 3.48;
27  theBounds[32] = 3.655;
28 }
29 
31  int number = 0;
32  for (int num = 1; num <= NumberOfTowers; num++) {
33  if (fabs(eta) > theBounds[num - 1]) {
34  number = num;
35  if (eta < 0)
36  number = -num;
37  }
38  }
39  if (fabs(eta) >= theBounds[NumberOfTowers - 1])
40  number = 0;
41  return number;
42 }
43 
44 vector<double> NominalEfficiencyThresholds::bins() const {
45  vector<double> result;
46  for (unsigned int i = 1; i <= EtaBounds::NumberOfTowers; i++)
47  result.push_back(etabounds(i));
48  return result;
49 }
50 
52  return e1.eff <= e2.eff_previous;
53 }
54 
56  int itow1 = abs(etabounds.towerFromEta(l1.eta));
57  int itow2 = abs(etabounds.towerFromEta(l2.eta));
58  if (itow1 < itow2)
59  return true;
60  if (itow1 == itow2 && l1.cone < l2.cone)
61  return true;
62  return false;
63 }
64 
66  FILE *INFILE;
67  char buffer[81];
68  char tag[5];
69  if ((INFILE = fopen(infile.c_str(), "r")) == nullptr) {
70  cout << "Cannot open input file " << infile << endl;
71  return;
72  }
73  ThresholdLocation location;
74  EfficiencyBin eb;
75  eb.eff = 0;
76  float thr_val;
77  while (fgets(buffer, 80, INFILE)) {
78  sscanf(buffer, "%4s", tag);
79  if (strcmp(tag, "ver:") == 0) {
80  cout << " NominalEfficiencyThresholds: " << infile << " comment: " << buffer << endl;
81  thresholds.clear();
82  }
83  if (strcmp(tag, "loc:") == 0) {
84  sscanf(buffer, "%*s %f %*s %d", &location.eta, &location.cone);
85  eb.eff = 0.;
86  }
87  if (strcmp(tag, "thr:") == 0) {
88  eb.eff_previous = eb.eff;
89  sscanf(buffer, "%*s %f %f", &eb.eff, &thr_val);
90  add(location, ThresholdConstituent(eb, thr_val));
91  }
92  }
93  fclose(INFILE);
94  cout << "... done" << endl;
95  //dump();
96 }
97 
99  MapType::iterator ploc = thresholds.find(location);
100  if (ploc == thresholds.end()) {
102  mt.insert(threshold);
104  } else {
105  // cout << "insert element ("<<threshold.first.eff<<","
106  // <<threshold.first.eff_previous<<") to map "<<endl;
107  (*ploc).second.insert(threshold);
108  // cout << "new size is:"<< (*ploc).second.size() <<endl;
109  }
110 }
111 
113  MapType::iterator ploc;
114  for (ploc = thresholds.begin(); ploc != thresholds.end(); ploc++) {
115  cout << "eta: " << (*ploc).first.eta << " icone: " << (*ploc).first.cone << endl;
116  ThresholdConstituents::iterator it;
117  for (it = (*ploc).second.begin(); it != (*ploc).second.end(); it++) {
118  cout << " eff: " << (*it).first.eff << " eff_previous: " << (*it).first.eff_previous
119  << " cut value: " << (*it).second << endl;
120  }
121  }
122 }
123 
125  MapType::const_iterator ploc = thresholds.find(location);
126  if (ploc == thresholds.end()) {
127  cout << "NominalEfficiencyThresholds: Problem:can't find location in the map :( " << location.eta << " "
128  << location.cone << " " << eff_thr << endl;
129  return -1;
130  }
131 
132  const float epsilon = 1.e-6;
133  EfficiencyBin eb = {eff_thr, eff_thr - epsilon};
134  ThresholdConstituents::const_iterator it = (*ploc).second.find(eb);
135  if (it == (*ploc).second.end()) {
136  cout << "NominalEfficiencyThresholds: Problem:can't find threshold in the map :(" << endl;
137  return -1;
138  }
139 
140  return (*it).second;
141 }
muonisolation::NominalEfficiencyThresholds::dump
void dump()
Definition: NominalEfficiencyThresholds.cc:112
muonisolation::NominalEfficiencyThresholds::EfficiencyBin
compare to efficiencies
Definition: NominalEfficiencyThresholds.h:29
mps_fire.i
i
Definition: mps_fire.py:428
particleFlowZeroSuppressionECAL_cff.thresholds
thresholds
Definition: particleFlowZeroSuppressionECAL_cff.py:31
gather_cfg.cout
cout
Definition: gather_cfg.py:144
muonisolation::NominalEfficiencyThresholds::NominalEfficiencyThresholds
NominalEfficiencyThresholds()
Definition: NominalEfficiencyThresholds.h:12
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PVValHelper::eta
Definition: PVValidationHelpers.h:70
muonisolation::NominalEfficiencyThresholds::add
void add(ThresholdLocation location, ThresholdConstituent threshold)
Definition: NominalEfficiencyThresholds.cc:98
muonisolation::NominalEfficiencyThresholds::EtaBounds::towerFromEta
int towerFromEta(double eta) const
Definition: NominalEfficiencyThresholds.cc:30
muonisolation::NominalEfficiencyThresholds::EtaBounds::EtaBounds
EtaBounds()
Definition: NominalEfficiencyThresholds.cc:11
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
muonisolation::NominalEfficiencyThresholds::locless::operator()
bool operator()(const ThresholdLocation &l1, const ThresholdLocation &l2) const
Definition: NominalEfficiencyThresholds.cc:55
muonisolation::NominalEfficiencyThresholds::ThresholdConstituent
std::pair< EfficiencyBin, float > ThresholdConstituent
Definition: NominalEfficiencyThresholds.h:52
muonisolation::NominalEfficiencyThresholds::ThresholdConstituents
std::map< EfficiencyBin, float, EfficiencyBin > ThresholdConstituents
Definition: NominalEfficiencyThresholds.h:53
muonisolation::NominalEfficiencyThresholds::thresholdValueForEfficiency
float thresholdValueForEfficiency(ThresholdLocation location, float eff_thr) const
Definition: NominalEfficiencyThresholds.cc:124
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
muonisolation
Definition: CandViewExtractor.h:16
muonisolation::NominalEfficiencyThresholds::EfficiencyBin::eff_previous
float eff_previous
Definition: NominalEfficiencyThresholds.h:31
muonisolation::NominalEfficiencyThresholds::ThresholdLocation::eta
float eta
Definition: NominalEfficiencyThresholds.h:18
std
Definition: JetResolutionObject.h:76
muonisolation::NominalEfficiencyThresholds::bins
std::vector< double > bins() const
Definition: NominalEfficiencyThresholds.cc:44
NominalEfficiencyThresholds.h
muonisolation::NominalEfficiencyThresholds::EfficiencyBin::operator()
bool operator()(const EfficiencyBin &e1, const EfficiencyBin &e2) const
Definition: NominalEfficiencyThresholds.cc:51
TtSemiLepEvtBuilder_cfi.mt
mt
Definition: TtSemiLepEvtBuilder_cfi.py:47
groupFilesInBlocks.INFILE
INFILE
Definition: groupFilesInBlocks.py:41
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:350
EcalCondDBWriter_cfi.location
location
Definition: EcalCondDBWriter_cfi.py:63
muonisolation::NominalEfficiencyThresholds::ThresholdLocation::cone
int cone
Definition: NominalEfficiencyThresholds.h:19
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
muonisolation::NominalEfficiencyThresholds::ThresholdLocation
threshold location
Definition: NominalEfficiencyThresholds.h:17