MCNNFunctions.h File Reference

#include <cmath>
#include "MCNNAnalysis/NNReader.h"
#include "StandardNtuple/NtpStRecord.h"
#include "CandNtupleSR/NtpSREvent.h"
#include "MCNNAnalysis/MinosEvent.h"
#include "MCNNAnalysis/NtpTools.h"
#include "MCNNAnalysis/NueAnaReader.h"

Go to the source code of this file.

Functions

float Oscillate (int nuFlavor, int nonOscNuFlavor, float Energy, float L, float dm2, float theta23, float UE32)
float Calcweight (int inu, int inunoosc)
float DistanceToEdgeFD (Float_t vtxx_in, Float_t vtxy_in)
bool VtxIsContainedFD (NNReader *nread_in)
bool VtxIsContainedND (NNReader *nread_in)
bool DataPreselected (const NtpStRecord *record, const int eventno)
bool DataPreselected (const NtpSREvent *srevent)
bool PreselModif (NNReader *nread)
bool MCLibraryPreselected (const NtpStRecord *record, Int_t evtno)
bool MCLibraryPreselected (MinosEvent *event)
bool MarkPreselection (NueAnaReader *nueana)

Function Documentation

float Calcweight ( int  inu,
int  inunoosc 
)

Definition at line 76 of file MCNNFunctions.h.

00076                                        {
00077 
00078   Float_t weight=1;
00079 
00080   if(abs(inu)==12 || abs(inu)==14 || abs(inu)==16){
00081     if(abs(inunoosc)==12 || abs(inunoosc)==14 || abs(inunoosc)==16){
00082       weight = 1.0;
00083       if(abs(inu)==12 && abs(inunoosc)==12){
00084         weight=0.5;
00085       }
00086     }
00087   }
00088   
00089   return weight;
00090 
00091 }//end of Calcweight

bool DataPreselected ( const NtpSREvent srevent  ) 

Definition at line 173 of file MCNNFunctions.h.

References NtpSRPlane::n, NtpSREvent::nstrip, NtpSRPlane::nu, NtpSRPlane::nv, NtpSRPulseHeight::pe, NtpSREvent::ph, and NtpSREvent::plane.

00173                                                {
00174 
00175   bool isPreselected = true;
00176   if(srevent->ph.pe<50) isPreselected = 0; 
00177   if(srevent->ph.pe>10000) isPreselected = 0;
00178   if(srevent->plane.nu<2) isPreselected = 0;
00179   if(srevent->plane.nv<2) isPreselected = 0;
00180   if(srevent->plane.n<5) isPreselected = 0;
00181   if(srevent->plane.n>30) isPreselected = 0;
00182   if(srevent->nstrip<8) isPreselected = 0;
00183   if(srevent->nstrip>80) isPreselected = 0;
00184 
00185   return isPreselected;
00186 }

bool DataPreselected ( const NtpStRecord record,
const int  eventno 
)

Definition at line 157 of file MCNNFunctions.h.

References NtpTools::GetEvent().

Referenced by MCNNRunner::WriteResults().

00157                                                                   {
00158 
00159   bool isPreselected = true;
00160   const NtpSREvent* event = NtpTools::GetEvent(record, eventno); 
00161   if(event->ph.pe<50) isPreselected = 0; 
00162   if(event->ph.pe>10000) isPreselected = 0;
00163   if(event->plane.nu<2) isPreselected = 0;
00164   if(event->plane.nv<2) isPreselected = 0;
00165   if(event->plane.n<5) isPreselected = 0;
00166   if(event->plane.n>30) isPreselected = 0;
00167   if(event->nstrip<8) isPreselected = 0;
00168   if(event->nstrip>80) isPreselected = 0;
00169 
00170   return isPreselected;
00171 }

float DistanceToEdgeFD ( Float_t  vtxx_in,
Float_t  vtxy_in 
)

Definition at line 95 of file MCNNFunctions.h.

References min.

