MadNsID Class Reference

#include <MadNsID.h>

List of all members.

Public Member Functions

 MadNsID ()
bool GetPID (MadQuantities *mq, Int_t event, const Detector::Detector_t &det, Double_t &pid)
bool GetPID (NtpSREvent *ntpEvent, NtpSRTrack *ntpTrack, NtpSRShower *ntpShower, NtpStRecord *st, const Detector::Detector_t &det, Double_t &pid)
bool ChooseWeightFile (const Detector::Detector_t &det, const BeamType::BeamType_t &beam, Int_t fid=1, Int_t prior=1)
void SetWeightFile (const char *file)
bool CompareAnnBlocks (MadQuantities *mq, Int_t event, const AnnInputBlock &ext)
bool CalcVars (NtpSREvent *ntpEvent, NtpSRTrack *ntpTrack, NtpSRShower *ntpShower, NtpStRecord *st, AnnInputBlock &anninput)
std::string GetWeightFileName (const Detector::Detector_t &det, const BeamType::BeamType_t &beam, Int_t fid, Int_t prior)
bool ReadWeights (const char *file)
Double_t Sigmoid (Double_t x)
Double_t CalcPID (const AnnInputBlock &b, const Detector::Detector_t &det)

Private Member Functions

bool CalcVars (MadQuantities *mq, Int_t event, AnnInputBlock &anninput)

Private Attributes

Double_t rin [hidneuron]
Double_t weight1 [inneuron][hidneuron]
Double_t constant1 [hidneuron]
Double_t weighto [hidneuron]
Double_t constanto [1]
bool weights_read
std::string weight_fname
Detector::Detector_t cache_det
BeamType::BeamType_t cache_beam
Int_t cache_fid
Int_t cache_prior

Static Private Attributes

static const Int_t inneuron = 7
static const Int_t hidneuron = 15

Detailed Description

Definition at line 74 of file MadNsID.h.


Constructor & Destructor Documentation

MadNsID::MadNsID (  ) 

Definition at line 103 of file MadNsID.cxx.

References cache_beam, cache_det, cache_fid, cache_prior, Detector::kUnknown, and BeamType::kUnknown.

00103                  : weights_read(false), weight_fname("") {
00104   cache_det=Detector::kUnknown;
00105   cache_beam=BeamType::kUnknown;
00106   cache_fid = -1;
00107   cache_prior = -1;
00108 
00109 }


Member Function Documentation

Double_t MadNsID::CalcPID ( const AnnInputBlock b,
const Detector::Detector_t det 
)

Definition at line 171 of file MadNsID.cxx.

References AnnInputBlock::aPh3, AnnInputBlock::aPh6, AnnInputBlock::aPhlast, AnnInputBlock::aPhperpl, AnnInputBlock::aShwplu, AnnInputBlock::aTotlen, AnnInputBlock::aTotph, AnnInputBlock::aTotrk, AnnInputBlock::aTrkpass, AnnInputBlock::aTrkphperpl, AnnInputBlock::aTrkplu, constant1, constanto, hidneuron, inneuron, Detector::kFar, Detector::kNear, ReadWeights(), rin, Sigmoid(), weight1, weight_fname, weighto, and weights_read.

Referenced by GetPID().

