DSTUtil Namespace Reference


Namespaces

namespace  Bflux
namespace  Calo
namespace  Ckov
namespace  Global
namespace  GoodRun
namespace  NuMI
namespace  Prsc
namespace  RICH
namespace  RootUtil
namespace  Target
namespace  ToF
namespace  Trig

Functions

int HavePileUpCommon (const MIPPEventSummary *evt)
 Functions which can be used to select (reject) pile-up events independent of beam particle momentum.
int HavePileUp60 (const MIPPEventSummary *evt)
 Functions which can be used to select (reject) pile-up events in 60 GeV/c momentum.
int HavePileUp120 (const MIPPEventSummary *evt)
 Functions which can be used to select (reject) pile-up events in 120 GeV/c momentum.
bool GoodBeam (const MIPPRunSummary *rs, const MIPPEventSummary *evt, const MIPPBeamTrkSummary *fBeam)
bool GoodVertex (const MIPPRunSummary *runsum, const MIPPVertexSummary *vtx, float rWin, float zWin)
bool GoodTrack (const MIPPTrackSummary *trk)
void SigHandle (int sig)
 Default signal handler.
TTree * GetTreeByName (TFile *const f, std::string const fTreeDir, std::string const fTreeName)
 Given a MIPP histogram file, return a tree with name fTreeName in the first directory with name starting with fTreeDir.
TTree * GetEvtTree (TFile *f)
 Given a MIPP histogram file, return DST tree.
TTree * GetSpillTree (TFile *f)
 Given a MIPP histogram file, return DST tree.
void GetFileList (int argc, char **argv, std::vector< std::string > &list)
 Parses command-line arguments to extract names of valid ROOT files.
void AddToFileList (char *arg, std::vector< std::string > &list)
 Parses arg and add to list if it is a ROOT file or add all ROOT fileslisted in file arg to list.
MIPPRunSummaryGetRunSummary (TFile *f)
 Gets the first entry from run summary tree.
MIPPRunSummaryGetRunSummaryVerbose (TFile *f)
 like DSTUtil::GetRunSummary(TFile* f), but print some info about this run to stdout.
MIPPRunSummaryGetRunSummary (TFile *f, const int &subrun)
 Gets entry for subrun from run summary tree.
TTree * GetMCMatchTree (TFile *f)
 Given a MIPP histogram file, return MCMatch tree.
TTree * GetVeeTree (TFile *f, string &ntuple)
TTree * GetVeeTree (TFile *f, std::string &ntuple)


Function Documentation

int DSTUtil::HavePileUpCommon ( const MIPPEventSummary evt  ) 

Functions which can be used to select (reject) pile-up events independent of beam particle momentum.

Definition at line 39 of file DSTUtil.cxx.

References MIPPBeamTrkSummary::avgt, MIPPEventSummary::GetBTrk(), MIPPEventSummary::GetT0(), RIMCConfig::kMCRunOffset, MIPPEventSummary::NBTrk(), MIPPEventSummary::NT0(), MIPPT0Summary::Qtot(), and MIPPEventSummary::run.

Referenced by HavePileUp120(), and HavePileUp60().

00039                                                         {
00040   // No pile up on MC events
00041   if (evt->run >= RIMCConfig::kMCRunOffset) return 0;
00042   
00043   // Avoid multiple beam tracks
00044   if (evt->NBTrk() > 1) return 1;
00045   
00046   // Make sure beam track time is ok, if we have a beam track at all
00047   MIPPBeamTrkSummary* trk = evt->GetBTrk(0);
00048   if (trk && (trk->avgt < -5 || trk->avgt > 20)) return 2;
00049   
00050   // Check T0 summed charge
00051   float maxT0ADC = 1.8 * 4 * 3;// 3 counters with 4 tubes each
00052   float minT0ADC = 0.5 * 4 * 3;// 3 counters with 4 tubes each
00053   if (evt->NT0() == 5) {
00054     float totADC = 0;
00055     totADC += evt->GetT0(0)->Qtot(); // T00
00056     totADC += evt->GetT0(1)->Qtot(); // T01
00057     totADC += evt->GetT0(3)->Qtot(); // TBD
00058     
00059     if (totADC > maxT0ADC || totADC < minT0ADC) return 3; 
00060   }
00061   return 0;
00062 }

int DSTUtil::HavePileUp60 ( const MIPPEventSummary evt  ) 

Functions which can be used to select (reject) pile-up events in 60 GeV/c momentum.

Definition at line 65 of file DSTUtil.cxx.

References HavePileUpCommon().

Referenced by main().

00065                                                     {
00066   return HavePileUpCommon(evt);
00067 }

int DSTUtil::HavePileUp120 ( const MIPPEventSummary evt  ) 

Functions which can be used to select (reject) pile-up events in 120 GeV/c momentum.

