ANtpInfoObjectFillerMRCC Class Reference

#include <ANtpInfoObjectFillerMRCC.h>

List of all members.

Public Member Functions

void FillEventInformation (int i, const NtpMRRecord *mrRecord, const NtpStRecord *stRecord, ANtpEventInfoMRCC *antp, ANtpTruthInfoBeam *truth) const
 Fill antp mrcc information corresponding to i using best_event.

Protected Member Functions

void FillEventInformationHelper (const NtpMREvent *mrnt, const NtpStRecord *sntp_orig, ANtpEventInfoMRCC *antp, ANtpTruthInfoBeam *truth) const
 Internal helper, copy contents of mrnt into antp.
double ABPID (const NtpSREvent *ev, const NtpStRecord *st) const
double ROPID (const NtpSREvent *ev, const NtpStRecord *st) const

Detailed Description

Definition at line 13 of file ANtpInfoObjectFillerMRCC.h.


Member Function Documentation

double ANtpInfoObjectFillerMRCC::ABPID ( const NtpSREvent ev,
const NtpStRecord st 
) const [protected]

Return the AB PID value for event ev in snarl st, reading the appropriate PDFs if necessary

Definition at line 150 of file ANtpInfoObjectFillerMRCC.cxx.

References bfld::AsString(), base, MadAbID::CalcPID(), det, fname, VldContext::GetDetector(), NtpStRecord::GetRelease(), RecRecordImp< T >::GetVldContext(), gSystem(), ReleaseType::IsCedar(), Detector::kFar, Msg::kFatal, Detector::kNear, Msg::kWarning, MSG, and MadAbID::ReadPDFs().

Referenced by FillEventInformationHelper().

00151 {
00152   static bool once=false;
00153   static MadAbID ABID;
00154   
00155   // Code stolen from NueAna's MuonRemovalInfoAna
00156   if(!once){
00157     once=true;
00158     string base=getenv("SRT_PRIVATE_CONTEXT");
00159      if(base!="" && base!="."){
00160        // check if directory exists in SRT_PRIVATE_CONTEXT
00161        string path = base + "/Mad/data";
00162        void* dir_ptr = gSystem->OpenDirectory(path.c_str());
00163        if(!dir_ptr){
00164          base=getenv("SRT_PUBLIC_CONTEXT");
00165        }
00166      }
00167      else{  
00168        base=getenv("SRT_PUBLIC_CONTEXT"); 
00169      }
00170      if(base=="") {
00171        MSG("ObjectFillerMRCC",Msg::kFatal)<<"No SRT_PUBLIC_CONTEXT set "
00172                                          <<"Do not know where to look "
00173                                          <<"for AB pdf files "<<std::endl;
00174        // Dummy message to make sure it exits
00175        MSG("ObjectFillerMRCC",Msg::kFatal) << "Goodbye" << endl;
00176      }
00177      base+="/Mad/data";
00178      string fname=base;
00179      string rmc="";
00180      // ARGH! Can't do this at all sensibly, since there aren't PDF
00181      // files for dogwood (I guess). Should also really check on MC
00182      // version, but this code is never going to be run on anything
00183      // other than daikon, so it doesn't matter.
00184      ReleaseType::Release_t release=st->GetRelease();
00185      if(ReleaseType::IsCedar(release)){
00186        rmc="cedar_daikon";
00187      }
00188      else{
00189        MSG("ObjectFillerMRCC",Msg::kWarning) 
00190          << "Running on release type " << ReleaseType::AsString(release)
00191          << " which has no PDFs. Using cedar_daikon instead." << endl;
00192        rmc="cedar_daikon";
00193      }
00194 
00195      string sdet="";
00196      Detector::Detector_t det=st->GetVldContext()->GetDetector();
00197      if(det==Detector::kNear){
00198        sdet="near";
00199      }
00200      else if(det==Detector::kFar){
00201        sdet="far";
00202      }
00203      else{
00204        MSG("ObjectFillerMRCC",Msg::kFatal) << "Dont know detector type."
00205                                            << " Bailing"<<endl;
00206        // Dummy message to make sure it exits
00207        MSG("ObjectFillerMRCC",Msg::kFatal) << "Goodbye" << endl;
00208      }
00209      string sbeam="le";
00210      /*
00211        Should really do this switch, but I don't know how to get the
00212        beamtype through to here to check against. Probably won't ever
00213        run it on non-LE events anyway.
00214 
00215      switch(current_beam){
00216      case BeamType::kL010z000i:
00217        sbeam="le0";
00218        break;
00219      case BeamType::kL010z170i:
00220        sbeam="le170";
00221        break;
00222      case BeamType::kL010z185i:
00223        sbeam="le";
00224        break;
00225      case BeamType::kL010z200i:
00226        sbeam="le200";
00227        break;
00228      case BeamType::kL100z200i:
00229        sbeam="pme";
00230        break;
00231      case BeamType::kL150z200i:
00232        sbeam="pme";
00233        break;
00234      case BeamType::kL250z200i:
00235        sbeam="phe";
00236        break;
00237      case BeamType::kLE:
00238        sbeam="le";
00239        break;
00240      default:
00241        MSG("ObjectFillerMRCC",Msg::kWarning)<<"Don't know beam type "
00242                                            <<" defaulting to LE"<<endl;
00243        sbeam="le";
00244        break;
00245      }
00246      */
00247                                                                                  
00248      fname+="/ab_pdf_"+sdet+"_"+sbeam+"_"+rmc+".root";
00249                                                                                  
00250      ABID.ReadPDFs(fname.c_str());
00251   }
00252                                                                                  
00253   return ABID.CalcPID(ev, st);
00254 }

