Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MadNsID.h

Go to the documentation of this file.
00001 
00002 //
00003 // MadNsID
00004 //
00005 // A class to calculate Niki Saoulidou's ANN based CC PID
00006 //
00007 // Created:  N. Saoulidou -- Analysis first presented early  2004, Code implementation in May-2005
00008 //
00009 // Converted to this format: M. Kordosky, 12 August 2005
00010 //
00011 // $Author: niki $ 
00012 //
00013 // $Revision: 1.10 $
00014 // 
00015 // $Name:  $
00016 //
00017 // $Id: MadNsID.h,v 1.10 2007/03/19 23:51:00 niki Exp $
00018 //
00019 // $Log: MadNsID.h,v $
00020 // Revision 1.10  2007/03/19 23:51:00  niki
00021 // New 7-Input Variable ANN
00022 //
00023 // Revision 1.9  2007/03/15 19:45:16  niki
00024 // Small changes in order to be able to call methods from NCUtils (If I have commited this twice I
00025 // apologize but I am having some cvs problems)
00026 //
00027 // Revision 1.8  2007/01/30 03:17:21  rhatcher
00028 // No longer user BeamType "class" found in MCReweight, but rather the
00029 // BeamType "namespace" found in Conventions package.
00030 // Also covert to using "Detector::" rather than "DetectorType::", though
00031 // for now they are synonyms.
00032 //
00033 // Revision 1.7  2006/05/08 21:27:44  boehm
00034 // Primary change is the addition of functions to calculate the PID's from NtpSt objects.  Both PIDs may now be generated without relying on the rest of the Mad infrastructure.  Mad based code though should not be changed.
00035 //
00036 // Also removed the if(!ntpTrack.fit.pass) return;  from MadDpID.cxx as it does not reflect the current state of the CC analysis. This was removed in the branched version but remained in the development version.
00037 //
00038 // Revision 1.6  2005/12/12 15:36:36  niki
00039 // Corresponding .h file
00040 //
00041 // Revision 1.5  2005/10/06 15:03:26  kordosky
00042 // various improvements, pids finally integrated into pan construction routine, still not fully debugged though
00043 //
00044 // Revision 1.4  2005/09/14 13:32:45  kordosky
00045 // DpID and NsID classes now fully working and validated with MadTestAnalysis by comparing nannpid vs. annpid and npid0 vs. pid0.  pdf files and weights stored in data subdirectory. FD pdfs needed for DpID.
00046 //
00047 //
00049 
00050 
00051 #ifndef madnsid_h
00052 #define madnsid_h
00053 
00054 #include <string>
00055 #include <cmath>
00056 
00057 //#include "Mad/MadQuantities.h"
00058 //#include "TH1.h"
00059 #include "Rtypes.h"
00060 #include "Conventions/Detector.h"
00061 #include "Conventions/BeamType.h"
00062 #include "Mad/AnnInputBlock.h"
00063 
00064 class MadQuantities;
00065 //class TH1;
00066 //class TFile;
00067 
00068 class NtpSREvent;
00069 class NtpSRTrack;
00070 class NtpSRShower;
00071 class NtpStRecord;
00072 
00073 
00074 class MadNsID {
00075 
00076   //  AnnInputBlock AnnVar(Int_t event=0);
00077   //  Double_t GetAnnPid(AnnInputBlock anninput,Int_t det, Int_t tar, Int_t fid, Int_t prior);  
00078  public:
00079   MadNsID();
00080   bool GetPID(MadQuantities* mq, Int_t event, 
00081               const Detector::Detector_t& det, Double_t& pid);
00082   bool GetPID(NtpSREvent* ntpEvent, NtpSRTrack *ntpTrack,
00083               NtpSRShower *ntpShower, NtpStRecord* st,
00084               const Detector::Detector_t& det, Double_t& pid);
00085 
00086   bool ChooseWeightFile(const Detector::Detector_t& det,
00087                      const BeamType::BeamType_t& beam, 
00088                      Int_t fid=1, Int_t prior=1);
00089   void SetWeightFile(const char* file);
00090 
00091   bool CompareAnnBlocks(MadQuantities* mq, 
00092                         Int_t event, const AnnInputBlock& ext);
00093 
00094   bool CalcVars(NtpSREvent* ntpEvent, NtpSRTrack *ntpTrack,
00095                        NtpSRShower *ntpShower, NtpStRecord* st,
00096                         AnnInputBlock& anninput);
00097 
00098 
00099  std::string GetWeightFileName(const Detector::Detector_t& det,
00100                                 const BeamType::BeamType_t& beam,
00101                                 Int_t fid, Int_t prior);
00102 
00103  bool ReadWeights(const char* file);
00104 
00105  Double_t Sigmoid(Double_t x);
00106  Double_t CalcPID(const AnnInputBlock& b,
00107                    const Detector::Detector_t& det);
00108 
00109  private:
00110 
00111   bool CalcVars(MadQuantities* mq, Int_t event, AnnInputBlock& anninput);
00112 
00113  // Double_t CalcPID(const AnnInputBlock& b, 
00114  //                const Detector::Detector_t& det);
00115  // Double_t Sigmoid(Double_t x);
00116 
00117 
00118 //  static const Int_t    inneuron  = 13;
00119   static const Int_t    inneuron  = 7;
00120   static const Int_t    hidneuron = 15;
00121   
00122   //  Double_t out[hidneuron]; // input neurons
00123   Double_t rin[hidneuron]; // first hidden layer
00124   
00125   Double_t weight1[inneuron][hidneuron];// weights first layer
00126   Double_t constant1[hidneuron];   // constant first layer
00127   
00128   Double_t weighto[hidneuron];// weights second  (output) layer
00129   Double_t constanto[1];   // constant second (output) layer  
00130   bool weights_read;
00131   std::string weight_fname;
00132 
00133   Detector::Detector_t cache_det;
00134   BeamType::BeamType_t cache_beam; 
00135   Int_t cache_fid;
00136   Int_t cache_prior;
00137 
00138 };
00139 
00140 inline Double_t MadNsID::Sigmoid(Double_t x)
00141 {
00142   double sig;
00143       if(x>37.0){
00144          sig = 1.0;
00145       }
00146       else if(x<-37.0){
00147          sig = 0.0;
00148       }
00149       else {
00150          sig = 1./(1.+std::exp(-x));
00151       }
00152       return sig;
00153 }
00154 
00155 #endif
00156 

Generated on Mon Feb 15 11:06:55 2010 for loon by  doxygen 1.3.9.1