00172                                                         {
00173   // calculate the ANN PID based on the information in the input block
00174   // code does a little detector specific stuff...
00175   if(!weights_read) assert( ReadWeights(weight_fname.c_str()) );
00176 
00177   Double_t rin[hidneuron];
00178   Double_t out[hidneuron];
00179   for(Int_t i=0; i<hidneuron; i++){rin[i]=0; out[i]=0;}
00180   
00181   
00182   if(det==Detector::kFar){  
00183   
00184       out[0]  =  (anninput.aTrkphperpl*anninput.aTotrk*anninput.aTrkpass)/2000.;
00185       out[1]  =  (anninput.aPhperpl/10000.); 
00186    // out[1]  =  (anninput.aTotph/50000.); 
00187       out[2]  =  (anninput.aTotlen/40);
00188       out[3]  =  (anninput.aPh3/(anninput.aTotph+1.));
00189       out[4]  =  (anninput.aPh6/(anninput.aTotph+1.));
00190       out[5]  =  (anninput.aPhlast/(anninput.aTotph+1.));
00191       out[6]  =  ((anninput.aTrkplu-anninput.aShwplu)+20.)/40.;
00192  /*     
00193     out[0]  =  anninput.aTrkphperpl/2000.;
00194     out[1]  =  anninput.aTotrk*anninput.aTrkpass;
00195     out[2]  = (anninput.aTotstp/100.);
00196     out[3]  = (anninput.aTotph/50000.);   
00197     out[4]  = (anninput.aTotlen/40);
00198     out[5]  = (anninput.aPhperpl/5000.);        
00199     out[6]  = (anninput.aPhperstp/1000.);
00200     out[10] = ((anninput.aTrkplv-anninput.aShwplv)+20.)/40.;
00201     out[11] = ((anninput.aTrkplu-anninput.aShwplu)+20.)/40.;
00202   */
00203   }
00204   else if(det==Detector::kNear){
00205        out[0]  =  (anninput.aTrkphperpl*anninput.aTotrk*anninput.aTrkpass)/5000.;
00206        out[1]  =  (anninput.aPhperpl/10000.); 
00207      //out[1]  =  (anninput.aTotph/100000.); 
00208        out[2]  =  (anninput.aTotlen/40);
00209        out[3]  =  (anninput.aPh3/(anninput.aTotph+1.));
00210        out[4]  =  (anninput.aPh6/(anninput.aTotph+1.));
00211        out[5]  =  (anninput.aPhlast/(anninput.aTotph+1.));
00212        out[6]  =  ((anninput.aTrkplu-anninput.aShwplu)+10.)/20.;
00213 /*       
00214     out[0]  = anninput.aTrkphperpl/5000.;
00215     out[1]  = anninput.aTotrk*anninput.aTrkpass;
00216     out[2]  = (anninput.aTotstp/100.);
00217     out[3]  = (anninput.aTotph/100000.);   
00218     out[4]  = (anninput.aTotlen/40);
00219     out[5]  = (anninput.aPhperpl/10000.);       
00220     out[6]  = (anninput.aPhperstp/2000.);  
00221     out[10] = ((anninput.aTrkplv-anninput.aShwplv)+10.)/20.;
00222     out[11] = ((anninput.aTrkplu-anninput.aShwplu)+10.)/20.;
00223   */
00224   }
00225  // out[7]  = (anninput.aPh3/(anninput.aTotph+1.));
00226  // out[8]  = (anninput.aPh6/(anninput.aTotph+1.));
00227  //  out[9]  = (anninput.aPhlast/(anninput.aTotph+1.));
00228  // out[12] = (anninput.aShwphperdig/800.);
00229 
00230 
00231      
00232   // first layer         
00233   for(Int_t i=0;i<hidneuron;i++){
00234     rin[i]=constant1[i];
00235     for(Int_t j=0;j<inneuron;j++){
00236       rin[i]=rin[i]+weight1[j][i]*out[j];
00237     }
00238   }
00239   // output                     
00240   for(Int_t i=0;i<hidneuron;i++){        
00241     out[i]=Sigmoid(rin[i]);      
00242   }             
00243 
00244   Double_t prob =constanto[0];  
00245   for(Int_t i=0;i<hidneuron;i++) prob=prob+weighto[i]*out[i];
00246   
00247   
00248   if(anninput.aTotlen>50) prob=0.;
00249 
00250   return prob;
00251 
00252 }

bool MadNsID::CalcVars ( MadQuantities mq,
Int_t  event,
AnnInputBlock anninput 
) [private]

Definition at line 254 of file MadNsID.cxx.

References AnnInputBlock::aPh3, AnnInputBlock::aPh6, AnnInputBlock::aPhcommon, AnnInputBlock::aPhlast, AnnInputBlock::aPhperpl, AnnInputBlock::aPhperstp, AnnInputBlock::aShwdig, AnnInputBlock::aShwph, AnnInputBlock::aShwphper, AnnInputBlock::aShwphperdig, AnnInputBlock::aShwphperpl, AnnInputBlock::aShwphperstp, AnnInputBlock::aShwpl, AnnInputBlock::aShwplu, AnnInputBlock::aShwplv, AnnInputBlock::aShwstp, AnnInputBlock::aTotlen, AnnInputBlock::aTotph, AnnInputBlock::aTotrk, AnnInputBlock::aTotstp, AnnInputBlock::aTrklen, AnnInputBlock::aTrkpass, AnnInputBlock::aTrkph, AnnInputBlock::aTrkphper, AnnInputBlock::aTrkphperpl, AnnInputBlock::aTrkplu, AnnInputBlock::aTrkplv, AnnInputBlock::aTrkstp, NtpSRPlane::beg, NtpSRPlane::end, NtpSRTrack::fit, MadBase::GetEvent(), MadBase::GetLargestShowerFromEvent(), MadBase::GetLargestTrackFromEvent(), MadBase::GetStrip(), NtpSRPlane::n, NtpSRShower::ndigit, NtpSREvent::nstrip, NtpSRTrack::nstrip, NtpSRShower::nstrip, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NtpSRPlane::nu, NtpSRPlane::nv, NtpSRFitTrack::pass, NtpSRShower::ph, NtpSRTrack::ph, NtpSREvent::ph, NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRShower::plane, NtpSRStrip::plane, NtpSRTrack::plane, NtpSREvent::plane, NtpSRPulseHeight::sigcor, NtpSREvent::stp, NtpSRShower::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