void ANtpInfoObjectFillerMRCC::FillEventInformation ( int  i,
const NtpMRRecord mrRecord,
const NtpStRecord stRecord,
ANtpEventInfoMRCC antp,
ANtpTruthInfoBeam truth 
) const

Fill antp mrcc information corresponding to i using best_event.

Parameters:
i Index in "normal" ANtp branches we should be matching
mrRecord sntp mrcc information for this snarl
stRecord The corresponding non-MRCC sntp record for this snarl
antp Output. Will be untouched if no match found
truth The truth info branch, which is filled here because of the problem documented in docdb 6599

Definition at line 31 of file ANtpInfoObjectFillerMRCC.cxx.

References NtpMREvent::best_event, FillEventInformationHelper(), and NtpMRRecord::mrevt.

Referenced by CondensedNtpModuleNC::Ana().

00036 {
00037   assert(i >= 0);
00038   assert(mrRecord);
00039 
00040   // The number of mrcc records in this snarl
00041   const int J = mrRecord->mrevt->GetEntriesFast();
00042   // Go through all the mrcc records in this snarl
00043   for(int j = 0; j < J; ++j){
00044     const NtpMREvent* mrevt = (NtpMREvent*)(mrRecord->mrevt->At(j));
00045     assert(mrevt);
00046     // See if any of them are matched up to the current event
00047     if(mrevt->best_event == i){
00048       FillEventInformationHelper(mrevt, stRecord, antp, truth);
00049       // Assume there is only one match. If there are more then there's
00050       // nothing sensible we can do about it anyway.
00051       return;
00052     }
00053   } // end for j
00054   // No matches, leave antp alone (it should already be default)
00055 }

void ANtpInfoObjectFillerMRCC::FillEventInformationHelper ( const NtpMREvent mrnt,
const NtpStRecord sntp_orig,
ANtpEventInfoMRCC antp,
ANtpTruthInfoBeam truth 
) const [protected]

Internal helper, copy contents of mrnt into antp.

Definition at line 59 of file ANtpInfoObjectFillerMRCC.cxx.

