CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
EndcapPiZeroDiscriminatorAlgo Class Reference

#include <EndcapPiZeroDiscriminatorAlgo.h>

Public Types

enum  DebugLevel_pi0 { pDEBUG = 0, pINFO = 1, pERROR = 2 }
 
typedef std::map< DetId,
EcalRecHit
RecHitsMap
 

Public Member Functions

float Activation_fun (float SUM)
 
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, DebugLevel_pi0 debugLevel)
 
void findPi0Road (ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
 
std::vector< float > findPreshVector (ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
 
float * get_input_vector ()
 
float GetBarrelNNOutput (float EB_Et)
 
float getNNoutput (int sel_wfile)
 
float GetNNOutput (float EE_Et)
 
bool goodPi0Strip (RecHitsMap::iterator candidate_it, ESDetId lastID)
 
void readWeightFile (const char *WFile)
 
 ~EndcapPiZeroDiscriminatorAlgo ()
 

Private Attributes

int barrelstart
 
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
 
float * H_O_Weight
 
std::vector< float > H_O_Weight_all
 
float * H_Thresh
 
std::vector< float > H_Thresh_all
 
int Hidden
 
float * I_H_Weight
 
std::vector< float > I_H_Weight_all
 
int Indim
 
int inp_var
 
float * input_var
 
int Layers
 
int Nfiles_EB
 
int Nfiles_EE
 
float * O_Thresh
 
std::vector< float > O_Thresh_all
 
int Outdim
 
std::string pathToFiles_
 
int preshSeededNstr_
 
double preshStripEnergyCut_
 
RecHitsMaprechits_map
 

Detailed Description

Definition at line 16 of file EndcapPiZeroDiscriminatorAlgo.h.

Member Typedef Documentation

Definition at line 22 of file EndcapPiZeroDiscriminatorAlgo.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( )
inline
EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo ( double  stripEnergyCut,
int  nStripCut,
const std::string &  path,
DebugLevel_pi0  debugLevel 
)
EndcapPiZeroDiscriminatorAlgo::~EndcapPiZeroDiscriminatorAlgo ( )
inline

Definition at line 31 of file EndcapPiZeroDiscriminatorAlgo.h.

31 {};

Member Function Documentation

float EndcapPiZeroDiscriminatorAlgo::Activation_fun ( float  SUM)

Definition at line 331 of file EndcapPiZeroDiscriminatorAlgo.cc.

References funct::exp().

Referenced by getNNoutput().

331  {
332  return( 1.0 / ( 1.0 + exp(-2.0*SUM) ) );
333 }
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
#define SUM(A, B)
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 473 of file EndcapPiZeroDiscriminatorAlgo.cc.

References EB_Indim, input_var, lam, and mathSSE::sqrt().

477 {
478  input_var = new float[EB_Indim];
479 
480  double lam, lam1, lam2;
481 
482  if(xcog < 0.) {
483  input_var[0] = -xcog/s25;
484  } else {
485  input_var[0] = xcog/s25;
486  }
487 
488  input_var[1] = cee/0.0004;
489 
490  if(cpp<.001) {
491  input_var[2] = cpp/.001;
492  } else {
493  input_var[2] = 0.;
494  }
495 
496  if(s9!=0.) {
497  input_var[3] = s1/s9;
498  input_var[8] = s6/s9;
499  input_var[10] = (m2+s1)/s9;
500  }
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 
542 }
T sqrt(T t)
Definition: SSEVec.h:28
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 345 of file EndcapPiZeroDiscriminatorAlgo.cc.

References gather_cfg::cout, debugLevel_, ExpressReco_HICollisions_FallBack::e, EE_Indim, i, input_var, gen::k, and pDEBUG.

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

Definition at line 163 of file EndcapPiZeroDiscriminatorAlgo.cc.

References gather_cfg::cout, debugLevel_, CaloNavigator< T >::east(), CaloNavigator< T >::home(), CaloNavigator< T >::north(), pDEBUG, preshSeededNstr_, CaloNavigator< T >::setHome(), CaloNavigator< T >::south(), strip(), and CaloNavigator< T >::west().

Referenced by findPreshVector().

164  {
165  if ( strip == ESDetId(0) ) return;
166  ESDetId next;
167  theESNav.setHome(strip);
168 
169  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip << endl;
170  if (plane == 1) {
171  // east road
172  int n_east= 0;
173  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East " << endl;
174  while ( ((next=theESNav.east()) != ESDetId(0) && next != strip) ) {
175  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is " << next << endl;
176  vout.push_back(next);
177  ++n_east;
178  if (n_east == preshSeededNstr_) break;
179  }
180  // west road
181  int n_west= 0;
182  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West " << endl;
183  theESNav.home();
184  while ( ((next=theESNav.west()) != ESDetId(0) && next != strip )) {
185  if ( debugLevel_ == pDEBUG ) cout << "findPi0Road: West: " << n_west << " current strip is " << next << endl;
186  vout.push_back(next);
187  ++n_west;
188  if (n_west == preshSeededNstr_) break;
189  }
190  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is " << n_east+n_west << endl;
191  }
192  else if (plane == 2) {
193  // north road
194  int n_north= 0;
195  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North " << endl;
196  while ( ((next=theESNav.north()) != ESDetId(0) && next != strip) ) {
197  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north << " current strip is " << next << endl;
198  vout.push_back(next);
199  ++n_north;
200  if (n_north == preshSeededNstr_) break;
201  }
202  // south road
203  int n_south= 0;
204  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South " << endl;
205  theESNav.home();
206  while ( ((next=theESNav.south()) != ESDetId(0) && next != strip) ) {
207  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south << " current strip is " << next << endl;
208  vout.push_back(next);
209  ++n_south;
210  if (n_south == preshSeededNstr_) break;
211  }
212  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is " << n_south+n_north << endl;
213  }
214  else {
215  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! " << endl;
216  } // end of if
217 
218  theESNav.home();
219 }
void setHome(const T &startingPoint)
set the starting position
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void home() const
move the navigator back to the starting point
virtual T west() const
move the navigator west
Definition: CaloNavigator.h:81
virtual T north() const
move the navigator north
Definition: CaloNavigator.h:51
virtual T east() const
move the navigator east
Definition: CaloNavigator.h:71
tuple cout
Definition: gather_cfg.py:41
virtual T south() const
move the navigator south
Definition: CaloNavigator.h:61
vector< float > EndcapPiZeroDiscriminatorAlgo::findPreshVector ( ESDetId  strip,
RecHitsMap rechits_map,
CaloSubdetectorTopology topology_p 
)

Definition at line 63 of file EndcapPiZeroDiscriminatorAlgo.cc.

References gather_cfg::cout, debugLevel_, findPi0Road(), goodPi0Strip(), i, pDEBUG, ESDetId::plane(), CaloNavigator< T >::setHome(), and ESDetId::strip().

65 {
66  vector<float> vout_stripE;
67 
68  // skip if rechits_map contains no hits
69  if ( rechits_map->size() == 0 ) {
70  edm::LogWarning("EndcapPiZeroDiscriminatorAlgo") << "RecHitsMap has size 0.";
71  return vout_stripE;
72  }
73 
74  vout_stripE.clear();
75 
76  vector<ESDetId> road_2d;
77  road_2d.clear();
78 
79  int plane = strip.plane();
80 
81  if ( debugLevel_ <= pDEBUG ) {
82  cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters" << "n"
83  << "findPreshVectors: Preshower is intersected at strip " << strip.strip() << ", at plane " << plane << endl;
84  }
85 
86  if ( strip == ESDetId(0) ) { //works in case of no intersected strip found
87  for(int i=0;i<11;i++) {
88  vout_stripE.push_back(-100.);
89  }
90  }
91 
92  // Add to the road the central strip
93  road_2d.push_back(strip);
94 
95  //Make a navigator, and set it to the strip cell.
96  EcalPreshowerNavigator navigator(strip, topology_p);
97  navigator.setHome(strip);
98  //search for neighbours in the central road
99  findPi0Road(strip, navigator, plane, road_2d);
100  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: " << road_2d.size() << endl;
101 
102  // Find the energy of each strip
103  RecHitsMap::iterator final_strip = rechits_map->end();
104  // very dangerous, added a protection on the rechits_map->size()
105  // at the beginning of the method
106  final_strip--;
107  ESDetId last_stripID = final_strip->first;
108 
109  float E = 0;
110  vector<ESDetId>::iterator itID;
111  for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
112  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID << endl;
113  RecHitsMap::iterator strip_it = rechits_map->find(*itID);
114  if(goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map
115  E = strip_it->second.energy();
116  } else E = 0;
117  vout_stripE.push_back(E);
118  if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E << endl;
119  }
120 
121  // ***ML beg***
122  // vector of size=11, content of vout_stripE is copied into vout_ElevenStrips_Energy
123  // to avoid problem in case number of strips is less than 11
124  vector<float> vout_ElevenStrips_Energy;
125  for(int i=0;i<11;i++)
126  {
127  vout_ElevenStrips_Energy.push_back(0.);
128  }
129 
130  for(unsigned int i=0;i<vout_stripE.size();i++)
131  {
132  vout_ElevenStrips_Energy[i] = vout_stripE.at(i);
133  }
134 
135  //return vout_stripE;
136  return vout_ElevenStrips_Energy;
137  // ***ML end***
138 
139 }
void findPi0Road(ESDetId strip, EcalPreshowerNavigator &theESNav, int plane, std::vector< ESDetId > &vout)
int i
Definition: DBlmapReader.cc:9
int strip() const
Definition: ESDetId.h:41
bool goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
int plane() const
Definition: ESDetId.h:35
tuple cout
Definition: gather_cfg.py:41
float* EndcapPiZeroDiscriminatorAlgo::get_input_vector ( )
inline
float EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput ( float  EB_Et)

Definition at line 586 of file EndcapPiZeroDiscriminatorAlgo.cc.

References barrelstart, gather_cfg::cout, debugLevel_, EB_Hidden, EB_Indim, EB_Layers, EB_Outdim, getNNoutput(), Indim, input_var, Layers, Outdim, and pDEBUG.

587 {
588 
590 
591  float nnout = -1;
592 // Print the NN input variables that are related to the ECAL Barrel
593 // ------------------------------------------------------------------------
594  if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = " ;
595  for(int k1=0;k1<Indim;k1++) {
596  if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
597  }
598  if ( debugLevel_ <= pDEBUG )cout << endl;
599 
600  // select the appropriate Weigth file
601  int sel_wfile;
602  if(EB_Et<25.0) {sel_wfile = 0;}
603  else if(EB_Et>=25.0 && EB_Et<35.0) {sel_wfile = 1;}
604  else if(EB_Et>=35.0 && EB_Et<45.0) {sel_wfile = 2;}
605  else if(EB_Et>=45.0 && EB_Et<55.0) {sel_wfile = 3;}
606  else {sel_wfile = 4;}
607 
608  if ( debugLevel_ <= pDEBUG ) {
609  cout << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et << " and I select Weight file Number = " << sel_wfile << endl;
610  }
611 
612  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
613  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
614 
615  return nnout;
616 }
tuple cout
Definition: gather_cfg.py:41
float EndcapPiZeroDiscriminatorAlgo::getNNoutput ( int  sel_wfile)

Definition at line 291 of file EndcapPiZeroDiscriminatorAlgo.cc.

References Activation_fun(), barrelstart, gather_cfg::cout, debugLevel_, EE_Hidden, EE_Indim, EE_Outdim, h, H_O_Weight_all, H_Thresh_all, Hidden, i, I_H_Weight_all, Indim, input_var, gen::k, O_Thresh_all, Outdim, and pDEBUG.

Referenced by GetBarrelNNOutput(), and GetNNOutput().

292 {
293  float* I_SUM;
294  float* OUT;
295  float nnout=0.0;
296  int mij;
297 
298  I_SUM = new float[Hidden];
299  OUT = new float[Outdim];
300 
301  for(int k=0;k<Hidden;k++) I_SUM[k]=0.0;
302  for(int k1=0;k1<Outdim;k1++) OUT[k1]=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] * input_var[i];
309  }
310  I_SUM[h] += H_Thresh_all[h+sel_wfile*Hidden + barrelstart*Nfiles_EE*EE_Hidden];
311  for (int o1 = 0; o1<Outdim; o1++) {
312  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]);
313 
314  }
315  }
316  for (int o2 = 0; o2<Outdim; o2++){
317  OUT[o2] += O_Thresh_all[barrelstart*Nfiles_EE*EE_Outdim + o2 + sel_wfile*Outdim];
318  }
319  nnout = Activation_fun(OUT[0]);
320 
321  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " << nnout << endl;
322 
323  delete I_SUM;
324  delete OUT;
325  delete input_var;
326 
327  return (nnout);
328 }
int i
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
tuple cout
Definition: gather_cfg.py:41
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
float EndcapPiZeroDiscriminatorAlgo::GetNNOutput ( float  EE_Et)