Definition at line 70 of file DSTUtil.cxx.

References MIPPEventSummary::bckov1adc, MIPPEventSummary::bckov1tdc, MIPPEventSummary::bckov2adc, MIPPEventSummary::bckov2tdc, MIPPEventSummary::GetT0(), MIPPEventSummary::GetTrk(), HavePileUpCommon(), MIPPEventSummary::NT0(), MIPPEventSummary::NTrk(), MIPPEventSummary::t0, and t0.

Referenced by TOFCalib2::Ana(), Ana(), TOFTempCorrector::GraphAna(), main(), TOFTempCorrector::PreAna(), and PreAna().

00070                                                      {
00071   // Check common PileUp criteria
00072   int fCommon = HavePileUpCommon(evt);
00073   if(fCommon != 0) return fCommon;
00074 
00075   // Check beam Cherenkov summed charge
00076   if (evt->bckov1adc[0] + evt->bckov2adc[0] > 330 * 2) return 4;
00077 
00078   // Check T0 time differences
00079   float minT0diff[5] = {-1.5, -0.5, -0.2, -6, -1};
00080   float maxT0diff[5] = {1.5, 0.5, 0.25, 7, 0.8};
00081   for (int i = 0; i < evt->NT0(); ++i) {
00082     MIPPT0Summary* t0 = evt->GetT0(i);
00083     if (t0->timeavg - evt->t0 < minT0diff[i] || 
00084     t0->timeavg - evt->t0 > maxT0diff[i]) return 5;
00085   }
00086 
00087   // Check BCkov TDC's
00088   // Require upper inner PMT have a valid signal
00089   if (evt->bckov1tdc[0] < 800 || evt->bckov1tdc[0] > 1040) return 6;
00090   
00091   // Require upper outer PMT have no signal
00092   if (evt->bckov1tdc[1] > 1 && evt->bckov1tdc[1] < 2000) return 6;
00093 
00094   // Require downstream inner PMT have a valid signal
00095   if (evt->bckov1tdc[0] < 700 || evt->bckov2tdc[0] > 950) return 6;
00096   
00097   // Require downstream outer PMT have no signal
00098   if (evt->bckov1tdc[1] > 1 && evt->bckov1tdc[1] < 2000) return 6;
00099 
00100   // Check for out-of-time tracks
00101   float minT = -15;
00102   float maxT = 55;
00103   for (int i = 0; i < evt->NTrk(); ++i) {
00104     MIPPTrackSummary* trk = evt->GetTrk(i);
00105     if (trk->avgt < minT || trk->avgt > maxT) return 7;
00106   }
00107 
00108   return 0;
00109 }

bool DSTUtil::GoodBeam ( const MIPPRunSummary rs,
const MIPPEventSummary evt,
const MIPPBeamTrkSummary fBeam 
)

Definition at line 121 of file DSTUtil.cxx.

References MIPPBeamTrkSummary::dxdzbc3, MIPPBeamTrkSummary::dydzbc3, MIPPEventSummary::GetBTrk(), MIPPEventSummary::NBTrk(), MIPPRunSummary::tgta, MIPPRunSummary::tgtPos, and MIPPBeamTrkSummary::xbc3.

00123 {
00124   if (rs->tgta > 1000) return false;     // do not apply it for NuMI target
00125 
00126   int beamPosFlag = 0;
00127   for(int ibeam=0; ibeam<evt->NBTrk(); ++ibeam) {
00128 
00129     fBeam = evt->GetBTrk(ibeam);
00130 
00131     // Recalculate beam track position at center of target
00132     double dzz = rs->tgtPos[2] - fBeam->xbc3[2];   
00133     double dxpos = (fBeam->xbc3[0] + fBeam->dxdzbc3 * dzz) - rs->tgtPos[0];
00134     double dypos = (fBeam->xbc3[1] + fBeam->dydzbc3 * dzz) - rs->tgtPos[1];
00135     double xyp = sqrt(dxpos*dxpos + (dypos-0.1)*(dypos-0.1));
00136     if(xyp < 1.5) beamPosFlag++;
00137   } // end ibeam loop
00138 
00139   if(beamPosFlag > 0) return true;
00140   return false;
00141 }

bool DSTUtil::GoodVertex ( const MIPPRunSummary runsum,
const MIPPVertexSummary vtx,
float  rWin = 1.,
float  zWin = 1. 
)

Definition at line 152 of file DSTUtil.cxx.

References MIPPVertexSummary::intrkindex, MIPPVertexSummary::ntrk, runsum, MIPPRunSummary::tgtPos, MIPPRunSummary::tgtSize, and MIPPVertexSummary::x.

