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

SimDaqMultTrigger.cxx

Go to the documentation of this file.
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, // Digit list
00021                                           UInt_t         startAt,         // Which digit to start looking at
00022                                           UInt_t         stopAt           // Which digit is the end of the burst
00023                                           )
00024 {
00025   //
00026   // this is the standard  PlaneTrigger just working on significant hits
00027   // which are above some ADC threshold. it furthermore requires
00028   // a total number of hits to be present in the M plane window
00029   //
00030   MSG("DetSim",Msg::kDebug) << "Multiplicity Trigger Running." 
00031                             << "    Calculating " << fNhits << " hits in " 
00032                             << fN << " out of "
00033                             << fM <<" planes.\n";
00034 
00035   // Quick check: do we have enough hits at all?
00036   if(Int_t(stopAt-startAt) < fN) return false; // Not enough digits total.
00037 
00038   // Add the hits to a plane map.
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     // Find the plane.
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       // Add plane to map.
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   // Second quick check: enough planes were hit in total.
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; // 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