// --- ROOT system ---
+#include "TMath.h"
// --- ALIROOT system ---
+#include "AliConfig.h"
#include "AliPHOS.h"
#include "AliPHOSTrigger.h"
#include "AliPHOSGeometry.h"
-#include "AliPHOSGetter.h"
+#include "AliPHOSDigit.h"
+#include "AliPHOSLoader.h"
#include "AliPHOSPulseGenerator.h"
#include "AliTriggerInput.h"
fnxnMaxAmp(-1), fnxnCrystalPhi(-1), fnxnCrystalEta(-1), fnxnSM(0),
fADCValuesHighnxn(0), fADCValuesLownxn(0),
fADCValuesHigh2x2(0), fADCValuesLow2x2(0), fDigitsList(0),
+ fAmptrus(0), fAmpmods(0), fTimeRtrus(0),
fL0Threshold(50), fL1JetLowPtThreshold(200), fL1JetMediumPtThreshold(500),
fL1JetHighPtThreshold(1000),
fNTRU(8), fNTRUZ(2), fNTRUPhi(4),
SetName("PHOS");
CreateInputs();
- //Print("") ;
+ fAmptrus = new TClonesArray("TMatrixD",1000);
+ fAmpmods = new TClonesArray("TMatrixD",1000);
+ fTimeRtrus = new TClonesArray("TMatrixD",1000);
}
//____________________________________________________________________________
fADCValuesHigh2x2(trig.fADCValuesHigh2x2),
fADCValuesLow2x2(trig.fADCValuesLow2x2),
fDigitsList(trig.fDigitsList),
+ fAmptrus(trig.fAmptrus), fAmpmods(trig.fAmpmods), fTimeRtrus(trig.fTimeRtrus),
fL0Threshold(trig.fL0Threshold),
fL1JetLowPtThreshold(trig.fL1JetLowPtThreshold),
fL1JetMediumPtThreshold(trig.fL1JetMediumPtThreshold),
// cpy ctor
}
+//_________________________________________________________________________
+AliPHOSTrigger::~AliPHOSTrigger()
+{
+ // dtor
+
+ if(fADCValuesHighnxn)delete [] fADCValuesHighnxn;
+ if(fADCValuesLownxn)delete [] fADCValuesLownxn;
+ if(fADCValuesHigh2x2)delete [] fADCValuesHigh2x2;
+ if(fADCValuesLow2x2)delete [] fADCValuesLow2x2;
+ // fDigitsList is now ours...
+ if(fAmptrus) { fAmptrus->Delete() ; delete fAmptrus ; }
+ if(fAmpmods) { fAmpmods->Delete() ; delete fAmpmods ; }
+ if(fTimeRtrus) { fTimeRtrus->Delete(); delete fTimeRtrus; }
+}
+
//_________________________________________________________________________
AliPHOSTrigger & AliPHOSTrigger::operator = (const AliPHOSTrigger &)
{
// Do not create inputs again!!
if( fInputs.GetEntriesFast() > 0 ) return;
+
+ TString name = GetName();
- fInputs.AddLast( new AliTriggerInput( "PHOS_L0", "PHOS L0", 0x02 ) );
- fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1","PHOS Jet High Pt L1", 0x04 ) );
- fInputs.AddLast( new AliTriggerInput( "PHOS_JetMPt_L1","PHOS Jet Medium Pt L1", 0x08 ) );
- fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1","PHOS Jet Low Pt L1", 0x016 ) );
+ fInputs.AddLast( new AliTriggerInput( "0PH0", name, 0 ) );
+ fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1",name, 1 ) );
+ fInputs.AddLast( new AliTriggerInput( "PHOS_JetMPt_L1",name, 1 ) );
+ fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1",name, 1 ) );
}
//____________________________________________________________________________
-void AliPHOSTrigger::FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom, TClonesArray * ampmatrixtru, TClonesArray * ampmatrixmod, TClonesArray * timeRmatrixtru) const {
+void AliPHOSTrigger::FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom) const {
//Orders digits ampitudes list and times in fNTRU TRUs (28x16 crystals)
//per module. Each TRU is a TMatrixD, and they are kept in TClonesArrays.
timeRtrus(i,j) = 0.0;
}
}
- new((*ampmatrixtru)[k]) TMatrixD(amptrus) ;
- new((*timeRmatrixtru)[k]) TMatrixD(timeRtrus) ;
+ new((*fAmptrus)[k]) TMatrixD(amptrus) ;
+ new((*fTimeRtrus)[k]) TMatrixD(timeRtrus) ;
}
//List of Modules matrices initialized to 0.
ampmods(i,j) = 0.0;
}
}
- new((*ampmatrixmod)[k]) TMatrixD(ampmods) ;
+ new((*fAmpmods)[k]) TMatrixD(ampmods) ;
}
AliPHOSDigit * dig ;
Int_t itru = (row-1) + (col-1)*fNTRUPhi + (relid[0]-1)*fNTRU ;
//Fill TRU matrix with crystal values
- TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrixtru->At(itru)) ;
- TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrixtru->At(itru)) ;
+ TMatrixD * amptrus = static_cast<TMatrixD *>(fAmptrus ->At(itru)) ;
+ TMatrixD * timeRtrus = static_cast<TMatrixD *>(fTimeRtrus->At(itru)) ;
//Calculate row and column of the crystal inside the TRU with number itru
Int_t irow = (relid[2]-1) - (row-1) * fNCrystalsPhi;
(*timeRtrus)(irow,icol) = timeR ;
//####################MODULE MATRIX ##################
- TMatrixD * ampmods = dynamic_cast<TMatrixD *>(ampmatrixmod->At(relid[0]-1)) ;
+ TMatrixD * ampmods = static_cast<TMatrixD *>(fAmpmods->At(relid[0]-1)) ;
(*ampmods)(relid[2]-1,relid[3]-1) = amp ;
}
}
}
//______________________________________________________________________
-void AliPHOSTrigger::GetCrystalPhiEtaIndexInModuleFromTRUIndex(const Int_t itru,const Int_t iphitru,const Int_t ietatru,Int_t &iphiMod,Int_t &ietaMod) const
+void AliPHOSTrigger::GetCrystalPhiEtaIndexInModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru,Int_t &iphiMod,Int_t &ietaMod) const
{
// This method transforms the (eta,phi) index of a crystals in a
// TRU matrix into Super Module (eta,phi) index.
}
//____________________________________________________________________________
-Bool_t AliPHOSTrigger::IsPatchIsolated(Int_t iPatchType, const TClonesArray * ampmatrixes, const Int_t imod, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) {
+Bool_t AliPHOSTrigger::IsPatchIsolated(Int_t iPatchType, const Int_t imod, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) {
//Calculate if the maximum patch found is isolated, find amplitude around maximum (2x2 or nxn) patch,
//inside isolation patch . iPatchType = 0 means calculation for 2x2 patch,
Int_t rowborder = 0;
if(fIsolateInModule){
- ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(imod)) ;
+ ampmatrix = static_cast<TMatrixD *>(fAmpmods->At(imod)) ;
rowborder = fNCrystalsPhi*fNTRUPhi;
colborder = fNCrystalsZ*fNTRUZ;
AliDebug(2,"Isolate trigger in Module");
}
else{
- ampmatrix = dynamic_cast<TMatrixD *>(ampmatrixes->At(itru)) ;
+ ampmatrix = static_cast<TMatrixD *>(fAmptrus->At(itru)) ;
rowborder = fNCrystalsPhi;
colborder = fNCrystalsZ;
AliDebug(2,"Isolate trigger in TRU");
AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
- if(TMath::Nint(amp*1E5) < TMath::Nint(maxamp*1E5)){
+ if(amp < maxamp){
AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
return kFALSE;
}
//____________________________________________________________________________
-void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, const Int_t imod, TMatrixD &max2, TMatrixD &maxn){
+void AliPHOSTrigger::MakeSlidingCell(const Int_t imod, TMatrixD &max2, TMatrixD &maxn)
+{
//Sums energy of all possible 2x2 (L0) and nxn (L1) crystals per each TRU.
//Fast signal in the experiment is given by 2x2 crystals,
//for this reason we loop inside the TRU crystals by 2.
//Loop over all TRUS in a module
for(Int_t itru = 0 + imod * fNTRU ; itru < (imod+1)*fNTRU ; itru++){
- TMatrixD * amptru = dynamic_cast<TMatrixD *>(amptrus->At(itru)) ;
- TMatrixD * timeRtru = dynamic_cast<TMatrixD *>(timeRtrus->At(itru)) ;
+ TMatrixD * amptru = static_cast<TMatrixD *>(fAmptrus ->At(itru)) ;
+ TMatrixD * timeRtru = static_cast<TMatrixD *>(fTimeRtrus->At(itru)) ;
Int_t mtru = itru-imod*fNTRU ; //Number of TRU in Module
//Sliding 2x2, add 2x2 amplitudes (NOT OVERLAP)
fL0Threshold) ;
printf( " Threshold for LO %10.2f\n", fL0Threshold) ;
- in = (AliTriggerInput*)fInputs.FindObject( "PHOS_L0" );
+ in = (AliTriggerInput*)fInputs.FindObject( "0PH0" );
if(in->GetValue())
printf( " *** PHOS LO is set ***\n") ;
}
//____________________________________________________________________________
-void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMod, const TMatrixD & ampmax2, const TMatrixD & ampmaxn)
+void AliPHOSTrigger::SetTriggers(const Int_t iMod, const TMatrixD & ampmax2, const TMatrixD & ampmaxn)
{
//Checks the 2x2 and nxn maximum amplitude per each TRU and compares
//with the different L0 and L1 triggers thresholds. It finds if maximum amplitudes are isolated.
//Isolated patch?
if(fIsolateInModule)
- fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iMod, mtru2, f2x2MaxAmp, f2x2CrystalPhi,f2x2CrystalEta) ;
+ fIs2x2Isol = IsPatchIsolated(0, iMod, mtru2, f2x2MaxAmp, f2x2CrystalPhi,f2x2CrystalEta) ;
else
- fIs2x2Isol = IsPatchIsolated(0, ampmatrix, iMod, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
+ fIs2x2Isol = IsPatchIsolated(0, iMod, mtru2, f2x2MaxAmp, static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
//Transform digit amplitude in Raw Samples
if (fADCValuesLow2x2 == 0) {
fADCValuesLow2x2 = new Int_t[nTimeBins];
- fADCValuesHigh2x2 = new Int_t[nTimeBins];
}
+ if(!fADCValuesHigh2x2) fADCValuesHigh2x2 = new Int_t[nTimeBins];
+
pulse.SetAmplitude(f2x2MaxAmp);
pulse.SetTZero(maxtimeR2);
//Set L0
for(Int_t i = 0 ; i < nTimeBins ; i++){
if(fADCValuesHigh2x2[i] >= fL0Threshold || fADCValuesLow2x2[i] >= fL0Threshold) {
- SetInput("PHOS_L0") ;
+ SetInput("0PH0") ;
break;
}
}
//Isolated patch?
if(fIsolateInModule)
- fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iMod, mtrun, fnxnMaxAmp, fnxnCrystalPhi, fnxnCrystalEta) ;
+ fIsnxnIsol = IsPatchIsolated(1, iMod, mtrun, fnxnMaxAmp, fnxnCrystalPhi, fnxnCrystalEta) ;
else
- fIsnxnIsol = IsPatchIsolated(1, ampmatrix, iMod, mtrun, fnxnMaxAmp, static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
+ 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) {
fADCValuesLownxn = new Int_t[nTimeBins];
}
- pulse.SetAmplitude(maxtimeRn);
- pulse.SetTZero(fnxnMaxAmp);
+ pulse.SetAmplitude(fnxnMaxAmp);
+ pulse.SetTZero(maxtimeRn);
pulse.MakeSamples();
pulse.GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ;
}
//____________________________________________________________________________
-void AliPHOSTrigger::Trigger()
-{
-
- //Main Method to select triggers.
-
- AliRunLoader * rl = gAlice->GetRunLoader() ;
- TString fileName = rl->GetFileName() ;
- DoIt(fileName.Data()) ;
-}
-
-//____________________________________________________________________________
-void AliPHOSTrigger::Trigger(const char * fileName)
+void AliPHOSTrigger::Trigger(TClonesArray *digits)
{
-
//Main Method to select triggers.
-
- DoIt(fileName) ;
+ fDigitsList = digits;
+ DoIt() ;
}
//____________________________________________________________________________
-void AliPHOSTrigger::DoIt(const char * fileName)
+void AliPHOSTrigger::DoIt()
{
// does the trigger job
- AliPHOSGetter * gime = AliPHOSGetter::Instance( fileName ) ;
+ AliRunLoader* rl = AliRunLoader::Instance() ;
+ AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
- //Get Geometry
- const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
+ // Get PHOS Geometry object
+ AliPHOSGeometry *geom;
+ if (!(geom = AliPHOSGeometry::GetInstance()))
+ geom = AliPHOSGeometry::GetInstance("IHEP","");
//Define parameters
Int_t nModules = geom->GetNModules();
//Take the digits list if simulation
if(fSimulation)
- fDigitsList = gime->Digits() ;
+ 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,amptrus, ampmods,timeRtrus) ;
+// 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
for(Int_t imod = 0 ; imod < nModules ; imod++) {
//Do 2x2 and nxn sums, select maximums.
- MakeSlidingCell(amptrus, timeRtrus, imod, ampmax2, ampmaxn);
+ MakeSlidingCell(imod, ampmax2, ampmaxn);
//Set the trigger
- if(fIsolateInModule)
- SetTriggers(ampmods,imod,ampmax2,ampmaxn) ;
- if(!fIsolateInModule)
- SetTriggers(amptrus,imod,ampmax2,ampmaxn) ;
+ SetTriggers(imod,ampmax2,ampmaxn) ;
}
- amptrus->Delete();
- delete amptrus; amptrus=0;
- ampmods->Delete();
- delete ampmods; ampmods=0;
- timeRtrus->Delete();
- delete timeRtrus; timeRtrus=0;
+ fAmptrus->Delete();
+// delete amptrus; amptrus=0;
+ fAmpmods->Delete();
+// delete ampmods; ampmods=0;
+ fTimeRtrus->Delete();
+// delete timeRtrus; timeRtrus=0;
//Print();
}