00001 #include "SimDaqTrigMaker.h"
00002 #include "SimDaqPlaneTrigger.h"
00003 #include "MessageService/MsgService.h"
00004 #include <vector>
00005
00006 CVSID("$Id: SimDaqPlaneTrigger.cxx,v 1.5 2007/03/01 17:22:11 rhatcher Exp $");
00007
00008 SimDaqTrigMakerProxy<SimDaqPlaneTrigger> gSimDaqPlaneTriggerProxy("PlaneTrigger");
00009
00010 ClassImp(SimDaqPlaneTrigger)
00011
00012
00013 Bool_t SimDaqPlaneTrigger::ApplyTriggerAt(PlexHandle plex,
00014 SimDigitList& sortedDigitList,
00015 UInt_t startAt,
00016 UInt_t stopAt
00017 )
00018 {
00019 MSG("DetSim",Msg::kDebug) << "Plane Trigger Running." << endl;
00020
00021
00022 if(Int_t(stopAt-startAt) < fN) return false;
00023
00024
00025 std::vector<Int_t> planeMap(600);
00026 for(UInt_t i = 0;i<planeMap.size();i++) planeMap[i]=0;
00027
00028
00029 Int_t totplanes = 0;
00030 Int_t firstPlane = 9999;
00031 Int_t lastPlane = -9999;
00032
00033 for(UInt_t idig = startAt; idig<stopAt; idig++) {
00034
00035 if(sortedDigitList[idig].GetErrors()) continue;
00036 PlexPixelSpotId psid = sortedDigitList[idig].GetPixelSpotId();
00037 PlexStripEndId seid = plex.GetStripEndId(psid);
00038 if(!seid.IsValid()) {
00039 psid.SetSpot(1);
00040 seid = plex.GetStripEndId(psid);
00041 }
00042 Int_t plane = seid.GetPlane();
00043
00044 if(plane > (Int_t)planeMap.size()) continue;
00045
00046
00047 if(planeMap[plane] ==0){
00048 totplanes++;
00049 if(plane<firstPlane) firstPlane = plane;
00050 if(plane>lastPlane) lastPlane = plane;
00051 }
00052
00053 planeMap[plane]++;
00054 }
00055
00056
00057 if(totplanes < fN) return false;
00058
00059 for(int i = firstPlane; i <= lastPlane; i++) {
00060 Int_t nPlane = 0;
00061
00062 for (Int_t j=0; (j<fM) && (i+j<=lastPlane); j++) {
00063 if ( planeMap[i+j]>0 ) nPlane++;
00064 }
00065 if (nPlane>=fN) {
00066 return true;
00067 }
00068 if (i+fM>lastPlane) break;
00069 }
00070
00071 return false;
00072 }