Anp::PlotPmt Class Reference

#include <PlotPmt.h>

Inheritance diagram for Anp::PlotPmt:
Anp::AlgSnarl Anp::Base

List of all members.

Public Types

typedef std::map< short,
PlaneHitColl
PlaneMap
typedef std::vector
< Anp::Handle< Anp::PmtHit > > 
PlotVec

Public Member Functions

 PlotPmt ()
virtual ~PlotPmt ()
bool Run (Record &record)
void Config (const Registry &reg)
void Set (TDirectory *dir)
bool Init (const Header &header)
void End (const DataBlock &)

Private Member Functions

const PlaneMap Collect (const Track &track, const Record &record) const
bool Add (const Header &header, double signal_cut, const std::string &dname)

Private Attributes

std::string fDirName
TDirectory * fDir
Registry fConfig
bool fPlotSpect
int fMinNPlane
int fStripWindow
double fTimeWindow
double fSkipFrac
int fPlaneKey
int fPlaneView
double fPidCut
int fPidKey
int fPmtKey
PlotVec fPlot

Detailed Description

Definition at line 23 of file PlotPmt.h.


Member Typedef Documentation

typedef std::map<short, PlaneHitColl> Anp::PlotPmt::PlaneMap

Definition at line 42 of file PlotPmt.h.

Definition at line 43 of file PlotPmt.h.


Constructor & Destructor Documentation

Anp::PlotPmt::PlotPmt (  ) 

Definition at line 26 of file PlotPmt.cxx.

00027    :fDirName("pmt"),
00028     fDir(0),
00029     fConfig(false),
00030     fPlotSpect(false),
00031     fMinNPlane(10),
00032     fStripWindow(4),
00033     fTimeWindow((2.0*18.83 + 0.1)*1.0e-9),
00034     fSkipFrac(0.2),
00035     fPlaneKey(0),
00036     fPlaneView(0),
00037     fPidCut(0.7),
00038     fPidKey(4180),
00039     fPmtKey(0)
00040 {
00041 }

Anp::PlotPmt::~PlotPmt (  )  [virtual]

Definition at line 44 of file PlotPmt.cxx.

00045 {
00046 }


Member Function Documentation

bool Anp::PlotPmt::Add ( const Header header,
double  signal_cut,
const std::string &  dname 
) [private]

Referenced by Init().

const Anp::PlotPmt::PlaneMap Anp::PlotPmt::Collect ( const Track track,
const Record record 
) const [private]

Definition at line 160 of file PlotPmt.cxx.

References Anp::PlaneHitColl::AddOtherHit(), Anp::Basic::BegPlane(), fPidCut, fPidKey, fPlaneKey, fPlaneView, fPlotSpect, fPmtKey, fSkipFrac, fStripWindow, fTimeWindow, Anp::Track::GetBasic(), Anp::Record::GetHeader(), VHS::GetPlane(), PlexPlaneId::GetPlaneCoverage(), PlexPlaneId::GetPlaneView(), Anp::Strip::GetStrip(), Anp::GetStrip(), Anp::PlaneHitColl::GetTrackVec(), Anp::Draw::GetValidity(), Anp::Pmt::IsSamePmt(), it, PlaneCoverage::kNearFull, PlaneCoverage::kNearPartial, PlaneView::kU, PlaneView::kV, Anp::Basic::MaxTime(), Anp::Basic::MinTime(), Anp::Basic::NPlaneSteel(), Munits::second, Anp::Record::StripBeg(), Anp::Record::StripEnd(), Anp::Record::TrackBeg(), Anp::Record::TrackEnd(), and Anp::Track::TrackIndex().

Referenced by Run().

