-
- //######################################################
- //#########Calculate trigger and set trigger info###########
- //######################################################
-
- AliEMCALTrigger tr;
- // tr.SetPatchSize(1); // create 4x4 patches
- tr.SetSimulation(kFALSE); // Reconstruction mode
- tr.SetDigitsList(fgDigitsArr);
- // Get VZERO total multiplicity for jet trigger simulation
- // The simulation of jey trigger will be incorrect if no VZERO data
- // at ESD
- AliESDVZERO* vZero = esd->GetVZEROData();
- if(vZero) {
- tr.SetVZER0Multiplicity(vZero->GetMTotV0A() + vZero->GetMTotV0C());
- }
- //
- tr.Trigger();
-
- Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
- Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
- Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
- Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
-
- Int_t iSM2x2 = tr.Get2x2SuperModule();
- Int_t iSMnxn = tr.GetnxnSuperModule();
- Int_t iModulePhi2x2 = tr.Get2x2ModulePhi();
- Int_t iModulePhinxn = tr.GetnxnModulePhi();
- Int_t iModuleEta2x2 = tr.Get2x2ModuleEta();
- Int_t iModuleEtanxn = tr.GetnxnModuleEta();
-
- AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iModulePhi2x2, iModuleEta2x2));
- AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iModulePhinxn, iModuleEtanxn));
-
- TVector3 pos2x2(-1,-1,-1);
- TVector3 posnxn(-1,-1,-1);
-
- Int_t iAbsId2x2 = fGeom->GetAbsCellIdFromCellIndexes( iSM2x2, iModulePhi2x2, iModuleEta2x2) ; // should be changed to Module
- Int_t iAbsIdnxn = fGeom->GetAbsCellIdFromCellIndexes( iSMnxn, iModulePhinxn, iModuleEtanxn) ;
- fGeom->GetGlobal(iAbsId2x2, pos2x2);
- fGeom->GetGlobal(iAbsIdnxn, posnxn);
- //printf(" iAbsId2x2 %i iAbsIdnxn %i \n", iAbsId2x2, iAbsIdnxn);
-
- TArrayF triggerPosition(6);
- triggerPosition[0] = pos2x2(0) ;
- triggerPosition[1] = pos2x2(1) ;
- triggerPosition[2] = pos2x2(2) ;
- triggerPosition[3] = posnxn(0) ;
- triggerPosition[4] = posnxn(1) ;
- triggerPosition[5] = posnxn(2) ;
- //printf(" triggerPosition ");
- //for(int i=0; i<6; i++) printf(" %i %f : ", i, triggerPosition[i]);
-
- TArrayF triggerAmplitudes(4);
- triggerAmplitudes[0] = maxAmp2x2 ;
- triggerAmplitudes[1] = ampOutOfPatch2x2 ;
- triggerAmplitudes[2] = maxAmpnxn ;
- triggerAmplitudes[3] = ampOutOfPatchnxn ;
- //printf("\n triggerAmplitudes ");
- //for(int i=0; i<4; i++) printf(" %i %f : ", i, triggerAmplitudes[i]);
- //printf("\n");
- tr.Print("");
-
- esd->AddEMCALTriggerPosition(triggerPosition);
- esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
- // Fill trigger hists
- AliEMCALHistoUtilities::FillTriggersListOfHists(fList,&triggerPosition,&triggerAmplitudes);
-
+
+ //########################################
+ // Trigger
+ //########################################
+
+ static int saveOnce = 0;
+
+ Int_t v0M[2] = {0, 0};
+
+ AliESDVZERO* esdV0 = esd->GetVZEROData();
+
+ if (esdV0)
+ {
+ v0M[0] = esdV0->GetTriggerChargeC();
+ v0M[1] = esdV0->GetTriggerChargeA();
+ }
+ else
+ {
+ AliWarning("No V0 ESD! Run trigger processor w/ null V0 charges");
+ }
+
+ if (fgTriggerDigits && fgTriggerDigits->GetEntriesFast()) fgTriggerDigits->Delete();
+
+ TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
+
+ if (!branchtrg)
+ {
+ AliError("Can't get the branch with the EMCAL trigger digits!");
+ return;
+ }
+
+ branchtrg->SetAddress(&fgTriggerDigits);
+ branchtrg->GetEntry(0);
+
+ // Note: fgTriggerProcessor reset done at the end of this method
+ fgTriggerProcessor->Digits2Trigger(fgTriggerDigits, v0M, fTriggerData);
+
+ // Fill ESD
+ AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL");
+
+ if (trgESD)
+ {
+ trgESD->Allocate(fgTriggerDigits->GetEntriesFast());
+
+ for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++)
+ {
+ AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i);
+ if (AliDebugLevel() > 999) rdig->Print("");
+
+ Int_t px, py;
+ if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
+ {
+ Int_t a = -1, t = -1, times[10];
+
+ rdig->GetMaximum(a, t);
+ rdig->GetL0Times(times);
+
+ trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits());
+ }
+ }
+
+ for (int i = 0; i < 2; i++) {
+ trgESD->SetL1Threshold(2 * i , fTriggerData->GetL1JetThreshold( i));
+ trgESD->SetL1Threshold(2 * i + 1, fTriggerData->GetL1GammaThreshold(i));
+ }
+
+ Int_t v0[2];
+ fTriggerData->GetL1V0(v0);
+
+ trgESD->SetL1V0(v0);
+ trgESD->SetL1FrameMask(fTriggerData->GetL1FrameMask());
+
+ if (!saveOnce && fTriggerData->GetL1DataDecoded())
+ {
+ int type[15] = {0};
+ fTriggerData->GetL1TriggerType(type);
+
+ esd->SetCaloTriggerType(type);
+
+ saveOnce = 1;
+ }
+ }
+
+ // Resetting
+ fTriggerData->Reset();
+