#include <TRegexp.h>
#include <TObjArray.h>
#include <TObjString.h>
+#include <assert.h>
+#include <TMatrixD.h>
+#include <TClonesArray.h>
// -- ALICE Headers.
//#include "AliConst.h"
// --- EMCAL headers
#include "AliEMCALGeometry.h"
+#include "AliEMCALDigit.h"
ClassImp(AliEMCALGeometry)
printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n",
GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
}
+ //TRU parameters. These parameters values are not the final ones.
+ fNTRU = 3 ;
+ fNTRUEta = 3 ;
+ fNTRUPhi = 1 ;
}
//______________________________________________________________________
}
}
+//____________________________________________________________________________
+TClonesArray * AliEMCALGeometry::FillTRU(const TClonesArray * digits) {
+
+
+ //Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule.
+ //Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of
+ //TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta. For the
+ //moment the TRU of the 2 smaller supermodules are considered to be equal
+ //to the rest.
+
+ //Check data members
+
+ if(fNTRUEta*fNTRUPhi != fNTRU)
+ Error("FillTRU"," Wrong number of TRUS per Eta or Phi");
+
+ //Initilize variables
+ //List of TRU matrices initialized to 0.
+ Int_t nCellsPhi = fNPhi*2/fNTRUPhi;
+ Int_t nCellsEta = fNZ*2/fNTRUEta;
+ TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
+
+ for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){
+ TMatrixD * trus = new TMatrixD(nCellsPhi,nCellsEta) ;
+ for(Int_t i = 0; i < nCellsPhi; i++)
+ for(Int_t j = 0; j < nCellsEta; j++)
+ (*trus)(i,j) = 0.0;
+
+ new((*matrix)[k]) TMatrixD(*trus) ;
+ }
+
+ AliEMCALDigit * dig ;
+
+ //Declare variables
+ Int_t id = -1;
+ Float_t amp = -1;
+ Int_t iSupMod = -1;
+ Int_t nTower = -1;
+ Int_t nIphi = -1;
+ Int_t nIeta = -1;
+ Int_t iphi = -1;
+ Int_t ieta = -1;
+
+ //Digits loop to fill TRU matrices with amplitudes.
+
+ for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
+
+ dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ;
+ amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
+ id = dig->GetId() ; //Id label of the cell
+ //cout<<"idig "<<idig<<" Amp "<<amp<<" Id "<<id<<endl;
+
+ //Get eta and phi cell position in supermodule
+ Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ;
+ if(!bCell)
+ Error("FillTRU","Wrong cell id number") ;
+
+ GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
+
+ //Check to which TRU in the supermodule belongs the cell.
+ //Supermodules are divided in a TRU matrix of dimension
+ //(fNTRUPhi,fNTRUEta).
+ //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta)
+
+ //First calculate the row and column in the supermodule
+ //of the TRU to which the cell belongs.
+
+ Int_t col = (ieta-1)/nCellsEta+1;
+ Int_t row = (iphi-1)/nCellsPhi+1;
+ Int_t itru = col*row + (iSupMod-1)*fNTRU - 1; //Label number of the TRU
+// Info("FillTRU","SM %d, cell: phi %d, eta %d",iSupMod,iphi,ieta);
+// Info("FillTRU","SM TRU: SMrow %d, SMcol %d, SMtru %d,",row,col,itru);
+
+
+ //Fill TRU matrix with cell values
+
+ TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(itru)) ;
+
+ //Calculate row and column of the cell inside the TRU with number itru
+
+ Int_t irow = (iphi-1) - (row-1) * nCellsPhi;
+ Int_t icol = (ieta-1) - (col-1) * nCellsEta;
+
+ (*trus)(irow,icol) = amp ;
+
+
+ // Info("FillTRU","TRU: row %d, col %d",irow,icol);
+
+ }
+ return matrix;
+}
+
+
//______________________________________________________________________
AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
// Returns the pointer of the unique instance
//*-- Author: Sahal Yacoob (LBL / UCT)
//*-- and : Yves Schutz (Subatech)
//*-- and : Aleksei Pavlinov (WSU) - shashlyk staff
+//*-- and : Gustavo Conesa: Add TRU mapping. TRU parameters still not fixed.
// --- ROOT system ---
class TString ;
class TObjArray;
class TVector3 ;
class TParticle ;
+class TClonesArray ;
// --- AliRoot header files ---
#include "AliGeometry.h"
};
Bool_t AreInSameTower(Int_t id1, Int_t id2) const ;
+
+ TClonesArray * FillTRU(const TClonesArray * digits) ;
+
virtual void GetGlobal(const AliRecPoint *, TVector3 &, TMatrixF &) const {}
virtual void GetGlobal(const AliRecPoint *, TVector3 &) const {}
virtual Bool_t Impact(const TParticle *) const {return kTRUE;}
Int_t GetNPHIdiv() const {return fNPHIdiv ;}
Int_t GetNETAdiv() const {return fNETAdiv ;}
Int_t GetNCells() const {return fNCells;}
+
+ Int_t GetNTRU() const {return fNTRU ; }
+ Int_t GetNTRUEta() const {return fNTRUEta ; }
+ Int_t GetNTRUPhi() const {return fNTRUPhi ; }
+
Float_t GetSteelFrontThickness() const { return fSteelFrontThick;}
Float_t GetLongModuleSize() const {return fLongModuleSize;}
// --
void SetNZ(Int_t nz) { fNZ= nz ; printf("SetNZ: Number of modules in Z set to %d", fNZ) ; }
void SetNPhi(Int_t nphi) { fNPhi= nphi ; printf("SetNPhi: Number of modules in Phi set to %d", fNPhi) ; }
+
+ void SetNTRU(Int_t ntru) {fNTRU = ntru; printf("SetNTRU: Number of TRUs per SuperModule set to %d", fNTRU) ; }
+ void SetNTRUEta(Int_t ntru) {fNTRUEta = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Etaset to %d", fNTRUEta) ;}
+ void SetNTRUPhi(Int_t ntru) {fNTRUPhi = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Phi set to %d", fNTRUPhi) ;}
+
void SetSampling(Float_t samp) { fSampling = samp; printf("SetSampling: Sampling factor set to %f", fSampling) ; }
protected:
Int_t fNCells; // number of cells in calo
Int_t fNCellsInSupMod; // number cell in super module
Int_t fNCellsInTower; // number cell in tower(or module)
+ //TRU parameters
+ Int_t fNTRU ; //! Number of TRUs per module
+ Int_t fNTRUEta ; //! Number of cell rows per Z in one TRU
+ Int_t fNTRUPhi ; //! Number of cell rows per Phi in one TRU
// TRD1 options - 30-sep-04
Float_t fTrd1Angle; // angle in x-z plane (in degree)
Float_t f2Trd1Dx2; // 2*dx2 for TRD1
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+/* $Id$ */
+
+
+//_________________________________________________________________________
+//
+// Class for trigger analysis.
+// Digits are grouped in TRU's (384 cells? ordered fNTRUPhi x fNTRUEta).
+// The algorithm searches all possible 4x4 cell combinations per each TRU,
+// adding the digits amplitude and finding the maximum. Maximums are compared
+// to triggers threshold and they are set. Thresholds need to be fixed.
+// Last 2 modules are half size but they are treated as fullsize, then their
+// TRU should be smaller. When this is fixed, class will be updated.
+// Usage:
+//
+// //Inside the event loop
+// AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
+// tr->SetL0MBPbPbThreshold(500);
+// tr->SetL0MBppThreshold(100);
+// tr->SetL1JetLowPtThreshold(1000);
+// tr->SetL1JetMediumPtThreshold(10000);
+// tr->SetL1JetHighPtThreshold(20000);
+// tr->Trigger(); //Execute Trigger
+// tr->Print(""); //Print results
+//
+//*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include "TMatrixD.h"
+
+// --- ALIROOT system ---
+
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliTriggerInput.h"
+#include "AliEMCAL.h"
+#include "AliEMCALLoader.h"
+#include "AliEMCALDigit.h"
+#include "AliEMCALTrigger.h"
+#include "AliEMCALGeometry.h"
+
+ClassImp(AliEMCALTrigger)
+
+//______________________________________________________________________
+AliEMCALTrigger::AliEMCALTrigger()
+ : AliTriggerDetector(),
+ fL0MBPbPbThreshold(500), fL0MBppThreshold(50),fL1JetLowPtThreshold(1000),
+ fL1JetMediumPtThreshold(10000), fL1JetHighPtThreshold(20000)
+{
+ //ctor
+
+ SetName("EMCAL");
+ CreateInputs();
+
+ //Print("all") ;
+}
+
+
+
+//____________________________________________________________________________
+AliEMCALTrigger::AliEMCALTrigger(const AliEMCALTrigger & trig)
+ : AliTriggerDetector(trig)
+{
+
+ // cpy ctor
+
+ fL0MBPbPbThreshold = trig.fL0MBPbPbThreshold ;
+ fL0MBppThreshold = trig.fL0MBppThreshold ;
+ fL1JetLowPtThreshold = trig.fL1JetLowPtThreshold ;
+ fL1JetMediumPtThreshold = trig.fL1JetMediumPtThreshold ;
+ fL1JetHighPtThreshold = trig.fL1JetHighPtThreshold ;
+
+}
+
+//----------------------------------------------------------------------
+void AliEMCALTrigger::CreateInputs()
+{
+ // inputs
+
+ // Do not create inputs again!!
+ if( fInputs.GetEntriesFast() > 0 ) return;
+
+ fInputs.AddLast( new AliTriggerInput( "EMCAL_MB_PbPb_L0", "EMCAL PbPb Minimum Bias L0", 0x01 ) );
+ fInputs.AddLast( new AliTriggerInput( "EMCAL_MB_pp_L0", "EMCAL pp Minimum Bias L0", 0x02 ) );
+ fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetHPt_L1", "EMCAL PbPb Jet High Pt L1", 0x04 ) );
+ fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetMPt_L1", "EMCAL PbPb Jet Medium Pt L1", 0x08 ) );
+ fInputs.AddLast( new AliTriggerInput( "EMCAL_PbPb_JetLPt_L1", "EMCAL PbPb Jet Low Pt L1", 0x016 ) );
+
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::MakeSlidingCell(const TClonesArray * trus ,
+ const Int_t isupermod,
+ const Int_t nTRU,
+ const Int_t nCellsPhi,
+ const Int_t nCellsEta,
+ Float_t *ampmax){
+
+ //Sums energy of all possible 4x4 cells per each TRU. Fast signal
+ //in the experiment is given by 2x2 cells, for this reason we loop
+ //inside the TRU cells by 2.
+
+ Float_t amp = 0 ;
+
+ for(Int_t i = 0 ; i < nTRU ; i++)
+ ampmax[i] = 0 ;
+
+ //Loop over all TRUS in the seleted supermodule
+ for(Int_t itru = 0 + (isupermod - 1) * nTRU ; itru < isupermod*nTRU ; itru++)
+ {
+ TMatrixD * tru = dynamic_cast<TMatrixD *>(trus->At(itru)) ;
+
+ //Sliding 2x2 cell
+ for(Int_t irow = 0 ; irow < nCellsPhi; irow += 2){
+ for(Int_t icol = 0 ; icol < nCellsEta ; icol += 2){
+ amp = 0;
+ if( (irow+3) < nCellsPhi && (icol+3) < nCellsEta){//Avoid exit the TRU
+ for(Int_t i = irow; i < irow + 4 ; i++){
+ for(Int_t j = icol; j < icol + 4 ; j++){
+ amp += (*tru)(i,j) ;
+ }
+ }
+ }
+ if(amp > ampmax[itru-(isupermod-1)*nTRU])
+ ampmax[itru-(isupermod-1)*nTRU] = amp ;
+
+ }
+ }
+ }
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::Trigger()
+{
+
+ //Main Method to select triggers.
+ //Loader
+ AliRunLoader *rl = AliRunLoader::GetRunLoader();
+ AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
+ (rl->GetDetectorLoader("EMCAL"));
+
+ //Load EMCAL Geometry
+ rl->LoadgAlice();
+ AliRun * gAlice = rl->GetAliRun();
+ AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
+ AliEMCALGeometry * geom = emcal->GetGeometry();
+ //AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
+
+ if (geom==0)
+ AliFatal("Did not get geometry from EMCALLoader");
+
+ //Define some useful parameters
+
+ Int_t nSuperModules = geom->GetNumberOfSuperModules() ; //12 SM in EMCAL
+ Int_t nTRU = geom->GetNTRU();//3 TRU per super module
+ Int_t nCellsPhi = geom->GetNPhi()*2/geom->GetNTRUPhi() ;
+ // 12(tow)*2(cell)/1 TRU, cells in Phi in one TRU
+ Int_t nCellsEta = geom->GetNEta()*2/geom->GetNTRUEta() ;
+ // 24(mod)*2(tower)/3 TRU, cells in Eta in one TRU
+
+ //Info("Trigger","nSuperModules %d, nCellsPhi %d, nCellsEta %d",
+ // nSuperModules, nCellsPhi,nCellsEta);
+
+ //Take the digits list and declare digits pointers
+ TClonesArray * digits = emcalLoader->Digits(); //gime->Digits() ;
+
+ TClonesArray * trus = geom->FillTRU(digits) ;
+
+ //Do Cell Sliding and select Trigger
+ Float_t max [10] ;
+ for(Int_t iSM = 1 ; iSM <= nSuperModules ; iSM++) {
+
+ MakeSlidingCell(trus, iSM, nTRU, nCellsPhi, nCellsEta, max);
+
+ //cout<<"Max Amplitude in SuperMod "<<iSM<<" TRU1 "<<max[0]
+ //<<" TRU2 "<<max[1]<<" TRU3 "<<max[2]<<endl;
+ SetTriggers(max, nTRU) ;
+ }
+
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::Print(const Option_t * opt) const
+{
+
+ //Prints main parameters
+
+ if(! opt)
+ return;
+ AliTriggerInput* in = 0x0 ;
+
+
+ AliInfo("EMCAL trigger information:") ;
+ printf( " Threshold for pp MB LO %d\n", fL0MBppThreshold) ;
+ in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_MB_pp_L0" );
+ if(in->GetValue())
+ printf( " *** EMCAL MB pp LO is set ***\n") ;
+
+ printf( " Threshold for PbPb MB LO %d\n", fL0MBPbPbThreshold) ;
+ in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_MB_PbPb_L0" );
+ if(in->GetValue())
+ printf( " *** EMCAL MB PbPb LO is set ***\n") ;
+
+ printf( " Jet Low Pt Threshold for PbPb L1 %d\n", fL1JetLowPtThreshold) ;
+ in = (AliTriggerInput*)fInputs.FindObject( "EMCAL_PbPb_JetLPt_L1" );
+ if(in->GetValue())
+ printf( " *** EMCAL Jet Low Pt for PbPb L1 is set ***\n") ;
+
+ printf( " Jet Medium Pt Threshold for L1 %d\n", fL1JetMediumPtThreshold) ;
+ in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_PbPb_JetMPt_L1" );
+ if(in->GetValue())
+ printf( " *** EMCAL Jet Medium Pt for PbPb L1 is set ***\n") ;
+
+ printf( " Jet High Pt Threshold for L1 %d\n", fL1JetHighPtThreshold) ;
+ in = (AliTriggerInput*) fInputs.FindObject( "EMCAL_PbPb_JetHPt_L1" );
+ if(in->GetValue())
+ printf( " *** EMCAL Jet High Pt for PbPb L1 is set ***\n") ;
+
+}
+
+//____________________________________________________________________________
+void AliEMCALTrigger::SetTriggers(const Float_t * amp, const Int_t nTRU)
+{
+
+ //Checks the maximum amplitude per each TRU and compares with the
+ //different triggers thresholds
+
+ Float_t max = 0;
+ for(Int_t i = 0 ; i < nTRU ; i++){
+ if(max < amp[i] )
+ max = amp[i] ;
+ }
+
+ if(max >= fL0MBppThreshold)
+ SetInput("EMCAL_MB_pp_L0");
+ if(max >= fL0MBPbPbThreshold)
+ SetInput("EMCAL_MB_PbPb_L0");
+ if(max >= fL1JetLowPtThreshold)
+ SetInput("EMCAL_PbPb_JetLPt_L1");
+ if(max >= fL1JetMediumPtThreshold)
+ SetInput("EMCAL_PbPb_JetMPt_L1");
+ if(max >= fL1JetHighPtThreshold)
+ SetInput("EMCAL_PbPb_JetHPt_L1");
+
+}
--- /dev/null
+#ifndef ALIEMCALTrigger_H
+#define ALIEMCALTrigger_H
+
+//___________________________________________________________
+// Class for trigger analysis.
+// Digits are grouped in TRU's (384 cells? ordered fNTRUPhi x fNTRUEta).
+// The algorithm searches all possible 4x4 cell combinations per each TRU,
+// adding the digits amplitude and finding the maximum. Maximums are compared
+// to triggers threshold and they are set. Thresholds need to be fixed.
+// Last 2 modules are half size but they are treated as fullsize, then their
+// TRU should be smaller. When this is fixed, class will be updated.
+// Usage:
+//
+// //Inside the event loop
+// AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
+// tr->SetL0MBPbPbThreshold(500);
+// tr->SetL0MBppThreshold(100);
+// tr->SetL1JetLowPtThreshold(1000);
+// tr->SetL1JetMediumPtThreshold(10000);
+// tr->SetL1JetHighPtThreshold(20000);
+// tr->Trigger(); //Execute Trigger
+// tr->Print(""); //Print results
+// //are printed
+//
+//*-- Author: Gustavo Conesa & Yves Schutz (IFIC, SUBATECH, CERN)
+
+// --- ROOT system ---
+
+class TClonesArray ;
+
+
+// --- AliRoot header files ---
+#include "AliTriggerDetector.h"
+
+class AliEMCALGeometry ;
+
+class AliEMCALTrigger : public AliTriggerDetector {
+
+ public:
+ AliEMCALTrigger() ; // ctor
+ AliEMCALTrigger(const AliEMCALTrigger & trig) ; // cpy ctor
+ virtual ~AliEMCALTrigger() {}; //virtual dtor
+ virtual void CreateInputs();
+ virtual void Trigger(); //Make EMCAL trigger
+
+ Int_t GetL0MBPbPbThreshold() const {return fL0MBPbPbThreshold ; }
+ Int_t GetL0MBppThreshold() const {return fL0MBppThreshold ; }
+ Int_t GetL1JetLowPtThreshold() const {return fL1JetLowPtThreshold ; }
+ Int_t GetL1JetMediumPtThreshold() const {return fL1JetMediumPtThreshold ; }
+ Int_t GetL1JetHighPtThreshold() const {return fL1JetHighPtThreshold ; }
+
+ void Print(const Option_t * opt ="") const ;
+
+ void SetL0MBPbPbThreshold(Int_t amp)
+ {fL0MBPbPbThreshold = amp; }
+ void SetL0MBppThreshold(Int_t amp)
+ {fL0MBppThreshold = amp; }
+ void SetL1JetLowPtThreshold(Int_t amp)
+ {fL1JetLowPtThreshold = amp; }
+ void SetL1JetMediumPtThreshold(Int_t amp)
+ {fL1JetMediumPtThreshold = amp; }
+ void SetL1JetHighPtThreshold(Int_t amp)
+ {fL1JetHighPtThreshold = amp; }
+ private:
+
+ void MakeSlidingCell(const TClonesArray * trus, const Int_t nTRU,
+ const Int_t supermod, const Int_t nCellsPhi,
+ const Int_t nCellsEta, Float_t *ampmax) ;
+
+
+ void SetTriggers(const Float_t * ampmax, const Int_t nTRU) ;
+
+
+ private:
+
+ Int_t fL0MBPbPbThreshold ; //! L0 PbPb trigger energy threshold
+ Int_t fL0MBppThreshold ; //! L0 pp trigger energy threshold
+ Int_t fL1JetLowPtThreshold ; //! Low pT trigger energy threshold
+ Int_t fL1JetMediumPtThreshold ; //! Medium pT trigger energy threshold
+ Int_t fL1JetHighPtThreshold ; //! High pT trigger energy threshold
+
+ ClassDef(AliEMCALTrigger,0)
+} ;
+
+
+#endif //ALIEMCALTrigger_H