CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoEcal/EgammaClusterAlgos/src/EndcapPiZeroDiscriminatorAlgo.cc

Go to the documentation of this file.
00001 
00002 #include "RecoEcal/EgammaClusterAlgos/interface/EndcapPiZeroDiscriminatorAlgo.h"
00003 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00004 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/ParameterSet/interface/FileInPath.h"
00008 #include <fstream>
00009 #include <iostream>
00010 
00011 using namespace std;
00012 
00013 EndcapPiZeroDiscriminatorAlgo::EndcapPiZeroDiscriminatorAlgo(double stripEnergyCut, int nStripCut, const string& path,
00014                                  DebugLevel_pi0 debugLevel = pINFO ) :
00015    preshStripEnergyCut_(stripEnergyCut),  preshSeededNstr_(nStripCut), debugLevel_(debugLevel), pathToFiles_(path)
00016 {   
00017    
00018      // Read all Weight files
00019      Nfiles_EB = 5;
00020      Nfiles_EE = 5;
00021      string file_pt[5] = {"20","30","40","50","60"};
00022      string file_barrel_pt[5] = {"20","30","40","50","60"};   
00023 
00024      string nn_paterns_file  = "";
00025      for(int j=0;j<Nfiles_EE;j++) {
00026        nn_paterns_file = "endcapPiZeroDiscriminatorWeights_et"+file_pt[j]+".wts";
00027        edm::FileInPath WFile(pathToFiles_+nn_paterns_file);
00028        readWeightFile(WFile.fullPath().c_str()); // read the weights' file
00029 
00030        EE_Layers = Layers;
00031        EE_Indim = Indim;
00032        EE_Hidden = Hidden;
00033        EE_Outdim = Outdim;
00034           
00035        for(int i=0;i<Indim*Hidden;i++)  I_H_Weight_all.push_back(I_H_Weight[i]);
00036        for(int i=0;i<Hidden;i++)  H_Thresh_all.push_back(H_Thresh[i]);
00037        for(int i=0;i<Outdim*Hidden;i++)  H_O_Weight_all.push_back(H_O_Weight[i]);
00038        for(int i=0;i<Outdim;i++)  O_Thresh_all.push_back(O_Thresh[i]);
00039      }
00040 
00041      for(int k=0;k<Nfiles_EB;k++) {
00042        nn_paterns_file = "barrelPiZeroDiscriminatorWeights_et"+file_barrel_pt[k]+".wts";
00043        edm::FileInPath WFile(pathToFiles_+nn_paterns_file);
00044        readWeightFile(WFile.fullPath().c_str()); // read the weights' file
00045 
00046        EB_Layers = Layers;
00047        EB_Indim = Indim;
00048        EB_Hidden = Hidden;
00049        EB_Outdim = Outdim;
00050 
00051        for(int i=0;i<Indim*Hidden;i++)  I_H_Weight_all.push_back(I_H_Weight[i]);
00052        for(int i=0;i<Hidden;i++)  H_Thresh_all.push_back(H_Thresh[i]);
00053        for(int i=0;i<Outdim*Hidden;i++)  H_O_Weight_all.push_back(H_O_Weight[i]);
00054        for(int i=0;i<Outdim;i++)  O_Thresh_all.push_back(O_Thresh[i]);
00055      }
00056    delete [] I_H_Weight;
00057    delete [] H_Thresh;
00058    delete [] H_O_Weight;
00059    delete [] O_Thresh;
00060 }
00061 
00062 
00063 vector<float> EndcapPiZeroDiscriminatorAlgo::findPreshVector(ESDetId strip,  RecHitsMap *rechits_map,
00064                                                      CaloSubdetectorTopology *topology_p)
00065 {
00066   vector<float> vout_stripE;
00067 
00068   // skip if rechits_map contains no hits
00069   if ( rechits_map->size() == 0 ) {
00070           edm::LogWarning("EndcapPiZeroDiscriminatorAlgo") << "RecHitsMap has size 0.";
00071           return vout_stripE;
00072   }
00073 
00074   vout_stripE.clear();
00075 
00076   vector<ESDetId> road_2d;
00077   road_2d.clear();
00078 
00079   int plane = strip.plane();
00080 
00081   if ( debugLevel_ <= pDEBUG ) {
00082     cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: Preshower Seeded Algorithm - looking for clusters" << "n"
00083               << "findPreshVectors: Preshower is intersected at strip " << strip.strip() << ", at plane " << plane << endl;
00084   }
00085 
00086   if ( strip == ESDetId(0) ) { //works in case of no intersected strip found
00087     for(int i=0;i<11;i++) {
00088        vout_stripE.push_back(-100.);
00089     }
00090   }
00091 
00092   // Add to the road the central strip
00093   road_2d.push_back(strip);
00094 
00095   //Make a navigator, and set it to the strip cell.
00096   EcalPreshowerNavigator navigator(strip, topology_p);
00097   navigator.setHome(strip);
00098  //search for neighbours in the central road
00099   findPi0Road(strip, navigator, plane, road_2d);
00100   if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo:findPreshVectors: Total number of strips in the central road: " << road_2d.size() << endl;
00101 
00102   // Find the energy of each strip
00103   RecHitsMap::iterator final_strip =  rechits_map->end();
00104   // very dangerous, added a protection on the rechits_map->size()
00105   // at the beginning of the method
00106   final_strip--;
00107   ESDetId last_stripID = final_strip->first;
00108 
00109   float E = 0;
00110   vector<ESDetId>::iterator itID;
00111   for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
00112     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID << endl;
00113     RecHitsMap::iterator strip_it = rechits_map->find(*itID);
00114     if(goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map
00115       E = strip_it->second.energy();
00116     } else  E = 0;
00117     vout_stripE.push_back(E);
00118     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: E = " << E <<  endl;
00119   }
00120  
00121   // ***ML beg***
00122   // vector of size=11, content of vout_stripE is copied into vout_ElevenStrips_Energy
00123   // to avoid problem in case number of strips is less than 11
00124   vector<float> vout_ElevenStrips_Energy;
00125   for(int i=0;i<11;i++)
00126   {
00127     vout_ElevenStrips_Energy.push_back(0.);
00128   }
00129   
00130   for(unsigned int i=0;i<vout_stripE.size();i++)
00131   {
00132     vout_ElevenStrips_Energy[i] = vout_stripE.at(i);
00133   }
00134 
00135   //return vout_stripE;
00136   return vout_ElevenStrips_Energy;
00137   // ***ML end***
00138 
00139 }
00140 
00141 // returns true if the candidate strip fulfills the requirements to be added to the cluster:
00142 bool EndcapPiZeroDiscriminatorAlgo::goodPi0Strip(RecHitsMap::iterator candidate_it, ESDetId lastID)
00143 {
00144   RecHitsMap::iterator candidate_tmp = candidate_it;
00145   candidate_tmp--;
00146   if ( debugLevel_ == pDEBUG ) {
00147     if (candidate_tmp->first == lastID )
00148         cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip No such a strip in rechits_map " << endl;
00149     if (candidate_it->second.energy() <= preshStripEnergyCut_)
00150         cout << "EndcapPiZeroDiscriminatorAlgo: goodPi0Strip Strip energy " << candidate_it->second.energy() <<" is below threshold " << endl;
00151   }
00152   // crystal should not be included...
00153   if ( (candidate_tmp->first == lastID )                    ||       // ...if it corresponds to a hit
00154        (candidate_it->second.energy() <= preshStripEnergyCut_ ) )   // ...if it has a negative or zero energy
00155     {
00156       return false;
00157     }
00158 
00159   return true;
00160 }
00161 
00162 // find strips in the road of size +/- preshSeededNstr_ from the central strip
00163 void EndcapPiZeroDiscriminatorAlgo::findPi0Road(ESDetId strip, EcalPreshowerNavigator& theESNav,
00164                                                                 int plane, vector<ESDetId>& vout) {
00165   if ( strip == ESDetId(0) ) return;
00166    ESDetId next;
00167    theESNav.setHome(strip);
00168 
00169    if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: starts from strip " << strip << endl;
00170    if (plane == 1) {
00171      // east road
00172      int n_east= 0;
00173      if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the East " <<  endl;
00174      while ( ((next=theESNav.east()) != ESDetId(0) && next != strip) ) {
00175         if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: East: " << n_east << " current strip is " << next << endl;
00176         vout.push_back(next);
00177         ++n_east;
00178         if (n_east == preshSeededNstr_) break;
00179      }
00180      // west road
00181      int n_west= 0;
00182      if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the West " <<  endl;
00183      theESNav.home();
00184      while ( ((next=theESNav.west()) != ESDetId(0) && next != strip )) {
00185         if ( debugLevel_ == pDEBUG ) cout << "findPi0Road: West: " << n_west << " current strip is " << next << endl;
00186         vout.push_back(next);
00187         ++n_west;
00188         if (n_west == preshSeededNstr_) break;
00189      }
00190      if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 1-st plane is " << n_east+n_west << endl;
00191   }
00192   else if (plane == 2) {
00193     // north road
00194     int n_north= 0;
00195     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the North " <<  endl;
00196     while ( ((next=theESNav.north()) != ESDetId(0) && next != strip) ) {
00197        if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: North: " << n_north << " current strip is " << next << endl;
00198        vout.push_back(next);
00199        ++n_north;
00200        if (n_north == preshSeededNstr_) break;
00201     }
00202     // south road
00203     int n_south= 0;
00204     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Go to the South " <<  endl;
00205     theESNav.home();
00206     while ( ((next=theESNav.south()) != ESDetId(0) && next != strip) ) {
00207        if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: South: " << n_south << " current strip is " << next << endl;
00208        vout.push_back(next);
00209        ++n_south;
00210        if (n_south == preshSeededNstr_) break;
00211     }
00212     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Total number of strips found in the road at 2-nd plane is " << n_south+n_north << endl;
00213   }
00214   else {
00215     if ( debugLevel_ == pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: findPi0Road: Wrong plane number, null cluster will be returned! " << endl;
00216   } // end of if
00217 
00218   theESNav.home();
00219 }
00220 
00221 
00222 //===================================================================
00223 // EndcapPiZeroDiscriminatorAlgo::readWeightFile(...), a method that reads the weigths of the NN
00224 // INPUT: Weights_file
00225 // OUTPUT: I_H_Weight, H_Thresh, H_O_Weight, O_Thresh arrays
00226 //===================================================================
00227 void EndcapPiZeroDiscriminatorAlgo::readWeightFile(const char *Weights_file){
00228    FILE *weights;
00229 
00230    char *line;
00231    line = new char[80];
00232 
00233    bool checkinit=false;
00234 // Open the weights file, generated by jetnet, and read
00235 // in the nodes and weights
00236 //*******************************************************
00237   weights = fopen(Weights_file, "r");
00238   if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: I opeded the Weights file  = " << Weights_file << endl;
00239 
00240   while( !feof(weights) ){
00241         fscanf(weights, "%s", line);
00242         if (line[0] == 'A') { //Read in ANN nodes: Layers, input , Hidden, Output
00243            fscanf(weights, "%d", &Layers);       // # of NN Layers  used
00244            fscanf(weights, "%d", &Indim);        // # of Inputs actually used
00245            fscanf(weights, "%d", &Hidden);       // # of hidden nodes
00246            fscanf(weights, "%d", &Outdim);   // # of output nodes
00247 
00248            inp_var = Indim + 1;
00249 
00250            I_H_Weight = new float[Indim*Hidden];
00251            H_Thresh = new float[Hidden];
00252            H_O_Weight = new float[Hidden*Outdim];
00253            O_Thresh = new float[Outdim];
00254            checkinit=true;
00255         }else if (line[0] == 'B') { // read in weights between hidden and intput nodes
00256             assert(checkinit);
00257             for (int i = 0; i<Indim; i++){
00258                 for (int j = 0; j<Hidden; j++){
00259                     fscanf(weights, "%f", &I_H_Weight[i*Hidden+j]);
00260                 }
00261             }
00262         }else if (line[0] == 'C'){       // Read in the thresholds for hidden nodes
00263             assert(checkinit);
00264             for (int i = 0; i<Hidden; i++){
00265                 fscanf(weights, "%f", &H_Thresh[i]);
00266             }
00267         }else if (line[0] == 'D'){ // read in weights between hidden and output nodes
00268             assert(checkinit);
00269             for (int i = 0; i<Hidden*Outdim; i++){
00270                 fscanf(weights, "%f", &H_O_Weight[i]);
00271             }
00272         }else if (line[0] == 'E'){ // read in the threshold for the output nodes
00273             assert(checkinit);
00274             for (int i = 0; i<Outdim; i++){
00275                 fscanf(weights, "%f", &O_Thresh[i]);
00276 
00277             }
00278         }
00279           else{cout << "EndcapPiZeroDiscriminatorAlgo: Not a Net file of Corrupted Net file " << endl;
00280         }
00281    }
00282    fclose(weights);
00283 }
00284 
00285 //=====================================================================================
00286 // EndcapPiZeroDiscriminatorAlgo::getNNoutput(int sel_wfile), a method that calculated the NN output
00287 // INPUT: sel_wfile -> Weight file selection
00288 // OUTPUT : nnout -> the NN output
00289 //=====================================================================================
00290 
00291 float EndcapPiZeroDiscriminatorAlgo::getNNoutput(int sel_wfile)
00292 {
00293  float* I_SUM;
00294  float* OUT;
00295  float nnout=0.0;
00296  int mij;
00297 
00298  I_SUM = new float[Hidden];
00299  OUT = new  float[Outdim];
00300 
00301  for(int k=0;k<Hidden;k++) I_SUM[k]=0.0;
00302  for(int k1=0;k1<Outdim;k1++) OUT[k1]=0.0;
00303 
00304  for (int h = 0; h<Hidden; h++){
00305      mij = h - Hidden;
00306      for (int i = 0; i<Indim; i++){
00307          mij = mij + Hidden;
00308          I_SUM[h] += I_H_Weight_all[mij+sel_wfile*Indim*Hidden + barrelstart*Nfiles_EE*EE_Indim*EE_Hidden] * input_var[i];
00309      }
00310      I_SUM[h] += H_Thresh_all[h+sel_wfile*Hidden + barrelstart*Nfiles_EE*EE_Hidden];
00311      for (int o1 = 0; o1<Outdim; o1++) {
00312         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]); 
00313 
00314      }
00315  }
00316  for (int o2 = 0; o2<Outdim; o2++){      
00317                 OUT[o2] += O_Thresh_all[barrelstart*Nfiles_EE*EE_Outdim + o2 + sel_wfile*Outdim]; 
00318   }
00319   nnout = Activation_fun(OUT[0]);
00320 
00321   if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: getNNoutput :: -> NNout = " <<  nnout << endl;
00322 
00323   delete I_SUM;
00324   delete OUT;
00325   delete input_var;
00326    
00327   return (nnout);
00328 }
00329 
00330 
00331 float EndcapPiZeroDiscriminatorAlgo::Activation_fun(float SUM){
00332         return( 1.0 / ( 1.0 + exp(-2.0*SUM) ) );
00333 }
00334 //=====================================================================================
00335 // EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables(...), a method that calculates the 25 input variables
00336 // INPUTS:
00337 // vph1 -> vector of the stip energies in 1st Preshower plane
00338 // vph2 -> vector of the stip energies in 2nd Preshower plane
00339 // pS1_max -> E1
00340 // pS9_max -> E9
00341 // pS25_max -> E25
00342 // OUTPUT: 
00343 // input_var[25] -> the 25 input to the NN variables array
00344 //=====================================================================================
00345 bool EndcapPiZeroDiscriminatorAlgo::calculateNNInputVariables(vector<float>& vph1, vector<float>& vph2, 
00346                                           float pS1_max, float pS9_max, float pS25_max, int EScorr)
00347 {
00348    input_var = new float[EE_Indim];
00349 
00350    bool valid_NNinput = true;
00351    
00352    if ( debugLevel_ <= pDEBUG ) {
00353      cout << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in X plane = ( "; 
00354      for(int i = 0; i<11;i++) {
00355         cout << " " << vph1[i];
00356      }
00357      cout << ")" << endl;
00358      cout << "EndcapPiZeroDiscriminatorAlgo: Energies of the Preshower Strips in Y plane = ( "; 
00359      for(int i = 0; i<11;i++) {
00360         cout << " " << vph2[i];
00361      }
00362      cout << ")" << endl;
00363    }
00364    // check if all Preshower info is availabla - If NOT use remaning info
00365    for(int k = 0; k<11; k++) {
00366       if(vph1[k] < 0 ) {
00367          if ( debugLevel_ <= pDEBUG ) { 
00368            cout  << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of X plane Do not exists" << endl; 
00369          }  
00370          vph1[k] = 0.0;
00371       }          
00372       if(vph2[k] < 0 ) { 
00373         if ( debugLevel_ <= pDEBUG ) { 
00374           cout  << "EndcapPiZeroDiscriminatorAlgo: Oops!!! Preshower Info for strip : " << k << " of Y plane Do not exists" << endl;
00375         }
00376         vph2[k] = 0.0;
00377       }
00378    }   
00379    if ( debugLevel_ <= pDEBUG ) {
00380      cout << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in X plane = ( "; 
00381      for(int i = 0; i<11;i++) {
00382         cout << " " << vph1[i];
00383      }
00384      cout << ")" << endl;
00385      cout << "EndcapPiZeroDiscriminatorAlgo: After: Energies of the Preshower Strips in Y plane = ( "; 
00386      for(int i = 0; i<11;i++) {
00387         cout << " " << vph2[i];
00388      }
00389      cout << ")" << endl;
00390    }
00391 
00392 // FIRST : Produce the 22 NN variables related with the Preshower 
00393 // --------------------------------------------------------------
00394 // New normalization of the preshower strip energies Aris 8/11/2004
00395    for(int kk=0;kk<11;kk++){
00396      input_var[kk] = fabs(vph1[kk]/0.01);
00397      input_var[kk + 11] = fabs(vph2[kk]/0.02);       
00398      if(input_var[kk] < 0.0001) input_var[kk] = 0.;
00399      if(input_var[kk + 11] < 0.0001) input_var[kk + 11] = 0.;
00400    }
00401    input_var[0] = fabs(input_var[0]/2.); 
00402    input_var[1] = fabs(input_var[1]/2.); 
00403    input_var[6] = fabs(input_var[6]/2.); 
00404    input_var[11] = fabs(input_var[11]/2.); 
00405    input_var[12] = fabs(input_var[12]/2.); 
00406    input_var[17] = fabs(input_var[17]/2.); 
00407    
00408 // correction for version > CMSSW_3_1_0_pre5 where extra enegry is given to the ES strips 
00409 // Aris 18/5/2009   
00410    if( EScorr == 1) { 
00411      input_var[0] -= 0.05;
00412      input_var[1] -= 0.035;
00413      input_var[2] -= 0.035;
00414      input_var[3] -= 0.02;
00415      input_var[4] -= 0.015;
00416      input_var[5] -= 0.0075;
00417      input_var[6] -= 0.035;
00418      input_var[7] -= 0.035;
00419      input_var[8] -= 0.02;
00420      input_var[9] -= 0.015;
00421      input_var[10] -= 0.0075;
00422     
00423      input_var[11] -= 0.05;
00424      input_var[12] -= 0.035;
00425      input_var[13] -= 0.035;
00426      input_var[14] -= 0.02;
00427      input_var[15] -= 0.015;
00428      input_var[16] -= 0.0075;
00429      input_var[17] -= 0.035;
00430      input_var[18] -= 0.035;
00431      input_var[19] -= 0.02;
00432      input_var[20] -= 0.015;
00433      input_var[21] -= 0.0075;   
00434      
00435      for(int kk1=0;kk1<22;kk1++){
00436        if(input_var[kk1] < 0 ) input_var[kk1] = 0.0;   
00437      }
00438    }
00439 // SECOND: Take the final NN variable related to the ECAL
00440 // -----------------------------------------------
00441    float ECAL_norm_factor = 500.;
00442    if(pS25_max>500&&pS25_max<=1000) ECAL_norm_factor = 1000;
00443    if(pS25_max>1000) ECAL_norm_factor = 7000;
00444 
00445    input_var[22] = pS1_max/ECAL_norm_factor;
00446    input_var[23] = pS9_max/ECAL_norm_factor;
00447    input_var[24] = pS25_max/ECAL_norm_factor;
00448 
00449    if ( debugLevel_ <= pDEBUG ) {
00450      cout << "EndcapPiZeroDiscriminatorAlgo: S1/ECAL_norm_factor = " << input_var[22] << endl;
00451      cout << "EndcapPiZeroDiscriminatorAlgo: S9/ECAL_norm_factor = " << input_var[23] << endl;
00452      cout << "EndcapPiZeroDiscriminatorAlgo: S25/ECAL_norm_factor = " << input_var[24] << endl;
00453    }
00454    for(int i=0;i<EE_Indim;i++){
00455      if(input_var[i] > 1.0e+00) {
00456        valid_NNinput = false;
00457        break;
00458      }
00459    }
00460    if ( debugLevel_ <= pDEBUG ) {
00461      cout << " valid_NNinput = " << valid_NNinput << endl; }
00462    return valid_NNinput;
00463 }
00464 
00465 
00466 //=====================================================================================
00467 // EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables(...), a method that calculates
00468 // the 12 barrel NN input
00469 // OUTPUT:
00470 // input_var[12] -> the 12 input to the barrel NN variables array
00471 //=====================================================================================
00472 
00473 void EndcapPiZeroDiscriminatorAlgo::calculateBarrelNNInputVariables(float et, double s1, double s9, double s25,
00474                                                                     double m2, double cee, double cep,double cpp,
00475                                                                     double s4, double s6, double ratio,
00476                                                                     double xcog, double ycog)
00477 {
00478   input_var = new float[EB_Indim];
00479 
00480   double lam, lam1, lam2;
00481 
00482   if(xcog < 0.) { 
00483     input_var[0] = -xcog/s25;
00484   } else { 
00485     input_var[0] = xcog/s25;
00486   }    
00487 
00488   input_var[1] = cee/0.0004;
00489 
00490   if(cpp<.001) {
00491     input_var[2] = cpp/.001;
00492   } else  { 
00493     input_var[2] = 0.;
00494   }
00495 
00496   if(s9!=0.) {
00497     input_var[3] = s1/s9; 
00498     input_var[8] = s6/s9; 
00499     input_var[10] = (m2+s1)/s9;
00500   }
00501   else {
00502     input_var[3] = 0.;
00503     input_var[8] = 0.;
00504     input_var[10] = 0.;
00505   }
00506 
00507   if(s25-s1>0.) {
00508     input_var[4] = (s9-s1)/(s25-s1); 
00509   } else {
00510     input_var[4] = 0.;
00511   }  
00512 
00513   if(s25>0.) {
00514     input_var[5] = s4/s25; 
00515   }  else {
00516     input_var[5] = 0.;
00517   } 
00518 
00519   if(ycog < 0.) {
00520     input_var[6] = -ycog/s25; 
00521   } else {
00522     input_var[6] = ycog/s25;
00523   } 
00524 
00525   input_var[7] = ratio;
00526 
00527   lam=sqrt((cee -cpp)*(cee -cpp)+4*cep*cep);
00528   lam1=(cee + cpp + lam)/2;
00529   lam2=(cee + cpp - lam)/2;
00530 
00531   if(lam1 == 0) {
00532     input_var[9] = .0;
00533   } else {
00534     input_var[9] = lam2/lam1;
00535   }
00536   if(s4!=0.) {
00537     input_var[11] = (m2+s1)/s4;
00538   } else {
00539     input_var[11] = 0.;
00540   }
00541 
00542 }
00543 
00544 
00545 //=====================================================================================
00546 // EndcapPiZeroDiscriminatorAlgo::GetNNOutput(...), a method that calculates the NNoutput
00547 // INPUTS: Super Cluster Energy
00548 // OUTPUTS : NNoutput
00549 //=====================================================================================
00550 float EndcapPiZeroDiscriminatorAlgo::GetNNOutput(float EE_Et)
00551 {
00552     Layers = EE_Layers; Indim = EE_Indim; Hidden = EE_Hidden; Outdim = EE_Outdim;  barrelstart = 0;  
00553 
00554     float nnout = -1;
00555 // Print the  NN input variables that are related to the Preshower + ECAL
00556 // ------------------------------------------------------------------------
00557      if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetNNoutput :nn_invar_presh = " ;
00558      for(int k1=0;k1<Indim;k1++) {
00559         if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
00560      }
00561      if ( debugLevel_ <= pDEBUG )cout << endl;
00562 
00563      // select the appropriate Weigth file
00564      int sel_wfile;
00565      if(EE_Et<25.0)                     {sel_wfile = 0;}
00566      else if(EE_Et>=25.0 && EE_Et<35.0) {sel_wfile = 1;}
00567      else if(EE_Et>=35.0 && EE_Et<45.0) {sel_wfile = 2;}
00568      else if(EE_Et>=45.0 && EE_Et<55.0) {sel_wfile = 3;}
00569      else                               {sel_wfile = 4;} 
00570 
00571      if ( debugLevel_ <= pDEBUG ) {
00572          cout << "EndcapPiZeroDiscriminatorAlgo: Et_SC = " << EE_Et << " and I select Weight file Number = " << sel_wfile << endl; 
00573      }
00574 
00575      nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
00576      if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout <<  endl;
00577    return nnout;
00578 }
00579 
00580 
00581 //=====================================================================================
00582 // EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput(...), a method that calculates the barrel NNoutput
00583 // INPUTS: Super Cluster Energy
00584 // OUTPUTS : NNoutput
00585 //=====================================================================================
00586 float EndcapPiZeroDiscriminatorAlgo::GetBarrelNNOutput(float EB_Et)
00587 {
00588 
00589     Layers = EB_Layers; Indim = EB_Indim; Hidden = EB_Hidden; Outdim = EB_Outdim;  barrelstart = 1;  
00590 
00591     float nnout = -1;
00592 // Print the  NN input variables that are related to the ECAL Barrel
00593 // ------------------------------------------------------------------------
00594      if ( debugLevel_ <= pDEBUG )cout << "EndcapPiZeroDiscriminatorAlgo::GetBarrelNNoutput :nn_invar_presh = " ;
00595      for(int k1=0;k1<Indim;k1++) {
00596         if ( debugLevel_ <= pDEBUG )cout << input_var[k1] << " " ;
00597      }     
00598      if ( debugLevel_ <= pDEBUG )cout << endl;
00599 
00600      // select the appropriate Weigth file
00601      int sel_wfile;
00602      if(EB_Et<25.0)                     {sel_wfile = 0;}
00603      else if(EB_Et>=25.0 && EB_Et<35.0) {sel_wfile = 1;}
00604      else if(EB_Et>=35.0 && EB_Et<45.0) {sel_wfile = 2;}
00605      else if(EB_Et>=45.0 && EB_Et<55.0) {sel_wfile = 3;}
00606      else                               {sel_wfile = 4;}
00607 
00608      if ( debugLevel_ <= pDEBUG ) {
00609          cout << "EndcapPiZeroDiscriminatorAlgo: E_SC = " << EB_Et << " and I select Weight file Number = " << sel_wfile << endl;
00610      }
00611 
00612      nnout = getNNoutput(sel_wfile); // calculate the nnoutput for the given ECAL object
00613      if ( debugLevel_ <= pDEBUG ) cout << "EndcapPiZeroDiscriminatorAlgo: ===================> GetNNOutput : NNout = " << nnout <<  endl;
00614 
00615    return nnout;
00616 }
00617