BiggestChopModule Class Reference

#include <BiggestChopModule.h>

Inheritance diagram for BiggestChopModule:

JobCModule List of all members.

Public Member Functions

 BiggestChopModule ()
 ~BiggestChopModule ()
JobCResult Ana (const MomNavigator *mom)
JobCResult Reco (MomNavigator *mom)
const RegistryDefaultConfig () const

Private Attributes

Int_t fChopsWithLi
Int_t fSnarlsWithLi

Detailed Description

Definition at line 13 of file BiggestChopModule.h.


Constructor & Destructor Documentation

BiggestChopModule::BiggestChopModule (  ) 

Definition at line 35 of file BiggestChopModule.cxx.

00035                                      :
00036   fChopsWithLi(0),
00037   fSnarlsWithLi(0)
00038 {
00039 }

BiggestChopModule::~BiggestChopModule (  ) 

Definition at line 43 of file BiggestChopModule.cxx.

References fChopsWithLi, fSnarlsWithLi, Msg::kInfo, and MSG.

00044 {
00045   MSG("BiggestChop",Msg::kInfo) << "Number of chops rejected as LI event: "   << fChopsWithLi << endl;
00046   MSG("BiggestChop",Msg::kInfo) << "Number of snarls with an  LI event:   "   << fSnarlsWithLi << endl;
00047 }


Member Function Documentation

JobCResult BiggestChopModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 225 of file BiggestChopModule.cxx.

References JobCResult::kPassed.

00226 {
00227   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00228 }

const Registry & BiggestChopModule::DefaultConfig (  )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 232 of file BiggestChopModule.cxx.

References JobCModule::GetName(), Registry::LockValues(), Munits::microsecond, Registry::Set(), and Registry::UnLockValues().

00233 {
00234   //======================================================================
00235   // Supply the default configuration for the module
00236   //======================================================================
00237   static Registry r; // Default configuration for module
00238   
00239   // Set name of config
00240   std::string name = this->JobCModule::GetName();
00241   name += ".config.default";
00242   r.SetName(name.c_str());
00243   
00244   // Set values in configuration
00245   r.UnLockValues();
00246   r.Set("BiggestChopAlgorithm","AlgChop");
00247   r.Set("BiggestChopAlgConfig","default");
00248   r.Set("ListIn",         "candchoplist");
00249   r.Set("ListOut",        "canddigitlist");
00250   r.Set("SwitchPersToTemp",1);
00251   r.Set("MinEnergy",      0.0);
00252   r.Set("OmitLiEvents",   1);
00253   r.Set("LiVetoWindowLow",-1.0*Munits::microsecond);
00254   r.Set("LiVetoWindowHigh",31.0*Munits::microsecond);
00255 
00256   r.LockValues();
00257 
00258   return r;
00259 }

JobCResult BiggestChopModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 51 of file BiggestChopModule.cxx.

References fChopsWithLi, CandRecord::FindCandHandle(), fSnarlsWithLi, RawDigit::GetADC(), AlgFactory::GetAlgHandle(), RawDigit::GetChannel(), Registry::GetCharString(), JobCModule::GetConfig(), RawDigitDataBlock::GetDatumIter(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), MomNavigator::GetFragment(), AlgFactory::GetInstance(), Registry::GetInt(), CandHandle::GetNDaughters(), PlexHandle::GetReadoutType(), RawDigit::GetTDC(), Calibrator::GetTimeFromTDC(), CandHandle::GetVldContext(), Calibrator::Instance(), Msg::kDebug, Msg::kError, JobCResult::kFailed, ReadoutType::kFlashTrigPMT, JobCResult::kPassed, Msg::kWarning, CandDigitList::MakeCandidate(), MSG, CandRecord::SecureCandHandle(), CandContext::SetDataIn(), JobCResult::SetFailed(), CandHandle::SetName(), CandHandle::SetTitle(), JobCResult::SetWarning(), and CandRecord::SwitchCandHandlePersToTemp().