00095                                                         {
00096 
00097   float uview=sqrt(2.)*0.5*(vtxx_in+vtxy_in);
00098   float vview=sqrt(2.)*0.5*(vtxy_in-vtxx_in);
00099 
00100   float du=min(4.-uview,4.+uview);
00101   float dv=min(4.-vview,4.+vview);
00102   float dx=min(4.-vtxx_in,4.+vtxx_in);
00103   float dy=min(4.-vtxy_in,4.+vtxy_in);
00104   
00105   float dr=min(min(du,dv),min(dx,dy));
00106 
00107   return dr;
00108 
00109 }

bool MarkPreselection ( NueAnaReader nueana  ) 

Definition at line 442 of file MCNNFunctions.h.

References MCNNVars::mcnn_var2, NueRecord::mcnnv, MCNNVars::meanPlane, MCNNVars::meanU, MCNNVars::meanV, and NueAnaReader::nuerecord.

00442                                            {
00443 
00444   bool passPresel=true;
00445   
00446   //if(nueana->nuerecord->mcnnv.bestmatches < 50) passPresel=false; //<--removed since normally included with standard MCNN selection
00447   if(nueana->nuerecord->mcnnv.meanPlane >= 474) passPresel=false;
00448   if(nueana->nuerecord->mcnnv.mcnn_var2 >= 14) passPresel=false;//<--- put nPlanes in mcnn_var2
00449 
00450   float u = fabs(nueana->nuerecord->mcnnv.meanU - 95.5);
00451   float v = fabs(nueana->nuerecord->mcnnv.meanV - 95.5);
00452   float dist = 0.707106*(u+v);
00453   if(u>dist)dist=u;
00454   if(v>dist)dist=v;
00455 
00456   if(dist >= 93) passPresel=false;
00457 
00458   return passPresel;
00459 
00460 }

bool MCLibraryPreselected ( MinosEvent event  ) 

Definition at line 332 of file MCNNFunctions.h.

References MinosMC::IDact, nPlanes, MinosStrip::Plane, MinosStrip::QPEcorr, MinosStrip::Strip, MinosEvent::StripList, and MinosStrip::View.

00332                                             {
00333   //================================================================
00334   // applies some preselection to the MC events in the ibrary
00335   // Author: Caius Howcroft (&Mark Thomson?)
00336   //================================================================
00337   
00338   //NOTE: this is OBSOLETE NOW. Has not been duly updated
00339 
00340   bool isPreselected = false;
00341 
00342   bool planes[500];
00343   for(int i=0;i<500;++i)planes[i]=false;
00344 
00345   // loop over the strips to determine number of u and v strips to be stored
00346   const int nstrips = (int)(event->StripList->GetEntries());
00347   const MinosMC& eventMC = event->MCInfo;
00348 
00349   // Don't process NC events in electron/tau neutrino samples
00350   int runType = event->Run;
00351   runType = runType/100000;
00352   if(runType==211&&eventMC.IDact==0)return false;
00353   if(runType==213&&eventMC.IDact==0)return false;
00354 
00355   //  if(DEBUG)cout << " PRESELECTION : " << nstrips << endl;
00356   float sumQ = 0.;
00357   float sumQU = 0.;
00358   float sumQV = 0.;
00359   float sumU = 0.;
00360   float sumV = 0.;
00361   int   nU   = 0;
00362   int   nV   = 0;
00363   for(int istp = 0; istp< nstrips; istp++){
00364     const MinosStrip* strip = dynamic_cast<const MinosStrip*>(event->StripList->At(istp));
00365     //    if(DEBUG)cout << " strip : " << istp << " " << strip << endl;
00366     float qpe = strip->QPEcorr[0]+strip->QPEcorr[1];
00367     sumQ  += qpe;   
00368     if(strip->View==0){
00369       nU++;
00370       sumU  += strip->Strip*qpe;
00371       sumQU += qpe; 
00372    }
00373     if(strip->View==1){
00374       nV++;
00375       sumV  += strip->Strip*qpe;
00376       sumQV += qpe;
00377     }
00378     planes[strip->Plane]=true;
00379   }
00380   
00381   float nPlanes = 0.;
00382   int firstPlane =  999;
00383   int lastPlane  = -999;
00384 
00385   for(int i=0;i<500;++i){
00386     if(planes[i]){
00387       nPlanes++;
00388       if(i<firstPlane)firstPlane=i;
00389       if(i>lastPlane)lastPlane=i;
00390     }
00391   }
00392 
00393   // no selection at the moment so pass everything
00394   isPreselected = true;
00395   float meanU = -96.*0.041666;//<--
00396   float meanV = -96.*0.041666;  
00397   if(nU!=0){
00398     meanU = (sumU/sumQU-96.)*0.041666;
00399   }
00400   if(nV!=0){
00401     meanV = (sumV/sumQV-96.)*0.041666;
00402   }
00403   float meanX = (meanU+meanV)/1.41421;
00404   float meanY = (meanU-meanV)/1.41421;
00405 
00406 
00407   // ------------ Fiducial Cuts ---------------------
00408   // cut out start of SM1
00409   if(firstPlane<5)isPreselected = false;
00410   // cut out end of SM2
00411   if(lastPlane>481)isPreselected = false;
00412   // cut out events cross SMs
00413   if(firstPlane<249&&lastPlane>249)isPreselected = false;
00414   // cut out start of SM2
00415   if(firstPlane>=249&&firstPlane<=251)isPreselected = false;
00416   // cut end of SM1
00417   if(lastPlane>=247&&lastPlane<=249)isPreselected = false;
00418   // cut away 25 cm from detector edges
00419   if(isPreselected){
00420     if(fabs(meanU)>3.75)isPreselected = false;
00421     if(fabs(meanV)>3.75)isPreselected = false;
00422     if(fabs(meanX)>3.75)isPreselected = false;
00423     if(fabs(meanY)>3.75)isPreselected = false;
00424   }
00425   // remove 0.4m radius around coil hole
00426   if(meanU*meanU+meanV*meanV<0.16)isPreselected = false;
00427 
00428   // ---------------- nue cuts -----------------------
00429   if(nU<2)isPreselected = false;
00430   if(nV<2)isPreselected = false;
00431   if(nPlanes<5.5)isPreselected = false;
00432   if(nPlanes>30.5)isPreselected = false;
00433   if(nstrips<7.5)isPreselected = false;
00434   if(nstrips>80.)isPreselected = false;
00435   if(sumQ<50.)isPreselected = false;
00436   if(sumQ>1600.)isPreselected = false;
00437 
00438   return isPreselected;
00439 
00440 }

