]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDQADataMakerSim.cxx
fix for Savannah bug #80565
[u/mrichter/AliRoot.git] / PMD / AliPMDQADataMakerSim.cxx
index fa9c133977ae36235253d850571dc318a338de93..df37e19791355dac7f0e463be15097cca921d28c 100644 (file)
@@ -141,112 +141,95 @@ void AliPMDQADataMakerSim::InitDigits()
 }
 
 //____________________________________________________________________________ 
-void AliPMDQADataMakerSim::MakeHits(TClonesArray *hits)
+void AliPMDQADataMakerSim::MakeHits()
 {
     //make QA data from Hits
 
-  // Check id histograms already created for this Event Specie
-  if ( ! GetHitsData(0) )
-    InitHits() ;
-
   Int_t premul = 0, cpvmul = 0;
-    Float_t edepkev = 0.;
-    TIter next(hits); 
-    AliPMDhit * hit; 
+  Float_t edepkev = 0.;
+  TIter next(fHitsArray); 
+  AliPMDhit * hit; 
     
-    while ( (hit = dynamic_cast<AliPMDhit *>(next())) )
-      {
-       if (hit->Z() > 361.5)
-         {
-           edepkev = (hit->GetEnergy())/1000.;
-           GetHitsData(0)->Fill(edepkev);
-           premul++;
-         }
-       else if (hit->Z() < 361.5)
-         {
-           edepkev = (hit->GetEnergy())/1000.;
-           GetHitsData(1)->Fill(edepkev);
-           cpvmul++;
-         }
+  while ( (hit = dynamic_cast<AliPMDhit *>(next())) )
+    {
+      if (hit->Z() > 361.5)
+       {
+         edepkev = (hit->GetEnergy())/1000.;
+         GetHitsData(0)->Fill(edepkev);
+         premul++;
+       }
+      else if (hit->Z() < 361.5)
+       {
+         edepkev = (hit->GetEnergy())/1000.;
+         GetHitsData(1)->Fill(edepkev);
+         cpvmul++;
+       }
     }
-
-    if(premul <= 0)
+  
+  if(premul <= 0)
     {
-       GetHitsData(2)->Fill(-1.); 
+      GetHitsData(2)->Fill(-1.); 
     }
-    else
+  else
     {
-       GetHitsData(2)->Fill(premul); 
+      GetHitsData(2)->Fill(premul); 
     }
-
-    if(cpvmul <= 0)
+  
+  if(cpvmul <= 0)
     {
-       GetHitsData(3)->Fill(-1.); 
+      GetHitsData(3)->Fill(-1.); 
     }
-    else
+  else
     {
-       GetHitsData(3)->Fill(cpvmul); 
+      GetHitsData(3)->Fill(cpvmul); 
     }
-
+  
 }
 
 //____________________________________________________________________________
 void AliPMDQADataMakerSim::MakeHits(TTree * hitTree)
 {
-    // make QA data from Hit Tree
-
-    TBranch * branch = hitTree->GetBranch("PMD") ;
-    if ( ! branch )
+  // make QA data from Hit Tree
+  
+  TBranch * branch = hitTree->GetBranch("PMD") ;
+  if ( ! branch )
     {
-       AliWarning("PMD branch in Hit Tree not found") ;
-       return;
+      AliWarning("PMD branch in Hit Tree not found") ;
+      return;
     }
 
-    static TClonesArray statichits("AliPMDhit", 1000);
-    statichits.Clear();
-    TClonesArray *hits = &statichits;
-    static TClonesArray staticdummy("AliPMDhit", 1000);
-    staticdummy.Clear();
-    TClonesArray *dummy = &staticdummy;
-    branch->SetAddress(&dummy);
-    Int_t index = 0 ;  
+  if (fHitsArray) 
+    fHitsArray->Clear() ; 
+  else 
+    fHitsArray = new TClonesArray("AliPMDhit", 1000);
 
-    for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
-       branch->GetEntry(ientry) ; 
-       for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
-           AliPMDhit * hit = dynamic_cast<AliPMDhit *> (dummy->At(ihit)) ; 
-           new((*hits)[index]) AliPMDhit(*hit) ; 
-
-           index++ ;
-       } 
-    }  
-
-    MakeHits(hits);
+  branch->SetAddress(&fHitsArray);
 
+  for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
+    branch->GetEntry(ientry) ; 
+    MakeHits();
+    fHitsArray->Clear() ; 
+  }    
 }
 //____________________________________________________________________________
