set reco param on an event by event basis
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 7 Mar 2011 12:58:08 +0000 (12:58 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 7 Mar 2011 12:58:08 +0000 (12:58 +0000)
fix container ownership (bug 78633)

PWG1/TRD/AliTRDcheckDET.cxx
PWG1/TRD/AliTRDcheckESD.cxx
PWG1/TRD/AliTRDcheckPID.cxx
PWG1/TRD/AliTRDefficiency.cxx
PWG1/TRD/AliTRDinfoGen.cxx
PWG1/TRD/AliTRDinfoGen.h
PWG1/TRD/AliTRDresolution.cxx

index 081ace2ae9448b4a8ab1a414218255b640733b87..54599176953db1122b06d9f12d830970be114722 100644 (file)
@@ -388,7 +388,7 @@ TObjArray *AliTRDcheckDET::Histos(){
   if(fContainer) return fContainer;
   
   fContainer = new TObjArray(20);
-  //fContainer->SetOwner(kTRUE);
+  fContainer->SetOwner(kTRUE);
 
   // Register Histograms
   TH1 * h = NULL;
index 3afb44f5ccfbb038ac18a7b8d68dc4200a886965..822c0c234427716ff1533c5e9567ec472d71a90e 100644 (file)
@@ -125,7 +125,7 @@ AliTRDcheckESD::~AliTRDcheckESD()
 {
 // Destructor
   if(fHistos){
-    //fHistos->Delete();
+    if(fHistos->IsOwner()) fHistos->Delete();
     delete fHistos;
   }
   if(fResults){
@@ -1088,7 +1088,7 @@ TObjArray* AliTRDcheckESD::Histos()
   if(fHistos) return fHistos;
 
   fHistos = new TObjArray(kNhistos);
-  //fHistos->SetOwner(kTRUE);
+  fHistos->SetOwner(kTRUE);
 
   TH1 *h = NULL;
 
index 832d181bc4118c5adf3bd74fe38dd219fc83a99c..cd37e4adeb3bb902c5cb5993f01e5c964b90f37e 100644 (file)
@@ -160,7 +160,7 @@ TObjArray * AliTRDcheckPID::Histos(){
   if(fContainer) return fContainer;
 
   Int_t xBins = AliPID::kSPECIES*fMomentumAxis->GetNbins(); 
-  fContainer = new TObjArray(); fContainer->Expand(kNPlots);
+  fContainer = new TObjArray(); fContainer->Expand(kNPlots); fContainer->SetOwner(kTRUE);
 
   const Float_t epsilon = 1./(2*(AliTRDpidUtil::kBins-1));     // get nice histos with bin center at 0 and 1
   TH1 *h = NULL;
index 0194ddc8ef5f351d87cd940d99a4d1e33cb29423..6ade10f4cd144eb9832b57a57b3bf5c3917d84bf 100644 (file)
@@ -86,7 +86,7 @@ void  AliTRDefficiency::UserCreateOutputObjects()
   Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
 
   TH1 *h = NULL;
-  fContainer = new TObjArray();
+  fContainer = new TObjArray(); fContainer->SetOwner();
   for(Int_t is=0; is<AliPID::kSPECIES; is++){
     fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), AliPID::ParticleShortName(is), nbins, xbins));
     h->SetLineColor(AliTRDCalPID::GetPartColor(is));
index 3e9128bc09993b5ffdd54a0472cd8a54c54b6033..3eb74420c58c527c5cb31c502eb144a329e04a83 100644 (file)
@@ -123,6 +123,7 @@ AliTRDinfoGen::AliTRDinfoGen()
   ,fTracksKink(NULL)\r
   ,fV0List(NULL)\r
   ,fContainer(NULL)\r
+  ,fRecos(NULL)\r
   ,fDebugStream(NULL)\r
 {\r
   //\r
@@ -149,6 +150,7 @@ AliTRDinfoGen::AliTRDinfoGen(char* name)
   ,fTracksKink(NULL)\r
   ,fV0List(NULL)\r
   ,fContainer(NULL)\r
+  ,fRecos(NULL)\r
   ,fDebugStream(NULL)\r
 {\r
   //\r
@@ -229,7 +231,7 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE);\r
 \r
   // define general monitor\r
-  fContainer = new TObjArray(1); fContainer->SetOwner(kTRUE);\r
+  fContainer = new TObjArray(2); fContainer->SetOwner(kTRUE);\r
   TH1 *h=new TH1I("hStat", "Run statistics;Observable;Entries", Int_t(kNObjects), -0.5, Float_t(kNObjects)-0.5);\r
   TAxis *ax(h->GetXaxis());\r
   ax->SetBinLabel(Int_t(kTracksESD) + 1, "ESD");\r
@@ -247,6 +249,13 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   ax->SetBinLabel(Int_t(kBarrelFriend) + 1, "BFriend");\r
   ax->SetBinLabel(Int_t(kSAFriend) + 1, "SFriend");\r
   fContainer->AddAt(h, 0);\r
+  h=new TH1I("hEv", "Run statistics;Event Class;Entries", 4, -0.5, 3.5);\r
+  ax = h->GetXaxis();\r
+  ax->SetBinLabel(1, "Low");\r
+  ax->SetBinLabel(2, "High");\r
+  ax->SetBinLabel(3, "Cosmic");\r
+  ax->SetBinLabel(4, "Calib");\r
+  fContainer->AddAt(h, 1);\r
   PostData(AliTRDpwg1Helper::kMonitor, fContainer);\r
 }\r
 \r
@@ -322,33 +331,40 @@ void AliTRDinfoGen::UserExec(Option_t *){
     AliTRDtrackerV1::SetNTimeBins(AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS());\r
     AliInfo(Form("OCDB :  Loc[%s] Run[%d] TB[%d]", fOCDB.Data(), ocdb->GetRun(), AliTRDtrackerV1::GetNTimeBins()));\r
 \r
-    // set reco param valid for this run/event\r
+    // load reco param list from OCDB\r
     AliInfo(Form("Initializing TRD reco params for EventSpecie[%d]...",\r
       fESDev->GetEventSpecie()));\r
     fgReconstructor = new AliTRDReconstructor();\r
     if(!(obj = ocdb->Get(AliCDBPath("TRD", "Calib", "RecoParam")))){\r
       AliError("RECO PARAM failed initialization.");\r
-      fgReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());\r
     } else {\r
       obj->PrintMetaData();\r
-      TObjArray *recos((TObjArray*)obj->GetObject());\r
-      for(Int_t ireco(0); ireco<recos->GetEntriesFast(); ireco++){\r
-        AliTRDrecoParam *reco((AliTRDrecoParam*)recos->At(ireco));\r
-        Int_t es(reco->GetEventSpecie());\r
-        if(!(es&fESDev->GetEventSpecie())) continue;\r
-        fgReconstructor->SetRecoParam(reco);\r
-        TString s;\r
-        if(es&AliRecoParam::kLowMult) s="LowMult";\r
-        else if(es&AliRecoParam::kHighMult) s="HighMult";\r
-        else if(es&AliRecoParam::kCosmic) s="Cosmic";\r
-        else if(es&AliRecoParam::kCalib) s="Calib";\r
-        else s="Unknown";\r
-        AliInfo(Form("Using reco params for %s", s.Data()));\r
-        break;\r
-      }\r
+      fRecos = (TObjArray*)obj->GetObject();\r
     }\r
     SetInitOCDB();\r
   }\r
+  // set reco param valid for this event\r
+  TH1 *h = (TH1I*)fContainer->At(1);\r
+  if(!fRecos){\r
+    fgReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());\r
+    h->Fill(0);\r
+  } else {\r
+    for(Int_t ireco(0); ireco<fRecos->GetEntriesFast(); ireco++){\r
+      AliTRDrecoParam *reco((AliTRDrecoParam*)fRecos->At(ireco));\r
+      Int_t es(reco->GetEventSpecie());\r
+      if(!(es&fESDev->GetEventSpecie())) continue;\r
+      fgReconstructor->SetRecoParam(reco);\r
+      if(AliLog::GetDebugLevel("PWG1/TRD", "AliTRDinfoGen")>1) reco->Dump();\r
+      TString s;\r
+      if(es&AliRecoParam::kLowMult){ s="LowMult"; h->Fill(0);}\r
+      else if(es&AliRecoParam::kHighMult){ s="HighMult"; h->Fill(1);}\r
+      else if(es&AliRecoParam::kCosmic){ s="Cosmic"; h->Fill(2);}\r
+      else if(es&AliRecoParam::kCalib){ s="Calib"; h->Fill(3);}\r
+      else s="Unknown";\r
+      AliDebug(2, Form("Using reco param \"%s\" for event %d.", s.Data(), fESDev->GetEventNumberInFile()));\r
+      break;\r
+    }\r
+  }\r
 \r
   // link MC if available\r
   fMCev = MCEvent();\r
@@ -708,7 +724,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
     ,nKink, nKinkMC, fTracksKink->GetEntries()\r
   ));\r
   // save track statistics\r
