]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
re-structured access to AliEMCALRawUtils in reconstruction
authorjklay <jklay@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 18:37:30 +0000 (18:37 +0000)
committerjklay <jklay@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 18:37:30 +0000 (18:37 +0000)
EMCAL/AliEMCAL.cxx
EMCAL/AliEMCALRawUtils.cxx
EMCAL/AliEMCALRawUtils.h
EMCAL/AliEMCALReconstructor.cxx
EMCAL/AliEMCALReconstructor.h

index 982cf0c68c8fba35279ee47838a64add0be6128e..781edf41baf0fca5d9b40e609b5af37a9905cfea 100644 (file)
@@ -80,7 +80,6 @@ class TFile;
 #include "AliCDBManager.h"
 #include "AliCDBEntry.h"
 
-
 ClassImp(AliEMCAL)
 
 //____________________________________________________________________________
@@ -94,6 +93,7 @@ AliEMCAL::AliEMCAL()
   // Default ctor 
   fName = "EMCAL" ;
   InitConstants();
+
   // Should call  AliEMCALGeometry::GetInstance(EMCAL->GetTitle(),"") for getting EMCAL geometry
 }
 
@@ -280,20 +280,10 @@ void AliEMCAL::CreateMaterials()
 }
 //____________________________________________________________________________
 void AliEMCAL::Digits2Raw() {
-  static AliEMCALRawUtils rawUtil;
-  //Get Mapping RCU files from the AliEMCALRecParam                                                          
-  static AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Mapping");
-  const TObjArray* maps = 0x0;
-  if(entry)
-    maps = (TObjArray*)entry->GetObject();
-
-  if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
-
-  AliAltroMapping * mapping[2] ; // For the moment only 2                                                    
-  for(Int_t i = 0; i < 2; i++) {
-    mapping[i] = (AliAltroMapping*)maps->At(i);
-  }
-  rawUtil.Digits2Raw(mapping);
+
+  static AliEMCALRawUtils rawUtils;
+  rawUtils.Digits2Raw();
+
 }
 //____________________________________________________________________________
 void AliEMCAL::Hits2SDigits()  
index 2a1770406014e2b2fa916e806235c49529f5fa3a..ebf9031f9fde1f79c99d7976d118d16a937dbc8b 100644 (file)
@@ -83,15 +83,64 @@ Int_t    AliEMCALRawUtils::fgThreshold = 1;
 Int_t    AliEMCALRawUtils::fgDDLPerSuperModule = 2;  // 2 ddls per SuperModule
 
 AliEMCALRawUtils::AliEMCALRawUtils()
-  : fHighLowGainFactor(0.), fOption("") 
+  : fHighLowGainFactor(0.), fGeom(0), 
+    fOption("")
 {
   fHighLowGainFactor = 16. ;          // adjusted for a low gain range of 82 GeV (10 bits) 
+
+  //Get Mapping RCU files from the AliEMCALRecParam                                 
+  const TObjArray* maps = AliEMCALRecParam::GetMappings();
+  if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
+
+  for(Int_t i = 0; i < 2; i++) {
+    fMapping[i] = (AliAltroMapping*)maps->At(i);
+  }
+
+
+  fGeom = AliEMCALGeometry::GetInstance();
+  if(!fGeom) {
+    fGeom = AliEMCALGeometry::GetInstance("","");
+    if(!fGeom) AliFatal(Form("Could not get geometry!!"));
+  }
+
 }
+
+//____________________________________________________________________________
+AliEMCALRawUtils::AliEMCALRawUtils(const AliEMCALRawUtils& rawU)
+  : TObject(),
+    fHighLowGainFactor(rawU.fHighLowGainFactor), 
+    fGeom(rawU.fGeom), 
+    fOption(rawU.fOption)
+{
+  //copy ctor
+  fMapping[0] = rawU.fMapping[0];
+  fMapping[1] = rawU.fMapping[1];
+}
+
+//____________________________________________________________________________
+AliEMCALRawUtils& AliEMCALRawUtils::operator =(const AliEMCALRawUtils &rawU)
+{
+  //assignment operator
+
+  if(this != &rawU) {
+    fHighLowGainFactor = rawU.fHighLowGainFactor;
+    fGeom = rawU.fGeom;
+    fOption = rawU.fOption;
+    fMapping[0] = rawU.fMapping[0];
+    fMapping[1] = rawU.fMapping[1];
+  }
+
+  return *this;
+
+}
+
 //____________________________________________________________________________
 AliEMCALRawUtils::~AliEMCALRawUtils() {
+
 }