00255                                                {
00256 
00257   // calculates ann input variables for this event and records them in
00258   // anninput.  returns false in case of problems, true otherwise
00259   
00260 
00261   // Initialize
00262   anninput.aTotrk       =0.;
00263   anninput.aTotstp      =0.;
00264   anninput.aTotph       =0.;
00265   anninput.aTotlen      =0.;
00266   anninput.aPhperpl     =0.;
00267   anninput.aPhperstp    =0.;
00268   
00269   
00270   anninput.aTrkpass     =0.;
00271   anninput.aTrkph       =0.;
00272   anninput.aTrklen      =0.;
00273   anninput.aTrkphperpl  =0.;
00274   anninput.aTrkphper    =0.;
00275   anninput.aTrkplu      =0.;
00276   anninput.aTrkplv      =0.;
00277   anninput.aTrkstp      =0.;
00278  
00279   anninput.aShwph       =0.;
00280   anninput.aShwstp      =0.;
00281   anninput.aShwdig      =0.;
00282   anninput.aShwpl       =0.;
00283   anninput.aShwphper    =0.;
00284   anninput.aShwphperpl  =0.;
00285   anninput.aShwphperdig =0.;
00286   anninput.aShwphperstp =0.;
00287   anninput.aShwplu      =0.;
00288   anninput.aShwplv      =0.;
00289   anninput.aPh3         =0.;
00290   anninput.aPh6         =0.;
00291   anninput.aPhlast      =0.;
00292   anninput.aPhcommon    =0.;
00293 //  
00294   
00295 // Calculate variables needed for ANN (and a few more)
00296   
00297   const NtpSREvent* ntpEvent = mq->GetEvent(event) ;  
00298   if(!ntpEvent) return false; // perhaps ought to assert here?
00299   int track_index   = -1;
00300   const NtpSRTrack* ntpTrack   = mq->GetLargestTrackFromEvent(event,track_index);
00301   int shower_index  = -1;
00302   const NtpSRShower* ntpShower = mq->GetLargestShowerFromEvent(event,shower_index);
00303  
00304   anninput.aTotrk       =ntpEvent->ntrack;
00305   anninput.aTotstp      =ntpEvent->nstrip;
00306   anninput.aTotph       =ntpEvent->ph.sigcor;
00307   anninput.aTotlen      =ntpEvent->plane.end-ntpEvent->plane.beg+1; // prepei na to alla3w
00308   anninput.aPhperpl     =ntpEvent->ph.sigcor/ntpEvent->plane.n;
00309   anninput.aPhperstp    =ntpEvent->ph.sigcor/ntpEvent->nstrip;
00310   
00311   if(track_index!=-1) {
00312     anninput.aTrkpass     =ntpTrack->fit.pass;
00313     anninput.aTrkph       =ntpTrack->ph.sigcor;
00314     anninput.aTrklen      =ntpTrack->plane.ntrklike;
00315     if(ntpTrack->plane.ntrklike>0) anninput.aTrkphperpl  =ntpTrack->ph.sigcor/ntpTrack->plane.ntrklike;
00316     if(ntpEvent->ph.sigcor>0)      anninput.aTrkphper    =ntpTrack->ph.sigcor/ntpEvent->ph.sigcor;
00317     anninput.aTrkplu      =ntpTrack->plane.nu;
00318     anninput.aTrkplv      =ntpTrack->plane.nv;
00319     anninput.aTrkstp      =ntpTrack->nstrip;
00320   }
00321   if(shower_index!=-1) {
00322     anninput.aShwph       =ntpShower->ph.sigcor;
00323     anninput.aShwstp      =ntpShower->nstrip;
00324     anninput.aShwdig      =ntpShower->ndigit;
00325     anninput.aShwpl       =ntpShower->plane.n;
00326     anninput.aShwphper    =ntpShower->ph.sigcor/ntpEvent->ph.sigcor;
00327     anninput.aShwphperpl  =ntpShower->ph.sigcor/ntpShower->plane.n;
00328     anninput.aShwphperdig =ntpShower->ph.sigcor/ntpShower->ndigit;
00329     anninput.aShwphperstp =ntpShower->ph.sigcor/ntpShower->nstrip;
00330     anninput.aShwplu      =ntpShower->plane.nu;
00331     anninput.aShwplv      =ntpShower->plane.nv; 
00332   }
00333 
00334   Int_t ssind,ssplind;
00335   Double_t ssphtot;
00336   Bool_t foundshw,foundtrk;
00337   Int_t planes=ntpEvent->plane.beg;
00338   
00339   Double_t ph3,ph6,phlast,phcommon,phnowere,hitcommon,hitnowere;
00340   ph3=0.;ph6=0.;phlast=0.;phcommon=0.;phnowere=0.;hitcommon=0.;hitnowere=0.;
00341   // loop over strips to compute ph3 ph6 phlast phcommon
00342   for(Int_t evss=0;evss<ntpEvent->nstrip;evss++){ 
00343     Int_t stp_index=((ntpEvent->stp)[evss]);
00344 
00345     if(stp_index!=-1){
00346  
00347     const NtpSRStrip* ntpStrip =  mq->GetStrip(stp_index);      
00348     if(!ntpStrip) continue;
00349     ssind   =ntpStrip->strip;
00350     ssplind =ntpStrip->plane;
00351     ssphtot =ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor; 
00352     
00353     foundshw=false;
00354     foundtrk=false;
00355     
00356     Double_t phstrips=0;
00357     Double_t phstript=0;       
00358     // shower strips
00359     Int_t sshwind,sshwplind;
00360     Double_t sshwphtot;
00361     
00362     if(shower_index!=-1) {
00363       for(Int_t jj=0;jj<ntpShower->nstrip;jj++){
00364         Int_t stp_indexs=((ntpShower->stp)[jj]);
00365         
00366        if(stp_indexs!=-1){
00367 
00368         ntpStrip = mq->GetStrip(stp_indexs);
00369         if(!foundshw){
00370           sshwind=ntpStrip->strip;
00371           sshwplind=ntpStrip->plane;
00372           sshwphtot=ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor;             
00373           if(sshwind==ssind && sshwplind==ssplind) {
00374             foundshw=true;
00375             phstrips=sshwphtot;
00376           }
00377         }
00378        }
00379       }
00380     }      
00381     // tracks strips
00382     Int_t strkind,strkplind;
00383     Double_t strkphtot;
00384     if(track_index!=-1) {
00385       for(Int_t jj=0;jj<ntpTrack->nstrip;jj++){
00386         Int_t stp_indext=((ntpTrack->stp)[jj]);
00387 
00388         if(stp_indext!=-1){
00389 
00390         ntpStrip = mq->GetStrip(stp_indext);
00391 
00392         if(!foundtrk){
00393           strkind  =ntpStrip->strip;
00394           strkplind=ntpStrip->plane;
00395           strkphtot=ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor;   
00396           if(strkind==ssind && strkplind==ssplind) {
00397             foundtrk=true;
00398             phstript=strkphtot;
00399           }
00400         }
00401 
00402        }
00403       }
00404     }
00405        
00406     if(foundshw && foundtrk) {
00407       hitcommon=hitcommon+1;
00408       phcommon=phcommon+phstrips+phstript;
00409     }  
00410     if(!foundshw && ! foundtrk) {
00411       hitnowere=hitnowere+1; 
00412       phnowere=phnowere+ssphtot; 
00413     }            
00414     if(ssplind>=planes && ssplind<=(planes+3)){
00415       ph3=ph3+ssphtot;
00416     }
00417     else if(ssplind>(planes+3) && ssplind<=(planes+6)){
00418       ph6=ph6+ssphtot; 
00419     }
00420     else {
00421       phlast=phlast+ssphtot;
00422     }     
00423 
00424    } // end of if stp_index != -1
00425 
00426   } // end of looping over event strips....    
00427 
00428 //
00429   anninput.aPh3       =ph3;
00430   anninput.aPh6       =ph6;
00431   anninput.aPhlast    =phlast;
00432   anninput.aPhcommon  =phcommon; 
00433   
00434   return true;
00435 
00436 
00437 }

