Changes for report #68914: Improper usage of TClonesArrays in EMCAL
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Aug 2010 22:49:21 +0000 (22:49 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Aug 2010 22:49:21 +0000 (22:49 +0000)
EMCAL/AliEMCALLoader.cxx
EMCAL/AliEMCALLoader.h
EMCAL/AliEMCALSDigitizer.cxx
EMCAL/AliEMCALSDigitizer.h
EVE/EveDet/AliEveEMCALData.cxx

index 5f12d82..ff96490 100644 (file)
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
 #include "AliCDBEntry.h"
-#include "AliEMCALHit.h"
 
  ClassImp(AliEMCALLoader)
   
 const TString         AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
 const TString         AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
 const TString         AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
-const TString         AliEMCALLoader::fgkECAHitsBranchName("HITS");//Name for branch with ECA Hits
 
 AliEMCALCalibData*    AliEMCALLoader::fgCalibData = 0; //calibration data
 //AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
@@ -61,28 +59,25 @@ AliEMCALSimParam*     AliEMCALLoader::fgSimParam  = 0; //simulation parameters
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader()
-: fDebug(0), fTempArr(0x0)
+: fDebug(0)
 {
   //Default constructor for EMCAL Loader Class
-  fTempArr =  new TClonesArray("AliEMCALHit",0);
 
 }
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
-  : AliLoader(detname,eventfoldername), fDebug(0), fTempArr(0x0)
+  : AliLoader(detname,eventfoldername), fDebug(0)
 {
   //Specific constructor for EMCAL Loader class
-  fTempArr =  new TClonesArray("AliEMCALHit",0);
 
 }
 
 //____________________________________________________________________________
 AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
-  : AliLoader(name,topfolder), fDebug(0), fTempArr(0x0)
+  : AliLoader(name,topfolder), fDebug(0)
 {
   //Specific constructor for EMCAL Loader class
-  fTempArr =  new TClonesArray("AliEMCALHit",0);
 
 }
 
@@ -90,8 +85,8 @@ AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
 AliEMCALLoader::~AliEMCALLoader()
 {
   // Disconnect trees and remove arrays
-//  if (TreeH())
-//    TreeH()->SetBranchAddress(fDetectorName,0);
+  if (TreeH())
+    TreeH()->SetBranchAddress(fDetectorName,0);
 //  if (TreeD())
 //    TreeD()->SetBranchAddress(fDetectorName,0);
 //  if (TreeS())
@@ -99,18 +94,12 @@ AliEMCALLoader::~AliEMCALLoader()
 //  if (TreeR())
 //    TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
        
-       Clean(fgkECAHitsBranchName);
        Clean(fgkECASDigitsBranchName);
        Clean(fgkECADigitsBranchName);
        Clean(fgkECARecPointsBranchName);
        
        AliLoader::CleanFolders();
-       
-       if (fTempArr) {
-               fTempArr->Delete();
-               delete fTempArr;
-       }
-       
+               
 }
 
 //____________________________________________________________________________ 
@@ -184,31 +173,9 @@ Int_t AliEMCALLoader::GetEvent()
   AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
   
   // *** Hits ***
-  // Initialize the Hits TClonesArray, only if it did not existed before
-  MakeHitsArray();
-  
-  TTree *treeH = TreeH();      
-  if (treeH) {
-    Int_t nEnt = treeH->GetEntries();  // TreeH has array of hits for every primary
-    Int_t index = 0;
-    TBranch * branchH = treeH->GetBranch(fDetectorName);
-    branchH->SetAddress(&fTempArr);
-    TClonesArray* hits = const_cast<AliEMCALLoader *>(this)->Hits();
-    if (hits) hits->Clear();
-    for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
-      branchH->GetEntry(iEnt);
-      Int_t nHit = fTempArr->GetEntriesFast();
-      for (Int_t iHit = 0; iHit < nHit; iHit++) {
-       new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)fTempArr->At(iHit)));
-       index++;
-      }
-    }
-    branchH->ResetAddress();
-       if (fTempArr) {
-                 fTempArr->Clear();
-       }
-  }
-  
+  // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested.
+  // together with AliEveEMCALData
+       
   // *** SDigits ***
   // Initialize the SDigits TClonesArray, only if it did not existed before
   MakeSDigitsArray();
