+
+ //Set max nxn amplitude and select L1 triggers
+ if(maxn[0] > fnxnMaxAmp && fPatchSize > 0){
+ fnxnMaxAmp = maxn[0] ;
+ fnxnSM = iMod ;
+ maxtimeRn = maxn[3] ;
+ GetCrystalPhiEtaIndexInModuleFromTRUIndex(mtrun,
+ static_cast<Int_t>(maxn[1]),
+ static_cast<Int_t>(maxn[2]),
+ fnxnCrystalPhi,fnxnCrystalEta) ;
+
+ //Isolated patch?
+ if(fIsolateInModule)
+ fIsnxnIsol = IsPatchIsolated(1, iMod, mtrun, fnxnMaxAmp, fnxnCrystalPhi, fnxnCrystalEta) ;
+ else
+ fIsnxnIsol = IsPatchIsolated(1, iMod, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
+
+ //Transform digit amplitude in Raw Samples
+ if (fADCValuesHighnxn == 0) {
+ fADCValuesHighnxn = new Int_t[nTimeBins];
+ fADCValuesLownxn = new Int_t[nTimeBins];
+ }
+
+ pulse.SetAmplitude(fnxnMaxAmp);
+ pulse.SetTZero(maxtimeRn);
+ pulse.MakeSamples();
+ pulse.GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ;
+
+ //Set Trigger Inputs, compare ADC time bins until threshold is attained
+ //SetL1 Low
+ for(Int_t i = 0 ; i < nTimeBins ; i++){
+ if(fADCValuesHighnxn[i] >= fL1JetLowPtThreshold || fADCValuesLownxn[i] >= fL1JetLowPtThreshold){
+ SetInput("PHOS_JetLPt_L1") ;
+ break;
+ }
+ }
+ //SetL1 Medium
+ for(Int_t i = 0 ; i < nTimeBins ; i++){
+ if(fADCValuesHighnxn[i] >= fL1JetMediumPtThreshold || fADCValuesLownxn[i] >= fL1JetMediumPtThreshold){
+ SetInput("PHOS_JetMPt_L1") ;
+ break;
+ }
+ }
+ //SetL1 High
+ for(Int_t i = 0 ; i < nTimeBins ; i++){
+ if(fADCValuesHighnxn[i] >= fL1JetHighPtThreshold || fADCValuesLownxn[i] >= fL1JetHighPtThreshold){
+ SetInput("PHOS_JetHPt_L1") ;
+ break;
+ }
+ }
+ }
+}
+
+//____________________________________________________________________________
+void AliPHOSTrigger::Trigger(TClonesArray *digits)
+{
+ //Main Method to select triggers.
+
+ fDigitsList = digits;
+ DoIt() ;
+}
+
+//____________________________________________________________________________
+void AliPHOSTrigger::DoIt()
+{
+ // does the trigger job
+
+ AliRunLoader* rl = AliRunLoader::Instance() ;
+ AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+
+ // Get PHOS Geometry object
+ AliPHOSGeometry *geom;
+ if (!(geom = AliPHOSGeometry::GetInstance()))
+ geom = AliPHOSGeometry::GetInstance("IHEP","");
+
+ //Define parameters
+ Int_t nModules = geom->GetNModules();
+ fNCrystalsPhi = geom->GetNPhi()/fNTRUPhi ;// 64/4=16
+ fNCrystalsZ = geom->GetNZ()/fNTRUZ ;// 56/2=28
+
+ //Intialize data members each time the trigger is called in event loop
+ f2x2MaxAmp = -1; f2x2CrystalPhi = -1; f2x2CrystalEta = -1;
+ fnxnMaxAmp = -1; fnxnCrystalPhi = -1; fnxnCrystalEta = -1;
+
+ //Take the digits list if simulation
+ if(fSimulation)
+ fDigitsList = phosLoader->Digits() ;
+
+ if(!fDigitsList)
+ AliFatal("Digits not found !") ;
+
+ //Fill TRU Matrix
+// TClonesArray * amptrus = new TClonesArray("TMatrixD",1000);
+// TClonesArray * ampmods = new TClonesArray("TMatrixD",1000);
+// TClonesArray * timeRtrus = new TClonesArray("TMatrixD",1000);
+ FillTRU(fDigitsList,geom) ;
+
+ //Do Crystal Sliding and select Trigger
+ //Initialize varible that will contain maximum amplitudes and
+ //its corresponding cell position in eta and phi, and time.
+ TMatrixD ampmax2(4,fNTRU) ;
+ TMatrixD ampmaxn(4,fNTRU) ;
+
+ for(Int_t imod = 0 ; imod < nModules ; imod++) {
+
+ //Do 2x2 and nxn sums, select maximums.
+ MakeSlidingCell(imod, ampmax2, ampmaxn);
+ //Set the trigger
+ SetTriggers(imod,ampmax2,ampmaxn) ;
+ }
+
+ fAmptrus->Delete();
+// delete amptrus; amptrus=0;
+ fAmpmods->Delete();
+// delete ampmods; ampmods=0;
+ fTimeRtrus->Delete();
+// delete timeRtrus; timeRtrus=0;
+ //Print();
+