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

DemoNPlaneCut.cxx

Go to the documentation of this file.
00001 
00002 // $Id: DemoNPlaneCut.cxx,v 1.1 2004/01/28 18:42:01 messier Exp $
00003 //
00004 // Select events with at least n continuous planes hit
00005 //
00006 // messier@huhepl.harvard.edu
00008 #include "Demo/DemoNPlaneCut.h"
00009 #include <cstdio>
00010 // ROOT includes
00011 #include "TFile.h"
00012 #include "CandData/CandRecord.h"           // DigitList handling
00013 #include "CandDigit/CandDigitListHandle.h" // "                "
00014 #include "CandDigit/CandDigitHandle.h"     // "                "
00015 #include "DataUtil/GetCandidate.h"         // Unpack data from Mom
00016 #include "JobControl/JobCModuleRegistry.h" // JOBMODULE registration macro
00017 
00018 JOBMODULE(DemoNPlaneCut,"NPlaneCut","Cut short events");
00019 
00020 //......................................................................
00021 
00022 DemoNPlaneCut::DemoNPlaneCut() :
00023   fNplaneCut(15),
00024   fMaxGap(2)
00025 { }
00026 
00027 //......................................................................
00028 
00029 int DemoNPlaneCut::CountPlanes(const CandDigitListHandle* cdlh)
00030 {
00031   // The loop is done with a class that iterates over the list
00032   int iPlane = 0;
00033   memset(fPlane, 0, PLANEARRAYSIZE*sizeof(fPlane[0]));
00034   CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00035   for (; cdhItr.IsValid(); cdhItr.Next()) {
00036     const PlexSEIdAltL&   altList = (*cdhItr)->GetPlexSEIdAltL();
00037     const PlexStripEndId& strEnd  = altList.GetBestSEId();
00038     iPlane = strEnd.GetPlane();
00039     if (iPlane>=0 && iPlane<PLANEARRAYSIZE) fPlane[iPlane] = 1;
00040   }
00041   int nPlane    = 0;
00042   int gapSz     = 0;
00043   int nPlaneMax = 0;
00044   for (int i=0; i<PLANEARRAYSIZE; ++i) {
00045     if (fPlane[i]==1) {
00046       // We have a hit on a plane. Increase the plane count and zero
00047       // out the gap counter
00048       ++nPlane;  
00049       gapSz = 0;
00050       if (nPlane > nPlaneMax) nPlaneMax = nPlane;
00051     }
00052     else {
00053 
00054       // No hit on the plane. Increase the gap size. If we reach the
00055       // maximum gap size, start the plane count again
00056 
00057       ++gapSz;
00058       if (gapSz > fMaxGap) nPlane = 0;
00059     }
00060   }
00061   return nPlaneMax;
00062 }
00063 
00064 //......................................................................
00065 
00066 JobCResult DemoNPlaneCut::Ana(const MomNavigator *mom) 
00067 {
00068 //======================================================================
00069 // Given the object to which the data is attached perform some
00070 // analysis of the data
00071 //======================================================================
00072   // Access to the event is given through handles. In this case I want
00073   // the list of candidate digits
00074   const CandDigitListHandle* canddigit = 
00075     DataUtil::GetCandidate<CandDigitListHandle>(mom,
00076                                                 "CandDigitListHandle", 
00077                                                 "canddigitlist");
00078   
00079   // If the GetDigitList is successful, loop over the elements in the
00080   // list to add up the charge
00081   int nplane = 0;
00082   if (canddigit) nplane = this->CountPlanes(canddigit);
00083   if (nplane >= fNplaneCut) return JobCResult::kPassed;
00084   return JobCResult::kFailed;
00085 }
00086 
00087 //......................................................................
00088 
00089 const Registry& DemoNPlaneCut::DefaultConfig() const
00090 {
00091 //======================================================================
00092 // Create a registry which holds the default configuration and return it
00093 //======================================================================
00094   static Registry r;
00095 
00096   // Set name of config
00097   std::string name = this->GetName();
00098   name += ".config.default";
00099   r.SetName(name.c_str());
00100 
00101   // Set values of config
00102   r.UnLockValues();
00103   r.Set("NplaneCut", 15);
00104   r.Set("MaxGap",    2);
00105   r.LockValues();
00106 
00107   return r;
00108 }
00109 
00110 //......................................................................
00111 
00112 void DemoNPlaneCut::Config(const Registry& r)
00113 {
00114 //======================================================================
00115 // Configure the module given the registry r
00116 //======================================================================
00117   int    tmpi;
00118   if (r.Get("NplaneCut", tmpi)) { fNplaneCut = tmpi; }
00119   if (r.Get("MaxGap",    tmpi)) { fMaxGap    = tmpi; }
00120 }
00121 

Generated on Mon Feb 15 11:06:37 2010 for loon by  doxygen 1.3.9.1