References ABPID(), NtpMREvent::best_complete, NtpMREvent::best_complete_phw, NtpMREvent::best_event, NtpMREvent::best_purity, NtpMREvent::best_purity_phw, ANtpEventInfoMRCC::bestComplete, ANtpEventInfoMRCC::bestCompletePHw, ANtpEventInfoMRCC::bestEvent, ANtpEventInfoMRCC::bestPurity, ANtpEventInfoMRCC::bestPurityPHw, ANtpEventInfoMRCC::contained, ANtpEventInfoMRCC::containedOrGoodFit, ANtpEventInfoMRCC::digits, NtpMREvent::endc, NtpMREvent::enddistance, NtpMREvent::endp, NtpMREvent::endx, NtpMREvent::endy, NtpMREvent::endz, ANtpInfoObjectFillerBeam::FillBeamMCTruthInformation(), ANtpInfoObjectFiller::FillMCTruthInformation(), ANtpEventInfoMRCC::fitMomentum, NtpMREvent::fitp, NtpStRecord::GetEventMCTruth(), NtpStRecord::GetEvents(), RecRecordImp< T >::GetHeader(), RecPhysicsHeader::GetSnarl(), ANtpEventInfoMRCC::index, NtpMREvent::index, Msg::kDebug, ANtpEventInfoMRCC::maxTrackPlane, NtpMREvent::mrmEshw, NtpMREvent::mrmpmux, NtpMREvent::mrmpmuy, NtpMREvent::mrmpmuz, NtpMREvent::mrmQ2, MSG, NtpMREvent::mxpl, NtpMREvent::ndigit, NtpMREvent::npln, NtpMREvent::nstrip, NtpMREvent::orig_event, ANtpEventInfoMRCC::origABPID, ANtpEventInfoMRCC::origEvent, ANtpEventInfoMRCC::origROPID, NtpMREvent::pass, ANtpEventInfoMRCC::passedFit, NtpMREvent::pcrv, NtpMREvent::pmux, NtpMREvent::pmuy, NtpMREvent::pmuz, NtpMREvent::prng, NtpMREvent::pvdx, NtpMREvent::pvdy, NtpMREvent::pvdz, ANtpEventInfoMRCC::qp, NtpMREvent::qp, ANtpEventInfoMRCC::rangeMomentum, ANtpTruthInfoBeam::Reset(), ROPID(), ANtpEventInfoMRCC::showerCharge, ANtpEventInfoMRCC::showerEndPlane, ANtpEventInfoMRCC::showerEndX, ANtpEventInfoMRCC::showerEndY, ANtpEventInfoMRCC::showerEndZ, ANtpEventInfoMRCC::showerPlanes, ANtpEventInfoMRCC::showerVtxPlane, ANtpEventInfoMRCC::showerVtxX, ANtpEventInfoMRCC::showerVtxY, ANtpEventInfoMRCC::showerVtxZ, NtpMREvent::shwcharge, NtpMREvent::shwendplane, NtpMREvent::shwendx, NtpMREvent::shwendy, NtpMREvent::shwendz, NtpMREvent::shwnplane, NtpMREvent::shwvtxplane, NtpMREvent::shwvtxx, NtpMREvent::shwvtxy, NtpMREvent::shwvtxz, NtpStRecord::stdhep, ANtpEventInfoMRCC::strips, ANtpEventInfoMRCC::trackDcosXVtx, ANtpEventInfoMRCC::trackDcosYVtx, ANtpEventInfoMRCC::trackDcosZVtx, ANtpEventInfoMRCC::trackEndDistanceToEdge, ANtpEventInfoMRCC::trackEndPlane, ANtpEventInfoMRCC::trackEndX, ANtpEventInfoMRCC::trackEndY, ANtpEventInfoMRCC::trackEndZ, ANtpEventInfoMRCC::trackMomentumX, ANtpEventInfoMRCC::trackMomentumY, ANtpEventInfoMRCC::trackMomentumZ, ANtpEventInfoMRCC::trackPlanes, ANtpEventInfoMRCC::trackVtxDistanceToEdge, ANtpEventInfoMRCC::trackVtxPlane, ANtpEventInfoMRCC::trackVtxX, ANtpEventInfoMRCC::trackVtxY, ANtpEventInfoMRCC::trackVtxZ, ANtpEventInfoMRCC::trueMomentumX, ANtpEventInfoMRCC::trueMomentumY, ANtpEventInfoMRCC::trueMomentumZ, ANtpEventInfoMRCC::trueQ2, ANtpEventInfoMRCC::trueShowerEnergy, NtpMREvent::vtxdistance, NtpMREvent::vtxp, NtpMREvent::vtxx, NtpMREvent::vtxy, and NtpMREvent::vtxz.