00154 {
00155   if (!vtx) return false;
00156   if (vtx->intrkindex < 0) return false; // a good vertex requires a beam track
00157   // if no beam track, then this could be a V0
00158 
00159   if (vtx->ntrk < 2) return false;
00160 
00161   const float* pos = vtx->x;
00162   float dx = pos[0] - runsum->tgtPos[0];
00163   float dy = pos[1] - runsum->tgtPos[1];
00164   float dr = sqrt(dx*dx+dy*dy);
00165   float dz = pos[2] - runsum->tgtPos[2];
00166 
00167   if (fabs(dr) > rWin*runsum->tgtSize[0]) return false;
00168   if (fabs(dz) > zWin*runsum->tgtSize[2]) return false;
00169 
00170   return true;
00171 }

bool DSTUtil::GoodTrack ( const MIPPTrackSummary trk  ) 

Definition at line 178 of file DSTUtil.cxx.

References MIPPTrackSummary::gof, and MIPPTrackSummary::ntpchit.

Referenced by ProcEvent().

00179 {
00180   if (trk->gof < 1.e-3) return false;
00181   if (trk->ntpchit < 20 || trk->ntpchit >= 100) return false;
00182   return true;
00183 }

void DSTUtil::SigHandle ( int  sig  ) 

Default signal handler.

Definition at line 188 of file DSTUtil.cxx.

References gStop.

Referenced by AddToFileList(), GetFileList(), and main().

00189 {
00190   ++gStop;
00191   if (gStop > 2) abort();
00192   cout << "Stopping on signal " << sig << endl;
00193 }

TTree * DSTUtil::GetTreeByName ( TFile *const   f,
std::string const   fTreeDir,
std::string const   fTreeName 
)

Given a MIPP histogram file, return a tree with name fTreeName in the first directory with name starting with fTreeDir.

