CMS 3D CMS Logo

EndcapPiZeroDiscriminatorAlgo.cc
Go to the documentation of this file.
1 
5 
8 #include <fstream>
9 #include <iostream>
10 
11 using namespace std;
12 
13 namespace {
14  constexpr int Nfiles_EE = 5;
15 }
16 
17 EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo(double stripEnergyCut, int nStripCut, const string& path)
18  : preshStripEnergyCut_(stripEnergyCut), preshSeededNstr_(nStripCut) {
19  // Read all Weight files
20  constexpr std::array<char const*, Nfiles_EE> file_pt{{"20", "30", "40", "50", "60"}};
21  constexpr std::array<char const*, 5> file_barrel_pt{{"20", "30", "40", "50", "60"}};
22 
23  for (auto ptName : file_pt) {
24  string nn_paterns_file = "endcapPiZeroDiscriminatorWeights_et";
25  nn_paterns_file += ptName;
26  nn_paterns_file += ".wts";
27  edm::FileInPath WFile(path + nn_paterns_file);
28  readWeightFile(WFile.fullPath().c_str(), EE_Layers, EE_Indim, EE_Hidden, EE_Outdim); // read the weights' file
29  }
30 
31  for (auto ptName : file_barrel_pt) {
32  string nn_paterns_file = "barrelPiZeroDiscriminatorWeights_et";
33  nn_paterns_file += ptName;
34  nn_paterns_file += ".wts";
35  edm::FileInPath WFile(path + nn_paterns_file);
36  readWeightFile(WFile.fullPath().c_str(), EB_Layers, EB_Indim, EB_Hidden, EB_Outdim); // read the weights' file
37  }
38 }
39 
41  RecHitsMap* rechits_map,
42  CaloSubdetectorTopology* topology_p) {
43  vector<float> vout_stripE;
44 
45  // skip if rechits_map contains no hits
46  if (rechits_map->empty()) {
47  edm::LogWarning("EndcapPiZeroDiscriminatorAlgo") << "RecHitsMap has size 0.";
48  return vout_stripE;
49  }
50 
51  vout_stripE.clear();
52 
53  vector<ESDetId> road_2d;
54  road_2d.clear();
55 
56  int plane = strip.plane();
57 
58  LogTrace("EcalClusters")
59  << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters"
60  << "n"
61  << "findPreshVectors: Preshower is intersected at strip " << strip.strip() << ", at plane " << plane;
62 
63  if (strip == ESDetId(0)) { //works in case of no intersected strip found
64  for (int i = 0; i < 11; i++) {
65  vout_stripE.push_back(-100.);
66  }
67  }
68 
69  // Add to the road the central strip
70  road_2d.push_back(strip);
71 
72  //Make a navigator, and set it to the strip cell.
74  navigator.setHome(strip);
75  //search for neighbours in the central road
76  findPi0Road(strip, navigator, plane, road_2d);
77 
78  LogTrace("EcalClusters")
79  << "EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: "
80  << road_2d.size();
81 
82  // Find the energy of each strip
83  RecHitsMap::iterator final_strip = rechits_map->end();
84  // very dangerous, added a protection on the rechits_map->size()
85  // at the beginning of the method
86  final_strip--;
87  ESDetId last_stripID = final_strip->first;
88 
89  vector<ESDetId>::iterator itID;
90  for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
91  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID;
92 
93  float E = 0.;
94  RecHitsMap::iterator strip_it = rechits_map->find(*itID);
95  if (goodPi0Strip(strip_it, last_stripID)) { // continue if strip not found in rechit_map
96  E = strip_it->second.energy();
97  }
98  vout_stripE.push_back(E);
99  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E;
100  }
101 
102  // ***ML beg***
103  // vector of size=11, content of vout_stripE is copied into vout_ElevenStrips_Energy
104  // to avoid problem in case number of strips is less than 11
105  vector<float> vout_ElevenStrips_Energy;
106  vout_ElevenStrips_Energy.reserve(11);
107  for (int i = 0; i < 11; i++) {
108  vout_ElevenStrips_Energy.push_back(0.);
109  }
110 
111  for (unsigned int i = 0; i < vout_stripE.size(); i++) {
112  vout_ElevenStrips_Energy[i] = vout_stripE.at(i);
113  }
114 
115  //return vout_stripE;
116  return vout_ElevenStrips_Energy;
117  // ***ML end***
118 }
119 
120 // returns true if the candidate strip fulfills the requirements to be added to the cluster:
121 bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID) {
122  RecHitsMap::iterator candidate_tmp = candidate_it;
123  candidate_tmp--;
124 
125  // crystal should not be included...
126  if (candidate_tmp->first == lastID) // ...if it corresponds to a hit
127  {
128  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map ";
129  return false;
130  } else if (candidate_it->second.energy() <= preshStripEnergyCut_) // ...if it has a negative or zero energy
131  {
132  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy "
133  << candidate_it->second.energy() << " is below threshold ";
134  return false;
135  }
136 
137  return true;
138 }
139 
140 // find strips in the road of size +/- preshSeededNstr_ from the central strip
142  EcalPreshowerNavigator& theESNav,
143  int plane,
144  vector<ESDetId>& vout) {
145  if (strip == ESDetId(0))
146  return;
147  ESDetId next;
148  theESNav.setHome(strip);
149  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip;
150 
151  if (plane == 1) {
152  // east road
153  int n_east = 0;
154  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East ";
155 
156  while (((next = theESNav.east()) != ESDetId(0) && next != strip)) {
157  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is "
158  << next;
159 
160  vout.push_back(next);
161  ++n_east;
162  if (n_east == preshSeededNstr_)
163  break;
164  }
165  // west road
166  int n_west = 0;
167  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West ";
168 
169  theESNav.home();
170  while (((next = theESNav.west()) != ESDetId(0) && next != strip)) {
171  LogTrace("EcalClusters") << "findPi0Road: West: " << n_west << " current strip is " << next;
172 
173  vout.push_back(next);
174  ++n_west;
175  if (n_west == preshSeededNstr_)
176  break;
177  }
178  LogTrace("EcalClusters")
179  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is "
180  << n_east + n_west;
181 
182  } else if (plane == 2) {
183  // north road
184  int n_north = 0;
185  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North ";
186 
187  while (((next = theESNav.north()) != ESDetId(0) && next != strip)) {
188  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north
189  << " current strip is " << next;
190 
191  vout.push_back(next);
192  ++n_north;
193  if (n_north == preshSeededNstr_)
194  break;
195  }
196  // south road
197  int n_south = 0;
198  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South ";
199 
200  theESNav.home();
201  while (((next = theESNav.south()) != ESDetId(0) && next != strip)) {
202  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south
203  << " current strip is " << next;
204 
205  vout.push_back(next);
206  ++n_south;
207  if (n_south == preshSeededNstr_)
208  break;
209  }
210  LogTrace("EcalClusters")
211  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is "
212  << n_south + n_north;
213 
214  } else {
215  LogTrace("EcalClusters")
216  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! ";
217 
218  } // end of if
219 
220  theESNav.home();
221 }
222 
223 //===================================================================
224 // EndcapPiZeroDiscriminatorAlgo::readWeightFile(...), a method that reads the weigths of the NN
225 // INPUT: Weights_file
226 // OUTPUT: I_H_Weight, H_Thresh, H_O_Weight, O_Thresh arrays
227 //===================================================================
229  const char* Weights_file, int& Layers, int& Indim, int& Hidden, int& Outdim) {
230  FILE* weights = nullptr;
231 
232  char line[80];
233 
234  bool checkinit = false;
235  // Open the weights file, generated by jetnet, and read
236  // in the nodes and weights
237  //*******************************************************
238  weights = fopen(Weights_file, "r");
239  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file;
240  if (weights == nullptr) {
241  throw cms::Exception("MissingWeightFile") << "Could not open the weights file: " << Weights_file;
242  }
243 
244  const auto I_H_W_offset = I_H_Weight_all.size();
245  const auto H_O_W_offset = H_O_Weight_all.size();
246  const auto H_T_offset = H_Thresh_all.size();
247  const auto O_T_offset = O_Thresh_all.size();
248 
249  while (!feof(weights)) {
250  fscanf(weights, "%s", line);
251  if (line[0] == 'A') { //Read in ANN nodes: Layers, input , Hidden, Output
252  fscanf(weights, "%d", &Layers); // # of NN Layers used
253  fscanf(weights, "%d", &Indim); // # of Inputs actually used
254  fscanf(weights, "%d", &Hidden); // # of hidden nodes
255  fscanf(weights, "%d", &Outdim); // # of output nodes
256 
257  I_H_Weight_all.resize(I_H_W_offset + Indim * Hidden);
258  H_Thresh_all.resize(H_T_offset + Hidden);
259  H_O_Weight_all.resize(H_O_W_offset + Hidden * Outdim);
260  O_Thresh_all.resize(O_T_offset + Outdim);
261  checkinit = true;
262  } else if (line[0] == 'B') { // read in weights between hidden and intput nodes
263  assert(checkinit);
264  for (int i = 0; i < Indim; i++) {
265  for (int j = 0; j < Hidden; j++) {
266  fscanf(weights, "%f", &I_H_Weight_all[I_H_W_offset + i * Hidden + j]);
267  }
268  }
269  } else if (line[0] == 'C') { // Read in the thresholds for hidden nodes
270  assert(checkinit);
271  for (int i = 0; i < Hidden; i++) {
272  fscanf(weights, "%f", &H_Thresh_all[H_T_offset + i]);
273  }
274  } else if (line[0] == 'D') { // read in weights between hidden and output nodes
275  assert(checkinit);
276  for (int i = 0; i < Hidden * Outdim; i++) {
277  fscanf(weights, "%f", &H_O_Weight_all[H_O_W_offset + i]);
278  }
279  } else if (line[0] == 'E') { // read in the threshold for the output nodes
280  assert(checkinit);
281  for (int i = 0; i < Outdim; i++) {
282  fscanf(weights, "%f", &O_Thresh_all[O_T_offset + i]);
283  }
284  } else {
285  edm::LogError("EEPi0Discrim") << "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
286  }
287  }
288  fclose(weights);
289 }
290 
291 //=====================================================================================
292 // EndcapPiZeroDiscriminatorAlgo::getNNoutput(int sel_wfile), a method that calculated the NN output
293 // INPUT: sel_wfile -> Weight file selection
294 // OUTPUT : nnout -> the NN output
295 //=====================================================================================
296 
298  int sel_wfile, int Layers, int Indim, int Hidden, int Outdim, int barrelstart) const {
299  float nnout = 0.0;
300  int mij;
301 
302  std::vector<float> I_SUM(size_t(Hidden), 0.0);
303  std::vector<float> OUT(size_t(Outdim), 0.0);
304 
305  for (int h = 0; h < Hidden; h++) {
306  mij = h - Hidden;
307  for (int i = 0; i < Indim; i++) {
308  mij = mij + Hidden;
309  I_SUM[h] += I_H_Weight_all[mij + sel_wfile * Indim * Hidden + barrelstart * Nfiles_EE * EE_Indim * EE_Hidden] *
310  input_var[i];
311  }
312  I_SUM[h] += H_Thresh_all[h + sel_wfile * Hidden + barrelstart * Nfiles_EE * EE_Hidden];
313  for (int o1 = 0; o1 < Outdim; o1++) {
314  OUT[o1] += H_O_Weight_all[barrelstart * Nfiles_EE * EE_Outdim * EE_Hidden + h * Outdim + o1 +
315  sel_wfile * Outdim * Hidden] *
316  Activation_fun(I_SUM[h]);
317  }
318  }
319  for (int o2 = 0; o2 < Outdim; o2++) {
320  OUT[o2] += O_Thresh_all[barrelstart * Nfiles_EE * EE_Outdim + o2 + sel_wfile * Outdim];
321  }
322  nnout = Activation_fun(OUT[0]);
323  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout;
324 
325  return (nnout);
326 }
327 
328 float EndcapPiZeroDiscriminatorAlgo::Activation_fun(float SUM) const { return (1.0 / (1.0 + exp(-2.0 * SUM))); }
329 //=====================================================================================
330 // EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables(...), a method that calculates the 25 input variables
331 // INPUTS:
332 // vph1 -> vector of the stip energies in 1st Preshower plane
333 // vph2 -> vector of the stip energies in 2nd Preshower plane
334 // pS1_max -> E1
335 // pS9_max -> E9
336 // pS25_max -> E25
337 // OUTPUT:
338 // input_var[25] -> the 25 input to the NN variables array
339 //=====================================================================================
341  vector<float>& vph1, vector<float>& vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr) {
342  input_var.resize(EE_Indim);
343  bool valid_NNinput = true;
344 
345  /*
346  for(int i = 0; i<11;i++) {
347  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = " << vph1[i] ;
348  }
349 
350  for(int i = 0; i<11;i++) {
351  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
352  }
353  */
354 
355  // check if all Preshower info is availabla - If NOT use remaning info
356  for (int k = 0; k < 11; k++) {
357  if (vph1[k] < 0) {
358  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k
359  << " of X plane Do not exists";
360 
361  vph1[k] = 0.0;
362  }
363  if (vph2[k] < 0) {
364  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k
365  << " of Y plane Do not exists";
366 
367  vph2[k] = 0.0;
368  }
369  }
370 
371  /*
372  for(int i = 0; i<11;i++) {
373  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = " << vph1[i] ;
374  }
375 
376  for(int i = 0; i<11;i++) {
377 
378  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
379  }
380  */
381 
382  // FIRST : Produce the 22 NN variables related with the Preshower
383  // --------------------------------------------------------------
384  // New normalization of the preshower strip energies Aris 8/11/2004
385  for (int kk = 0; kk < 11; kk++) {
386  input_var[kk] = fabs(vph1[kk] / 0.01);
387  input_var[kk + 11] = fabs(vph2[kk] / 0.02);
388  if (input_var[kk] < 0.0001)
389  input_var[kk] = 0.;
390  if (input_var[kk + 11] < 0.0001)
391  input_var[kk + 11] = 0.;
392  }
393  input_var[0] = fabs(input_var[0] / 2.);
394  input_var[1] = fabs(input_var[1] / 2.);
395  input_var[6] = fabs(input_var[6] / 2.);
396  input_var[11] = fabs(input_var[11] / 2.);
397  input_var[12] = fabs(input_var[12] / 2.);
398  input_var[17] = fabs(input_var[17] / 2.);
399 
400  // correction for version > CMSSW_3_1_0_pre5 where extra enegry is given to the ES strips
401  // Aris 18/5/2009
402  if (EScorr == 1) {
403  input_var[0] -= 0.05;
404  input_var[1] -= 0.035;
405  input_var[2] -= 0.035;
406  input_var[3] -= 0.02;
407  input_var[4] -= 0.015;
408  input_var[5] -= 0.0075;
409  input_var[6] -= 0.035;
410  input_var[7] -= 0.035;
411  input_var[8] -= 0.02;
412  input_var[9] -= 0.015;
413  input_var[10] -= 0.0075;
414 
415  input_var[11] -= 0.05;
416  input_var[12] -= 0.035;
417  input_var[13] -= 0.035;
418  input_var[14] -= 0.02;
419  input_var[15] -= 0.015;
420  input_var[16] -= 0.0075;
421  input_var[17] -= 0.035;
422  input_var[18] -= 0.035;
423  input_var[19] -= 0.02;
424  input_var[20] -= 0.015;
425  input_var[21] -= 0.0075;
426 
427  for (int kk1 = 0; kk1 < 22; kk1++) {
428  if (input_var[kk1] < 0)
429  input_var[kk1] = 0.0;
430  }
431  }
432  // SECOND: Take the final NN variable related to the ECAL
433  // -----------------------------------------------
434  float ECAL_norm_factor = 500.;
435  if (pS25_max > 500 && pS25_max <= 1000)
436  ECAL_norm_factor = 1000;
437  if (pS25_max > 1000)
438  ECAL_norm_factor = 7000;
439 
440  input_var[22] = pS1_max / ECAL_norm_factor;
441  input_var[23] = pS9_max / ECAL_norm_factor;
442  input_var[24] = pS25_max / ECAL_norm_factor;
443 
444  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " << input_var[22];
445  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " << input_var[23];
446  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " << input_var[24];
447 
448  for (int i = 0; i < EE_Indim; i++) {
449  if (input_var[i] > 1.0e+00) {
450  valid_NNinput = false;
451  break;
452  }
453  }
454 
455  LogTrace("EcalClusters") << " valid_NNinput = " << valid_NNinput;
456 
457  return valid_NNinput;
458 }
459 
460 //=====================================================================================
461 // EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables(...), a method that calculates
462 // the 12 barrel NN input
463 // OUTPUT:
464 // input_var[12] -> the 12 input to the barrel NN variables array
465 //=====================================================================================
466 
468  double s1,
469  double s9,
470  double s25,
471  double m2,
472  double cee,
473  double cep,
474  double cpp,
475  double s4,
476  double s6,
477  double ratio,
478  double xcog,
479  double ycog) {
480  input_var.resize(EB_Indim);
481 
482  double lam, lam1, lam2;
483 
484  if (xcog < 0.) {
485  input_var[0] = -xcog / s25;
486  } else {
487  input_var[0] = xcog / s25;
488  }
489 
490  input_var[1] = cee / 0.0004;
491 
492  if (cpp < .001) {
493  input_var[2] = cpp / .001;
494  } else {
495  input_var[2] = 0.;
496  }
497 
498  if (s9 != 0.) {
499  input_var[3] = s1 / s9;
500  input_var[8] = s6 / s9;
501  input_var[10] = (m2 + s1) / s9;
502  } else {
503  input_var[3] = 0.;
504  input_var[8] = 0.;
505  input_var[10] = 0.;
506  }
507 
508  if (s25 - s1 > 0.) {
509  input_var[4] = (s9 - s1) / (s25 - s1);
510  } else {
511  input_var[4] = 0.;
512  }
513 
514  if (s25 > 0.) {
515  input_var[5] = s4 / s25;
516  } else {
517  input_var[5] = 0.;
518  }
519 
520  if (ycog < 0.) {
521  input_var[6] = -ycog / s25;
522  } else {
523  input_var[6] = ycog / s25;
524  }
525 
526  input_var[7] = ratio;
527 
528  lam = sqrt((cee - cpp) * (cee - cpp) + 4 * cep * cep);
529  lam1 = (cee + cpp + lam) / 2;
530  lam2 = (cee + cpp - lam) / 2;
531 
532  if (lam1 == 0) {
533  input_var[9] = .0;
534  } else {
535  input_var[9] = lam2 / lam1;
536  }
537  if (s4 != 0.) {
538  input_var[11] = (m2 + s1) / s4;
539  } else {
540  input_var[11] = 0.;
541  }
542 }
543 
544 //=====================================================================================
545 // EndcapPiZeroDiscriminatorAlgo::GetNNOutput(...), a method that calculates the NNoutput
546 // INPUTS: Super Cluster Energy
547 // OUTPUTS : NNoutput
548 //=====================================================================================
550  float nnout = -1;
551  // Print the NN input variables that are related to the Preshower + ECAL
552  // ------------------------------------------------------------------------
553  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = ";
554 
555  LogTrace("EcalClusters").log([&](auto& lt) {
556  for (auto const v : input_var) {
557  lt << v << " ";
558  }
559  });
560  LogTrace("EcalClusters") << " ";
561 
562  // select the appropriate Weigth file
563  int sel_wfile;
564  if (EE_Et < 25.0) {
565  sel_wfile = 0;
566  } else if (EE_Et >= 25.0 && EE_Et < 35.0) {
567  sel_wfile = 1;
568  } else if (EE_Et >= 35.0 && EE_Et < 45.0) {
569  sel_wfile = 2;
570  } else if (EE_Et >= 45.0 && EE_Et < 55.0) {
571  sel_wfile = 3;
572  } else {
573  sel_wfile = 4;
574  }
575 
576  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et
577  << " and I select Weight file Number = " << sel_wfile;
578 
579  nnout = getNNoutput(
580  sel_wfile, EE_Layers, EE_Indim, EE_Hidden, EE_Outdim, 0); // calculate the nnoutput for the given ECAL object
581 
582  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
583 
584  return nnout;
585 }
586 
587 //=====================================================================================
588 // EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput(...), a method that calculates the barrel NNoutput
589 // INPUTS: Super Cluster Energy
590 // OUTPUTS : NNoutput
591 //=====================================================================================
593  float nnout = -1;
594  // Print the NN input variables that are related to the ECAL Barrel
595  // ------------------------------------------------------------------------
596  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = ";
597 
598  LogTrace("EcalCluster").log([&](auto& lt) {
599  for (auto const v : input_var) {
600  lt << v << " ";
601  }
602  });
603  LogTrace("EcalClusters") << " ";
604 
605  // select the appropriate Weigth file
606  int sel_wfile;
607  if (EB_Et < 25.0) {
608  sel_wfile = 0;
609  } else if (EB_Et >= 25.0 && EB_Et < 35.0) {
610  sel_wfile = 1;
611  } else if (EB_Et >= 35.0 && EB_Et < 45.0) {
612  sel_wfile = 2;
613  } else if (EB_Et >= 45.0 && EB_Et < 55.0) {
614  sel_wfile = 3;
615  } else {
616  sel_wfile = 4;
617  }
618  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et
619  << " and I select Weight file Number = " << sel_wfile;
620 
621  nnout = getNNoutput(
622  sel_wfile, EB_Layers, EB_Indim, EB_Hidden, EB_Outdim, 1); // calculate the nnoutput for the given ECAL object
623 
624  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
625 
626  return nnout;
627 }
EndcapPiZeroDiscriminatorAlgo::GetNNOutput
float GetNNOutput(float EE_Et)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:549
SUM
#define SUM(A, B)
Definition: Simplify_begin.h:52
CaloNavigator::north
T north() const
move the navigator north
Definition: CaloNavigator.h:30
mps_fire.i
i
Definition: mps_fire.py:428
EndcapPiZeroDiscriminatorAlgo::EB_Outdim
int EB_Outdim
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
MessageLogger.h
EndcapPiZeroDiscriminatorAlgo::O_Thresh_all
std::vector< float > O_Thresh_all
Definition: EndcapPiZeroDiscriminatorAlgo.h:67
CaloNavigator::east
T east() const
move the navigator east
Definition: CaloNavigator.h:42
EndcapPiZeroDiscriminatorAlgo::RecHitsMap
std::map< DetId, EcalRecHit > RecHitsMap
Definition: EndcapPiZeroDiscriminatorAlgo.h:17
HLT_FULL_cff.navigator
navigator
Definition: HLT_FULL_cff.py:13126
EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo
EndcapPiZeroDiscriminatorAlgo()
Definition: EndcapPiZeroDiscriminatorAlgo.h:19
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
EndcapPiZeroDiscriminatorAlgo.h
EndcapPiZeroDiscriminatorAlgo::readWeightFile
void readWeightFile(const char *WFile, int &Layers, int &Indim, int &Hidden, int &Outdim)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:228
EndcapPiZeroDiscriminatorAlgo::EE_Layers
int EE_Layers
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
cms::cuda::assert
assert(be >=bs)
ESDetId
Definition: ESDetId.h:15
EndcapPiZeroDiscriminatorAlgo::EB_Hidden
int EB_Hidden
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
findQualityFiles.v
v
Definition: findQualityFiles.py:179
EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables
void calculateBarrelNNInputVariables(float et, double s1, double s9, double s25, double m2, double cee, double cep, double cpp, double s4, double s6, double ratio, double xcog, double ycog)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:467
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EndcapPiZeroDiscriminatorAlgo::findPreshVector
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:40
FileInPath.h
EndcapPiZeroDiscriminatorAlgo::preshSeededNstr_
int preshSeededNstr_
Definition: EndcapPiZeroDiscriminatorAlgo.h:58
edm::FileInPath
Definition: FileInPath.h:64
EndcapPiZeroDiscriminatorAlgo::getNNoutput
float getNNoutput(int sel_wfile, int Layers, int Indim, int Hidden, int Outdim, int barrelstart) const
Definition: EndcapPiZeroDiscriminatorAlgo.cc:297
EndcapPiZeroDiscriminatorAlgo::preshStripEnergyCut_
double preshStripEnergyCut_
Definition: EndcapPiZeroDiscriminatorAlgo.h:57
h
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99170
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EndcapPiZeroDiscriminatorAlgo::input_var
std::vector< float > input_var
Definition: EndcapPiZeroDiscriminatorAlgo.h:69
CaloNavigator::setHome
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:90
EndcapPiZeroDiscriminatorAlgo::EE_Hidden
int EE_Hidden
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
EndcapPiZeroDiscriminatorAlgo::EB_Indim
int EB_Indim
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
CastorDigiReco.o1
o1
Definition: CastorDigiReco.py:84
dqmdumpme.k
k
Definition: dqmdumpme.py:60
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput
float GetBarrelNNOutput(float EB_Et)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:592
EndcapPiZeroDiscriminatorAlgo::goodPi0Strip
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:121
EndcapPiZeroDiscriminatorAlgo::H_O_Weight_all
std::vector< float > H_O_Weight_all
Definition: EndcapPiZeroDiscriminatorAlgo.h:65
CaloSubdetectorGeometry.h
CaloNavigator::home
void home() const
move the navigator back to the starting point
Definition: CaloNavigator.h:96
CaloNavigator::west
T west() const
move the navigator west
Definition: CaloNavigator.h:48
EndcapPiZeroDiscriminatorAlgo::I_H_Weight_all
std::vector< float > I_H_Weight_all
Definition: EndcapPiZeroDiscriminatorAlgo.h:64
CaloNavigator::south
T south() const
move the navigator south
Definition: CaloNavigator.h:36
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables
bool calculateNNInputVariables(std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:340
CaloCellGeometry.h
EndcapPiZeroDiscriminatorAlgo::EE_Outdim
int EE_Outdim
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
CaloNavigator
Definition: CaloNavigator.h:7
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
EndcapPiZeroDiscriminatorAlgo::EE_Indim
int EE_Indim
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
EndcapPiZeroDiscriminatorAlgo::EB_Layers
int EB_Layers
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
EndcapPiZeroDiscriminatorAlgo::Activation_fun
float Activation_fun(float SUM) const
Definition: EndcapPiZeroDiscriminatorAlgo.cc:328
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
mps_splice.line
line
Definition: mps_splice.py:76
CfgNavigationSchool_cfi.OUT
OUT
Definition: CfgNavigationSchool_cfi.py:9
EndcapPiZeroDiscriminatorAlgo::H_Thresh_all
std::vector< float > H_Thresh_all
Definition: EndcapPiZeroDiscriminatorAlgo.h:66
EndcapPiZeroDiscriminatorAlgo::findPi0Road
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:141
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37