Definition at line 550 of file EndcapPiZeroDiscriminatorAlgo.cc.

References barrelstart, gather_cfg::cout, debugLevel_, EE_Hidden, EE_Indim, EE_Layers, EE_Outdim, getNNoutput(), Indim, input_var, Layers, Outdim, and pDEBUG.

551 {
553 
554  float nnout = -1;
555 // Print the NN input variables that are related to the Preshower + ECAL
556 // ------------------------------------------------------------------------
557  if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = " ;
558  for(int k1=0;k1<Indim;k1++) {
559  if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
560  }
561  if ( debugLevel_ <= pDEBUG )cout << endl;
562 
563  // select the appropriate Weigth file
564  int sel_wfile;
565  if(EE_Et<25.0) {sel_wfile = 0;}
566  else if(EE_Et>=25.0 && EE_Et<35.0) {sel_wfile = 1;}
567  else if(EE_Et>=35.0 && EE_Et<45.0) {sel_wfile = 2;}
568  else if(EE_Et>=45.0 && EE_Et<55.0) {sel_wfile = 3;}
569  else {sel_wfile = 4;}
570 
571  if ( debugLevel_ <= pDEBUG ) {
572  cout << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et << " and I select Weight file Number = " << sel_wfile << endl;
573  }
574 
575  nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
576  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout << endl;
577  return nnout;
578 }
tuple cout
Definition: gather_cfg.py:41
bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip ( RecHitsMap::iterator  candidate_it,
ESDetId  lastID 
)

