00001 #include "SimDaqTrigMaker.h"
00002 #include "SimDaqMultTrigger.h"
00003 #include "MessageService/MsgService.h"
00004 #include <vector>
00005
00006 CVSID("$Id: SimDaqMultTrigger.cxx,v 1.6 2007/03/01 17:22:11 rhatcher Exp $");
00007
00008 SimDaqTrigMakerProxy<SimDaqMultTrigger> gSimDaqMultTriggerProxy("MultTrigger");
00009
00010 ClassImp(SimDaqMultTrigger)
00011
00012
00013 SimDaqMultTrigger::SimDaqMultTrigger(void):
00014 SimDaqTrigger()
00015 {
00016 }
00017
00018
00019 Bool_t SimDaqMultTrigger::ApplyTriggerAt(PlexHandle plex,
00020 SimDigitList& sortedDigitList,
00021 UInt_t startAt,
00022 UInt_t stopAt
00023 )
00024 {
00025
00026
00027
00028
00029
00030 MSG("DetSim",Msg::kDebug) << "Multiplicity Trigger Running."
00031 << " Calculating " << fNhits << " hits in "
00032 << fN << " out of "
00033 << fM <<" planes.\n";
00034
00035
00036 if(Int_t(stopAt-startAt) < fN) return false;
00037
00038
00039 std::vector<Int_t> planeMap(600);
00040 for(UInt_t i = 0;i<planeMap.size();i++) planeMap[i]=0;
00041
00042
00043 Int_t totplanes = 0;
00044 Int_t firstPlane = 9999;
00045 Int_t lastPlane = -9999;
00046
00047 for(UInt_t idig = startAt; idig<stopAt; idig++) {
00048
00049 if(sortedDigitList[idig].GetErrors()) continue;
00050 PlexPixelSpotId psid = sortedDigitList[idig].GetPixelSpotId();
00051 PlexStripEndId seid = plex.GetStripEndId(psid);
00052 if(!seid.IsValid()) {
00053 psid.SetSpot(1);
00054 seid = plex.GetStripEndId(psid);
00055 }
00056 Int_t plane = seid.GetPlane();
00057 Int_t adc = sortedDigitList[idig].GetADC();
00058
00059 if(plane > (Int_t)planeMap.size()) continue;
00060
00061 if(adc>=fThreshold) {
00062
00063 if(planeMap[plane] ==0){
00064 totplanes++;
00065 if(plane<firstPlane) firstPlane = plane;
00066 if(plane>lastPlane) lastPlane = plane;
00067 }
00068
00069 planeMap[plane]++;
00070 }
00071 }
00072
00073
00074 if(totplanes < fN) return false;
00075
00076 for(int i = firstPlane; i <= lastPlane; i++) {
00077 Int_t nPlane = 0;
00078 Int_t nDigit = 0;
00079
00080 for (Int_t j=0; (j<fM) && (i+j<=lastPlane); j++) {
00081 if ( planeMap[i+j]>0 ) {
00082 nPlane++;
00083 nDigit += planeMap[i+j];
00084 }
00085 }
00086 if ((nPlane>=fN)&&(nDigit>=fNhits)) {
00087 return true;
00088 }
00089 if (i+fM>lastPlane) break;
00090 }
00091
00092 return false;
00093 }