NCExtractionCuts Class Reference

A simple cuts based extraction. More...

#include <NCExtractionCuts.h>

Inheritance diagram for NCExtractionCuts:

NCExtraction List of all members.

Public Member Functions

 NCExtractionCuts (NCAnalysisCuts *cuts, const Registry &r)
void FillAnalysisInfo (NCEventInfo &evtInfo, int beamType)
 Fill the analysisInfo member of evtInfo based on the other members and the beamType (in whatever convention that is).

Protected Member Functions

virtual double GetIdProbability (NCEventInfo &evtInfo, int)
 The probability that this event is CC.
virtual double GetCutPosition () const
 Where to cut on the IdProbability.
void ReadPDFs (NCEventInfo &evtInfo)
void FillPDFs (ANtpHeaderInfo *headerInfo, ANtpEventInfoNC *eventInfo, ANtpShowerInfoNC *showerInfo, ANtpTrackInfoNC *trackInfo, ANtpTruthInfoBeam *truthInfo=0, ANtpRecoInfo *recoInfo=0, int interactionType=2, double weight=1.)

Private Member Functions

bool PassesTrackReclamation (NCEventInfo &evtInfo)
 Does the event pass the ND "good track or track reclamation" cut?
bool PassesNCCuts (NCEventInfo &evtInfo)
 Does the event pass the NC selection algorithm?
bool PassesCCCuts (NCEventInfo &evtInfo)
 Does the event pass the CC selection algorithm?
TString WhichCCPIDFiles (Detector::Detector_t detType, ReleaseType::Release_t mcType, BeamType::BeamType_t beamType)
 Function to return correct CC Pid file.
float FindPDFProbability (TH1F *pdf, float value)

Private Attributes

std::map< NCType::EEventType,
std::vector< TH1F * > > 
fPDFs
bool fPDFsFilled
BeamType::BeamType_t fBeamType

Detailed Description

A simple cuts based extraction.

Definition at line 22 of file NCExtractionCuts.h.


Constructor & Destructor Documentation

NCExtractionCuts::NCExtractionCuts ( NCAnalysisCuts cuts,
const Registry r 
)

Definition at line 32 of file NCExtractionCuts.cxx.

References Msg::kInfo, MSG, and BeamType::TagToEnum().

00033                                                       :
00034   NCExtraction(cuts, r),
00035   fPDFsFilled(false),
00036   fBeamType(BeamType::kUnknown)
00037 
00038 {
00039   MSG("JobC", Msg::kInfo) << "NCExtractionCuts::Constructor 2" << endl;
00040 
00041 
00042   const char* tmps;
00043   if (r.Get("BeamType", tmps)) fBeamType=BeamType::TagToEnum(tmps);
00044 }


Member Function Documentation

void NCExtractionCuts::FillAnalysisInfo ( NCEventInfo evtInfo,
int  beamType 
) [virtual]

Fill the analysisInfo member of evtInfo based on the other members and the beamType (in whatever convention that is).

The default implementation fills separationParameter with the value of GetIdProbability(), separationParameterCut with the value of GetCutPosition(), and sets isCC to 1 if separationParameter >= separationParameterCut, and isNC to 1 otherwise

Reimplemented from NCExtraction.

Definition at line 240 of file NCExtractionCuts.cxx.

References NCExtraction::fCuts, fPDFsFilled, GetCutPosition(), GetIdProbability(), NCAnalysisCuts::InBeamFiducialVolume(), ANtpAnalysisInfo::isCC, NCAnalysisCuts::IsGoodBeamEvent(), ANtpAnalysisInfo::isNC, ANtpAnalysisInfo::pass, PassesCCCuts(), PassesNCCuts(), ReadPDFs(), ANtpAnalysisInfo::Reset(), ANtpAnalysisInfo::separationParameter, and ANtpAnalysisInfo::separationParameterCut.

