CheckRegion.cc
00001 #include "CheckRegion.hh"
00002 #include "EvalRois.hh"
00003 #include "AddCutFunctor.hh"
00004 using namespace ProcessingCuts;
00005 AddCutFunctor::CutRegistrar<CheckRegion> _a;
00006
00007 ProcessingCuts::CheckRegion::CheckRegion() :
00008 ProcessingCut(GetCutName(), "Check that the defined variable for a certain region of interest is within the proscribed range")
00009 {
00010 RegisterParameter("channel", channel = -1,
00011 "Which channel to look at? -1 for all");
00012 RegisterParameter("region", region = 0, "Which region to look at?");
00013 RegisterParameter("minimum", minimum = -1.e9,
00014 "Minimum allowed value for variable");
00015 RegisterParameter("maximum", maximum = 1.e9,
00016 "Maximum allowed variable");
00017 RegisterParameter("variable", variable = INTEGRAL,
00018 "Which variable to look at? INTEGRAL, MAX, MIN, AMPLITUDE");
00019
00020 }
00021
00022 bool ProcessingCuts::CheckRegion::Process(EventDataPtr event)
00023 {
00024 if( channel == -1 )
00025 return ProcessingCut::Process(event);
00026 ChannelData* chdata = event->GetChannelByID(channel);
00027 if(!channel)
00028 return false;
00029 return ProcessChannel(chdata);
00030 }
00031
00032 bool ProcessingCuts::CheckRegion::ProcessChannel(ChannelData* chdata)
00033 {
00034 if(region >= (int)(chdata->regions.size())) return default_pass;
00035 Roi& roi = chdata->regions[region];
00036 double value=0;
00037 switch(variable){
00038 case MIN:
00039 value = roi.min;
00040 break;
00041 case MAX:
00042 value = roi.max;
00043 break;
00044 case INTEGRAL:
00045 value = roi.integral;
00046 break;
00047 case NPE:
00048 value = roi.npe;
00049 break;
00050 case AMPLITUDE:
00051 value = chdata->baseline.mean - roi.min;
00052 break;
00053 };
00054 return (value > minimum) && (value < maximum);
00055 }
00056
00057 int ProcessingCuts::CheckRegion::AddDependenciesToModule(BaseModule* mod)
00058 {
00059 mod->AddDependency("EvalRois");
00060 return 1;
00061 }