+ // Do patch sliding and select Jet Trigger
+ // 0-max amp-meanFromVZERO(if), 1-irow, 2-icol, 3-timeR,
+ // 4-max amp , 5-meanFromVZERO (Nov 25, 2007)
+ // fAmpJetMax(6,1)
+ MakeSlidingPatch((*fAmpJetMatrix), fNJetPatchPhi, fAmpJetMax); // no timing information here
+
+ //Print();
+ // fDigitsList = 0;
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::GetTriggerInfo(TArrayF &triggerPosition, TArrayF &triggerAmplitudes) const
+{
+ // Template - should be defined; Nov 5, 2007
+ triggerPosition[0] = 0.;
+ triggerAmplitudes[0] = 0.;
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::FillJetMatrixFromSMs(TClonesArray *ampmatrixsmod, TMatrixD* jetMat, AliEMCALGeometry *g)
+{
+ // Nov 5, 2007
+ // Fill matrix for jet trigger from SM matrixes of modules
+ //
+ static int keyPrint = 0;
+
+ if(ampmatrixsmod==0 || jetMat==0 || g==0) return;
+ Double_t amp = 0.0, ampSum=0.0;
+
+ Int_t nEtaModSum = g->GetNZ() / g->GetNEtaSubOfTRU(); // should be 4
+ Int_t nPhiModSum = g->GetNPhi() / g->GetNTRUPhi(); // should be 4
+
+ if(keyPrint) AliDebug(2,Form("%s",Form(" AliEMCALTrigger::FillJetMatrixFromSMs | nEtaModSum %i : nPhiModSum %i \n", nEtaModSum, nPhiModSum)));
+ Int_t jrow=0, jcol=0; // indexes of jet matrix
+ Int_t nEtaSM=0, nPhiSM=0;
+ for(Int_t iSM=0; iSM<ampmatrixsmod->GetEntries(); iSM++) {
+ TMatrixD * ampsmods = dynamic_cast<TMatrixD *>(ampmatrixsmod->At(iSM));
+
+ if(!ampsmods) return;
+
+ Int_t nrow = ampsmods->GetNrows();
+ Int_t ncol = ampsmods->GetNcols();
+ //printf("%s",Form(" ######## SM %i : nrow %i : ncol %i ##### \n", iSM, nrow, ncol));
+ for(Int_t row=0; row<nrow; row++) {
+ for(Int_t col=0; col<ncol; col++) {
+ amp = (*ampsmods)(row,col);
+ nPhiSM = iSM / 2;
+ nEtaSM = iSM % 2;
+ if (amp>0.0) {
+ if(keyPrint) AliDebug(2,Form("%s",Form(" ** nPhiSm %i : nEtaSM %i : row %2.2i : col %2.2i -> ", nPhiSM, nEtaSM, row, col)));
+ if(nEtaSM == 0) { // positive Z
+ jrow = 3*nPhiSM + row/nPhiModSum;
+ jcol = 6 + col / nEtaModSum;
+ } else { // negative Z
+ if(iSM<=9) jrow = 3*nPhiSM + 2 - row/nPhiModSum;
+ else jrow = 3*nPhiSM + 1 - row/nPhiModSum; // half size
+ jcol = 5 - col / nEtaModSum;
+ }
+ if(keyPrint) AliDebug(2,Form("%s",Form(" jrow %2.2i : jcol %2.2i : amp %f (jetMat) \n", jrow, jcol, amp)));
+
+ (*jetMat)(jrow,jcol) += amp;
+ ampSum += amp; // For controling
+ } else if(amp<0.0) {
+ AliDebug(1,Form(" jrow %2.2i : jcol %2.2i : amp %f (jetMat: amp<0) \n", jrow, jcol, amp));
+ assert(0);
+ }
+ }
+ }
+ } // cycle on SM
+ if(ampSum <= 0.0) AliDebug(1,Form("ampSum %f (<=0.0) ", ampSum));
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::MakeSlidingPatch(const TMatrixD &jm, const Int_t nPatchSize, TMatrixD &JetMax)
+{
+ // Sliding patch : nPatchSize x nPatchSize (OVERLAP)
+ static int keyPrint = 0;
+ if(keyPrint) AliDebug(2,Form(" AliEMCALTrigger::MakeSlidingPatch() was started \n"));
+ Double_t ampCur = 0.0, e=0.0;
+ ampJetMax(0,0) = 0.0;
+ ampJetMax(3,0) = 0.0; // unused now
+ ampJetMax(4,0) = ampJetMax(5,0) = 0.0;
+ for(Int_t row=0; row<fAmpJetMatrix->GetNrows(); row ++) {
+ for(Int_t col=0; col<fAmpJetMatrix->GetNcols(); col++) {
+ ampCur = 0.;
+ // check on patch size
+ if( (row+nPatchSize-1) < fAmpJetMatrix->GetNrows() && (col+nPatchSize-1) < fAmpJetMatrix->GetNcols()){
+ for(Int_t i = 0 ; i < nPatchSize ; i++) {
+ for(Int_t j = 0 ; j < nPatchSize ; j++) {
+ ampCur += jm(row+i, col+j);
+ }
+ } // end cycle on patch
+ if(ampCur > ampJetMax(0,0)){
+ ampJetMax(0,0) = ampCur;
+ ampJetMax(1,0) = row;
+ ampJetMax(2,0) = col;
+ }
+ } // check on patch size
+ }
+ }
+ if(keyPrint) AliDebug(2,Form(" ampJetMax %i row %2i->%2i col %2i->%2i \n", Int_t(ampJetMax(0,0)), Int_t(ampJetMax(1,0)), Int_t(ampJetMax(1,0))+nPatchSize-1, Int_t(ampJetMax(2,0)), Int_t(ampJetMax(2,0))+nPatchSize-1));
+
+ Double_t eCorrJetMatrix=0.0;
+ if(fVZER0Mult > 0.0) {
+ // Correct patch energy (adc) and jet patch matrix energy
+ Double_t meanAmpBG = GetMeanEmcalPatchEnergy(Int_t(fVZER0Mult), nPatchSize)/0.0153;
+ ampJetMax(4,0) = ampJetMax(0,0);
+ ampJetMax(5,0) = meanAmpBG;
+
+ Double_t eCorr = ampJetMax(0,0) - meanAmpBG;
+ AliDebug(2,Form(" ampJetMax(0,0) %f meanAmpBG %f eCorr %f : ampJetMax(4,0) %f \n",
+ ampJetMax(0,0), meanAmpBG, eCorr, ampJetMax(5,0)));
+ ampJetMax(0,0) = eCorr;
+ // --
+ eCorrJetMatrix = GetMeanEmcalEnergy(Int_t(fVZER0Mult)) / 208.;
+ }
+ // Fill patch energy matrix
+ for(int row=Int_t(ampJetMax(1,0)); row<Int_t(ampJetMax(1,0))+nPatchSize; row++) {
+ for(int col=Int_t(ampJetMax(2,0)); col<Int_t(ampJetMax(2,0))+nPatchSize; col++) {
+ e = Double_t(jm(row,col)*0.0153); // 0.0153 - hard coded now
+ if(eCorrJetMatrix > 0.0) { // BG subtraction case
+ e -= eCorrJetMatrix;
+ fJetMatrixE->SetBinContent(row+1, col+1, e);
+ } else if(e > 0.0) {
+ fJetMatrixE->SetBinContent(row+1, col+1, e);
+ }
+ }
+ }
+ // PrintJetMatrix();
+ // Set the jet trigger(s), multiple threshold now, Nov 19,2007
+ for(Int_t i=0; i<fNJetThreshold; i++ ) {
+ if(ampJetMax(0,0) >= fL1JetThreshold[i]) {
+ SetInput(GetNameOfJetTrigger(i));
+ }
+ }
+}
+
+//____________________________________________________________________________
+Double_t AliEMCALTrigger::GetEmcalSumAmp() const
+{
+ // Return sum of amplidutes from EMCal
+ // Used calibration coefficeint for transition to energy
+ return fAmpJetMatrix >0 ?fAmpJetMatrix->Sum() :0.0;
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::PrintJetMatrix() const
+{
+ // fAmpJetMatrix : (17,12); // 17-phi(row), 12-eta(col)
+ if(fAmpJetMatrix == 0) return;
+
+ AliInfo(Form("\n #### jetMatrix : (%i,%i) ##### \n ",
+ fAmpJetMatrix->GetNrows(), fAmpJetMatrix->GetNcols()));
+ PrintMatrix(*fAmpJetMatrix);
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::PrintAmpTruMatrix(Int_t ind) const
+{
+ // Print matrix with TRU patches
+ TMatrixD * tru = dynamic_cast<TMatrixD *>(fAmpTrus->At(ind));
+ if(tru == 0) return;
+ AliInfo(Form("\n #### Amp TRU matrix(%i) : (%i,%i) ##### \n ",
+ ind, tru->GetNrows(), tru->GetNcols()));
+ PrintMatrix(*tru);
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::PrintAmpSmMatrix(Int_t ind) const
+{
+ // Print matrix with SM amplitudes
+ TMatrixD * sm = dynamic_cast<TMatrixD *>(fAmpSMods->At(ind));
+ if(sm == 0) return;
+ AliInfo(Form("\n #### Amp SM matrix(%i) : (%i,%i) ##### \n ",
+ ind, sm->GetNrows(), sm->GetNcols()));
+ PrintMatrix(*sm);
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::PrintMatrix(const TMatrixD &mat) const
+{
+ //Print matrix object
+ for(Int_t col=0; col<mat.GetNcols(); col++) AliInfo(Form(" %3i ", col));
+ AliInfo(Form("\n -- \n"));
+ for(Int_t row=0; row<mat.GetNrows(); row++) {
+ AliInfo(Form(" row:%2i ", row));
+ for(Int_t col=0; col<mat.GetNcols(); col++) {
+ AliInfo(Form(" %4i", (Int_t)mat(row,col)));
+ }
+ AliInfo("\n");