-  TH1 *h((TH1S*)fContainer->At(0));\r
+  h = (TH1I*)fContainer->At(0);\r
   h->Fill(Float_t(kTracksESD), nTracksESD);\r
   h->Fill(Float_t(kTracksMC), nTracksMC);\r
   h->Fill(Float_t(kV0), fV0List->GetEntries());\r
index f82a4a94d4e7a26f215cd8a709c29ab047f878f7..826719932e52f23a79b590f88058aa0f34785e6c 100644 (file)
@@ -129,6 +129,7 @@ private:
   TObjArray        *fTracksKink;     //! Array of kink tracks\r
   TObjArray        *fV0List;         //! V0 container\r
   TObjArray        *fContainer;      //! container to store results\r
+  TObjArray        *fRecos;          //! array of reco params\r
   TTreeSRedirector *fDebugStream;    //! debug stream\r
 \r
   ClassDef(AliTRDinfoGen, 7)         // entry to TRD analysis train\r
index ab4dcfccbe65a1f1c283694ba5f5eb9622505d9d..b6cbea7fbaaf791e66452d3b1b60d21daf369240 100644 (file)
@@ -2442,7 +2442,7 @@ TObjArray* AliTRDresolution::Histos()
   if(fContainer) return fContainer;
 
   fContainer  = new TObjArray(kNviews);
-  //fContainer->SetOwner(kTRUE);
+  fContainer->SetOwner(kTRUE);
   TH1 *h(NULL);
   TObjArray *arr(NULL);