bool MCLibraryPreselected ( const NtpStRecord record,
Int_t  evtno 
)

Definition at line 215 of file MCNNFunctions.h.

References NtpStRecord::evt, nPlanes, NtpSREvent::nstrip, NtpSRPulseHeight::pe, NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRStrip::planeview, NtpSREvent::stp, NtpStRecord::stp, and NtpSRStrip::strip.

Referenced by MCNNRunner::WriteResults().

00215                                                                 {
00216   //================================================================
00217   // applies some preselection to the MC events in the library
00218   //
00219   // Original version: Caius Howcroft
00220   //
00221   // Modified by Pedro Ochoa to take NtpSt input instead of MinosEvent
00222   // Note that it does not fill histograms like its predecessor
00223   //
00224   // Last modif: May-31-2007
00225   // 
00226   // Note: changed some parameters from original values (like 
00227   // radius and maximum charge)
00228   //================================================================
00229 
00230   NtpSREvent *ntpEvent = 0;
00231   TClonesArray& evtArray = *(record->evt);
00232   ntpEvent = dynamic_cast<NtpSREvent *>(evtArray[evtno]);
00233   
00234   bool isPreselected = false;
00235 
00236   bool planes[500];
00237   for(int i=0;i<500;++i)planes[i]=false;
00238 
00239   // loop over the strips to determine number of u and v strips to be stored
00240   const int nstrips = (int)(ntpEvent->nstrip);
00241   //const NtpMCTruth *ntpTruth = NtpTools::GetTruth(record,evtno);
00242  
00243   //  if(DEBUG)cout << " PRESELECTION : " << nstrips << endl;
00244   float sumQ = 0.;
00245   float sumQU = 0.;
00246   float sumQV = 0.;
00247   float sumU = 0.;
00248   float sumV = 0.;
00249   int   nU   = 0;
00250   int   nV   = 0;
00251   for(int istp = 0; istp< nstrips; istp++){
00252     if(ntpEvent->stp[istp]<0) continue;
00253     const NtpSRStrip* ntpStrip = dynamic_cast<const NtpSRStrip *>(record->stp->At(ntpEvent->stp[istp]));
00254     //    if(DEBUG)cout << " strip : " << istp << " " << strip << endl;
00255     float qpe = ntpStrip->ph0.pe+ntpStrip->ph1.pe;
00256     sumQ  += qpe;   
00257     if(ntpStrip->planeview==2){
00258       nU++;
00259       sumU  += ntpStrip->strip*qpe;
00260       sumQU += qpe; 
00261    }
00262     if(ntpStrip->planeview==3){
00263       nV++;
00264       sumV  += ntpStrip->strip*qpe;
00265       sumQV += qpe;
00266     }
00267     planes[ntpStrip->plane]=true;
00268   }
00269 
00270 
00271   float nPlanes = 0.;
00272   int firstPlane =  999;
00273   int lastPlane  = -999;
00274 
00275   for(int i=0;i<500;++i){
00276     if(planes[i]){
00277       nPlanes++;
00278       if(i<firstPlane)firstPlane=i;
00279       if(i>lastPlane)lastPlane=i;
00280     }
00281   }
00282 
00283   // no selection at the moment so pass everything
00284   isPreselected = true;
00285   float meanU = -96.*0.041666;//<--
00286   float meanV = -96.*0.041666;  
00287   if(nU!=0){
00288     meanU = (sumU/sumQU-96.)*0.041666;
00289   }
00290   if(nV!=0){
00291     meanV = (sumV/sumQV-96.)*0.041666;
00292   }
00293   float meanX = (meanU+meanV)/1.41421;
00294   float meanY = (meanU-meanV)/1.41421;
00295 
00296 
00297   // ------------ Fiducial Cuts ---------------------
00298   // cut out start of SM1
00299   if(firstPlane<5)isPreselected = false;
00300   // cut out end of SM2
00301   if(lastPlane>481)isPreselected = false;
00302   // cut out events cross SMs
00303   if(firstPlane<249&&lastPlane>249)isPreselected = false;
00304   // cut out start of SM2
00305   if(firstPlane>=249&&firstPlane<=251)isPreselected = false;
00306   // cut end of SM1
00307   if(lastPlane>=247&&lastPlane<=249)isPreselected = false;
00308   // cut away 25 cm from detector edges
00309   if(isPreselected){
00310     if(fabs(meanU)>3.87)isPreselected = false;//<--used to be 3.75m
00311     if(fabs(meanV)>3.87)isPreselected = false;//<--used to be 3.75m
00312     if(fabs(meanX)>3.87)isPreselected = false;//<--used to be 3.75m
00313     if(fabs(meanY)>3.87)isPreselected = false;//<--used to be 3.75m
00314   }
00315   // remove 0.4m radius around coil hole
00316   if(meanU*meanU+meanV*meanV<0.16)isPreselected = false;
00317 
00318   // ---------------- nue cuts -----------------------
00319   if(nU<2)isPreselected = false;
00320   if(nV<2)isPreselected = false;
00321   if(nPlanes<5.5)isPreselected = false;
00322   if(nPlanes>30.5)isPreselected = false;
00323   if(nstrips<7.5)isPreselected = false;
00324   if(nstrips>80.)isPreselected = false;
00325   if(sumQ<50.)isPreselected = false;
00326   if(sumQ>3000.)isPreselected = false;//<--used to be 1600
00327 
00328   return isPreselected;
00329 
00330 }