@@ -264,15 +231,6 @@ Int_t AliEMCALLoader::GetEvent()
 }
 
 //____________________________________________________________________________
-void AliEMCALLoader::MakeHitsArray(){
-  // Add Hits array to the data folder
-  if (Hits()) return;
-  TClonesArray* hits = new TClonesArray("AliEMCALHit",0);
-  hits->SetName(fgkECAHitsBranchName);
-  GetDetectorDataFolder()->Add(hits);
-}
-
-//____________________________________________________________________________
 void AliEMCALLoader::MakeSDigitsArray(){
   // Add SDigits array to the data folder
   if (SDigits()) return;
index fe351e3..3a9d2ec 100644 (file)
@@ -33,7 +33,6 @@ class TTask ;
 
 class AliLoader ;
 class AliEMCAL ; 
-class AliEMCALHit ;
 class AliEMCALDigit ;
 class AliEMCALSDigit ;
 class AliEMCALRecPoint ; 
@@ -58,18 +57,11 @@ class AliEMCALLoader : public AliLoader {
   
   // Initialize arrays methods
   void MakeSDigitsArray() ;
-  void MakeHitsArray() ;
   void MakeDigitsArray() ;
   void MakeRecPointsArray() ;
   
   // ************    TClonesArrays Access functions
   
-  TClonesArray*  Hits(void) {return (TClonesArray*)GetDetectorData(fgkECAHitsBranchName);}  //{ return fHits;}
-  const AliEMCALHit*    Hit(Int_t index) {
-    if (Hits()) return (const AliEMCALHit*) Hits()->At(index);
-    return 0x0; 
-  }
-  
   TClonesArray*  SDigits() {return (TClonesArray*)GetDetectorData(fgkECASDigitsBranchName);} //const { return fSDigits;}
   const AliEMCALDigit*  SDigit(Int_t index)  {
     if (SDigits())return (const AliEMCALDigit*) SDigits()->At(index);
@@ -108,19 +100,17 @@ class AliEMCALLoader : public AliLoader {
   AliEMCALLoader(const AliEMCALLoader &); //Not implemented
   const AliEMCALLoader & operator = (const AliEMCALLoader &); //Not implemented
   
-  static const TString fgkECAHitsBranchName;      //! Name of branch with ECA Hits
   static const TString fgkECASDigitsBranchName;   //! Name of branch with ECA SDigits
   static const TString fgkECADigitsBranchName;    //! Name of branch with ECA Digits
   static const TString fgkECARecPointsBranchName; //! Name of branch with ECA Reconstructed Points
   
   Int_t  fDebug ;             // Debug level
-  TClonesArray *fTempArr;      //! Temporary array for hits
        
   static AliEMCALCalibData    * fgCalibData;  //  calibration data 
   //  static AliCaloCalibPedestal * fgCaloPed;    //  dead map
   static AliEMCALSimParam     * fgSimParam;   //  sim param 
   
-  ClassDef(AliEMCALLoader,6)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
+  ClassDef(AliEMCALLoader,7)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
     
 };
 
index 24de52b..9c6ee15 100644 (file)
@@ -85,7 +85,8 @@ AliEMCALSDigitizer::AliEMCALSDigitizer()
     fSDigitsInRun(0),
     fFirstEvent(0),
     fLastEvent(0),
-    fSampling(0.)
+    fSampling(0.),
+       fHits(0)
 {
   // ctor
   InitParameters();
@@ -102,7 +103,8 @@ AliEMCALSDigitizer::AliEMCALSDigitizer(const char * alirunFileName,
     fSDigitsInRun(0),
     fFirstEvent(0),
     fLastEvent(0),
-    fSampling(0.)
+    fSampling(0.),
+    fHits(0)
 {
   // ctor
   Init();
@@ -123,7 +125,8 @@ AliEMCALSDigitizer::AliEMCALSDigitizer(const AliEMCALSDigitizer & sd)
     fSDigitsInRun(sd.fSDigitsInRun),
     fFirstEvent(sd.fFirstEvent),
     fLastEvent(sd.fLastEvent),
-    fSampling(sd.fSampling)
+    fSampling(sd.fSampling),
+    fHits(0)
 {
   //cpy ctor 
 }
@@ -135,6 +138,11 @@ AliEMCALSDigitizer::~AliEMCALSDigitizer() {
   AliLoader *emcalLoader=0;
   if ((emcalLoader = AliRunLoader::Instance()->GetDetectorLoader("EMCAL")))
       emcalLoader->CleanSDigitizer();
+       
+  if(fHits){
+         fHits->Clear();
+         delete fHits;
+  }
 }
 
 //____________________________________________________________________________ 
@@ -214,146 +222,160 @@ void AliEMCALSDigitizer::InitParameters()
 //____________________________________________________________________________
 void AliEMCALSDigitizer::Exec(Option_t *option) 
 { 
-  // Collects all hit of the same tower into digits
-  TString o(option); o.ToUpper();
-  if (strstr(option, "print") ) {
-
-    AliDebug(2,Form("Print: \n------------------- %s -------------\n",GetName()));
-    AliDebug(2,Form("   fInit                                 %i\n", int(fInit)));
-    AliDebug(2,Form("   fFirstEvent                           %i\n", fFirstEvent));
-    AliDebug(2,Form("   fLastEvent                            %i\n", fLastEvent));
-    AliDebug(2,Form("   Writing SDigits to branch with title  %s\n", fEventFolderName.Data()));
-    AliDebug(2,Form("   with digitization parameters       A = %f\n", fA));
-    AliDebug(2,Form("                                      B = %f\n", fB));
-    AliDebug(2,Form("   Threshold for EC Primary assignment  = %f\n", fECPrimThreshold));
-    AliDebug(2,Form("   Sampling                             = %f\n", fSampling));
-    AliDebug(2,Form("---------------------------------------------------\n"));
-
-    return ; 
-  }
-
-  if(strstr(option,"tim"))
-    gBenchmark->Start("EMCALSDigitizer");
-
-  AliRunLoader *rl = AliRunLoader::Instance();
-  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
-
-  //switch off reloading of this task while getting event
-  if (!fInit) { // to prevent overwrite existing file
-    AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ;
-    return ;
-    }
-
-  if (fLastEvent == -1) 
-    fLastEvent = rl->GetNumberOfEvents() - 1 ;
-  else {
-    fLastEvent = TMath::Min(fLastEvent, rl->GetNumberOfEvents()-1);
-  }
-  Int_t nEvents   = fLastEvent - fFirstEvent + 1;
-
-  Int_t ievent;
-  Float_t energy=0.; // de * fSampling - 23-nov-04
-  rl->LoadKinematics();
-  rl->LoadHits("EMCAL");
-
-  for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
-    rl->GetEvent(ievent);
-    TTree * treeS = emcalLoader->TreeS();
-    if ( !treeS ) { 
-      emcalLoader->MakeSDigitsContainer();
-      treeS = emcalLoader->TreeS();
-    }
-    TClonesArray * hits = emcalLoader->Hits() ; 
-    TClonesArray * sdigits = emcalLoader->SDigits() ;
-    sdigits->Clear();
-
-    Int_t nSdigits = 0 ;
-    Int_t i;
-
-       AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); 
-    for ( i = 0 ; i < hits->GetEntries() ; i++ ) {
-      AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(hits->At(i)) ;
-      AliEMCALDigit * curSDigit = 0 ;
-      AliEMCALDigit * sdigit = 0 ;
-      Bool_t newsdigit = kTRUE; 
-      
-      // hit->GetId() - Absolute Id number EMCAL segment
-      if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
-       energy = hit->GetEnergy() * fSampling; // 23-nov-04
-       if(energy >  fECPrimThreshold )
-         // Assign primary number only if deposited energy is significant
-         curSDigit =  new AliEMCALDigit( hit->GetPrimary(),
-                                         hit->GetIparent(), hit->GetId(), 
-                                         Digitize(energy), hit->GetTime(),kFALSE,
-                                         -1, energy ) ;
-         else
-           curSDigit =  new AliEMCALDigit( -1, 
-                                           -1,
-                                           hit->GetId(), 
-                                           Digitize(energy), hit->GetTime(),kFALSE,
-                                           -1, energy ) ;
-      } else {
-       Warning("Exec"," abs id %i is bad \n", hit->GetId());
-       newsdigit = kFALSE;
-       curSDigit = 0;
-      }
-      
-      if(curSDigit != 0){
-       for(Int_t check= 0; check < nSdigits ; check++) {
-         sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
-         
-         if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?              
-           *sdigit = *sdigit + *curSDigit;
-           newsdigit = kFALSE;
-         }
+       // Collects all hit of the same tower into digits
+       TString o(option); o.ToUpper();
+       if (strstr(option, "print") ) {
+               
+               AliDebug(2,Form("Print: \n------------------- %s -------------\n",GetName()));
+               AliDebug(2,Form("   fInit                                 %i\n", int(fInit)));
+               AliDebug(2,Form("   fFirstEvent                           %i\n", fFirstEvent));
+               AliDebug(2,Form("   fLastEvent                            %i\n", fLastEvent));
+               AliDebug(2,Form("   Writing SDigits to branch with title  %s\n", fEventFolderName.Data()));
+               AliDebug(2,Form("   with digitization parameters       A = %f\n", fA));
+               AliDebug(2,Form("                                      B = %f\n", fB));
+               AliDebug(2,Form("   Threshold for EC Primary assignment  = %f\n", fECPrimThreshold));
+               AliDebug(2,Form("   Sampling                             = %f\n", fSampling));
+               AliDebug(2,Form("---------------------------------------------------\n"));
+               
+               return ; 
        }
-      }
-      if (newsdigit) {
-       new((*sdigits)[nSdigits])  AliEMCALDigit(*curSDigit);
-       nSdigits++ ;  
-      }
-      delete curSDigit ; 
-    }  // loop over all hits (hit = deposited energy/entering particle)
-    sdigits->Sort() ;
-    
-    nSdigits = sdigits->GetEntriesFast() ;
-    fSDigitsInRun += nSdigits ;  
-
-    for (i = 0 ; i < sdigits->GetEntriesFast() ; i++) { 
-      AliEMCALDigit * sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(i)) ;
-      sdigit->SetIndexInList(i) ;
+       
+       
+       if(strstr(option,"tim"))
+               gBenchmark->Start("EMCALSDigitizer");
+       
+       AliRunLoader *rl = AliRunLoader::Instance();
+       AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
+       
+       //switch off reloading of this task while getting event
+       if (!fInit) { // to prevent overwrite existing file
+               AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ;
+               return ;
     }
-    
-    // Now write SDigits    
-    
-    Int_t bufferSize = 32000 ;    
-    TBranch * sdigitsBranch = treeS->GetBranch("EMCAL");
-    if (sdigitsBranch)
-      sdigitsBranch->SetAddress(&sdigits);
-    else
-      treeS->Branch("EMCAL",&sdigits,bufferSize);
-    
-    treeS->Fill();
-    
-    emcalLoader->WriteSDigits("OVERWRITE");
-    
-    //NEXT - SDigitizer
-    emcalLoader->WriteSDigitizer("OVERWRITE");  // why in event cycle ?
-    
-    if(strstr(option,"deb"))
-      PrintSDigits(option) ;  
-  }
-  
-  Unload();
-  
-  emcalLoader->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
-  
-  if(strstr(option,"tim")){
-    gBenchmark->Stop("EMCALSDigitizer"); 
-    printf("\n Exec: took %f seconds for SDigitizing %f seconds per event\n", 
-          gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; 
-  }
+       
+       if (fLastEvent == -1) 
+               fLastEvent = rl->GetNumberOfEvents() - 1 ;
+       else {
+               fLastEvent = TMath::Min(fLastEvent, rl->GetNumberOfEvents()-1);
+       }
+       Int_t nEvents   = fLastEvent - fFirstEvent + 1;
+       
+       Int_t ievent;
+       Float_t energy=0.; // de * fSampling - 23-nov-04
+       rl->LoadKinematics();
+       rl->LoadHits("EMCAL");
+       
+       for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
+               rl->GetEvent(ievent);
+               TTree * treeS = emcalLoader->TreeS();
+               if ( !treeS ) { 
+                       emcalLoader->MakeSDigitsContainer();
+                       treeS = emcalLoader->TreeS();
+               }
+               //TClonesArray * hits = emcalLoader->Hits() ; 
+               TClonesArray * sdigits = emcalLoader->SDigits() ;
+               sdigits->Clear();
+               
+               Int_t nSdigits = 0 ;
+               Int_t iHit, iTrack, iSDigit;
+               
+               AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); 
+               
+               TTree *treeH = emcalLoader->TreeH();    
+               if (treeH) {
+                       Int_t nTrack = treeH->GetEntries();  // TreeH has array of hits for every primary
+                       TBranch * branchH = treeH->GetBranch("EMCAL");
+                       //if(fHits)fHits->Clear();
+                       branchH->SetAddress(&fHits);
+                       for (iTrack = 0; iTrack < nTrack; iTrack++) {
+                               branchH->GetEntry(iTrack);
+                               Int_t nHit = fHits->GetEntriesFast();
+                               for(iHit = 0; iHit< nHit;iHit++){
+                                       
+                                       AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
+                                       AliEMCALDigit * curSDigit = 0 ;
+                                       AliEMCALDigit * sdigit = 0 ;
+                                       Bool_t newsdigit = kTRUE; 
+                                       
+                                       // hit->GetId() - Absolute Id number EMCAL segment
+                                       if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
+                                               energy = hit->GetEnergy() * fSampling; // 23-nov-04
+                                               if(energy >  fECPrimThreshold )
+                                                       // Assign primary number only if deposited energy is significant
+                                                       curSDigit =  new AliEMCALDigit(hit->GetPrimary(),
+                                                                                                                  hit->GetIparent(), hit->GetId(), 
+                                                                                                                  Digitize(energy), hit->GetTime(),kFALSE,
+                                                                                                                  -1, 0,0,energy ) ;
+                                               else
+                                                       curSDigit =  new AliEMCALDigit(-1, 
+                                                                                                                  -1,
+                                                                                                                  hit->GetId(), 
+                                                                                                                  Digitize(energy), hit->GetTime(),kFALSE,
+                                                                                                                  -1, 0,0,energy ) ;
+                                       } else {
+                                               Warning("Exec"," abs id %i is bad \n", hit->GetId());
+                                               newsdigit = kFALSE;
+                                               curSDigit = 0;
+                                       }
+                                       
+                                       if(curSDigit != 0){
+                                               for(Int_t check= 0; check < nSdigits ; check++) {
+                                                       sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
+                                                       
+                                                       if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?              
+                                                               *sdigit = *sdigit + *curSDigit;
+                                                               newsdigit = kFALSE;
+                                                       }
+                                               }
+                                       }
+                                       if (newsdigit) {
+                                               new((*sdigits)[nSdigits])  AliEMCALDigit(*curSDigit);
+                                               nSdigits++ ;  
+                                       }
+                                       delete curSDigit ; 
+                               }  // loop over all hits (hit = deposited energy/entering particle)
+                               sdigits->Sort() ;
+                               
+                               nSdigits = sdigits->GetEntriesFast() ;
+                               fSDigitsInRun += nSdigits ;  
+                               
+                               for (iSDigit = 0 ; iSDigit < sdigits->GetEntriesFast() ; iSDigit++) { 
+                                       AliEMCALDigit * sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(iSDigit)) ;
+                                       sdigit->SetIndexInList(iSDigit) ;
+                               }       
+                               if(fHits)fHits->Clear();
+                       }//track loop
+               }// tree exists
+               
+               // Now write SDigits    
+               
+               Int_t bufferSize = 32000 ;    
+               TBranch * sdigitsBranch = treeS->GetBranch("EMCAL");
+               if (sdigitsBranch)
+                       sdigitsBranch->SetAddress(&sdigits);
+               else
+                       treeS->Branch("EMCAL",&sdigits,bufferSize);
+               
+               treeS->Fill();
+               
+               emcalLoader->WriteSDigits("OVERWRITE");
+               
+               //NEXT - SDigitizer
+               emcalLoader->WriteSDigitizer("OVERWRITE");  // why in event cycle ?
+               
+               if(strstr(option,"deb"))
+                       PrintSDigits(option) ;  
+       }
+       
+       Unload();
+       
+       emcalLoader->GetSDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
+       
+       if(strstr(option,"tim")){
+               gBenchmark->Stop("EMCALSDigitizer"); 
+               printf("\n Exec: took %f seconds for SDigitizing %f seconds per event\n", 
+                          gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; 
+       }
 }
 
 //__________________________________________________________________