+
 //____________________________________________________________________________
-void AliEMCALRawUtils::Digits2Raw(AliAltroMapping **mapping)
+void AliEMCALRawUtils::Digits2Raw()
 {
   // convert digits of the current event to raw data
   
@@ -107,14 +156,7 @@ void AliEMCALRawUtils::Digits2Raw(AliAltroMapping **mapping)
     Warning("Digits2Raw", "no digits found !");
     return;
   }
-    
-  // get the geometry
-  AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance();
-  if (!geom) {
-    AliError(Form("No geometry found !"));
-    return;
-  }
-  
+
   static const Int_t nDDL = 12*2; // 12 SM hardcoded for now. Buffers allocated dynamically, when needed, so just need an upper limit here
   AliAltroBuffer* buffers[nDDL];
   for (Int_t i=0; i < nDDL; i++)
@@ -136,8 +178,8 @@ void AliEMCALRawUtils::Digits2Raw(AliAltroMapping **mapping)
     Int_t iphi = 0;
     Int_t ieta = 0;
     Int_t nModule = 0;
-    geom->GetCellIndex(digit->GetId(), nSM, nModule, nIphi, nIeta);
-    geom->GetCellPhiEtaIndexInSModule(nSM, nModule, nIphi, nIeta,iphi, ieta) ;
+    fGeom->GetCellIndex(digit->GetId(), nSM, nModule, nIphi, nIeta);
+    fGeom->GetCellPhiEtaIndexInSModule(nSM, nModule, nIphi, nIeta,iphi, ieta) ;
     
     //Check which is the RCU of the cell.
     Int_t iRCU = -111;
@@ -160,7 +202,7 @@ void AliEMCALRawUtils::Digits2Raw(AliAltroMapping **mapping)
     if (buffers[iDDL] == 0) {      
       // open new file and write dummy header
       TString fileName = AliDAQ::DdlFileName("EMCAL",iDDL);
-      buffers[iDDL] = new AliAltroBuffer(fileName.Data(),mapping[iRCU]);
+      buffers[iDDL] = new AliAltroBuffer(fileName.Data(),fMapping[iRCU]);
       buffers[iDDL]->WriteDataHeader(kTRUE, kFALSE);  //Dummy;
     }
     
@@ -189,21 +231,14 @@ void AliEMCALRawUtils::Digits2Raw(AliAltroMapping **mapping)
       delete buffers[i];
     }
   }
-//PH   mapping[0]->Delete();
-//PH   mapping[1]->Delete();
+
   loader->UnloadDigits();
 }
 
 //____________________________________________________________________________
-void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr, 
-                                 AliAltroMapping **mapping)
+void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr)
 {
-  // convert raw data of the current event to digits
-  AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
-  if (!geom) {
-    AliError(Form("No geometry found !"));
-    return;
-  }
+  // convert raw data of the current event to digits                                                                                     
 
   digitsArr->Clear(); 
 
@@ -216,7 +251,7 @@ void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr,
     return;
   }
 
-  AliCaloRawStream in(reader,"EMCAL",mapping);
+  AliCaloRawStream in(reader,"EMCAL",fMapping);
   // Select EMCAL DDL's;
   reader->Select("EMCAL");
 