float Oscillate ( int  nuFlavor,
int  nonOscNuFlavor,
float  Energy,
float  L,
float  dm2,
float  theta23,
float  UE32 
)

Definition at line 22 of file MCNNFunctions.h.

00024 {
00025    float oscterm = TMath::Sin(1.27*dm2*L/Energy);
00026 
00027    float pmt=pow((1-UE32)*oscterm*TMath::Sin(2*theta23),2);
00028    float pme=pow(TMath::Sin(theta23),2)*4.*UE32*(1-UE32)*pow(oscterm,2);
00029    float pmm=1.-pmt-pme;
00030  
00031    float pet=4*(1-UE32)*UE32*pow(TMath::Cos(theta23)*oscterm,2);
00032    float pem=pow(TMath::Sin(theta23),2)*4.*UE32*(1-UE32)*pow(oscterm,2);
00033    float pee=1.-pet-pem;
00034 
00035    /* //simplified probas
00036    float pmt=pow(oscterm,2);
00037    float pme=pow(TMath::Sin(theta23),2)*pow(oscterm,2)*4*UE32*(1-UE32);
00038    float pmm=1-pow(oscterm,2);
00039 
00040    float pet=0;
00041    float pem=0;
00042    float pee=1;
00043    */
00044 
00045    if(abs(nonOscNuFlavor)==14){
00046       if(abs(nuFlavor)==12){
00047          return pme;
00048       }
00049       else if(abs(nuFlavor)==14){
00050          return pmm;
00051       }
00052       else if(abs(nuFlavor)==16){
00053          return pmt;
00054       }
00055    }
00056    else if(abs(nonOscNuFlavor)==12){
00057       if(abs(nuFlavor)==12){
00058          return pee;
00059       }
00060       else if(abs(nuFlavor)==14){
00061         return pem;
00062       }
00063       else if(abs(nuFlavor)==16){
00064          return pet;
00065       }
00066    }
00067    else{
00068      std::cout<<"I don't know what to do with "<<nonOscNuFlavor
00069          <<" "<<nuFlavor<<" "<<pee<<std::endl;
00070    }
00071    return 0.;
00072 }//end of Oscillate