Referenced by FillEventInformation().

00063 {
00064   assert(mrnt);
00065   assert(sntp_orig);
00066   assert(antp);
00067 
00068   antp->index = mrnt->index;
00069   antp->digits = mrnt->ndigit;
00070   antp->strips = mrnt->nstrip;
00071 
00072   antp->origEvent = mrnt->orig_event;
00073   antp->bestEvent = mrnt->best_event;
00074   antp->bestPurity = mrnt->best_purity;
00075   antp->bestComplete = mrnt->best_complete;
00076   antp->bestPurityPHw = mrnt->best_purity_phw;
00077   antp->bestCompletePHw = mrnt->best_complete_phw;
00078 
00079   MSG("ObjectFillerMRCC",Msg::kDebug) 
00080     << "orig_event=" << mrnt->orig_event << endl
00081     //<< "mrnt->snarl=" << mrnt->GetHeader().GetSnarl() << endl
00082     << "sntp_orig->snarl=" << sntp_orig->GetHeader().GetSnarl() << endl;
00083 
00084   vector<const NtpSREvent*> orig_evts=sntp_orig->GetEvents();
00085   assert(mrnt->orig_event < (int)orig_evts.size());
00086 
00087   const NtpSREvent* orig_event=orig_evts[mrnt->orig_event];
00088   antp->origABPID = ABPID(orig_event, sntp_orig);
00089   antp->origROPID = ROPID(orig_event, sntp_orig);
00090 
00091   if(truth){
00092     // Fill the truth information. This code copied from
00093     // ANtpInfoObjectFillerNC::FillMCInformation
00094     truth->Reset();
00095     // Gah, const correctness, or lack of it
00096     NtpMCTruth* ntpMCTruth=const_cast<NtpMCTruth*>(sntp_orig->GetEventMCTruth(mrnt->orig_event));
00097     
00098     ANtpInfoObjectFiller::FillMCTruthInformation(ntpMCTruth, truth);
00099     ANtpInfoObjectFillerBeam::FillBeamMCTruthInformation(ntpMCTruth, sntp_orig->stdhep, 
00100                                                          truth);
00101   }
00102 
00103   antp->showerVtxX = mrnt->shwvtxx;
00104   antp->showerVtxY = mrnt->shwvtxy;
00105   antp->showerVtxZ = mrnt->shwvtxz;
00106   antp->showerEndX = mrnt->shwendx;
00107   antp->showerEndY = mrnt->shwendy;
00108   antp->showerEndZ = mrnt->shwendz;
00109   antp->showerVtxPlane = mrnt->shwvtxplane;
00110   antp->showerEndPlane = mrnt->shwendplane;
00111   antp->showerPlanes = mrnt->shwnplane;
00112   antp->showerCharge = mrnt->shwcharge;
00113 
00114   antp->trackVtxX = mrnt->vtxx;
00115   antp->trackVtxY = mrnt->vtxy;
00116   antp->trackVtxZ = mrnt->vtxz;
00117   antp->trackVtxDistanceToEdge = mrnt->vtxdistance;
00118   antp->trackEndX = mrnt->endx;
00119   antp->trackEndY = mrnt->endy;
00120   antp->trackEndZ = mrnt->endz;
00121   antp->trackEndDistanceToEdge = mrnt->enddistance;
00122 
00123   antp->trackVtxPlane = mrnt->vtxp;
00124   antp->trackEndPlane = mrnt->endp;
00125   antp->trackPlanes = mrnt->npln;
00126   antp->rangeMomentum = mrnt->prng;
00127   antp->fitMomentum = mrnt->pcrv;
00128   antp->trackDcosXVtx = mrnt->pvdx;
00129   antp->trackDcosYVtx = mrnt->pvdy;
00130   antp->trackDcosZVtx = mrnt->pvdz;
00131 
00132   antp->passedFit = mrnt->fitp;
00133   antp->contained = mrnt->endc;
00134   antp->containedOrGoodFit = mrnt->pass;
00135   antp->trackMomentumX = mrnt->pmux;
00136   antp->trackMomentumY = mrnt->pmuy;
00137   antp->trackMomentumZ = mrnt->pmuz;
00138   antp->maxTrackPlane = mrnt->mxpl;
00139   antp->qp = mrnt->qp;
00140 
00141   antp->trueMomentumX = mrnt->mrmpmux;
00142   antp->trueMomentumY = mrnt->mrmpmuy;
00143   antp->trueMomentumZ = mrnt->mrmpmuz;
00144   antp->trueQ2 = mrnt->mrmQ2;
00145   antp->trueShowerEnergy = mrnt->mrmEshw;
00146 
00147 }