bool MadNsID::CalcVars ( NtpSREvent ntpEvent,
NtpSRTrack ntpTrack,
NtpSRShower ntpShower,
NtpStRecord st,
AnnInputBlock anninput 
)

Definition at line 439 of file MadNsID.cxx.

References AnnInputBlock::aPh3, AnnInputBlock::aPh6, AnnInputBlock::aPhcommon, AnnInputBlock::aPhlast, AnnInputBlock::aPhperpl, AnnInputBlock::aPhperstp, AnnInputBlock::aShwdig, AnnInputBlock::aShwph, AnnInputBlock::aShwphper, AnnInputBlock::aShwphperdig, AnnInputBlock::aShwphperpl, AnnInputBlock::aShwphperstp, AnnInputBlock::aShwpl, AnnInputBlock::aShwplu, AnnInputBlock::aShwplv, AnnInputBlock::aShwstp, AnnInputBlock::aTotlen, AnnInputBlock::aTotph, AnnInputBlock::aTotrk, AnnInputBlock::aTotstp, AnnInputBlock::aTrklen, AnnInputBlock::aTrkpass, AnnInputBlock::aTrkph, AnnInputBlock::aTrkphper, AnnInputBlock::aTrkphperpl, AnnInputBlock::aTrkplu, AnnInputBlock::aTrkplv, AnnInputBlock::aTrkstp, NtpSRPlane::beg, NtpSRPlane::end, NtpSRTrack::fit, NtpSRPlane::n, NtpSRShower::ndigit, NtpSREvent::nstrip, NtpSRTrack::nstrip, NtpSRShower::nstrip, NtpSREvent::ntrack, NtpSRTrackPlane::ntrklike, NtpSRPlane::nu, NtpSRPlane::nv, NtpSRFitTrack::pass, NtpSRShower::ph, NtpSRTrack::ph, NtpSREvent::ph, NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRShower::plane, NtpSRStrip::plane, NtpSRTrack::plane, NtpSREvent::plane, NtpSRPulseHeight::sigcor, NtpSREvent::stp, NtpSRShower::stp, NtpStRecord::stp, NtpSRTrack::stp, and NtpSRStrip::strip.