-void AliPMDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
+void AliPMDQADataMakerSim::MakeSDigits()
 {
     // makes data from SDigits
 
-  // Check id histograms already created for this Event Specie
-  if ( ! GetSDigitsData(0) )
-    InitSDigits() ;
-
   Int_t cpvmul = 0, premul = 0;
-    Float_t edepkev = 0.;
-
-    TIter next(sdigits) ; 
-    AliPMDsdigit * sdigit ; 
-    while ( (sdigit = dynamic_cast<AliPMDsdigit *>(next())) )
+  Float_t edepkev = 0.;
+  
+  TIter next(fSDigitsArray) ; 
+  AliPMDsdigit * sdigit ; 
+  while ( (sdigit = dynamic_cast<AliPMDsdigit *>(next())) )
     {
-       if(sdigit->GetDetector() == 0)
+      if(sdigit->GetDetector() == 0)
        {
          edepkev = (sdigit->GetCellEdep())/1000.;
          GetSDigitsData(0)->Fill(edepkev);
          premul++;
        }
-       if(sdigit->GetDetector() == 1)
+      if(sdigit->GetDetector() == 1)
        {
          edepkev = (sdigit->GetCellEdep())/1000.;
          GetSDigitsData(1)->Fill(edepkev);
@@ -254,66 +237,61 @@ void AliPMDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
        }
        
     } 
-    if (premul > 0) GetSDigitsData(2)->Fill(premul);
-    if (cpvmul > 0) GetSDigitsData(3)->Fill(cpvmul);
-    
+  if (premul > 0) GetSDigitsData(2)->Fill(premul);
+  if (cpvmul > 0) GetSDigitsData(3)->Fill(cpvmul);
+  
 }
 
 //____________________________________________________________________________
 void AliPMDQADataMakerSim::MakeSDigits(TTree * sdigitTree)
 {
     // makes data from SDigit Tree
-
-    TClonesArray * sdigits = new TClonesArray("AliPMDsdigit", 1000) ; 
+  
+  if (fSDigitsArray) 
+    fSDigitsArray->Clear() ; 
+  else 
+    fSDigitsArray = new TClonesArray("AliPMDsdigit", 1000) ; 
     
-    TBranch * branch = sdigitTree->GetBranch("PMDSDigit") ;
-    branch->SetAddress(&sdigits) ;
-
-    if ( ! branch )
+  TBranch * branch = sdigitTree->GetBranch("PMDSDigit") ;
+  if ( ! branch )
     {
-       AliWarning("PMD branch in SDigit Tree not found") ; 
+      AliWarning("PMD branch in SDigit Tree not found") ; 
     }
-    else
+  else
     {
-       for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
-       {
-           branch->GetEntry(ient) ;
-           MakeSDigits(sdigits) ; 
-       }
+      branch->SetAddress(&fSDigitsArray) ;
+      branch->GetEntry(0) ;
+      MakeSDigits() ; 
     }
 }
 
 //____________________________________________________________________________
-void AliPMDQADataMakerSim::MakeDigits(TClonesArray * digits)
+void AliPMDQADataMakerSim::MakeDigits()
 {
     // makes data from Digits
-    
-  // Check id histograms already created for this Event Specie
-  if ( ! GetDigitsData(0) )
-    InitDigits() ;
 
   Int_t cpvmul = 0, premul = 0;
-
-    TIter next(digits) ; 
-    AliPMDdigit * digit ; 
-    while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
+  
+  TIter next(fDigitsArray) ; 
+  AliPMDdigit * digit ; 
+  while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
     {
-       if(digit->GetDetector() == 0)
+      if(digit->GetDetector() == 0)
        {
-           GetDigitsData(0)->Fill( digit->GetADC()) ;
-           premul++;
+         GetDigitsData(0)->Fill( digit->GetADC()) ;
+         premul++;
        }
-       if(digit->GetDetector() == 1)
+      if(digit->GetDetector() == 1)
        {
-           GetDigitsData(1)->Fill( digit->GetADC());
-           cpvmul++;
+         GetDigitsData(1)->Fill( digit->GetADC());
+         cpvmul++;
        }
     }  
-
-    if (premul > 0) GetDigitsData(2)->Fill(premul);
-    if (cpvmul > 0) GetDigitsData(3)->Fill(cpvmul);
-
-
+  
+  if (premul > 0) GetDigitsData(2)->Fill(premul);
+  if (cpvmul > 0) GetDigitsData(3)->Fill(cpvmul);
+  
+  
 }
 
 //____________________________________________________________________________
@@ -321,23 +299,28 @@ void AliPMDQADataMakerSim::MakeDigits(TTree * digitTree)
 {
     // makes data from Digit Tree
 
-    TClonesArray * digits = new TClonesArray("AliPMDdigit", 1000) ; 
-    
-    TBranch * branch = digitTree->GetBranch("PMDDigit") ;
-    branch->SetAddress(&digits) ;
+  if (fDigitsArray) 
+    fDigitsArray->Clear() ; 
+  else 
+    fDigitsArray = new TClonesArray("AliPMDdigit", 1000) ; 
+  
+  TBranch * branch = digitTree->GetBranch("PMDDigit") ;
 
-    if ( ! branch )
+  if ( ! branch )
     {
-       AliWarning("PMD branch in Digit Tree not found") ; 
+      AliWarning("PMD branch in Digit Tree not found") ; 
     }
-    else
+  else
     {
-       for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
+      branch->SetAddress(&fDigitsArray) ;
+      for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
        {
-           branch->GetEntry(ient) ; 
-           MakeDigits(digits) ; 
+         branch->GetEntry(ient) ; 
+         MakeDigits() ; 
+         fDigitsArray->Clear() ; 
+         
        }
-       
+      
     }
 }