]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
fixed a memory leak, cleaned some code...
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Nov 2006 08:18:46 +0000 (08:18 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Nov 2006 08:18:46 +0000 (08:18 +0000)
PWG0/TPC/AliROCESDAnalysisSelector.cxx
PWG0/TPC/AliROCESDAnalysisSelector.h
PWG0/TPC/AliTPCClusterHistograms.cxx
PWG0/TPC/AliTPCRawHistograms.cxx

index dc3da34437894ed8caeacfae2e84af05fa3398a7..d9a88ee8087b6de1ddc1f3aa60443ad66c8163f2 100644 (file)
 #include <AliLog.h>
 #include <AliESD.h>
 #include <AliESDfriend.h>
-#include <../TPC/AliTPCclusterMI.h>
-#include <../TPC/AliTPCseed.h>
+#include <AliTPCclusterMI.h>
+#include <AliTPCseed.h>
 
 #include <TFile.h>
 #include <TMath.h>
 #include <TTree.h>
 #include <TCanvas.h>
+#include <TSystem.h>
 #include <TObjArray.h>
+#include <TTimeStamp.h>
 
 #include "TPC/AliTPCClusterHistograms.h"
 
+extern TSystem* gSystem;
+
 ClassImp(AliROCESDAnalysisSelector)
 
 AliROCESDAnalysisSelector::AliROCESDAnalysisSelector() :
@@ -123,9 +127,9 @@ Bool_t AliROCESDAnalysisSelector::Process(Long64_t entry)
   
   fESD->SetESDfriend(fESDfriend);
 
-  Int_t flag = ProcessEvent(kFALSE);
-  if (flag==1)
-    ProcessEvent(kTRUE, Form("flash_entry%d",entry));
+  Int_t flag = ProcessEvent(entry, kFALSE);
+  if (flag == 1)
+    ProcessEvent(entry, kTRUE);
 
   // TODO This should not be needed, the TTree::GetEntry() should take care of this, maybe because it has a reference member, to be analyzed
   // if the ESDfriend is not deleted we get a major memory leak
@@ -141,7 +145,7 @@ Bool_t AliROCESDAnalysisSelector::Process(Long64_t entry)
   return kTRUE;
 }
 
-Int_t AliROCESDAnalysisSelector::ProcessEvent(Bool_t detailedHistogram, const Char_t* label)
+Int_t AliROCESDAnalysisSelector::ProcessEvent(Long64_t entry, Bool_t detailedHistogram)
 {
   //
   // Looping over tracks and clusters in event and filling histograms 
@@ -151,11 +155,11 @@ Int_t AliROCESDAnalysisSelector::ProcessEvent(Bool_t detailedHistogram, const Ch
   //   1 : if a "flash" is detected something special in this event
   //   
 
-  // save maximum 100 objects
+  // save maximum 50 objects
   if (detailedHistogram) 
-    if (fObjectsToSave->GetSize()>10) 
+    if (fObjectsToSave->GetEntries() > 50) 
       return 0;
-
+      
   // for saving single events
   AliTPCClusterHistograms* clusterHistograms[kTPCSectors];
   for (Int_t i=0; i<kTPCSectors; i++) 
@@ -214,71 +218,66 @@ Int_t AliROCESDAnalysisSelector::ProcessEvent(Bool_t detailedHistogram, const Ch
       
       Int_t detector = cluster->GetDetector();
       
-      if (detector < 0 || detector >= kTPCSectors) {
-       AliDebug(AliLog::kDebug, Form("We found a cluster from invalid sector %d", detector));
-       continue;
+      if (detector < 0 || detector >= kTPCSectors) 
+      {
+        AliDebug(AliLog::kDebug, Form("We found a cluster from invalid sector %d", detector));
+        continue;
       }
 
       if (!detailedHistogram) {
-    
-       // TODO: find a clever way to handle the time      
-       Int_t time = 0;
-       
-       if (fESD->GetTimeStamp()>1160000000)
-         time = fESD->GetTimeStamp();      
-       
-       if (!fClusterHistograms[detector])
-         fClusterHistograms[detector] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60);
-       
-       if (!fClusterHistograms[detector+kTPCSectors])
-         fClusterHistograms[detector+kTPCSectors] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60, kTRUE);
-       
-       fClusterHistograms[detector]->FillCluster(cluster, time);
-       fClusterHistograms[detector+kTPCSectors]->FillCluster(cluster, time);
-       
-       Int_t z = Int_t(cluster->GetZ()); 
-       if (z>=0 && z<250) {
-         nClusters++;
-         clusterQtotSumVsTime[z] += cluster->GetQ();
-       }
+        // TODO: find a clever way to handle the time      
+       Int_t time = 0;
+       
+       if (fESD->GetTimeStamp()>1160000000)
+         time = fESD->GetTimeStamp();      
+       
+       if (!fClusterHistograms[detector])
+         fClusterHistograms[detector] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60);
+       
+       if (!fClusterHistograms[detector+kTPCSectors])
+         fClusterHistograms[detector+kTPCSectors] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60, kTRUE);
+       
+       fClusterHistograms[detector]->FillCluster(cluster, time);
+       fClusterHistograms[detector+kTPCSectors]->FillCluster(cluster, time);
+       
+       Int_t z = Int_t(cluster->GetZ()); 
+       if (z>=0 && z<250) {
+         nClusters++;
+         clusterQtotSumVsTime[z] += cluster->GetQ();
+       }
       } // end of if !detailedHistograms
       else {
-       // if we need the detailed histograms for this event
-       if (!clusterHistograms[detector])
-         clusterHistograms[detector] = new AliTPCClusterHistograms(detector,label);
-       
-       clusterHistograms[detector]->FillCluster(cluster);
+       // if we need the detailed histograms for this event
+       if (!clusterHistograms[detector])
+         clusterHistograms[detector] = new AliTPCClusterHistograms(detector, Form("flash_entry%d", entry));
+       
+       clusterHistograms[detector]->FillCluster(cluster);
       }
