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