@@ -465,7 +487,7 @@ void AliEMCALSDigitizer::PrintSDigits(Option_t * option)
        printf("%s",tempo); 
       }         
     }
-    delete [] tempo ;
+    delete tempo ;
     printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum));
   } else printf("\n");
 }
index 3eaf583..9c88d82 100644 (file)
@@ -68,8 +68,9 @@ private:
   Int_t   fFirstEvent;             // first event to process
   Int_t   fLastEvent;              // last  event to process
   Float_t fSampling;               // See AliEMCALGeometry
-
-  ClassDef(AliEMCALSDigitizer,6)  // description 
+  TClonesArray* fHits;             //-> Temporal array with hits
+       
+  ClassDef(AliEMCALSDigitizer,7)  // description 
 };
 
 #endif // AliEMCALSDIGITIZER_H
index 029da42..fe9151c 100644 (file)
@@ -356,34 +356,44 @@ void AliEveEMCALData::LoadHitsFromEMCALLoader(AliEMCALLoader* const emcl)
   // Get hit information from EMCAL Loader
   //
 
-  AliEMCALHit* hit;
+       AliEMCALHit* hit;
   
-  //Fill array of hits                                                                        
-  TClonesArray *hits = (TClonesArray*)emcl->Hits();
-
-  //Get hits from the list                                                                    
-  for(Int_t ihit = 0; ihit< hits->GetEntries();ihit++){
-
-    hit = static_cast<AliEMCALHit *>(hits->At(ihit)) ;
+       //Fill array of hits                                                                        
+       TClonesArray *hits = 0;//(TClonesArray*)emcl->Hits();
+       TTree *treeH = emcl->TreeH();   
+       if (treeH) {
+               Int_t nTrack = treeH->GetEntries();  // TreeH has array of hits for every primary
+               TBranch * branchH = treeH->GetBranch("EMCAL");
+               //if(fHits)fHits->Clear();
+               branchH->SetAddress(&hits);
+               for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
+                       branchH->GetEntry(iTrack);
+                       
+                       //Get hits from the list                                                                    
+                       for(Int_t ihit = 0; ihit< hits->GetEntries();ihit++){
+
+                               hit = static_cast<AliEMCALHit *>(hits->At(ihit)) ;
     
-    if(hit != 0){
-      if(fDebug>1) cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
-
-      Int_t id = hit->GetId();
-      // These are local coordinates
-      Double_t xl = 0.; Double_t yl = 0.; Double_t zl = 0.;
-      // Get global coordinates
-      Double_t x = hit->X();
-      Double_t y = hit->Y();
-      Double_t z = hit->Z();
-      Double_t amp = hit->GetEnergy();
-      Int_t iSupMod = 0;
-      // Get SM Id
-      GetGeomInfo(id,iSupMod,xl,yl,zl);
-      fSM[iSupMod]->RegisterHit(id,iSupMod,amp,x,y,z);
-    }
-  }
-  
+                               if(hit != 0){
+                                       if(fDebug>1) cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
+
+                                       Int_t id = hit->GetId();
+                                       // These are local coordinates
+                                       Double_t xl = 0.; Double_t yl = 0.; Double_t zl = 0.;
+                                       // Get global coordinates
+                                       Double_t x = hit->X();
+                                       Double_t y = hit->Y();
+                                       Double_t z = hit->Z();
+                                       Double_t amp = hit->GetEnergy();
+                                       Int_t iSupMod = 0;
+                                       // Get SM Id
+                                       GetGeomInfo(id,iSupMod,xl,yl,zl);
+                                       fSM[iSupMod]->RegisterHit(id,iSupMod,amp,x,y,z);
+                               }//hit exists
+                       }//hit loop
+                       if(hits)hits->Clear();
+               }// track loop
+       }//treeH exists
 }
 
 //______________________________________________________________________________
@@ -464,7 +474,7 @@ void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* const emcl)
      dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
 
      if(dig != 0){
-       if(fDebug>1) cout << "Digit info " << dig->GetId() << " " << dig->GetAmp() << endl;
+       if(fDebug>1) cout << "Digit info " << dig->GetId() << " " << dig->GetAmplitude() << endl;
        id   = dig->GetId() ; //cell (digit) label
        // adc
        ampFlo  = dig->GetAmplitude(); //amplitude in cell (digit)