00241 {
00242 
00243   if(!fPDFsFilled) ReadPDFs(evtInfo);
00244 
00245   ANtpAnalysisInfo* ana=evtInfo.analysis;
00246   //double separationParameter=GetIdProbability(evtInfo, beamType);
00247   double separationCut=GetCutPosition();
00248 
00249   ana->Reset();
00250 
00251   ana->separationParameterCut = separationCut;
00252   ana->separationParameter = GetIdProbability(evtInfo, beamType);
00253 
00254   // Events that pass the NC algorithm are NC...
00255   ana->isNC = PassesNCCuts(evtInfo);
00256   // ...of those that aren't, only the ones passing the CC cuts are CC
00257   ana->isCC = (!ana->isNC) && PassesCCCuts(evtInfo);
00258 
00259   if(ana->isCC) {
00260     ana->pass = (int)( evtInfo.reco->trackMomentum <= 0 && 
00261                        fCuts->IsGoodBeamEvent() && 
00262                        fCuts->InBeamFiducialVolume() );
00263   } else if(ana->isNC) {
00264     ana->pass = (int)fCuts->InBeamFiducialVolume();
00265   }
00266   else ana->pass=0; // neither NC nor CC
00267 }

void NCExtractionCuts::FillPDFs ( ANtpHeaderInfo headerInfo,
ANtpEventInfoNC eventInfo,
ANtpShowerInfoNC showerInfo,
ANtpTrackInfoNC trackInfo,
ANtpTruthInfoBeam truthInfo = 0,
ANtpRecoInfo recoInfo = 0,
int  interactionType = 2,
double  weight = 1. 
) [protected]

float NCExtractionCuts::FindPDFProbability ( TH1F *  pdf,
float  value 
) [private]

Definition at line 105 of file NCExtractionCuts.cxx.

Referenced by PassesCCCuts().

00106 {
00107   int bin = 0;
00108   float binContent = 0.;
00109 
00110   bin = pdf->FindBin(pdfValue);
00111   binContent = pdf->GetBinContent(bin);
00112 
00113   if(binContent>0. && pdf->Integral()>0.) return binContent/pdf->Integral();
00114   else                                    return 0;
00115 }

virtual double NCExtractionCuts::GetCutPosition (  )  const [inline, protected, virtual]

Where to cut on the IdProbability.

Implements NCExtraction.

Definition at line 32 of file NCExtractionCuts.h.

Referenced by FillAnalysisInfo().

00032 {return 0.5;}

double NCExtractionCuts::GetIdProbability ( NCEventInfo evtInfo,
int   
) [protected, virtual]

The probability that this event is CC.

Implements NCExtraction.

Definition at line 118 of file NCExtractionCuts.cxx.

References Msg::kDebug, MAXMSG, PassesCCCuts(), and PassesNCCuts().

Referenced by FillAnalysisInfo().

00119 {
00120   MAXMSG("NCExtractionCuts", Msg::kDebug,20) << "GetIdProbabilty" << endl;
00121 
00122   bool passesNCCuts=PassesNCCuts(evtInfo);
00123   bool passesCCCuts=PassesCCCuts(evtInfo);
00124 
00125   // Mini truth table for return value:
00126   //     |  CC  | !CC
00127   //  ----------------
00128   //  NC |  -1  |   0 
00129   // !NC |   1  |  -2
00130 
00131   if     ( passesCCCuts && !passesNCCuts) return 1;
00132   else if(!passesCCCuts &&  passesNCCuts) return 0;
00133   else if( passesCCCuts &&  passesNCCuts) return -1;
00134   else if(!passesCCCuts && !passesNCCuts) return -2;
00135 
00136   assert(0 && "This should never happen");
00137 }

bool NCExtractionCuts::PassesCCCuts ( NCEventInfo evtInfo  )  [private]

Does the event pass the CC selection algorithm?

Definition at line 172 of file NCExtractionCuts.cxx.

References det, ANtpHeaderInfo::detector, MuELoss::e, NCEventInfo::event, ANtpEventInfoNC::eventSummaryPlanes, FindPDFProbability(), fPDFs, NCEventInfo::header, NCType::kCC, NCType::kNC, Detector::kNear, ANtpEventInfoNC::lengthInPlanes, PassesTrackReclamation(), ANtpTrackInfo::planes, ANtpEventInfo::pulseHeight, ANtpTrackInfo::pulseHeight, NCEventInfo::track, and ANtpEventInfo::tracks.

Referenced by FillAnalysisInfo(), and GetIdProbability().