Referenced by CompareAnnBlocks(), and GetPID().

00442 {                                                                            
00443                                                                                 
00444   // calculates ann input variables for this event and records them in
00445   // anninput.  returns false in case of problems, true otherwise
00446                                                                                 
00447   // Initialize
00448   anninput.aTotrk       =0.;
00449   anninput.aTotstp      =0.;
00450   anninput.aTotph       =0.;
00451   anninput.aTotlen      =0.;
00452   anninput.aPhperpl     =0.;
00453   anninput.aPhperstp    =0.;
00454                                                                                 
00455   anninput.aTrkpass     =0.;
00456   anninput.aTrkph       =0.;
00457   anninput.aTrklen      =0.;
00458   anninput.aTrkphperpl  =0.;
00459   anninput.aTrkphper    =0.;
00460   anninput.aTrkplu      =0.;
00461   anninput.aTrkplv      =0.;
00462   anninput.aTrkstp      =0.;
00463                                                                                 
00464   anninput.aShwph       =0.;
00465   anninput.aShwstp      =0.;
00466   anninput.aShwdig      =0.;
00467   anninput.aShwpl       =0.;
00468   anninput.aShwphper    =0.;
00469   anninput.aShwphperpl  =0.;
00470   anninput.aShwphperdig =0.;
00471   anninput.aShwphperstp =0.;
00472   anninput.aShwplu      =0.;
00473   anninput.aShwplv      =0.;
00474   
00475   anninput.aPh3         =0.;
00476   anninput.aPh6         =0.;
00477   anninput.aPhlast      =0.;
00478   anninput.aPhcommon    =0.;
00479 
00480   // Calculate variables needed for ANN (and a few more)
00481                                                                                 
00482   if(!ntpEvent) return false; // perhaps ought to assert here?
00483                                                                                 
00484   anninput.aTotrk       =ntpEvent->ntrack;
00485   anninput.aTotstp      =ntpEvent->nstrip;
00486   anninput.aTotph       =ntpEvent->ph.sigcor;
00487   anninput.aTotlen      =ntpEvent->plane.end-ntpEvent->plane.beg+1; // prepei na to alla3w
00488   anninput.aPhperpl     =ntpEvent->ph.sigcor/ntpEvent->plane.n;
00489   anninput.aPhperstp    =ntpEvent->ph.sigcor/ntpEvent->nstrip;
00490                                                                                 
00491   if(ntpTrack != 0) {
00492     anninput.aTrkpass     =ntpTrack->fit.pass;
00493     anninput.aTrkph       =ntpTrack->ph.sigcor;
00494     anninput.aTrklen      =ntpTrack->plane.ntrklike;
00495     if(ntpTrack->plane.ntrklike>0) anninput.aTrkphperpl  =ntpTrack->ph.sigcor/ntpTrack->plane.ntrklike;
00496     if(ntpEvent->ph.sigcor>0)      anninput.aTrkphper    =ntpTrack->ph.sigcor/ntpEvent->ph.sigcor;
00497     anninput.aTrkplu      =ntpTrack->plane.nu;
00498     anninput.aTrkplv      =ntpTrack->plane.nv;
00499     anninput.aTrkstp      =ntpTrack->nstrip;
00500   }
00501   if(ntpShower != 0) {
00502     anninput.aShwph       =ntpShower->ph.sigcor;
00503     anninput.aShwstp      =ntpShower->nstrip;
00504     anninput.aShwdig      =ntpShower->ndigit;
00505     anninput.aShwpl       =ntpShower->plane.n;
00506     anninput.aShwphper    =ntpShower->ph.sigcor/ntpEvent->ph.sigcor;
00507     anninput.aShwphperpl  =ntpShower->ph.sigcor/ntpShower->plane.n;
00508     anninput.aShwphperdig =ntpShower->ph.sigcor/ntpShower->ndigit;
00509     anninput.aShwphperstp =ntpShower->ph.sigcor/ntpShower->nstrip;
00510     anninput.aShwplu      =ntpShower->plane.nu;
00511     anninput.aShwplv      =ntpShower->plane.nv;
00512   }
00513                                                                                 
00514   Int_t ssind,ssplind;
00515   Double_t ssphtot;
00516   Bool_t foundshw,foundtrk;
00517   Int_t planes =ntpEvent->plane.beg;
00518   Double_t ph3,ph6,phlast,phcommon,phnowere,hitcommon,hitnowere;
00519   ph3=0.;ph6=0.;phlast=0.;phcommon=0.;phnowere=0.;hitcommon=0.;hitnowere=0.;
00520   // loop over strips to compute ph3 ph6 phlast phcommon
00521                                                                                 
00522   for(Int_t i = 0; i < ntpEvent->nstrip;i++)
00523   {
00524     Int_t stp_index=((ntpEvent->stp)[i]);
00525 
00526     if(stp_index!=-1){
00527 
00528     NtpSRStrip* ntpStrip = dynamic_cast<NtpSRStrip *>((*st->stp)[stp_index]);
00529 
00530                                                                                 
00531     ssind   = ntpStrip->strip;
00532     ssplind = ntpStrip->plane;
00533     ssphtot = ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor;
00534                                                                                 
00535     foundshw=false;
00536     foundtrk=false;
00537                                                                                 
00538     Double_t phstrips=0;
00539     Double_t phstript=0;
00540     // shower strips
00541     Int_t sshwind,sshwplind;
00542     Double_t sshwphtot;
00543                                                                                 
00544     if(ntpShower != 0) {
00545       for(Int_t jj=0;jj<ntpShower->nstrip;jj++){
00546         Int_t stp_indexs=((ntpShower->stp)[jj]);
00547        
00548         if(stp_indexs!=-1){
00549 
00550         ntpStrip = dynamic_cast<NtpSRStrip *>((*st->stp)[stp_indexs]);
00551 
00552         if(!foundshw){
00553           sshwind=ntpStrip->strip;
00554           sshwplind=ntpStrip->plane;
00555           sshwphtot=ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor;
00556           if(sshwind==ssind && sshwplind==ssplind) {
00557             foundshw=true;
00558             phstrips=sshwphtot;
00559           }
00560         }
00561        }
00562       }
00563     }
00564     // tracks strips
00565     Int_t strkind,strkplind;
00566     Double_t strkphtot;
00567     if(ntpTrack != 0) {
00568       for(Int_t jj=0;jj<ntpTrack->nstrip;jj++){
00569         Int_t stp_indext=((ntpTrack->stp)[jj]);
00570        
00571         if(stp_indext!=-1){
00572 
00573          ntpStrip = dynamic_cast<NtpSRStrip *>((*st->stp)[stp_indext]);
00574 
00575         if(!foundtrk){                                                                                
00576           strkind=ntpStrip->strip;
00577           strkplind=ntpStrip->plane;
00578           strkphtot=ntpStrip->ph1.sigcor+ntpStrip->ph0.sigcor;
00579           if(strkind==ssind && strkplind==ssplind) {
00580             foundtrk=true;
00581             phstript=strkphtot;
00582           }
00583         }
00584        }
00585       }
00586     }
00587                                                                                 
00588     if(foundshw && foundtrk) {
00589       hitcommon=hitcommon+1;
00590       phcommon=phcommon+phstrips+phstript;
00591     }
00592     if(!foundshw && ! foundtrk) {
00593       hitnowere=hitnowere+1;
00594       phnowere=phnowere+ssphtot;
00595     }
00596     if(ssplind>=planes && ssplind<=(planes+3)){
00597       ph3=ph3+ssphtot;
00598     }
00599     else if(ssplind>(planes+3) && ssplind<=(planes+6)){
00600       ph6=ph6+ssphtot;
00601     }
00602     else {
00603       phlast=phlast+ssphtot;
00604     }
00605    } // end of if strip index !=-1
00606   } // end of looping over event strips....
00607 //
00608   anninput.aPh3       =ph3;
00609   anninput.aPh6       =ph6;
00610   anninput.aPhlast    =phlast;
00611   anninput.aPhcommon  =phcommon;
00612                                                                                 
00613   return true;
00614 }