00161 {
00162    //
00163    // Select strips matching this track, subject to various cuts. This function 
00164    // returns map: key is plane number and value is PlaneHitColl struct.
00165    //
00166 
00167    //
00168    // First loop: collect all track strips 
00169    //
00170    const VldContext vldc = Pmt::GetValidity(record.GetHeader());
00171    PlexHandle plex(vldc);
00172    PlaneMap pmap;
00173 
00174    for(StripIter istrip = record.StripBeg(); istrip != record.StripEnd(); ++istrip)
00175    {
00176       if(!(istrip -> MatchTrk(track.TrackIndex())))
00177       {
00178          continue;
00179       }
00180 
00181       if(!fPlotSpect && istrip -> GetPlane() > 120)
00182       {
00183          continue;
00184       }
00185       
00186       const double nplane = track.GetBasic().NPlaneSteel();
00187       if(nplane < 10.0)
00188       {
00189          continue;
00190       }
00191       
00192       //
00193       // Ignore first fSkipFrac fraction of planes away from vertex
00194       //
00195       if((double) std::fabs((double) (istrip->GetPlane() - track.GetBasic().BegPlane()))/nplane < fSkipFrac)
00196       {
00197          continue;
00198       }
00199 
00200       if(fPlaneKey == 1 || fPlaneKey == 2)
00201       {
00202          const PlexStripEndId seid(istrip -> GetEncoded());
00203 
00204          if     (fPlaneKey == 1 && seid.GetPlaneCoverage() != PlaneCoverage::kNearPartial) continue;
00205          else if(fPlaneKey == 2 && seid.GetPlaneCoverage() != PlaneCoverage::kNearFull)    continue;
00206       }
00207 
00208       if(fPlaneView == 1 || fPlaneView == 2)
00209       {
00210          const PlexStripEndId seid(istrip -> GetEncoded());
00211 
00212          if     (fPlaneView == 1 && seid.GetPlaneView() != PlaneView::kV) continue;
00213          else if(fPlaneView == 2 && seid.GetPlaneView() != PlaneView::kU) continue;
00214       }
00215 
00216       PlaneMap::iterator pit = pmap.find(istrip -> GetPlane());
00217       if(pit == pmap.end())
00218       {
00219          pit = pmap.insert(PlaneMap::value_type(istrip -> GetPlane(), 
00220                                                 Anp::PlaneHitColl(istrip -> GetPlane()))).first;
00221       }
00222       
00223       (pit -> second).AddTrackHit(istrip, record);
00224    }
00225    
00226    //
00227    // Get time window
00228    //
00229    const double min_time = track.GetBasic().MinTime() - fTimeWindow;
00230    const double max_time = track.GetBasic().MaxTime() + fTimeWindow;
00231 
00232    //
00233    // Second loop: collect all "nearby" non-track strips 
00234    //
00235    for(StripIter istrip = record.StripBeg(); istrip != record.StripEnd(); ++istrip)
00236    {
00237       //
00238       // No track hits in this plane
00239       //
00240       PlaneMap::iterator pit = pmap.find(istrip -> GetPlane());
00241       if(pit == pmap.end())
00242       {
00243          continue;
00244       }
00245 
00246       //
00247       // Ignore track hits
00248       //
00249       bool skip_this = false;
00250       for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00251       {
00252          if(!(itrack -> KeyExists(fPidKey)) || itrack -> DataAt(fPidKey) < fPidCut)
00253          {
00254             continue;
00255          }
00256          
00257          if(istrip -> MatchTrk(itrack -> TrackIndex()))
00258          {
00259             skip_this = true;
00260             break;
00261          }
00262       }
00263       
00264       if(skip_this)
00265       {
00266          continue;
00267       }
00268 
00269       //
00270       // Ignore hits outside time window
00271       //
00272       if(!(fTimeWindow < 0.0))
00273       {
00274          if(istrip -> Time() < min_time || istrip -> Time() > max_time)
00275          {
00276             continue;
00277          }
00278       }
00279 
00280       //
00281       // Collect hits within strip window
00282       //
00283       PlaneHitColl &coll = pit -> second;
00284 
00285       const vector<StripIter> &tvec = coll.GetTrackVec();
00286       short separation = -1;
00287       
00288       for(vector<StripIter>::const_iterator it = tvec.begin(); it != tvec.end(); ++it)
00289       {
00290          const Strip &tstrip = *(*it);
00291          const short diff = std::abs(tstrip.GetStrip() - istrip -> GetStrip());
00292 
00293          if(it == tvec.begin())
00294          {
00295             separation = diff;
00296          }
00297          else
00298          {
00299             separation = std::min<short>(separation, diff);
00300          }
00301          
00302          if(fPmtKey == +1 && !Pmt::IsSamePmt(vldc, *istrip, tstrip))
00303          {
00304             separation = -1;
00305             break;
00306          }
00307          if(fPmtKey == -1 && Pmt::IsSamePmt(vldc, *istrip, tstrip))
00308          {
00309             separation = -1;
00310             break;
00311          }       
00312       }
00313 
00314       if(separation < 0)
00315       {
00316          continue;
00317       }
00318       
00319       //
00320       // Strip is too far
00321       //
00322       if(separation > fStripWindow)
00323       {
00324          continue;
00325       }
00326 
00327       coll.AddOtherHit(istrip, record);
00328    }
00329 
00330    return pmap;
00331 }