Definition at line 142 of file EndcapPiZeroDiscriminatorAlgo.cc.

References gather_cfg::cout, debugLevel_, pDEBUG, and preshStripEnergyCut_.

Referenced by findPreshVector().

143 {
144  RecHitsMap::iterator candidate_tmp = candidate_it;
145  candidate_tmp--;
146  if ( debugLevel_ == pDEBUG ) {
147  if (candidate_tmp->first == lastID )
148  cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map " << endl;
149  if (candidate_it->second.energy() <= preshStripEnergyCut_)
150  cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " << candidate_it->second.energy() <<" is below threshold " << endl;
151  }
152  // crystal should not be included...
153  if ( (candidate_tmp->first == lastID ) || // ...if it corresponds to a hit
154  (candidate_it->second.energy() <= preshStripEnergyCut_ ) ) // ...if it has a negative or zero energy
155  {
156  return false;
157  }
158 
159  return true;
160 }
tuple cout
Definition: gather_cfg.py:41
void EndcapPiZeroDiscriminatorAlgo::readWeightFile ( const char *  WFile)

Definition at line 227 of file EndcapPiZeroDiscriminatorAlgo.cc.

References gather_cfg::cout, debugLevel_, H_O_Weight, H_Thresh, Hidden, I_H_Weight, Indim, inp_var, j, Layers, geometryCSVtoXML::line, O_Thresh, Outdim, pDEBUG, and ExpressReco_HICollisions_FallBack::weights.