bool MadNsID::ChooseWeightFile ( const Detector::Detector_t det,
const BeamType::BeamType_t beam,
Int_t  fid = 1,
Int_t  prior = 1 
)

Definition at line 689 of file MadNsID.cxx.

References cache_beam, cache_det, cache_fid, cache_prior, GetWeightFileName(), gSystem(), id, size, weight_fname, and weights_read.

Referenced by ANtpAnalysisInfoAna::Analyze(), MuonRemovalInfoAna::Analyze(), AnalysisInfoAna::Analyze(), MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00691                                                       {
00692   // look for the proper weight file
00693   // return true if we already have read it
00694   // or if we haven't read it but can find it
00695   if(det==cache_det && beam==cache_beam && 
00696      prior==cache_prior && fid==cache_fid){
00697     // no action needed
00698     return true;
00699   }
00700   
00701   weight_fname = GetWeightFileName(det,beam,fid,prior);
00702   // check if this file or directory exists
00703   Long_t id,size,flags,modtime;
00704   if(gSystem->GetPathInfo(weight_fname.c_str(),&id,&size,&flags,&modtime) == 1) {
00705     return false;
00706   }
00707   // check that it is a file and not a directory
00708   if(flags>1) return false;
00709   else {
00710     cache_det=det; cache_beam=beam; cache_prior=prior; cache_fid=fid;
00711     weights_read=false;
00712     return true;
00713   }
00714 }

bool MadNsID::CompareAnnBlocks ( MadQuantities mq,
Int_t  event,
const AnnInputBlock ext 
)

