CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
EndcapPiZeroDiscriminatorAlgo Class Reference

#include <EndcapPiZeroDiscriminatorAlgo.h>

Public Types

typedef std::map< DetId, EcalRecHitRecHitsMap
 

Public Member Functions

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)
 
bool calculateNNInputVariables (std::vector< float > &vph1, std::vector< float > &vph2, float pS1_max, float pS9_max, float pS25_max, int EScorr)
 
 EndcapPiZeroDiscriminatorAlgo ()
 
 EndcapPiZeroDiscriminatorAlgo (double stripEnergyCut, int nStripCut, const std::string &path)
 
void findPi0Road (ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
 
std::vector< float > findPreshVector (ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
 
std::vector< float > const & get_input_vector () const
 
float GetBarrelNNOutput (float EB_Et)
 
float GetNNOutput (float EE_Et)
 
bool goodPi0Strip (RecHitsMap::iterator candidate_it, ESDetId lastID)
 

Private Member Functions

float Activation_fun (float SUM) const
 
float getNNoutput (int sel_wfile, int Layers, int Indim, int Hidden, int Outdim, int barrelstart) const
 
void readWeightFile (const char *WFile, int &Layers, int &Indim, int &Hidden, int &Outdim)
 

Private Attributes

int debugLevel_
 
int EB_Hidden
 
int EB_Indim
 
int EB_Layers
 
int EB_Outdim
 
int EE_Hidden
 
int EE_Indim
 
int EE_Layers
 
int EE_Outdim
 
std::vector< float > H_O_Weight_all
 
std::vector< float > H_Thresh_all
 
std::vector< float > I_H_Weight_all
 
std::vector< float > input_var
 
std::vector< float > O_Thresh_all
 
int preshSeededNstr_
 
double preshStripEnergyCut_
 

Detailed Description

Definition at line 15 of file EndcapPiZeroDiscriminatorAlgo.h.

Member Typedef Documentation

◆ RecHitsMap

Definition at line 17 of file EndcapPiZeroDiscriminatorAlgo.h.

Constructor & Destructor Documentation

◆ EndcapPiZeroDiscriminatorAlgo() [1/2]

EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( )
inline

Definition at line 19 of file EndcapPiZeroDiscriminatorAlgo.h.

◆ EndcapPiZeroDiscriminatorAlgo() [2/2]

EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( double  stripEnergyCut,
int  nStripCut,
const std::string &  path 
)

Member Function Documentation

◆ Activation_fun()

float EndcapPiZeroDiscriminatorAlgo::Activation_fun ( float  SUM) const
private

Definition at line 327 of file EndcapPiZeroDiscriminatorAlgo.cc.

327 { return (1.0 / (1.0 + exp(-2.0 * SUM))); }

References JetChargeProducer_cfi::exp, and SUM.

Referenced by getNNoutput().

◆ calculateBarrelNNInputVariables()

void EndcapPiZeroDiscriminatorAlgo::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 at line 466 of file EndcapPiZeroDiscriminatorAlgo.cc.

478  {
479  input_var.resize(EB_Indim);
480 
481  double lam, lam1, lam2;
482 
483  if (xcog < 0.) {
484  input_var[0] = -xcog / s25;
485  } else {
486  input_var[0] = xcog / s25;
487  }
488 
489  input_var[1] = cee / 0.0004;
490 
491  if (cpp < .001) {
492  input_var[2] = cpp / .001;
493  } else {
494  input_var[2] = 0.;
495  }
496 
497  if (s9 != 0.) {
498  input_var[3] = s1 / s9;
499  input_var[8] = s6 / s9;
500  input_var[10] = (m2 + s1) / s9;
501  } else {
502  input_var[3] = 0.;
503  input_var[8] = 0.;
504  input_var[10] = 0.;
505  }
506 
507  if (s25 - s1 > 0.) {
508  input_var[4] = (s9 - s1) / (s25 - s1);
509  } else {
510  input_var[4] = 0.;
511  }
512 
513  if (s25 > 0.) {
514  input_var[5] = s4 / s25;
515  } else {
516  input_var[5] = 0.;
517  }
518 
519  if (ycog < 0.) {
520  input_var[6] = -ycog / s25;
521  } else {
522  input_var[6] = ycog / s25;
523  }
524 
525  input_var[7] = ratio;
526 
527  lam = sqrt((cee - cpp) * (cee - cpp) + 4 * cep * cep);
528  lam1 = (cee + cpp + lam) / 2;
529  lam2 = (cee + cpp - lam) / 2;
530 
531  if (lam1 == 0) {
532  input_var[9] = .0;
533  } else {
534  input_var[9] = lam2 / lam1;
535  }
536  if (s4 != 0.) {
537  input_var[11] = (m2 + s1) / s4;
538  } else {
539  input_var[11] = 0.;
540  }
541 }

References EB_Indim, input_var, particleFlowDisplacedVertex_cfi::ratio, and mathSSE::sqrt().

◆ calculateNNInputVariables()

bool EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables ( std::vector< float > &  vph1,
std::vector< float > &  vph2,
float  pS1_max,
float  pS9_max,
float  pS25_max,
int  EScorr 
)

Definition at line 339 of file EndcapPiZeroDiscriminatorAlgo.cc.

340  {
341  input_var.resize(EE_Indim);
342  bool valid_NNinput = true;
343 
344  /*
345  for(int i = 0; i<11;i++) {
346  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = " << vph1[i] ;
347  }
348 
349  for(int i = 0; i<11;i++) {
350  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
351  }
352  */
353 
354  // check if all Preshower info is availabla - If NOT use remaning info
355  for (int k = 0; k < 11; k++) {
356  if (vph1[k] < 0) {
357  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k
358  << " of X plane Do not exists";
359 
360  vph1[k] = 0.0;
361  }
362  if (vph2[k] < 0) {
363  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k
364  << " of Y plane Do not exists";
365 
366  vph2[k] = 0.0;
367  }
368  }
369 
370  /*
371  for(int i = 0; i<11;i++) {
372  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = " << vph1[i] ;
373  }
374 
375  for(int i = 0; i<11;i++) {
376 
377  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = " << vph2[i] ;
378  }
379  */
380 
381  // FIRST : Produce the 22 NN variables related with the Preshower
382  // --------------------------------------------------------------
383  // New normalization of the preshower strip energies Aris 8/11/2004
384  for (int kk = 0; kk < 11; kk++) {
385  input_var[kk] = fabs(vph1[kk] / 0.01);
386  input_var[kk + 11] = fabs(vph2[kk] / 0.02);
387  if (input_var[kk] < 0.0001)
388  input_var[kk] = 0.;
389  if (input_var[kk + 11] < 0.0001)
390  input_var[kk + 11] = 0.;
391  }
392  input_var[0] = fabs(input_var[0] / 2.);
393  input_var[1] = fabs(input_var[1] / 2.);
394  input_var[6] = fabs(input_var[6] / 2.);
395  input_var[11] = fabs(input_var[11] / 2.);
396  input_var[12] = fabs(input_var[12] / 2.);
397  input_var[17] = fabs(input_var[17] / 2.);
398 
399  // correction for version > CMSSW_3_1_0_pre5 where extra enegry is given to the ES strips
400  // Aris 18/5/2009
401  if (EScorr == 1) {
402  input_var[0] -= 0.05;
403  input_var[1] -= 0.035;
404  input_var[2] -= 0.035;
405  input_var[3] -= 0.02;
406  input_var[4] -= 0.015;
407  input_var[5] -= 0.0075;
408  input_var[6] -= 0.035;
409  input_var[7] -= 0.035;
410  input_var[8] -= 0.02;
411  input_var[9] -= 0.015;
412  input_var[10] -= 0.0075;
413 
414  input_var[11] -= 0.05;
415  input_var[12] -= 0.035;
416  input_var[13] -= 0.035;
417  input_var[14] -= 0.02;
418  input_var[15] -= 0.015;
419  input_var[16] -= 0.0075;
420  input_var[17] -= 0.035;
421  input_var[18] -= 0.035;
422  input_var[19] -= 0.02;
423  input_var[20] -= 0.015;
424  input_var[21] -= 0.0075;
425 
426  for (int kk1 = 0; kk1 < 22; kk1++) {
427  if (input_var[kk1] < 0)
428  input_var[kk1] = 0.0;
429  }
430  }
431  // SECOND: Take the final NN variable related to the ECAL
432  // -----------------------------------------------
433  float ECAL_norm_factor = 500.;
434  if (pS25_max > 500 && pS25_max <= 1000)
435  ECAL_norm_factor = 1000;
436  if (pS25_max > 1000)
437  ECAL_norm_factor = 7000;
438 
439  input_var[22] = pS1_max / ECAL_norm_factor;
440  input_var[23] = pS9_max / ECAL_norm_factor;
441  input_var[24] = pS25_max / ECAL_norm_factor;
442 
443  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " << input_var[22];
444  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " << input_var[23];
445  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " << input_var[24];
446 
447  for (int i = 0; i < EE_Indim; i++) {
448  if (input_var[i] > 1.0e+00) {
449  valid_NNinput = false;
450  break;
451  }
452  }
453 
454  LogTrace("EcalClusters") << " valid_NNinput = " << valid_NNinput;
455 
456  return valid_NNinput;
457 }

References MillePedeFileConverter_cfg::e, EE_Indim, mps_fire::i, input_var, dqmdumpme::k, GetRecoTauVFromDQM_MC_cff::kk, and LogTrace.

◆ findPi0Road()

void EndcapPiZeroDiscriminatorAlgo::findPi0Road ( ESDetId  strip,
EcalPreshowerNavigator theESNav,
int  plane,
std::vector< ESDetId > &  vout 
)

Definition at line 140 of file EndcapPiZeroDiscriminatorAlgo.cc.

143  {
144  if (strip == ESDetId(0))
145  return;
146  ESDetId next;
147  theESNav.setHome(strip);
148  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip;
149 
150  if (plane == 1) {
151  // east road
152  int n_east = 0;
153  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East ";
154 
155  while (((next = theESNav.east()) != ESDetId(0) && next != strip)) {
156  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is "
157  << next;
158 
159  vout.push_back(next);
160  ++n_east;
161  if (n_east == preshSeededNstr_)
162  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_)
175  break;
176  }
177  LogTrace("EcalClusters")
178  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is "
179  << n_east + n_west;
180 
181  } else if (plane == 2) {
182  // north road
183  int n_north = 0;
184  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North ";
185 
186  while (((next = theESNav.north()) != ESDetId(0) && next != strip)) {
187  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north
188  << " current strip is " << next;
189 
190  vout.push_back(next);
191  ++n_north;
192  if (n_north == preshSeededNstr_)
193  break;
194  }
195  // south road
196  int n_south = 0;
197  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South ";
198 
199  theESNav.home();
200  while (((next = theESNav.south()) != ESDetId(0) && next != strip)) {
201  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south
202  << " current strip is " << next;
203 
204  vout.push_back(next);
205  ++n_south;
206  if (n_south == preshSeededNstr_)
207  break;
208  }
209  LogTrace("EcalClusters")
210  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is "
211  << n_south + n_north;
212 
213  } else {
214  LogTrace("EcalClusters")
215  << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! ";
216 
217  } // end of if
218 
219  theESNav.home();
220 }

References CaloNavigator< T, TOPO >::east(), CaloNavigator< T, TOPO >::home(), LogTrace, GetRecoTauVFromDQM_MC_cff::next, CaloNavigator< T, TOPO >::north(), preshSeededNstr_, CaloNavigator< T, TOPO >::setHome(), CaloNavigator< T, TOPO >::south(), digitizers_cfi::strip, and CaloNavigator< T, TOPO >::west().

Referenced by findPreshVector().

◆ findPreshVector()

vector< float > EndcapPiZeroDiscriminatorAlgo::findPreshVector ( ESDetId  strip,
RecHitsMap rechits_map,
CaloSubdetectorTopology topology_p 
)

Definition at line 40 of file EndcapPiZeroDiscriminatorAlgo.cc.

42  {
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  for (int i = 0; i < 11; i++) {
107  vout_ElevenStrips_Energy.push_back(0.);
108  }
109 
110  for (unsigned int i = 0; i < vout_stripE.size(); i++) {
111  vout_ElevenStrips_Energy[i] = vout_stripE.at(i);
112  }
113 
114  //return vout_stripE;
115  return vout_ElevenStrips_Energy;
116  // ***ML end***
117 }

References findPi0Road(), goodPi0Strip(), mps_fire::i, LogTrace, HLT_2018_cff::navigator, and digitizers_cfi::strip.

◆ get_input_vector()

std::vector<float> const& EndcapPiZeroDiscriminatorAlgo::get_input_vector ( ) const
inline

Definition at line 50 of file EndcapPiZeroDiscriminatorAlgo.h.

50 { return input_var; }

References input_var.

◆ GetBarrelNNOutput()

float EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput ( float  EB_Et)

Definition at line 591 of file EndcapPiZeroDiscriminatorAlgo.cc.

591  {
592  float nnout = -1;
593  // Print the NN input variables that are related to the ECAL Barrel
594  // ------------------------------------------------------------------------
595  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = ";
596 
597  LogTrace("EcalCluster").log([&](auto& lt) {
598  for (auto const v : input_var) {
599  lt << v << " ";
600  }
601  });
602  LogTrace("EcalClusters") << " ";
603 
604  // select the appropriate Weigth file
605  int sel_wfile;
606  if (EB_Et < 25.0) {
607  sel_wfile = 0;
608  } else if (EB_Et >= 25.0 && EB_Et < 35.0) {
609  sel_wfile = 1;
610  } else if (EB_Et >= 35.0 && EB_Et < 45.0) {
611  sel_wfile = 2;
612  } else if (EB_Et >= 45.0 && EB_Et < 55.0) {
613  sel_wfile = 3;
614  } else {
615  sel_wfile = 4;
616  }
617  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et
618  << " and I select Weight file Number = " << sel_wfile;
619 
620  nnout = getNNoutput(
621  sel_wfile, EB_Layers, EB_Indim, EB_Hidden, EB_Outdim, 1); // calculate the nnoutput for the given ECAL object
622 
623  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
624 
625  return nnout;
626 }

References EB_Hidden, EB_Indim, EB_Layers, EB_Outdim, getNNoutput(), input_var, LogTrace, and findQualityFiles::v.

◆ GetNNOutput()

float EndcapPiZeroDiscriminatorAlgo::GetNNOutput ( float  EE_Et)

Definition at line 548 of file EndcapPiZeroDiscriminatorAlgo.cc.

548  {
549  float nnout = -1;
550  // Print the NN input variables that are related to the Preshower + ECAL
551  // ------------------------------------------------------------------------
552  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = ";
553 
554  LogTrace("EcalClusters").log([&](auto& lt) {
555  for (auto const v : input_var) {
556  lt << v << " ";
557  }
558  });
559  LogTrace("EcalClusters") << " ";
560 
561  // select the appropriate Weigth file
562  int sel_wfile;
563  if (EE_Et < 25.0) {
564  sel_wfile = 0;
565  } else if (EE_Et >= 25.0 && EE_Et < 35.0) {
566  sel_wfile = 1;
567  } else if (EE_Et >= 35.0 && EE_Et < 45.0) {
568  sel_wfile = 2;
569  } else if (EE_Et >= 45.0 && EE_Et < 55.0) {
570  sel_wfile = 3;
571  } else {
572  sel_wfile = 4;
573  }
574 
575  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et
576  << " and I select Weight file Number = " << sel_wfile;
577 
578  nnout = getNNoutput(
579  sel_wfile, EE_Layers, EE_Indim, EE_Hidden, EE_Outdim, 0); // calculate the nnoutput for the given ECAL object
580 
581  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout;
582 
583  return nnout;
584 }

References EE_Hidden, EE_Indim, EE_Layers, EE_Outdim, getNNoutput(), input_var, LogTrace, and findQualityFiles::v.

◆ getNNoutput()

float EndcapPiZeroDiscriminatorAlgo::getNNoutput ( int  sel_wfile,
int  Layers,
int  Indim,
int  Hidden,
int  Outdim,
int  barrelstart 
) const
private

Definition at line 296 of file EndcapPiZeroDiscriminatorAlgo.cc.

297  {
298  float nnout = 0.0;
299  int mij;
300 
301  std::vector<float> I_SUM(size_t(Hidden), 0.0);
302  std::vector<float> OUT(size_t(Outdim), 0.0);
303 
304  for (int h = 0; h < Hidden; h++) {
305  mij = h - Hidden;
306  for (int i = 0; i < Indim; i++) {
307  mij = mij + Hidden;
308  I_SUM[h] += I_H_Weight_all[mij + sel_wfile * Indim * Hidden + barrelstart * Nfiles_EE * EE_Indim * EE_Hidden] *
309  input_var[i];
310  }
311  I_SUM[h] += H_Thresh_all[h + sel_wfile * Hidden + barrelstart * Nfiles_EE * EE_Hidden];
312  for (int o1 = 0; o1 < Outdim; o1++) {
313  OUT[o1] += H_O_Weight_all[barrelstart * Nfiles_EE * EE_Outdim * EE_Hidden + h * Outdim + o1 +
314  sel_wfile * Outdim * Hidden] *
315  Activation_fun(I_SUM[h]);
316  }
317  }
318  for (int o2 = 0; o2 < Outdim; o2++) {
319  OUT[o2] += O_Thresh_all[barrelstart * Nfiles_EE * EE_Outdim + o2 + sel_wfile * Outdim];
320  }
321  nnout = Activation_fun(OUT[0]);
322  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout;
323 
324  return (nnout);
325 }

References Activation_fun(), EE_Hidden, EE_Indim, EE_Outdim, h, H_O_Weight_all, H_Thresh_all, mps_fire::i, I_H_Weight_all, input_var, LogTrace, CastorDigiReco::o1, O_Thresh_all, and CfgNavigationSchool_cfi::OUT.

Referenced by GetBarrelNNOutput(), and GetNNOutput().

◆ goodPi0Strip()

bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip ( RecHitsMap::iterator  candidate_it,
ESDetId  lastID 
)

Definition at line 120 of file EndcapPiZeroDiscriminatorAlgo.cc.

120  {
121  RecHitsMap::iterator candidate_tmp = candidate_it;
122  candidate_tmp--;
123 
124  // crystal should not be included...
125  if (candidate_tmp->first == lastID) // ...if it corresponds to a hit
126  {
127  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map ";
128  return false;
129  } else if (candidate_it->second.energy() <= preshStripEnergyCut_) // ...if it has a negative or zero energy
130  {
131  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy "
132  << candidate_it->second.energy() << " is below threshold ";
133  return false;
134  }
135 
136  return true;
137 }

References LogTrace, and preshStripEnergyCut_.

Referenced by findPreshVector().

◆ readWeightFile()

void EndcapPiZeroDiscriminatorAlgo::readWeightFile ( const char *  WFile,
int &  Layers,
int &  Indim,
int &  Hidden,
int &  Outdim 
)
private

Definition at line 227 of file EndcapPiZeroDiscriminatorAlgo.cc.

228  {
229  FILE* weights = nullptr;
230 
231  char line[80];
232 
233  bool checkinit = false;
234  // Open the weights file, generated by jetnet, and read
235  // in the nodes and weights
236  //*******************************************************
237  weights = fopen(Weights_file, "r");
238  LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file;
239  if (weights == nullptr) {
240  throw cms::Exception("MissingWeightFile") << "Could not open the weights file: " << Weights_file;
241  }
242 
243  const auto I_H_W_offset = I_H_Weight_all.size();
244  const auto H_O_W_offset = H_O_Weight_all.size();
245  const auto H_T_offset = H_Thresh_all.size();
246  const auto O_T_offset = O_Thresh_all.size();
247 
248  while (!feof(weights)) {
249  fscanf(weights, "%s", line);
250  if (line[0] == 'A') { //Read in ANN nodes: Layers, input , Hidden, Output
251  fscanf(weights, "%d", &Layers); // # of NN Layers used
252  fscanf(weights, "%d", &Indim); // # of Inputs actually used
253  fscanf(weights, "%d", &Hidden); // # of hidden nodes
254  fscanf(weights, "%d", &Outdim); // # of output nodes
255 
256  I_H_Weight_all.resize(I_H_W_offset + Indim * Hidden);
257  H_Thresh_all.resize(H_T_offset + Hidden);
258  H_O_Weight_all.resize(H_O_W_offset + Hidden * Outdim);
259  O_Thresh_all.resize(O_T_offset + Outdim);
260  checkinit = true;
261  } else if (line[0] == 'B') { // read in weights between hidden and intput nodes
262  assert(checkinit);
263  for (int i = 0; i < Indim; i++) {
264  for (int j = 0; j < Hidden; j++) {
265  fscanf(weights, "%f", &I_H_Weight_all[I_H_W_offset + i * Hidden + j]);
266  }
267  }
268  } else if (line[0] == 'C') { // Read in the thresholds for hidden nodes
269  assert(checkinit);
270  for (int i = 0; i < Hidden; i++) {
271  fscanf(weights, "%f", &H_Thresh_all[H_T_offset + i]);
272  }
273  } else if (line[0] == 'D') { // read in weights between hidden and output nodes
274  assert(checkinit);
275  for (int i = 0; i < Hidden * Outdim; i++) {
276  fscanf(weights, "%f", &H_O_Weight_all[H_O_W_offset + i]);
277  }
278  } else if (line[0] == 'E') { // read in the threshold for the output nodes
279  assert(checkinit);
280  for (int i = 0; i < Outdim; i++) {
281  fscanf(weights, "%f", &O_Thresh_all[O_T_offset + i]);
282  }
283  } else {
284  edm::LogError("EEPi0Discrim") << "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
285  }
286  }
287  fclose(weights);
288 }

References cms::cuda::assert(), Exception, H_O_Weight_all, H_Thresh_all, mps_fire::i, I_H_Weight_all, dqmiolumiharvest::j, mps_splice::line, LogTrace, O_Thresh_all, and HLT_2018_cff::weights.

Member Data Documentation

◆ debugLevel_

int EndcapPiZeroDiscriminatorAlgo::debugLevel_
private

Definition at line 59 of file EndcapPiZeroDiscriminatorAlgo.h.

◆ EB_Hidden

int EndcapPiZeroDiscriminatorAlgo::EB_Hidden
private

Definition at line 62 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

◆ EB_Indim

int EndcapPiZeroDiscriminatorAlgo::EB_Indim
private

◆ EB_Layers

int EndcapPiZeroDiscriminatorAlgo::EB_Layers
private

Definition at line 62 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

◆ EB_Outdim

int EndcapPiZeroDiscriminatorAlgo::EB_Outdim
private

Definition at line 62 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

◆ EE_Hidden

int EndcapPiZeroDiscriminatorAlgo::EE_Hidden
private

Definition at line 61 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetNNOutput(), and getNNoutput().

◆ EE_Indim

int EndcapPiZeroDiscriminatorAlgo::EE_Indim
private

◆ EE_Layers

int EndcapPiZeroDiscriminatorAlgo::EE_Layers
private

Definition at line 61 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetNNOutput().

◆ EE_Outdim

int EndcapPiZeroDiscriminatorAlgo::EE_Outdim
private

Definition at line 61 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetNNOutput(), and getNNoutput().

◆ H_O_Weight_all

std::vector<float> EndcapPiZeroDiscriminatorAlgo::H_O_Weight_all
private

Definition at line 65 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

◆ H_Thresh_all

std::vector<float> EndcapPiZeroDiscriminatorAlgo::H_Thresh_all
private

Definition at line 66 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

◆ I_H_Weight_all

std::vector<float> EndcapPiZeroDiscriminatorAlgo::I_H_Weight_all
private

Definition at line 64 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

◆ input_var

std::vector<float> EndcapPiZeroDiscriminatorAlgo::input_var
private

◆ O_Thresh_all

std::vector<float> EndcapPiZeroDiscriminatorAlgo::O_Thresh_all
private

Definition at line 67 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

◆ preshSeededNstr_

int EndcapPiZeroDiscriminatorAlgo::preshSeededNstr_
private

Definition at line 58 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by findPi0Road().

◆ preshStripEnergyCut_

double EndcapPiZeroDiscriminatorAlgo::preshStripEnergyCut_
private

Definition at line 57 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by goodPi0Strip().

SUM
#define SUM(A, B)
Definition: Simplify_begin.h:52
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
CaloNavigator::north
T north() const
move the navigator north
Definition: CaloNavigator.h:30
mps_fire.i
i
Definition: mps_fire.py:355
EndcapPiZeroDiscriminatorAlgo::EB_Outdim
int EB_Outdim
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
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
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::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::preshSeededNstr_
int preshSeededNstr_
Definition: EndcapPiZeroDiscriminatorAlgo.h:58
EndcapPiZeroDiscriminatorAlgo::getNNoutput
float getNNoutput(int sel_wfile, int Layers, int Indim, int Hidden, int Outdim, int barrelstart) const
Definition: EndcapPiZeroDiscriminatorAlgo.cc:296
EndcapPiZeroDiscriminatorAlgo::preshStripEnergyCut_
double preshStripEnergyCut_
Definition: EndcapPiZeroDiscriminatorAlgo.h:57
h
HLT_2018_cff.navigator
navigator
Definition: HLT_2018_cff.py:11734
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
edm::LogWarning
Definition: MessageLogger.h:141
EndcapPiZeroDiscriminatorAlgo::goodPi0Strip
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:120
EndcapPiZeroDiscriminatorAlgo::H_O_Weight_all
std::vector< float > H_O_Weight_all
Definition: EndcapPiZeroDiscriminatorAlgo.h:65
edm::LogError
Definition: MessageLogger.h:183
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
EndcapPiZeroDiscriminatorAlgo::EE_Outdim
int EE_Outdim
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
CaloNavigator
Definition: CaloNavigator.h:7
Exception
Definition: hltDiff.cc:246
EndcapPiZeroDiscriminatorAlgo::EE_Indim
int EE_Indim
Definition: EndcapPiZeroDiscriminatorAlgo.h:61
EndcapPiZeroDiscriminatorAlgo::EB_Layers
int EB_Layers
Definition: EndcapPiZeroDiscriminatorAlgo.h:62
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
EndcapPiZeroDiscriminatorAlgo::Activation_fun
float Activation_fun(float SUM) const
Definition: EndcapPiZeroDiscriminatorAlgo.cc:327
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:140
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37