@@ -258,7 +293,7 @@ void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr,
   Int_t row = 0;
 
   while (readOk) { 
-    id =  geom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
+    id =  fGeom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
     lowGain = in.IsLowGain();
     Int_t maxTime = in.GetTime();  // timebins come in reverse order
     if (maxTime < 0 || maxTime >= GetRawFormatTimeBins()) {
index 5ca6da96fd9188b1db28241baff9b72f2ba87104..1a13a34934fffb857b125a3ad05535e68c86d07c 100644 (file)
 class TGraph;
 class TF1;
 class AliRawReader;
+class AliEMCALGeometry;
 
 class AliEMCALRawUtils : public TObject {
  public:
   AliEMCALRawUtils();
   virtual ~AliEMCALRawUtils();
 
-  void Digits2Raw(AliAltroMapping **mapping = NULL);
-  void Raw2Digits(AliRawReader *reader,TClonesArray *digitsArr, AliAltroMapping **mapping = NULL);
+  AliEMCALRawUtils(const AliEMCALRawUtils& rawUtils);  //copy ctor
+  AliEMCALRawUtils& operator =(const AliEMCALRawUtils& rawUtils);
+
+  void Digits2Raw();
+  void Raw2Digits(AliRawReader *reader,TClonesArray *digitsArr);
+
   void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Int_t amp, Float_t time);
 
   // Signal shape parameters
@@ -79,6 +84,9 @@ class AliEMCALRawUtils : public TObject {
   static Int_t fgThreshold;             // threshold
   static Int_t fgDDLPerSuperModule;     // number of DDL per SuperModule
 
+  AliEMCALGeometry* fGeom;         //geometry
+  AliAltroMapping*  fMapping[2];   //only two for now
+
   TString fOption;                      //! option passed from Reconstructor
 };
 
index 412ebf458c8c9a26f8c4a48bdb8f2be87556b3ef..6f65e85b5adf8045df840922989f5fd25d25150a 100644 (file)
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
 #include "AliEMCALRecParam.h"
-// to be removed - it is here just because of geom
-#include "AliRun.h"
-#include "AliRunLoader.h"
+#include "AliEMCALGeometry.h"
+
 
 ClassImp(AliEMCALReconstructor)
 
 AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0;  // EMCAL rec. parameters
-
+AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0;   // EMCAL raw utilities class
 //____________________________________________________________________________
 AliEMCALReconstructor::AliEMCALReconstructor() 
-  : fDebug(kFALSE) 
+  : fDebug(kFALSE),fGeom(0) 
 {
   // ctor
+  InitRecParam();
+
+  fgRawUtils = new AliEMCALRawUtils;
+  fGeom = AliEMCALGeometry::GetInstance();
+  if(!fGeom) {
+    fGeom = AliEMCALGeometry::GetInstance("","");
+    if(!fGeom) AliFatal(Form("Could not get geometry!"));
+  }
 
 } 
 
 //____________________________________________________________________________
 AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
   : AliReconstructor(rec),
-    fDebug(rec.fDebug)
+    fDebug(rec.fDebug),
+    fGeom(rec.fGeom)
 {
   //copy ctor
 }
@@ -72,7 +80,7 @@ AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
 AliEMCALReconstructor::~AliEMCALReconstructor()
 {
   // dtor
-
+  delete fGeom;
   AliCodeTimer::Instance()->Print();
 } 
 
@@ -105,7 +113,6 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree)
 
   AliCodeTimerAuto("")
 
-  InitRecParam();
   AliEMCALClusterizerv1 clu;
   clu.SetInput(digitsTree);
   clu.SetOutput(clustersTree);
@@ -124,27 +131,15 @@ void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
   // EMCAL digits.
   // Works on a single-event basis
 
-
-  AliCodeTimerAuto("")
-
   rawReader->Reset() ; 
 
   TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",100);
   Int_t bufsize = 32000;
   digitsTree->Branch("EMCAL", &digitsArr, bufsize);
 
-  //Get Mapping RCU files from the AliEMCALRecParam                                                          
-  const TObjArray* maps = AliEMCALRecParam::GetMappings();
-  if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
-
-  AliAltroMapping * mapping[2] ; // For the moment only 2                                                    
-  for(Int_t i = 0; i < 2; i++) {
-    mapping[i] = (AliAltroMapping*)maps->At(i);
-  }
-
-  static AliEMCALRawUtils rawUtils;
-  rawUtils.SetOption(GetOption());
-  rawUtils.Raw2Digits(rawReader,digitsArr,mapping);
+  //must be done here because, in constructor, option is not yet known
+  fgRawUtils->SetOption(GetOption());
+  fgRawUtils->Raw2Digits(rawReader,digitsArr);
 
   digitsTree->Fill();
   digitsArr->Delete();
@@ -166,7 +161,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   //#########Calculate trigger and set trigger info###########
   //######################################################
 
-  AliCodeTimerStart(Form("JLK trigger info"));
   AliEMCALTrigger tr ;
   //   tr.SetPatchSize(1);//create 4x4 patches
   tr.Trigger();
@@ -176,13 +170,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   Float_t ampOutOfPatch2x2  = tr.Get2x2AmpOutOfPatch() ;
   Float_t ampOutOfPatchnxn  = tr.GetnxnAmpOutOfPatch() ;
 
-  AliEMCALGeometry * geom = 0;
-  AliRunLoader *runLoader = AliRunLoader::GetRunLoader();
-  if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
-    geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-  if (geom == 0) 
-    geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
-
   Int_t iSM2x2      = tr.Get2x2SuperModule();
   Int_t iSMnxn      = tr.GetnxnSuperModule();
   Int_t iCellPhi2x2 = tr.Get2x2CellPhi();
@@ -196,10 +183,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   TVector3    pos2x2(-1,-1,-1);
   TVector3    posnxn(-1,-1,-1);
 
-  Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ;
-  Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ;
-  geom->GetGlobal(iAbsId2x2, pos2x2);
-  geom->GetGlobal(iAbsIdnxn, posnxn);
+  Int_t iAbsId2x2 = fGeom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ;
+  Int_t iAbsIdnxn = fGeom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ;
+  fGeom->GetGlobal(iAbsId2x2, pos2x2);
+  fGeom->GetGlobal(iAbsIdnxn, posnxn);
   
   TArrayF triggerPosition(6);
   triggerPosition[0] = pos2x2(0) ;   
@@ -218,14 +205,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   esd->AddEMCALTriggerPosition(triggerPosition);
   esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
 
-  AliCodeTimerStop(Form("JLK trigger info"));
-
   //########################################
   //##############Fill CaloCells###############
   //########################################
 
-  AliCodeTimerStart(Form("JLK fill calocells"));
-
   TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000);
   TBranch *branchdig = digitsTree->GetBranch("EMCAL");
   if (!branchdig) { 
@@ -250,8 +233,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   emcCells.SetNumberOfCells(idignew);
   emcCells.Sort();
 
-  AliCodeTimerStop(Form("JLK fill calocells"));
-
   //------------------------------------------------------------
   //-----------------CLUSTERS-----------------------------
   //------------------------------------------------------------
@@ -269,8 +250,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   //######################################################
   //Fill list of integers, each one is index of track to which the cluster belongs.
 
-  AliCodeTimerStart(Form("JLK track matching"));
-
   // step 1 - initialize array of matched track indexes
   Int_t *matchedTrack = new Int_t[nClusters];
   for (Int_t iclus = 0; iclus < nClusters; iclus++)
@@ -285,14 +264,10 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack;
   } 
 