Definition at line 740 of file MadNsID.cxx.

References CalcVars().

00740                                                                                       {
00741   AnnInputBlock ib;
00742   CalcVars(mq, event, ib);
00743   if( !(ib==ext) ){
00744     std::cout<<"AnnInputBlocks disagree!!!"<<std::endl;
00745     std::cout<<"Event: "<<event<<std::endl;
00746     std::cout<<"This block: "<<std::endl;
00747     std::cout<<ib<<std::endl;
00748     std::cout<<"Other block: "<<std::endl;
00749     std::cout<<ext<<std::endl;
00750     return false;
00751   }
00752   else return true;
00753 }

bool MadNsID::GetPID ( NtpSREvent ntpEvent,
NtpSRTrack ntpTrack,
NtpSRShower ntpShower,
NtpStRecord st,
const Detector::Detector_t det,
Double_t &  pid 
)

Definition at line 729 of file MadNsID.cxx.

References CalcPID(), and CalcVars().

00732 {
00733   AnnInputBlock ib;
00734   bool result=true;
00735   result = CalcVars(ntpEvent, ntpTrack, ntpShower, st, ib);
00736   if(result) pid = CalcPID(ib,det);
00737   return result;
00738 }

bool MadNsID::GetPID ( MadQuantities mq,
Int_t  event,
const Detector::Detector_t det,
Double_t &  pid 
)

Definition at line 720 of file MadNsID.cxx.

References CalcPID(), and CalcVars().

Referenced by ANtpAnalysisInfoAna::Analyze(), MuonRemovalInfoAna::Analyze(), AnalysisInfoAna::Analyze(), MadTestAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), and MadTVAnalysis::CreatePAN().

00721                                                                    {
00722   AnnInputBlock ib;
00723   bool result=true;
00724   result = CalcVars(mq, event, ib);
00725   if(result) pid = CalcPID(ib,det);
00726   return result;
00727 }

std::string MadNsID::GetWeightFileName ( const Detector::Detector_t det,
const BeamType::BeamType_t beam,
Int_t  fid,
Int_t  prior 
)

Definition at line 616 of file MadNsID.cxx.

References base, BeamType::k100, BeamType::k250, Detector::kFar, BeamType::kL000z200i, BeamType::kL010z170i, BeamType::kL010z185i, BeamType::kL010z200i, Detector::kNear, and stat.

Referenced by ChooseWeightFile().

00619 {
00620   // M. Kordosky Sept 09, 2005
00621   //
00622   // Choose a file of ANN weights according to the detector, beam, 
00623   // fiducial volue and prior 
00624   // 
00625   //
00626   // N Saoulidou December 12 2005
00627   // DET IS THE DETECTOR 1 = NEAR 2 = FAR
00628   // TAR IS THE ENERGY   1 = LE 2 = PME 3 = PHE
00629   // FID IS THE FIDUCIAL REGION FOR FAR , 2 = DAVIDS  1 = MINE (MORE STRICT)
00630   // PRIOR IS THE FAR TRAINED METHOD    , 1 = NO OSCILLATIONS , 
00631   //                                      2 = DM2 0.0025 SINTHETA2 = 0.95
00632   //                                      3 = DM2 0.002 SINTHETA2 = 0.95
00633                                                                                                                          
00634 
00635   //
00636   std::string priv="";
00637   std::string pub="";
00638                                                                                 
00639   std::string base="";
00640                                                                                 
00641   priv=getenv("SRT_PRIVATE_CONTEXT");
00642   pub = getenv("SRT_PUBLIC_CONTEXT");
00643                                                                                 
00644   if(priv == "" && pub == ""){
00645     std::cerr<<"No SRT_PUBLIC_CONTEXT set"<<std::endl;
00646     assert(false);
00647   }
00648                                                                                 
00649   priv += "/Mad/data/";
00650   pub  += "/Mad/data/";
00651                                                                                 
00652   struct stat ss;
00653   if(stat(priv.c_str(), &ss) == -1) {
00654    std::cout<<"Data not present in SRT_PRIVATE_CONTEXT trying SRT_PUBLIC"<<std::endl;
00655    if(stat(pub.c_str(), &ss) == -1) {
00656      std::cout<<"Data not present in SRT_PUBLIC - doesn't seem to exist"<<std::endl;
00657       assert(false);
00658    }else{ base = pub; }
00659   }else { base = priv; }
00660   
00661   if(det==Detector::kFar){  
00662     if(prior==1){ 
00663       if(fid==1) base+="weights_farle_cedar_daikon7v2.dat";    
00664       if(fid==2) base+="weights_farle_cedar_daikon7v2.dat";      
00665     }
00666     if(prior==2){ 
00667       if(fid==1) base+="weights_farle_cedar_daikon7v2.dat";    
00668       if(fid==2) base+="weights_farle_cedar_daikon7v2.dat";
00669     }
00670     if(prior==3){ 
00671       if(fid==1) base+="weights_farle_cedar_daikon7v2.dat";    
00672       if(fid==2) base+="weights_farle_cedar_daikon7v2.dat";
00673     }
00674   }
00675   else if(det==Detector::kNear){
00676     if(beam==BeamType::kL010z185i || beam==BeamType::kL000z200i || beam==BeamType::kL010z170i || beam==BeamType::kL010z200i)  base+="weights_nearle_cedar_daikon7v2.dat";    
00677     if(beam==BeamType::k100)  base+="weights_nearpme_cedar_daikon7v2.dat";    
00678     if(beam==BeamType::k250)  base+="weights_nearphe_cedar_daikon7v2.dat";    
00679   }
00680 
00681   if(stat(base.c_str(),&ss) == -1) {
00682     std::cerr<<"The file '"<<base<<"' doesn't seem to exist"<<std::endl;
00683     assert(false);
00684   }
00685 
00686   return base;
00687 }