-      
     }
     
     for (Int_t i=0; i<kTPCHists; i++) 
       if (fClusterHistograms[i]) 
-       fClusterHistograms[i]->FillTrack(seed);
-    
+        fClusterHistograms[i]->FillTrack(seed);
+
   }
   
   // check if there's a very large q deposit ("flash")
   if (!detailedHistogram) {
     for (Int_t z=0; z<250; z++) {
       if (clusterQtotSumVsTime[z] > 150000) {
-       printf(Form("  \n   -> sum of clusters at time %d  %f \n \n", z, clusterQtotSumVsTime[z]));
-       intToReturn = 1;
+       printf(Form("  \n   -> Entry %lld sum of clusters at time %d is %f, ESD timestamp: %s (%d) \n \n", entry, z, clusterQtotSumVsTime[z], TTimeStamp(fESD->GetTimeStamp()).AsString(), fESD->GetTimeStamp()));
+               intToReturn = 1;
       }
     }
   }
   else {
     for (Int_t i=0; i< kTPCSectors; i++) {
       if (clusterHistograms[i]) {
-       if (fObjectsToSave->GetSize()<100) {
-         fObjectsToSave->Expand(fObjectsToSave->GetSize()+1);
-         fObjectsToSave->AddAt(clusterHistograms[i], fObjectsToSave->GetSize()-1);
-       }
+        fObjectsToSave->Add(clusterHistograms[i]);
       }
     }    
   }
 
-
 //   if (nSkippedSeeds > 0)
 //     printf("WARNING: The seed was not found for %d out of %d tracks.\n", nSkippedSeeds, nTracks);
 //   if (nSkippedTracks > 0)
@@ -381,19 +380,22 @@ void AliROCESDAnalysisSelector::Terminate()
 
   if (comment)
   {
-    AliDebug(AliLog::kInfo, Form("INFO: Found comment in input list: %s \n", comment->GetTitle()));
+    AliDebug(AliLog::kInfo, Form("INFO: Found comment in input list: %s", comment->GetTitle()));
   }
   else
     return;
 
   TFile* file = TFile::Open(Form("rocESD_%s.root",comment->GetTitle()), "RECREATE");