double ANtpInfoObjectFillerMRCC::ROPID ( const NtpSREvent ev,
const NtpStRecord st 
) const [protected]

Return the RO PID value for event ev in snarl st, reading the appropriate training files if necessary

Definition at line 257 of file ANtpInfoObjectFillerMRCC.cxx.

Referenced by FillEventInformationHelper().

00258 {
00259   // ***********
00260   // Don't calculate the kNN stuff. It's too slow
00261   // ***********
00262   return -1;
00263 
00264   /*
00265   // TODO: This code copied wholesale from ANtpInfoObjectFillerNC. Should rationalize.
00266 
00267   static bool once=false;
00268   static Anp::Interface anpint;
00269 
00270   if(!once){
00271     once=true;
00272     //set the location of the weight files based on the detector
00273     TString weightFileName = "knn.train.far.cedar.daikon.root";
00274     Detector::Detector_t det=st->GetVldContext()->GetDetector();
00275     if(det == Detector::kNear) weightFileName = "knn.train.near.cedar.daikon.root";
00276 
00277     TString base = getenv("SRT_PRIVATE_CONTEXT");
00278     TString ncutils = "/NCUtils/data/";
00279     if(base != "" && base != "."){
00280       //check that the private context director exists, if not use public context
00281       void *dirptr = gSystem->OpenDirectory(base+ncutils);
00282       if(!dirptr){
00283         base = getenv("SRT_PUBLIC_CONTEXT");
00284       }//end if private context doesnt exist
00285     }//end if private context is defined
00286     else base = getenv("SRT_PUBLIC_CONTEXT");
00287 
00288     //check that the public context exists, if not assert false
00289     if(base == ""){
00290       MSG("ObjectFillerMRCC", Msg::kFatal) << "no SRT_PUBLIC_CONTEXT set"
00291                                                  << endl;
00292       assert(false);
00293     }
00294 
00295     TString weightFilePath = base+ncutils+weightFileName;
00296     TString baseConf = getenv("SRT_PUBLIC_CONTEXT");
00297 
00298     Registry reg;
00299     reg.Set("InterfaceConfigPath", 
00300             baseConf+"/PhysicsNtuple/Config/Config2007Real.txt");
00301     reg.Set("FillkNNFilePath", weightFilePath);
00302     
00303     anpint.Config(reg);
00304   }
00305 
00306   static int prevSnarl=-1;
00307   int thisSnarl=st->GetHeader().GetSnarl();
00308   // Only refill the Anp interface once per snarl
00309   if(thisSnarl!=prevSnarl){
00310     prevSnarl=thisSnarl;
00311     // Gah, I wish const correctness wasn't such a pain
00312     if(!anpint.FillSnarl(const_cast<NtpStRecord*>(st))){
00313       MSG("ObjectFillerMRCC", Msg::kFatal) << "Couldn't set up Anp::Interface" << endl;
00314       // Dummy message to make sure it exits here
00315       MSG("ObjectFillerMRCC", Msg::kFatal) << "Goodbye" << endl;
00316     }
00317   }
00318 
00319   // Gah, I wish const correctness wasn't such a pain
00320   return anpint.GetVar("knn_pid", const_cast<NtpSREvent*>(ev));
00321   */
00322 }


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1