AlgChopListFar Class Reference

#include <AlgChopListFar.h>

Inheritance diagram for AlgChopListFar:

AlgBase List of all members.

Public Member Functions

 AlgChopListFar ()
virtual ~AlgChopListFar ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Detailed Description

Definition at line 13 of file AlgChopListFar.h.


Constructor & Destructor Documentation

AlgChopListFar::AlgChopListFar (  ) 

Definition at line 46 of file AlgChopListFar.cxx.

00047 {
00048 }

AlgChopListFar::~AlgChopListFar (  )  [virtual]

Definition at line 51 of file AlgChopListFar.cxx.

00052 {
00053 }


Member Function Documentation

void AlgChopListFar::RunAlg ( AlgConfig algConfig,
CandHandle candHandle,
CandContext candContext 
) [virtual]

Set functions are called to load the CandStrip member variables based on the CandDigit members, and the daughter list is filled.

Implements AlgBase.

Definition at line 60 of file AlgChopListFar.cxx.

References digits(), Form(), CandDigitListHandle::GetAbsTime(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), Msg::kDebug, Msg::kWarning, CandDigitList::MakeCandidate(), MSG, and CandHandle::SetName().

00063 {
00064   assert(candHandle.InheritsFrom("CandChopListHandle"));
00065   CandChopListHandle &sliceList = dynamic_cast<CandChopListHandle &>(candHandle);
00066 
00067    assert(candContext.GetDataIn());
00068    // Check for CandDigitListHandle input
00069    if (!(candContext.GetDataIn()->InheritsFrom("CandDigitListHandle"))) {
00070      MSG("Chop",Msg::kWarning ) << "Data into AlgChopListFar is not a digit list." << std::endl;
00071    }
00072    
00073    const CandDigitListHandle *cdlh_ptr = 
00074      dynamic_cast<const CandDigitListHandle*>(candContext.GetDataIn());
00075    
00076    const MomNavigator *mom = candContext.GetMom();
00077    const RawDigitDataBlock* rddb = DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00078    if (!rddb) {
00079      MSG("Chop", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00080      return;
00081    }
00082    
00083    // Get setup for the DigitList maker algorithm
00084    AlgFactory &af = AlgFactory::GetInstance();
00085    AlgHandle ah = af.GetAlgHandle("AlgChop","default");
00086    CandContext cxx(this,candContext.GetMom());
00087 
00088    // Configuration:
00089    double cTimeGap           = algConfig.GetDouble("TimeGap");
00090    double cExtraShieldWindow = algConfig.GetDouble("ExtraShieldWindow");
00091    bool   cIgnorePreTrigger  = algConfig.GetInt("IgnorePreTrigger");
00092  
00093 
00094    // First, make a nice stl vector of the digits.
00095    DigitVector digits(cdlh_ptr);
00096 
00097    UInt_t ndigits = digits.size();
00098    if(ndigits==0) return; // No data.
00099 
00100    // Sort the list by time.
00101    std::sort(digits.begin(), digits.end(), compareDigitTimes());
00102 
00103    // Trigger time.
00104    double trigTime = cdlh_ptr->GetAbsTime();
00105    if(!cIgnorePreTrigger) trigTime = -100.0; // Set trigger time infinately early.
00106 
00107    // Find the first digit after the pre-trigger window.
00108    int first_digit = 0;
00109    for(UInt_t i=0;i<ndigits;i++) {
00110      if( (digits[i].GetTime()-trigTime) >0) {
00111        first_digit = i;
00112        break;
00113      }
00114    }
00115 
00116     
00117    // Go through, look for gaps. When you find a gap, make a new slice.
00118 
00119    int nslice = 0;
00120    double slice_start = digits[first_digit].GetTime();    // start time (inclusive)
00121    double slice_end   = slice_start;                      // stop  time (inclusive)
00122    double t_last = 99e9;
00123    bool have_slice = false;
00124 
00125    for(UInt_t i=first_digit; i<ndigits; i++) {     
00126      double t = digits[i].GetTime();
00127      bool create_slice = false;
00128 
00129      // Only look at non-veto digits.
00130      if(!(digits[i].GetPlexSEIdAltL().IsVetoShield()) ) {
00131        // This digit isn't in veto.. use it.
00132        double delta_t = t-t_last;
00133        t_last = t;
00134        if(!have_slice) {
00135          slice_start = t;
00136          have_slice = true;
00137        } else {
00138          if( (delta_t >= cTimeGap) ) create_slice = true;
00139        }
00140      }
00141 
00142      // Hack for last digit: close off the slice:
00143      if(i == ndigits-1) {
00144        if(have_slice) {
00145          create_slice = true;
00146          slice_end = 99e9;
00147        }
00148      }
00149      
00150      if(create_slice) {
00151 
00152        // Set start and end times. Note that the extra window
00153        // will only catch shield hits, assuming the extra window 
00154        // is smaller than the gap window.
00155        double tstart = slice_start - cExtraShieldWindow;
00156        double tend   = slice_end   + cExtraShieldWindow;
00157        
00158        // Make a new slice.
00159        MSG("Chop",Msg::kDebug) << "Forming new slice, digit " << slice_start
00160                                << " to " << slice_end << endl;
00161        DigitVector slice_data;
00162        for(UInt_t j=0; j<ndigits; j++) {
00163          double tt = digits[j].GetTime();            
00164          if((tt>=tstart)&&(tt<=tend))  slice_data.push_back(digits[j]);
00165        }
00166          
00167        cxx.SetDataIn(&(slice_data));
00168        CandDigitListHandle sliceHandle = CandDigitList::MakeCandidate(ah,cxx);
00169        sliceHandle.SetName(Form("Chop %d",nslice++));
00170        sliceList.AddDaughterLink(sliceHandle);
00171        
00172        // Prep next slice.
00173        slice_start = t;
00174      }
00175 
00176      slice_end = t;
00177 
00178 
00179    }      
00180    
00181 }

void AlgChopListFar::Trace ( const char *  c  )  const [virtual]

Reimplemented from AlgBase.

Definition at line 185 of file AlgChopListFar.cxx.

00186 {
00187 }


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