00173 {
00174   const Detector::Detector_t det = (Detector::Detector_t)evtInfo.header->detector;
00175 
00176   // David uses end-beg for the event length in the near,
00177   //not the number of hit planes
00178   int dpPlanes = det==Detector::kNear ? evtInfo.event->lengthInPlanes :
00179                                         evtInfo.event->eventSummaryPlanes;
00180   
00181   float trackSignalUseFraction = evtInfo.track->pulseHeight;
00182   if(evtInfo.event->pulseHeight > 0.)
00183     trackSignalUseFraction /= evtInfo.event->pulseHeight;
00184 
00185   float trackSignalPerPlane = evtInfo.track->pulseHeight;
00186   if(evtInfo.track->planes > 0) trackSignalPerPlane /= evtInfo.track->planes;
00187 
00188   vector<float> dpInputs;
00189 
00190   dpInputs.push_back(dpPlanes);
00191   dpInputs.push_back(trackSignalUseFraction);
00192   dpInputs.push_back(trackSignalPerPlane);
00193 
00194   float ncLikelihood = 1.;
00195   float ccLikelihood = 1.;
00196 
00197   for(int i = 0; i < (int)dpInputs.size(); ++i){
00198     //check to see if we should use the current distribution
00199     float ncProbability = FindPDFProbability(fPDFs[NCType::kNC][i],
00200                                              dpInputs[i]);
00201     float ccProbability = FindPDFProbability(fPDFs[NCType::kCC][i],
00202                                              dpInputs[i]);
00203 
00204     if(ncProbability == 0.) ncProbability = 1e-4;
00205     if(ccProbability == 0.) ccProbability = 1e-4;
00206 
00207     ncLikelihood *= ncProbability;
00208     ccLikelihood *= ccProbability;
00209   }//end over pdfs
00210 
00211 
00212 
00213   double probPID = TMath::Sqrt(-TMath::Log(ccLikelihood)) - 
00214                    TMath::Sqrt(-TMath::Log(ncLikelihood));
00215   probPID *= -1.;
00216 
00217   const float cc_cut = det == Detector::kNear ? -0.1 : -0.2;
00218 
00219   int tracks = evtInfo.event->tracks;
00220 
00221   bool passesCCCuts = probPID > cc_cut && tracks > 0;
00222   // In the near detector we additionally require to pass the track
00223   // fit pass/reclamation cut
00224   if(det == Detector::kNear) 
00225     passesCCCuts = passesCCCuts && PassesTrackReclamation(evtInfo);
00226 
00227   return passesCCCuts;
00228 }

bool NCExtractionCuts::PassesNCCuts ( NCEventInfo evtInfo  )  [private]

Does the event pass the NC selection algorithm?

Definition at line 140 of file NCExtractionCuts.cxx.

References det, ANtpHeaderInfo::detector, NCEventInfo::event, NCEventInfo::header, Detector::kNear, ANtpEventInfoNC::lengthInPlanes, ANtpTrackInfo::planes, ANtpShowerInfo::planes, ANtpEventInfo::planes, NCEventInfo::shower, NCEventInfo::track, and ANtpEventInfo::tracks.

Referenced by FillAnalysisInfo(), and GetIdProbability().

00141 {
00142   const Detector::Detector_t det = (Detector::Detector_t)evtInfo.header->detector;
00143 
00144   int tracks = evtInfo.event->tracks;
00145 
00146   int planes = det==Detector::kNear ? evtInfo.event->lengthInPlanes :
00147                                       evtInfo.event->planes;
00148 
00149   int trackExtension = evtInfo.shower->planes - evtInfo.track->planes;
00150 
00151   //NC Algorithm:
00152 
00153   // 1. Long events are definitely not NC
00154   if(planes >= 47) return false;
00155   else{
00156     // 2. Events without tracks definitely *are* NC
00157     if(tracks == 0) {
00158       return true;
00159     } else {
00160       // 3. Short events with tracks need to pass the track extension cut
00161       if(trackExtension > -6) {
00162         return true;
00163       } else {
00164         return false;
00165       }
00166     }
00167   }
00168 
00169 }

bool NCExtractionCuts::PassesTrackReclamation ( NCEventInfo evtInfo  )  [private]

Does the event pass the ND "good track or track reclamation" cut?

Definition at line 231 of file NCExtractionCuts.cxx.

References ANtpTrackInfo::begPlaneU, ANtpTrackInfo::begPlaneV, ANtpTrackInfo::endPlane, ANtpTrackInfo::endPlaneU, ANtpTrackInfo::endPlaneV, ANtpTrackInfo::passedFit, and NCEventInfo::track.

Referenced by PassesCCCuts().

