00001
00002
00003
00004
00005
00006
00008 #include "Demo/DemoNPlaneCut.h"
00009 #include <cstdio>
00010
00011 #include "TFile.h"
00012 #include "CandData/CandRecord.h"
00013 #include "CandDigit/CandDigitListHandle.h"
00014 #include "CandDigit/CandDigitHandle.h"
00015 #include "DataUtil/GetCandidate.h"
00016 #include "JobControl/JobCModuleRegistry.h"
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
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
00047
00048 ++nPlane;
00049 gapSz = 0;
00050 if (nPlane > nPlaneMax) nPlaneMax = nPlane;
00051 }
00052 else {
00053
00054
00055
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
00070
00071
00072
00073
00074 const CandDigitListHandle* canddigit =
00075 DataUtil::GetCandidate<CandDigitListHandle>(mom,
00076 "CandDigitListHandle",
00077 "canddigitlist");
00078
00079
00080
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
00093
00094 static Registry r;
00095
00096
00097 std::string name = this->GetName();
00098 name += ".config.default";
00099 r.SetName(name.c_str());
00100
00101
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
00116
00117 int tmpi;
00118 if (r.Get("NplaneCut", tmpi)) { fNplaneCut = tmpi; }
00119 if (r.Get("MaxGap", tmpi)) { fMaxGap = tmpi; }
00120 }
00121