227  {
228  FILE *weights;
229 
230  char *line;
231  line = new char[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  if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file = " << Weights_file << endl;
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  inp_var = Indim + 1;
249 
250  I_H_Weight = new float[Indim*Hidden];
251  H_Thresh = new float[Hidden];
252  H_O_Weight = new float[Hidden*Outdim];
253  O_Thresh = new float[Outdim];
254  checkinit=true;
255  }else if (line[0] == 'B') { // read in weights between hidden and intput nodes
256  assert(checkinit);
257  for (int i = 0; i<Indim; i++){
258  for (int j = 0; j<Hidden; j++){
259  fscanf(weights, "%f", &I_H_Weight[i*Hidden+j]);
260  }
261  }
262  }else if (line[0] == 'C'){ // Read in the thresholds for hidden nodes
263  assert(checkinit);
264  for (int i = 0; i<Hidden; i++){
265  fscanf(weights, "%f", &H_Thresh[i]);
266  }
267  }else if (line[0] == 'D'){ // read in weights between hidden and output nodes
268  assert(checkinit);
269  for (int i = 0; i<Hidden*Outdim; i++){
270  fscanf(weights, "%f", &H_O_Weight[i]);
271  }
272  }else if (line[0] == 'E'){ // read in the threshold for the output nodes
273  assert(checkinit);
274  for (int i = 0; i<Outdim; i++){
275  fscanf(weights, "%f", &O_Thresh[i]);
276 
277  }
278  }
279  else{cout << "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
280  }
281  }
282  fclose(weights);
283 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