-  AliCodeTimerStop(Form("JLK track matching"));
-
   //########################################
   //##############Fill CaloClusters############
   //########################################
 
-  AliCodeTimerStart(Form("JLK fill caloclusters"));
-
   esd->SetNumberOfEMCALClusters(nClusters);
   for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
     const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust);
@@ -389,8 +364,6 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
    pid->RunPID(esd);
    delete pid;
 
-  AliCodeTimerStop(Form("JLK fill caloclusters"));
-  
 }
 
 
index 5a820644c438edca0aeb0168b266a2b883413b32..755924356b2a96cc345f39e8881f11cd0c662139 100644 (file)
@@ -22,6 +22,8 @@ class AliEMCALSDigitizer ;
 class AliEMCALRecParam;
 class AliESDEvent ;
 class AliRawReader ;
+class AliEMCALRawUtils;
+class AliEMCALGeometry;
 
 // --- Standard library ---
 
@@ -65,8 +67,11 @@ private:
   
   Bool_t fDebug; //! verbosity controller
   static AliEMCALRecParam*   fgkRecParam; // reconstruction parameters for EMCAL
+  static AliEMCALRawUtils*   fgRawUtils;  // raw utilities class -
+                                         // only need one per reco
+  AliEMCALGeometry         *fGeom;           // pointer to the EMCAL geometry
 
-  ClassDef(AliEMCALReconstructor,2)  // Reconstruction algorithm class (Base Class)
+  ClassDef(AliEMCALReconstructor,3)  // Reconstruction algorithm class (Base Class)
 
 };