Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

Constructor & Destructor Documentation

AlgChopListFar::AlgChopListFar  ) 
 

Definition at line 45 of file AlgChopListFar.cxx.

00046 {
00047 }

AlgChopListFar::~AlgChopListFar  )  [virtual]
 

Definition at line 50 of file AlgChopListFar.cxx.

00051 {
00052 }


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 59 of file AlgChopListFar.cxx.

References CandHandle::AddDaughterLink(), digits(), RawRecord::FindRawBlock(), Form(), CandDigitListHandle::GetAbsTime(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), Registry::GetDouble(), MomNavigator::GetFragment(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), CandDigitList::MakeCandidate(), MSG, and CandHandle::SetName().

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

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

Reimplemented from AlgBase.

Definition at line 190 of file AlgChopListFar.cxx.

00191 {
00192 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 21 22:49:13 2009 for loon by  doxygen 1.3.9.1