00232 {
00233   return evtInfo.track->passedFit>0 ||
00234     (TMath::Abs(evtInfo.track->begPlaneU - evtInfo.track->begPlaneV) < 6
00235      && TMath::Abs(evtInfo.track->endPlaneU - evtInfo.track->endPlaneV) < 41
00236      && evtInfo.track->endPlane < 270);
00237 }

void NCExtractionCuts::ReadPDFs ( NCEventInfo evtInfo  )  [protected]

Definition at line 47 of file NCExtractionCuts.cxx.

References ANtpHeaderInfo::detector, fBeamType, Form(), fPDFs, fPDFsFilled, NCExtraction::fReleaseType, NCEventInfo::header, NCType::kCC, Msg::kFatal, Msg::kInfo, NCType::kNC, kNumPDFBaseNamesDP, MSG, and WhichCCPIDFiles().

Referenced by FillAnalysisInfo().

00048 {
00049   MSG("NCExtractionCuts", Msg::kInfo) << "ReadPDFs" << endl;
00050 
00051   TDirectory *savedir = gDirectory;
00052 
00053   // Try $SRT_LOCAL, $SRT_PRIVATE_CONTEXT then $SRT_PUBLIC_CONTEXT
00054   TString basedir(getenv("SRT_LOCAL"));
00055   if(basedir=="") basedir=getenv("SRT_PRIVATE_CONTEXT");
00056   // SRT_PRIVATE_CONTEXT gets set to '.' instead of empty, for some reason
00057   if(basedir==".") basedir=getenv("SRT_PUBLIC_CONTEXT");
00058 
00059   TString pdfPath = basedir+"/NCUtils/data/";
00060   
00061   Detector::Detector_t detType = (Detector::Detector_t)evtInfo.header->detector;
00062   
00063   TString pdffile = WhichCCPIDFiles(detType, fReleaseType, fBeamType);
00064   assert(pdffile!="");
00065   
00066   pdfPath += pdffile;
00067   MSG("NCExtractionCuts", Msg::kInfo)
00068     << "Reading PDFS from file " << pdfPath << endl;
00069   savedir->cd();
00070   
00071   TFile pdfFile(pdfPath);
00072   
00073   //clear the existing vectors
00074   fPDFs.clear();
00075   const char* pdfNamesInFile[kNumPDFBaseNamesDP] = {"Event length - %s",
00076                                                     "Track ph frac - %s",
00077                                                     "ph per plane (%s)"};
00078   vector<TString> ncccNames;
00079   ncccNames.resize(2);
00080   ncccNames[NCType::kNC]="nc";
00081   ncccNames[NCType::kCC]="cc";
00082 
00083   for(int i=0; i<kNumPDFBaseNamesDP; ++i){
00084     for(int evtType=0; evtType<2; ++evtType){
00085       TString histname=Form(pdfNamesInFile[i], ncccNames[evtType].Data());
00086       TH1F* hist=(TH1F*)pdfFile.Get(histname);
00087       if(!hist){ 
00088         MSG("NCExtractionCuts", Msg::kFatal) 
00089           << "Can't find histogram with name " << histname 
00090           << " in file." << endl;
00091         // Dummy message to make sure it aborts
00092         MSG("NCExtractionCuts", Msg::kFatal) << "Goodbye" << endl;
00093       }
00094       hist->SetDirectory(0);
00095       fPDFs[(NCType::EEventType)evtType].push_back(hist);
00096     }
00097   }
00098 
00099   savedir->cd();
00100 
00101   fPDFsFilled = true;
00102 }

TString NCExtractionCuts::WhichCCPIDFiles ( Detector::Detector_t  detType,
ReleaseType::Release_t  mcType,
BeamType::BeamType_t  beamType 
) [private]

Function to return correct CC Pid file.

Definition at line 270 of file NCExtractionCuts.cxx.

References ReleaseType::IsCarrot(), ReleaseType::IsDaikon(), ReleaseType::IsDogwood(), Msg::kError, Detector::kFar, BeamType::kL000z200i, BeamType::kL010z000i, BeamType::kL010z170i, BeamType::kL010z185i, BeamType::kL010z185i_i124, BeamType::kL010z185i_i191, BeamType::kL010z185i_i213, BeamType::kL010z185i_i224, BeamType::kL010z185i_i232, BeamType::kL010z185i_i243, BeamType::kL010z185i_i257, BeamType::kL010z185i_i282, BeamType::kL010z185i_i303, BeamType::kL010z185i_i324, BeamType::kL010z185i_lowintensity, BeamType::kL010z200i, BeamType::kL050z200i, BeamType::kL100z200i, BeamType::kL150z200i, BeamType::kL200z200i, BeamType::kL250z200i, Detector::kNear, BeamType::kUnknown, ReleaseType::kUnknown, and MAXMSG.