-  
+
   for (Int_t i=0; i<kTPCHists; i++)
     if (fClusterHistograms[i]) {
       fClusterHistograms[i]->SaveHistograms();
       TCanvas* c = fClusterHistograms[i]->DrawHistograms();
-      c->SaveAs(Form("plots_%s_%s.eps",comment->GetTitle(),c->GetName()));
-      c->SaveAs(Form("plots_%s_%s.gif",comment->GetTitle(),c->GetName()));
+                       TString dir;
+                       dir.Form("WWW/%s/%s", comment->GetTitle(), c->GetName());
+                       gSystem->mkdir(dir, kTRUE);
+      c->SaveAs(Form("%s/plots_%s_%s.eps",dir.Data(),comment->GetTitle(),c->GetName()));
+      c->SaveAs(Form("%s/plots_%s_%s.gif",dir.Data(),comment->GetTitle(),c->GetName()));
 
       c->Close();
       delete c;
@@ -416,4 +418,4 @@ void AliROCESDAnalysisSelector::Terminate()
 
 
   file->Close();
-} 
+}
index 9cec2643a4553acf9a510d9f82a0c8913cd65518..e632728a7d34b9a896c55cd97cb74967deb88852 100644 (file)
@@ -29,7 +29,7 @@ class AliROCESDAnalysisSelector : public AliSelector {
     virtual void    SlaveTerminate();
     virtual void    Terminate();
 
-    Int_t           ProcessEvent(Bool_t detailedHistogram=kFALSE, const Char_t* label="");
+    Int_t           ProcessEvent(Long64_t entry, Bool_t detailedHistogram=kFALSE);
 
     Bool_t          AcceptTrack(const AliTPCseed* track, Int_t minRowsIncluded=0);
 
index bd267705f57dcc2ab40209861434b745c5e1e3d1..92807e157338e47b2f214a0a423d118854b77519 100644 (file)
@@ -18,8 +18,9 @@
 #include <TObjArray.h>
 #include <TLatex.h>
 
-#include <../TPC/AliTPCclusterMI.h>
-#include <../TPC/AliTPCseed.h>
+#include <AliTPCclusterMI.h>
+#include <AliTPCseed.h>
+
 #include <AliLog.h>
 
 
index 837d35d4314b84c6d256fad1aba769498788f018..9b3ecee02250d6a1c23e415bb8ea366222346bca 100644 (file)
@@ -79,14 +79,16 @@ AliTPCRawHistograms::AliTPCRawHistograms(Int_t detector, const Char_t* /* commen
     nPadRows = 63;
   }
   
-  // 1 bin for each 0.5 cm
-  Int_t nBinsY = Int_t(4*yRange);
+  // do not add this hists to the directory
+  Bool_t oldStatus = TH1::AddDirectoryStatus();
+  TH1::AddDirectory(kFALSE);
 
-  // TODO do NOT attach to the directory!
-  fhDigits = new TH3F("fhDigits", Form("signal distribution;row;pad;time", name.Data()), nPadRows, -0.5, -0.5 + nPadRows, 120, -0.5, 119.5, 100, 0, 1200);
+  fhDigits = new TH3F("fhDigits", Form("signal distribution;row;pad;time", name.Data()), nPadRows, -0.5, -0.5 + nPadRows, 150, -0.5, 149.5, 100, 0, 1200);
   fhSignal = new TH1F("fhSignal", "fhSignal", 200, 0, 2000);
   
   fDigitTree = new TNtuple("fDigitTree", "fDigitTree", "row:pad:time:signal");
+
+  TH1::AddDirectory(oldStatus);
 }
 
 //____________________________________________________________________
@@ -224,7 +226,7 @@ Long64_t AliTPCRawHistograms::Merge(TCollection* list)
 }
 
 //____________________________________________________________________
-void AliTPCRawHistograms::FillDigit(AliTPCRawStream* rawStream, Int_t time
+void AliTPCRawHistograms::FillDigit(AliTPCRawStream* rawStream, Int_t /*time*/
 {
   //
   // Fills the different histograms with the information from a raw digit
@@ -240,7 +242,7 @@ void AliTPCRawHistograms::FillDigit(AliTPCRawStream* rawStream, Int_t time)
     
   fhSignal->Fill(signal);
   
-  //fDigitTree->Fill(row, pad, timeBin, signal);
+  fDigitTree->Fill(row, pad, timeBin, signal);
 }
 
 //____________________________________________________________________
@@ -261,7 +263,7 @@ void AliTPCRawHistograms::SaveHistograms()
 }
 
 //____________________________________________________________________
-TCanvas* AliTPCRawHistograms::DrawHistograms(const Char_t* opt) {
+TCanvas* AliTPCRawHistograms::DrawHistograms(const Char_t* /*opt*/) {
   //
   // Draws some histograms and save the canvas as eps and gif file.
   //