bool MadNsID::ReadWeights ( const char *  file  ) 

Definition at line 111 of file MadNsID.cxx.

References constant1, constanto, hidneuron, inneuron, weight1, weighto, and weights_read.

Referenced by CalcPID().

00111                                          {
00112   // read a text file containing the ANN weights
00113   // returns true if file was correctly read
00114   // returns false otherwise
00115   weights_read = false;
00116 
00117   std::ifstream weightfile(file);
00118   if(!weightfile){ 
00119     std::cout<<"MadNsID::ReadWeights(), cannot read: "<<file<<std::endl;
00120     return false;
00121   }
00122   std::cout<<"Reading MadNsID weights from: "<<file<<std::endl;
00123   
00124   Int_t all  = inneuron*hidneuron+hidneuron+hidneuron+1;
00125   Int_t all1 = inneuron*hidneuron+hidneuron;
00126   Int_t n1  =0;
00127   Int_t nw1 =0;
00128   Int_t no  =0;
00129   Int_t nwo =0;
00130 
00131   // read weights
00132   for(Int_t k=0;k<all;k++){  
00133     Double_t var;
00134     weightfile >> var ;
00135     if(!weightfile.good()){
00136       std::cerr<<"MadNsID::ReadWeights() bad input, k="<<k<<std::endl;
00137       weightfile.close();
00138       return false;
00139     }
00140     if(k<all1){
00141       if(k%(inneuron+1)==0){
00142         nw1=0;
00143         constant1[n1]=var;        
00144         n1=n1+1;           
00145       }
00146       else {
00147         weight1[nw1][n1-1]=var;    
00148         nw1=nw1+1;         
00149       }
00150     }
00151     else if(k>=all1){
00152       if((k-all1)%(hidneuron+1)==0){
00153         nwo=0;
00154         constanto[no]=var;        
00155         no=no+1;          
00156       }
00157       else {
00158         weighto[nwo]=var;          
00159         nwo=nwo+1;         
00160       }
00161     }          
00162   }
00163   
00164   weightfile.close();  
00165   weights_read=true;
00166   return true;
00167 
00168 }

void MadNsID::SetWeightFile ( const char *  file  ) 

Definition at line 716 of file MadNsID.cxx.

References weight_fname.

00716                                            {
00717   weight_fname = file;
00718 }

Double_t MadNsID::Sigmoid ( Double_t  x  )  [inline]

Definition at line 140 of file MadNsID.h.

Referenced by CalcPID().

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 }


Member Data Documentation

Definition at line 134 of file MadNsID.h.

Referenced by ChooseWeightFile(), and MadNsID().

Definition at line 133 of file MadNsID.h.

Referenced by ChooseWeightFile(), and MadNsID().

Int_t MadNsID::cache_fid [private]

Definition at line 135 of file MadNsID.h.

Referenced by ChooseWeightFile(), and MadNsID().

Int_t MadNsID::cache_prior [private]

Definition at line 136 of file MadNsID.h.

Referenced by ChooseWeightFile(), and MadNsID().

Double_t MadNsID::constant1[hidneuron] [private]

Definition at line 126 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

Double_t MadNsID::constanto[1] [private]

Definition at line 129 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

const Int_t MadNsID::hidneuron = 15 [static, private]

Definition at line 120 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

const Int_t MadNsID::inneuron = 7 [static, private]

Definition at line 119 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

Double_t MadNsID::rin[hidneuron] [private]

Definition at line 123 of file MadNsID.h.

Referenced by CalcPID().

Double_t MadNsID::weight1[inneuron][hidneuron] [private]

Definition at line 125 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

std::string MadNsID::weight_fname [private]

Definition at line 131 of file MadNsID.h.

Referenced by CalcPID(), ChooseWeightFile(), and SetWeightFile().

Double_t MadNsID::weighto[hidneuron] [private]

Definition at line 128 of file MadNsID.h.

Referenced by CalcPID(), and ReadWeights().

bool MadNsID::weights_read [private]

Definition at line 130 of file MadNsID.h.

Referenced by CalcPID(), ChooseWeightFile(), and ReadWeights().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1