00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00049
00050
00051 #ifndef madnsid_h
00052 #define madnsid_h
00053
00054 #include <string>
00055 #include <cmath>
00056
00057
00058
00059 #include "Rtypes.h"
00060 #include "Conventions/Detector.h"
00061 #include "Conventions/BeamType.h"
00062 #include "Mad/AnnInputBlock.h"
00063
00064 class MadQuantities;
00065
00066
00067
00068 class NtpSREvent;
00069 class NtpSRTrack;
00070 class NtpSRShower;
00071 class NtpStRecord;
00072
00073
00074 class MadNsID {
00075
00076
00077
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
00114
00115
00116
00117
00118
00119 static const Int_t inneuron = 7;
00120 static const Int_t hidneuron = 15;
00121
00122
00123 Double_t rin[hidneuron];
00124
00125 Double_t weight1[inneuron][hidneuron];
00126 Double_t constant1[hidneuron];
00127
00128 Double_t weighto[hidneuron];
00129 Double_t constanto[1];
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