int EndcapPiZeroDiscriminatorAlgo::barrelstart
private

Definition at line 67 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput(), getNNoutput(), and GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::debugLevel_
private
int EndcapPiZeroDiscriminatorAlgo::EB_Hidden
private

Definition at line 74 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EB_Indim
private
int EndcapPiZeroDiscriminatorAlgo::EB_Layers
private

Definition at line 74 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EB_Outdim
private

Definition at line 74 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Hidden
private

Definition at line 73 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Indim
private
int EndcapPiZeroDiscriminatorAlgo::EE_Layers
private

Definition at line 73 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetNNOutput().

int EndcapPiZeroDiscriminatorAlgo::EE_Outdim
private

Definition at line 73 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and GetNNOutput().

float* EndcapPiZeroDiscriminatorAlgo::H_O_Weight
private

Definition at line 77 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

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

Definition at line 82 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

float* EndcapPiZeroDiscriminatorAlgo::H_Thresh
private

Definition at line 78 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

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

Definition at line 83 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Hidden
private

Definition at line 72 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput(), and readWeightFile().

float* EndcapPiZeroDiscriminatorAlgo::I_H_Weight
private

Definition at line 76 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

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

Definition at line 81 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Indim
private
int EndcapPiZeroDiscriminatorAlgo::inp_var
private

Definition at line 66 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

float* EndcapPiZeroDiscriminatorAlgo::input_var
private
int EndcapPiZeroDiscriminatorAlgo::Layers
private

Definition at line 72 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by GetBarrelNNOutput(), GetNNOutput(), and readWeightFile().

int EndcapPiZeroDiscriminatorAlgo::Nfiles_EB
private

Definition at line 69 of file EndcapPiZeroDiscriminatorAlgo.h.

int EndcapPiZeroDiscriminatorAlgo::Nfiles_EE
private

Definition at line 70 of file EndcapPiZeroDiscriminatorAlgo.h.

float* EndcapPiZeroDiscriminatorAlgo::O_Thresh
private

Definition at line 79 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by readWeightFile().

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

Definition at line 84 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by getNNoutput().

int EndcapPiZeroDiscriminatorAlgo::Outdim
private
std::string EndcapPiZeroDiscriminatorAlgo::pathToFiles_
private

Definition at line 94 of file EndcapPiZeroDiscriminatorAlgo.h.

int EndcapPiZeroDiscriminatorAlgo::preshSeededNstr_
private

Definition at line 63 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by findPi0Road().

double EndcapPiZeroDiscriminatorAlgo::preshStripEnergyCut_
private

Definition at line 58 of file EndcapPiZeroDiscriminatorAlgo.h.

Referenced by goodPi0Strip().

RecHitsMap* EndcapPiZeroDiscriminatorAlgo::rechits_map
private

Definition at line 91 of file EndcapPiZeroDiscriminatorAlgo.h.