bool PreselModif ( NNReader nread  ) 

Definition at line 189 of file MCNNFunctions.h.

References NNReader::npln, NNReader::nstp, and NNReader::qtot.

00189                                  {
00190   //================================================================
00191   // applies some preselection to the events
00192   //
00193   // Pedro Ochoa
00194   //
00195   // Last modif: June-4-2007
00196   //================================================================
00197   
00198   bool isPreselected = true;
00199 
00200   // ---------------- nue cuts -----------------------
00201   //if(nread->cce->UStrips.size()<2)isPreselected = false;
00202   //if(nread->cce->VStrips.size()<2)isPreselected = false;
00203   if(nread->npln<5.5)isPreselected = false;
00204   if(nread->npln>30.5)isPreselected = false;
00205   if(nread->nstp<7.5)isPreselected = false;
00206   if(nread->nstp>80.)isPreselected = false;
00207   if(nread->qtot<50.)isPreselected = false;
00208   if(nread->qtot>3000.)isPreselected = false;
00209 
00210   return isPreselected;
00211 
00212 }

bool VtxIsContainedFD ( NNReader nread_in  ) 

Definition at line 113 of file MCNNFunctions.h.

References NNReader::vtxx, NNReader::vtxy, and NNReader::vtxz.

00113                                          {
00114 
00115   bool veredicto=true;
00116   Float_t radius=sqrt(pow(nread_in->vtxx,2)+pow(nread_in->vtxy,2));
00117 
00118   if(nread_in->vtxz>29.&& nread_in->vtxz<0.35){//End of SM2, beginning of SM1
00119     veredicto=false;
00120   }
00121   if(nread_in->vtxz>14.57 && nread_in->vtxz<16.2){//Between end of SM1 and SM2
00122     veredicto=false;
00123   }
00124   //if(DistanceToEdgeFD(nread_in->vtxx,nread_in->vtxy)<0.25){
00125   //  veredicto=false;
00126   //}
00127   if(radius>3.87 && radius<0.4){
00128     veredicto=false;
00129   }
00130 
00131 
00132   return veredicto;
00133 
00134 }

bool VtxIsContainedND ( NNReader nread_in  ) 

Definition at line 138 of file MCNNFunctions.h.

References NNReader::vtxx, NNReader::vtxy, and NNReader::vtxz.

00138                                          {
00139 
00140   bool veredicto=true;
00141   Float_t radius=sqrt(pow(nread_in->vtxx-1.4885,2)+pow(nread_in->vtxy-0.1397,2));
00142 
00143   if(nread_in->vtxz>5.&& nread_in->vtxz<1.0){
00144     veredicto=false;
00145   }  
00146   if(radius>1.0){
00147     veredicto=false;
00148   }
00149 
00150 
00151   return veredicto;
00152 
00153 }


Generated on 22 Nov 2017 for loon by  doxygen 1.6.1