(Don't have to know if we deal with FillEventSummary_pass4 or FillEventSummary_mc, ...)

Definition at line 860 of file DSTUtil.cxx.

References tree.

Referenced by GetEvtTree(), GetMCMatchTree(), GetRunSummary(), GetSpillTree(), GetVeeTree(), and main().

00863 {
00864   TList* l = f->GetListOfKeys();
00865   for (int i = 0; i < l->GetEntries(); ++i) {
00866     string fNm(l->At(i)->GetName());
00867     if (fNm.substr(0,fTreeDir.size()) == fTreeDir) {
00868       fNm += "/"+fTreeName;
00869       TTree* tree = dynamic_cast<TTree*>(f->Get(fNm.c_str()));
00870       if (tree) return tree;
00871     }
00872   }
00873   cout << "Couldn't find " << fTreeName << " in " << f->GetName()
00874        << endl;
00875   return 0;
00876 }

TTree * DSTUtil::GetEvtTree ( TFile *  f  ) 

Given a MIPP histogram file, return DST tree.

This function will return the tree from the first DST folder that it finds

Definition at line 882 of file DSTUtil.cxx.

References GetTreeByName().

Referenced by TOFTempCorrector::init(), main(), ValiMC::SetupDSTTree(), and GlobalPid::SetupDSTTree().

00883 {
00884   return GetTreeByName(f, "FillEventSummary", "fNtTree");
00885 }

TTree * DSTUtil::GetSpillTree ( TFile *  f  ) 

Given a MIPP histogram file, return DST tree.

This function will return the tree from the first DST folder that it finds

Definition at line 891 of file DSTUtil.cxx.

References GetTreeByName().

Referenced by DSTUtil::Bflux::GetBeamFluxForRun(), and main().

00892 {
00893   return GetTreeByName(f, "FillEventSummary", "fSpillTree");
00894 }

void DSTUtil::GetFileList ( int  argc,
char **  argv,
std::vector< std::string > &  list 
)

Parses command-line arguments to extract names of valid ROOT files.

The valid arguments are either ROOT file name or name of file which contains ROOT file names

Definition at line 901 of file DSTUtil.cxx.

References AddToFileList(), and SigHandle().

Referenced by main(), and ParseArgs().

00903 {
00904   signal(SIGINT, SigHandle);
00905   //  struct stat buf;
00906 
00907   for (int i = 1; i < argc; ++i) {
00908     AddToFileList(argv[i],list);
00909   }
00910 }

void DSTUtil::AddToFileList ( char *  arg,
std::vector< std::string > &  list 
)

Parses arg and add to list if it is a ROOT file or add all ROOT fileslisted in file arg to list.

Definition at line 916 of file DSTUtil.cxx.

References SigHandle().

Referenced by GetFileList(), and main().

00917 {
00918   signal(SIGINT, SigHandle);
00919   struct stat buf;
00920 
00921   int len = strlen(arg);
00922   if (len > 5 && strcmp(".root", &arg[len-5]) == 0) {
00923     // Should be a valid ROOT file name
00924     if (strncmp("root:/", arg, 6) == 0 ||
00925         strncmp("dcap:/", arg, 6) == 0 ||
00926         stat(arg, &buf) == 0) {
00927       cout << "Adding file " << arg << endl;
00928       list.push_back(arg);
00929     }
00930     else cout << "File " << arg << " doesn't exist?" << endl;
00931   }
00932   else {
00933     // This must be a text file containing ROOT file names
00934     ifstream ifi(arg);
00935     std::string str;
00936     while (ifi >> str) {
00937       if (str.size() < 5) continue;
00938       if (str.substr(str.size() - 5) != ".root") continue;
00939       cout << "Adding file " << str << endl;
00940       list.push_back(str);
00941     }
00942   }
00943 }

MIPPRunSummary * DSTUtil::GetRunSummary ( TFile *  f  ) 

Gets the first entry from run summary tree.

User is responsible for deleting the new object that gets created

Definition at line 949 of file DSTUtil.cxx.

References GetTreeByName(), and tree.

Referenced by DSTUtil::Bflux::GetBeamFluxForRun(), GetRunSummaryVerbose(), TOFTempCorrector::init(), main(), ValiMC::SetupRunSummary(), and GlobalPid::SetupRunSummary().

00950 {
00951   TTree* tree = GetTreeByName(f, "FillEventSummary", "fRunTree");
00952   if (tree && tree->GetEntries() > 0) {
00953     MIPPRunSummary* rs = new MIPPRunSummary;
00954     tree->SetBranchAddress("fRunInfo", &rs);
00955     tree->GetEntry(0);
00956     if (tree->GetEntries() > 1) {
00957       cout << "DSTUtil::GetRunSummary: Warning: The file " 
00958            << f->GetName()
00959            << " contains more than 1 RunSummary. The first is returned"
00960            << "\n (Multiple subruns processed into one DST file.)"
00961            << endl;
00962     }
00963     return rs;
00964   }
00965   return 0;  
00966 }

MIPPRunSummary * DSTUtil::GetRunSummaryVerbose ( TFile *  f  ) 

like DSTUtil::GetRunSummary(TFile* f), but print some info about this run to stdout.

Definition at line 972 of file DSTUtil.cxx.

References GetRunSummary(), and MIPPRunSummary::Print().

00973 {
00974   MIPPRunSummary* rs = GetRunSummary(f);
00975   if (rs) rs->Print();
00976   return rs;
00977 }

MIPPRunSummary * DSTUtil::GetRunSummary ( TFile *  f,
const int &  subrun 
)

Gets entry for subrun from run summary tree.

User is responsible for deleting the new object that gets created

Definition at line 983 of file DSTUtil.cxx.

References GetTreeByName(), MIPPRunSummary::Print(), MIPPRunSummary::subrun, and tree.

00984 {
00985   TTree* tree = GetTreeByName(f, "FillEventSummary", "fRunTree");
00986   if (!tree) return 0;
00987   MIPPRunSummary* rs = new MIPPRunSummary;
00988   tree->SetBranchAddress("fRunInfo", &rs);
00989   int fEntry = -1;
00990   for (int i=0; i!=tree->GetEntries(); ++i) {
00991     tree->GetEntry(i);
00992     if (subrun == rs->subrun) {
00993       if (fEntry == -1) fEntry = i;
00994       else {
00995         cout << "DSTUtil::GetRunSummary: Warning: The file " 
00996              << f->GetName()
00997              << " contains more than 1 RunSummary for subrun " 
00998              << subrun
00999              << ". The first is returned.\n (This really should "
01000              << "not happen. You should check this DST.)" << endl;
01001       }
01002     }
01003   }
01004   if (fEntry>=0) {
01005     tree->GetEntry(fEntry);
01006     rs->Print();
01007     return rs;
01008   }
01009   //don't have this subrun
01010   delete rs;
01011   return 0;  
01012 }

TTree * DSTUtil::GetMCMatchTree ( TFile *  f  ) 

Given a MIPP histogram file, return MCMatch tree.

This function will return the tree from the first DST folder that it finds

Definition at line 1018 of file DSTUtil.cxx.

References GetTreeByName().

Referenced by main().

01019 {
01020   return GetTreeByName(f, "MCMatch", "fMatchesNt");
01021 }

TTree* DSTUtil::GetVeeTree ( TFile *  f,
string &  ntuple 
)

Definition at line 1023 of file DSTUtil.cxx.

References GetTreeByName().

Referenced by plot_MCTree(), and plot_RCTree().

01024 {
01025   return GetTreeByName(f, "VFinder", ntuple);
01026 }

TTree* DSTUtil::GetVeeTree ( TFile *  f,
std::string &  ntuple 
)


Generated on Mon Nov 23 08:05:24 2009 for MIPP(E907) by  doxygen 1.4.7