00052 {
00053   JobCResult result = JobCResult::kPassed;
00054 
00055   // config.
00056   Registry& cfg = this->GetConfig();
00057   const char* algName        = cfg.GetCharString("BiggestChopAlgorithm");
00058   const char* algConfigName  = cfg.GetCharString("BiggestChopAlgConfig");
00059   const char* listIn         = cfg.GetCharString("ListIn");
00060   const char* listOut        = cfg.GetCharString("ListOut");
00061   bool        switchPerToTemp = cfg.GetInt("SwitchPersToTemp");
00062   double      minEnergy      = cfg.GetDouble("MinEnergy");
00063   bool        omitLiEvents   = cfg.GetInt("OmitLiEvents");
00064   double      liVetoWindowLow = cfg.GetDouble("LiVetoWindowLow");
00065   double      liVetoWindowHigh= cfg.GetDouble("LiVetoWindowHigh");
00066   
00067   // Find PrimaryCandidateRecord fragment in MOM.
00068   CandRecord *candrec = dynamic_cast<CandRecord *>
00069     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00070   if (candrec == 0) {
00071     MSG("BiggestChop", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00072                                  << endl;
00073     return JobCResult::kFailed;
00074   }
00075 
00076   
00077   if(switchPerToTemp) {
00078     // The user requested that we get rid of the original CandDigitList
00079     // in favor of the new (chopped) list.
00080     // Find the original digit list. of chops.
00081     CandDigitListHandle *orig_cdlh = dynamic_cast<CandDigitListHandle*>
00082       (candrec->FindCandHandle("CandDigitListHandle", listOut));
00083    
00084     if(orig_cdlh)
00085       candrec->SwitchCandHandlePersToTemp(orig_cdlh);
00086   }
00087 
00088   // find the list of chops.
00089   CandChopListHandle *chopList = dynamic_cast<CandChopListHandle*>
00090     (candrec->FindCandHandle("CandChopListHandle", listIn));
00091 
00092 
00093   if(!chopList) {
00094     MSG("BiggestChop",Msg::kError) << "Could not find a ChopList in Mom." << endl;
00095     result.SetWarning().SetFailed();
00096     return result;
00097   }
00098 
00099   if(chopList->GetNDaughters()==0) {
00100     MSG("BiggestChop",Msg::kError) << "Could not find any Chops in the ChopList." << endl;
00101     result.SetWarning().SetFailed();
00102     return result;
00103   }
00104 
00105   
00106   const VldContext* contextptr = chopList->GetVldContext();
00107 
00108   // Find the RawDigitDataBlock.
00109   // Use it to find any TPMT hits to reject LI
00110   double liTime = 100.;
00111   if(omitLiEvents) {
00112     const RawDigitDataBlock* rddb = DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00113     if(!rddb) {
00114       MSG("BiggestChop",Msg::kError) << "Could not find a RawDigitDataBlock in Mom." << endl;
00115       result.SetWarning().SetFailed();
00116       return result;
00117     }
00118     assert(contextptr);
00119     PlexHandle plex(*contextptr);
00120 
00121     RawDigit *rawdigit;
00122     TIter iter = rddb->GetDatumIter();
00123     TObject* tobj;
00124     while( (tobj=iter.Next() ) ) {
00125       if( ( rawdigit = dynamic_cast<RawDigit*>(tobj) ) ) {;
00126         RawDigit* rawdigit = dynamic_cast<RawDigit*>(tobj);
00127         
00128         RawChannelId rcid = rawdigit->GetChannel();
00129         ReadoutType::Readout_t type = plex.GetReadoutType(rcid);
00130         
00131         if(type == ReadoutType::kFlashTrigPMT) {
00132           if( rawdigit->GetADC() > 100) {
00133             liTime = Calibrator::Instance().GetTimeFromTDC(rawdigit->GetTDC(),rawdigit->GetChannel());    
00134             MSG("BiggestChop",Msg::kDebug) << "Found LI trigger at " << liTime << endl;
00135           }
00136         }
00137       }
00138     }
00139   }
00140 
00141   // Loop through and find the best.
00142   CandDigitListHandleItr listItr(chopList->GetDaughterIterator());
00143 
00144   CandDigitListHandle bestChop;
00145   double              bestChopEnergy = -1;
00146   bool                vetoedLi = false;
00147 
00148   double vetoLow  = liTime + liVetoWindowLow;
00149   double vetoHigh = liTime + liVetoWindowHigh;
00150 
00151   while( CandDigitListHandle *chop = listItr()) {
00152     
00153     // Add up the energy in this chop.
00154     double energy = 0;    
00155     double chopStart = 99e9;
00156     double chopEnd   = -99e9;
00157     CandDigitHandleItr digitItr(chop->GetDaughterIterator());
00158     while(CandDigitHandle *cdh = digitItr()) {
00159       if(!cdh->GetPlexSEIdAltL().IsVetoShield()) {
00160         energy += cdh->GetCharge();
00161         double t = cdh->GetTime();
00162         if(t<chopStart) chopStart = t;
00163         if(t>chopEnd)   chopEnd   = t;
00164       }
00165     }
00166     
00167     // Is this chop an LI event?    
00168     double choptime = chop->GetAbsTime();   
00169     bool isLI = false;
00170 
00171     MSG("BiggestChop",Msg::kDebug) << "Comparing chop time " << choptime 
00172                                    << " to " << liTime 
00173                                    << " delta = " << chopStart-liTime << endl;    
00174     
00175     // look for any intersection with the LI event, from -1 to +31 us from the 
00176     // TPMT hit.
00177     if( (chopEnd>vetoLow) && (chopStart<vetoHigh) ) isLI = true;
00178     
00179     // See if we have a winner.
00180     if(energy>bestChopEnergy) {
00181       if(isLI){
00182         vetoedLi = true;
00183         fChopsWithLi++;
00184       }    
00185 
00186       if(isLI && omitLiEvents) {
00187         MSG("BiggestChop",Msg::kDebug) << "Chop is too close to an LI event." << endl;  
00188       } else {     
00189         bestChopEnergy = energy;
00190         bestChop = *chop;
00191       }
00192     }     
00193   }
00194 
00195   if(vetoedLi) fSnarlsWithLi++; // Statistics gathering.
00196      
00197   if(bestChopEnergy<minEnergy) {
00198     // We didn't find a match.
00199     MSG("Chop",Msg::kWarning) << "Found insufficient energy in any chop. NO chop chosen" << endl;
00200     return JobCResult::kFailed;
00201   }
00202 
00203   MSG("Chop",Msg::kDebug) << "Chose chop " << bestChop.GetName() << " with energy " << bestChopEnergy << endl;
00204   
00205   // Ok, now we want a copy of bestChop. Boy, this is laborious:
00206   DigitVector v(&bestChop);
00207   AlgFactory &af = AlgFactory::GetInstance();
00208   AlgHandle adlh = af.GetAlgHandle(algName,algConfigName);
00209   CandContext cx(this, mom);
00210   cx.SetDataIn(&v);
00211   CandDigitListHandle outList = CandDigitList::MakeCandidate(adlh,cx);
00212   outList.SetName(listOut);
00213   outList.SetTitle("Biggest chop chosen by BiggestChopModule");
00214  
00215   candrec->SecureCandHandle(outList);
00216                      
00217 
00218   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00219 }


Member Data Documentation

Int_t BiggestChopModule::fChopsWithLi [private]

Definition at line 30 of file BiggestChopModule.h.

Referenced by Reco(), and ~BiggestChopModule().

Int_t BiggestChopModule::fSnarlsWithLi [private]

Definition at line 31 of file BiggestChopModule.h.

Referenced by Reco(), and ~BiggestChopModule().


The documentation for this class was generated from the following files:
Generated on Mon Aug 11 01:05:32 2014 for loon by  doxygen 1.4.7