Referenced by ReadPDFs().

00273 {
00274 
00275   if(ReleaseType::IsDogwood(mcType)){
00276     MAXMSG("NCExtractionCuts", Msg::kError,5)                   << endl
00277       << "****************************************************" << endl
00278       << "* USING CEDAR CC PID FILES ON DOGWOOD. FIX THIS    *" << endl
00279       << "* BEFORE DOING A REAL ANALYSIS                     *" << endl
00280       << "****************************************************" << endl;
00281   }
00282 
00283   assert(mcType != ReleaseType::kUnknown);
00284 
00285   assert(!ReleaseType::IsCarrot(mcType));
00286 
00287   if(detType == Detector::kFar) {
00288      if(ReleaseType::IsDaikon(mcType)) {
00289        switch (beamType){
00290        case BeamType::kL010z185i:
00291        case BeamType::kL010z185i_i124:
00292        case BeamType::kL010z185i_i191:
00293        case BeamType::kL010z185i_i213:
00294        case BeamType::kL010z185i_i224:
00295        case BeamType::kL010z185i_i232:
00296        case BeamType::kL010z185i_i243:
00297        case BeamType::kL010z185i_i257:
00298        case BeamType::kL010z185i_i282:
00299        case BeamType::kL010z185i_i303:
00300        case BeamType::kL010z185i_i324: 
00301        case BeamType::kUnknown:
00302          return "dp_pdf_far_le_cedar_daikon.root";
00303        default:
00304          return "";
00305        }
00306      }
00307      return "";
00308   }
00309 
00310   if(detType == Detector::kNear){
00311     if(ReleaseType::IsDaikon(mcType)){
00312       switch (beamType){
00313       case BeamType::kL000z200i:
00314       case BeamType::kL010z185i:
00315       case BeamType::kL010z185i_i124:
00316       case BeamType::kL010z185i_i191:
00317       case BeamType::kL010z185i_i213:
00318       case BeamType::kL010z185i_i224:
00319       case BeamType::kL010z185i_i232:
00320       case BeamType::kL010z185i_i243:
00321       case BeamType::kL010z185i_i257:
00322       case BeamType::kL010z185i_i282:
00323       case BeamType::kL010z185i_i303:
00324       case BeamType::kL010z185i_i324:
00325       case BeamType::kL050z200i:
00326       case BeamType::kL200z200i:
00327       case BeamType::kL010z000i:
00328       case BeamType::kL010z170i:
00329       case BeamType::kL010z200i:
00330       case BeamType::kL010z185i_lowintensity:
00331       case BeamType::kUnknown:
00332         return "dp_pdf_near_L010z185i_cedar_daikon.root";
00333 
00334       case BeamType::kL100z200i:
00335         return "dp_pdf_near_L100z200i_cedar_daikon.root";
00336 
00337       case BeamType::kL250z200i:
00338         return "dp_pdf_near_L250z200i_cedar_daikon.root";
00339 
00340       case BeamType::kL150z200i:
00341         return "dp_pdf_near_L150z200i_cedar_daikon.root";
00342 
00343       default:
00344         return "";
00345       }
00346     }
00347     return "";
00348   }
00349 
00350   return "";
00351 }


Member Data Documentation

BeamType::BeamType_t NCExtractionCuts::fBeamType [private]

Definition at line 66 of file NCExtractionCuts.h.

Referenced by ReadPDFs().

std::map< NCType::EEventType, std::vector<TH1F *> > NCExtractionCuts::fPDFs [private]

Definition at line 46 of file NCExtractionCuts.h.

Referenced by PassesCCCuts(), and ReadPDFs().

bool NCExtractionCuts::fPDFsFilled [private]

Definition at line 64 of file NCExtractionCuts.h.

Referenced by FillAnalysisInfo(), and ReadPDFs().


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 00:55:50 2014 for loon by  doxygen 1.4.7