void Anp::PlotPmt::Config ( const Registry reg  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 91 of file PlotPmt.cxx.

References fConfig, fDirName, fMinNPlane, fPidCut, fPidKey, fPlaneKey, fPlaneView, fPlotSpect, fPmtKey, fSkipFrac, fStripWindow, fTimeWindow, Registry::Get(), Registry::KeyExists(), and Anp::Read().

00092 {
00093    //
00094    // Configure self
00095    //
00096    fConfig = reg;
00097 
00098    const char *value_char = 0;
00099    if(reg.Get("PlotPmtDirName", value_char))
00100    {
00101       fDirName = value_char;
00102    }
00103 
00104    Anp::Read(reg, "PlotPmtPlotSpect", fPlotSpect);
00105 
00106    reg.Get("PlotPmtMinNPlane",   fMinNPlane);
00107    reg.Get("PlotPmtStripWindow", fStripWindow);
00108    reg.Get("PlotPmtTimeWindow",  fTimeWindow);
00109    reg.Get("PlotPmtSkipFrac",    fSkipFrac);
00110    reg.Get("PlotPmtPlaneKey",    fPlaneKey);
00111    reg.Get("PlotPmtPlaneView",   fPlaneView);
00112    reg.Get("PlotPmtPidCut",      fPidCut);
00113    reg.Get("PlotPmtPidKey",      fPidKey);
00114    reg.Get("PlotPmtKey",         fPmtKey);
00115 
00116    if(reg.KeyExists("PrintConfig"))
00117    {
00118       cout << "PlotPmt::Config" << endl
00119            << "   DirName = " << fDirName << endl
00120            << "   PlotSpect = " << fPlotSpect << endl
00121            << "   MinNPlane = " << fMinNPlane << endl
00122            << "   StripWindow = " << fStripWindow << endl
00123            << "   TimeWindow = "  << fTimeWindow << endl
00124            << "   SkipFrac = "    << fSkipFrac << endl
00125            << "   PlaneKey = "    << fPlaneKey << endl
00126            << "   PlaneView = "   << fPlaneView << endl
00127            << "   PidCut = "      << fPidCut << endl
00128            << "   PidKey = "      << fPidKey << endl
00129            << "   PmtKey = "      << fPmtKey << endl;
00130    }
00131 }

void Anp::PlotPmt::End ( const DataBlock  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 155 of file PlotPmt.cxx.

00156 {
00157 }

bool Anp::PlotPmt::Init ( const Header header  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 143 of file PlotPmt.cxx.

References Add().

00144 {
00145    //
00146    // Create histograms
00147    //
00148    Anp::PlotPmt::Add(header, 0.0, "pmt_all");
00149    Anp::PlotPmt::Add(header, 2.8, "pmt_cut");
00150 
00151    return true;
00152 }

bool Anp::PlotPmt::Run ( Record record  )  [virtual]

Implements Anp::AlgSnarl.

Definition at line 49 of file PlotPmt.cxx.

References Collect(), fMinNPlane, fPidCut, fPidKey, fPlot, Munits::second, Anp::Record::TrackBeg(), and Anp::Record::TrackEnd().

00050 {
00051    //
00052    // Run over all tracks and strips 
00053    //
00054 
00055    for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00056    {
00057       //
00058       // Ignore non muon tracks
00059       //
00060       if(!(itrack -> KeyExists(fPidKey)) || itrack -> DataAt(fPidKey) < fPidCut)
00061       {
00062          continue;
00063       }
00064 
00065       if(itrack -> GetBasic().NPlaneScint() < fMinNPlane)
00066       {
00067          continue;
00068       }
00069 
00070       //
00071       // Collect hits from planes that are hit by current track
00072       //
00073       const PlaneMap pmap = PlotPmt::Collect(*itrack, record);
00074 
00075       for(PlaneMap::const_iterator iplane = pmap.begin(); iplane != pmap.end(); ++iplane)
00076       {
00077          //
00078          // Fill plane hits
00079          //
00080          for(PlotVec::iterator iplot = fPlot.begin(); iplot != fPlot.end(); ++iplot)
00081          {
00082             (*iplot) -> Plot(iplane -> second);
00083          }
00084       }
00085    }
00086 
00087    return true;
00088 }

void Anp::PlotPmt::Set ( TDirectory *  dir  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 134 of file PlotPmt.cxx.

References fDir, fDirName, and Anp::GetDir().

00135 {
00136    //
00137    // Get, or create new, TDirectory pointer
00138    //
00139    fDir = Anp::GetDir(fDirName, dir);   
00140 }


Member Data Documentation

Definition at line 57 of file PlotPmt.h.

Referenced by Config().

TDirectory* Anp::PlotPmt::fDir [private]

Definition at line 55 of file PlotPmt.h.

Referenced by Set().

std::string Anp::PlotPmt::fDirName [private]

Definition at line 53 of file PlotPmt.h.

Referenced by Config(), and Set().

int Anp::PlotPmt::fMinNPlane [private]

Definition at line 60 of file PlotPmt.h.

Referenced by Config(), and Run().

double Anp::PlotPmt::fPidCut [private]

Definition at line 66 of file PlotPmt.h.

Referenced by Collect(), Config(), and Run().

int Anp::PlotPmt::fPidKey [private]

Definition at line 67 of file PlotPmt.h.

Referenced by Collect(), Config(), and Run().

int Anp::PlotPmt::fPlaneKey [private]

Definition at line 64 of file PlotPmt.h.

Referenced by Collect(), and Config().

int Anp::PlotPmt::fPlaneView [private]

Definition at line 65 of file PlotPmt.h.

Referenced by Collect(), and Config().

Definition at line 70 of file PlotPmt.h.

Referenced by Run().

bool Anp::PlotPmt::fPlotSpect [private]

Definition at line 59 of file PlotPmt.h.

Referenced by Collect(), and Config().

int Anp::PlotPmt::fPmtKey [private]

Definition at line 68 of file PlotPmt.h.

Referenced by Collect(), and Config().

double Anp::PlotPmt::fSkipFrac [private]

Definition at line 63 of file PlotPmt.h.

Referenced by Collect(), and Config().

Definition at line 61 of file PlotPmt.h.

Referenced by Collect(), and Config().

double Anp::PlotPmt::fTimeWindow [private]

Definition at line 62 of file PlotPmt.h.

Referenced by Collect(), and Config().


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

Generated on 24 Jul 2018 for loon by  doxygen 1.6.1