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

SimDaqEnergyTrigger.cxx

Go to the documentation of this file.
00001 #include "SimDaqTrigMaker.h"
00002 #include "SimDaqEnergyTrigger.h"
00003 #include "MessageService/MsgService.h"
00004 #include <vector>
00005 
00006 CVSID("$Id: SimDaqEnergyTrigger.cxx,v 1.5 2007/03/01 17:22:11 rhatcher Exp $");
00007 
00008 SimDaqTrigMakerProxy<SimDaqEnergyTrigger> gSimDaqEnergyTriggerProxy("EnergyTrigger");
00009 
00010 ClassImp(SimDaqEnergyTrigger)
00011 
00012 
00013 Bool_t SimDaqEnergyTrigger::ApplyTriggerAt(PlexHandle    plex,
00014                                           SimDigitList& sortedDigitList, // Digit list
00015                                           UInt_t         startAt,         // Which digit to start looking at
00016                                           UInt_t         stopAt           // Which digit is the end of the burst
00017                                           )
00018 {
00019   //
00020   // This trigger looks if the energy sum of any M consecutive planes 
00021   // is larger than Threshold.
00022   // It has the further requirement that N planes out of M must be hit,
00023   // and Nhits digits must have occoured.
00024   //
00025   MSG("DetSim",Msg::kDebug) << "Energy Trigger Running: "                          
00026                             << fThreshold << " ADC and " 
00027                             << fNhits << " hits and " 
00028                             << fN << " planes hit in a window of " 
00029                             << fM  << " planes.\n";
00030 
00031   // Quick check: do we have enough hits at all?
00032   if(Int_t(stopAt-startAt) < fN) return false; // Not enough digits total.
00033   
00034   // Quick check: enough digits at all?
00035   if(Int_t(stopAt-startAt) < fNhits) return false; // Not enough digits total.
00036 
00037   // Add the hits to a plane map.
00038   std::vector<Int_t> planeEnergy(600,0);
00039   std::vector<Int_t> planeHits(600,0);
00040 
00041   Int_t totADC = 0;
00042   Int_t firstPlane = 9999;
00043   Int_t lastPlane = -9999;
00044 
00045   for(UInt_t idig = startAt; idig<stopAt; idig++) {
00046     // Find the plane.
00047     if(sortedDigitList[idig].GetErrors()) continue;
00048     PlexPixelSpotId psid = sortedDigitList[idig].GetPixelSpotId();
00049     PlexStripEndId  seid = plex.GetStripEndId(psid);
00050     if(!seid.IsValid()) {
00051       psid.SetSpot(1);
00052       seid = plex.GetStripEndId(psid);
00053     }
00054     Int_t plane = seid.GetPlane();
00055     Int_t adc = sortedDigitList[idig].GetADC();
00056     totADC+=adc;
00057 
00058     if( (UInt_t)plane >= planeEnergy.size()) continue;
00059 
00060     // Add plane to map.
00061     if(planeEnergy[plane] ==0){
00062       if(plane<firstPlane) firstPlane = plane;
00063       if(plane>lastPlane) lastPlane = plane;
00064     }
00065 
00066     planeEnergy[plane]+= adc;
00067     planeHits[plane]+= 1;
00068   }
00069   
00070   // Second quick check: enough ADCs in total to fire trigger
00071   if(totADC < fThreshold) return false;
00072 
00073 
00074 
00075   for(Int_t i = firstPlane; i <= lastPlane; i++) {
00076     Int_t local_energy = 0;
00077     Int_t local_nhit = 0;
00078     Int_t local_planeshit = 0;
00079 
00080     for (Int_t j=0; (j<fM) && (i+j<=lastPlane); j++) {
00081       local_energy += planeEnergy[i+j];
00082       local_nhit   += planeHits[i+j];
00083       if(planeHits[i+j]>0) local_planeshit++;
00084     }
00085     if ((local_energy >= fThreshold) && (local_nhit >=fNhits) && (local_planeshit >= fN)) {
00086       return true;
00087     }
00088 
00089     if (i+fM>lastPlane) break; // We're done... stop looking.
00090   }
00091   
00092   return false;
00093 }

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