]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDinfoGen.cxx
Fixed compilation
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDinfoGen.cxx
index 64d61e114a19b53eaf386f678cb1aee7d918e216..5f5603e4d57ae10f2e1ddb243b7006966318cd73 100644 (file)
@@ -35,7 +35,8 @@
 #include <TObjArray.h>
 #include <TObject.h>
 #include <TString.h>
-#include <TH1F.h>
+#include <TH1S.h>
+#include <TPad.h>
 #include <TFile.h>
 #include <TTree.h>
 #include <TROOT.h>
@@ -44,6 +45,7 @@
 
 #include "AliLog.h"
 #include "AliAnalysisManager.h"
+#include "AliCDBManager.h"
 #include "AliESDEvent.h"
 #include "AliMCEvent.h"
 #include "AliESDInputHandler.h"
 #include "AliMCParticle.h"
 #include "AliPID.h"
 #include "AliStack.h"
-#include "AliTRDtrackV1.h"
 #include "AliTrackReference.h"
-#include "AliTRDgeometry.h"
-#include "AliTRDcluster.h"
-#include "AliTRDseedV1.h"
 #include "TTreeStream.h"
 
 #include <cstdio>
 #include <cstring>
 #include <iostream>
 
+#include "AliTRDcalibDB.h"
+#include "AliTRDtrackerV1.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDtrackV1.h"
+#include "AliTRDseedV1.h"
+#include "AliTRDcluster.h"
 #include "AliTRDinfoGen.h"
 #include "info/AliTRDtrackInfo.h"
 #include "info/AliTRDeventInfo.h"
@@ -101,6 +105,7 @@ AliTRDinfoGen::AliTRDinfoGen()
   ,fEventCut(NULL)
   ,fTrackCut(NULL)
   ,fV0Cut(NULL)
+  ,fOCDB("local://$ALICE_ROOT/OCDB")
   ,fTrackInfo(NULL)
   ,fEventInfo(NULL)
   ,fV0Info(NULL)
@@ -108,12 +113,13 @@ AliTRDinfoGen::AliTRDinfoGen()
   ,fTracksSA(NULL)
   ,fTracksKink(NULL)
   ,fV0List(NULL)
+  ,fContainer(NULL)
   ,fDebugStream(NULL)
 {
   //
   // Default constructor
   //
-  SetNameTitle("infoGen", "MC-REC TRD-track list generator");
+  SetNameTitle("TRDinfoGen", "MC-REC TRD-track list generator");
 }
 
 //____________________________________________________________________
@@ -125,6 +131,7 @@ AliTRDinfoGen::AliTRDinfoGen(char* name)
   ,fEventCut(NULL)
   ,fTrackCut(NULL)
   ,fV0Cut(NULL)
+  ,fOCDB("local://$ALICE_ROOT/OCDB")
   ,fTrackInfo(NULL)
   ,fEventInfo(NULL)
   ,fV0Info(NULL)
@@ -132,6 +139,7 @@ AliTRDinfoGen::AliTRDinfoGen(char* name)
   ,fTracksSA(NULL)
   ,fTracksKink(NULL)
   ,fV0List(NULL)
+  ,fContainer(NULL)
   ,fDebugStream(NULL)
 {
   //
@@ -143,6 +151,7 @@ AliTRDinfoGen::AliTRDinfoGen(char* name)
   DefineOutput(kTracksKink, TObjArray::Class());
   DefineOutput(kEventInfo, AliTRDeventInfo::Class());
   DefineOutput(kV0List, TObjArray::Class());
+  DefineOutput(kMonitor, TObjArray::Class()); // histogram list
 }
 
 //____________________________________________________________________
@@ -175,6 +184,22 @@ AliTRDinfoGen::~AliTRDinfoGen()
     delete fV0List;
     fV0List = NULL;
   }
+  if(fContainer){ 
+    fContainer->Delete(); 
+    delete fContainer;
+    fContainer = NULL;
+  }
+}
+
+//____________________________________________________________________
+Bool_t AliTRDinfoGen::GetRefFigure(Int_t)
+{
+  if(!gPad){
+    AliWarning("Please provide a canvas to draw results.");
+    return kFALSE;
+  }
+  fContainer->At(0)->Draw("bar");
+  return kTRUE;
 }
 
 //____________________________________________________________________
@@ -191,6 +216,51 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   fTracksSA = new TObjArray(20); fTracksSA->SetOwner(kTRUE);
   fTracksKink = new TObjArray(20); fTracksKink->SetOwner(kTRUE);
   fV0List = new TObjArray(10); fV0List->SetOwner(kTRUE);
+
+  // define general monitor
+  fContainer = new TObjArray(1); fContainer->SetOwner(kTRUE);
+  TH1 *h=new TH1S("hStat", "Run statistics;Observable;Entries", 12, -0.5, 11.5);
+  TAxis *ax(h->GetXaxis());
+  ax->SetBinLabel( 1, "ESD");
+  ax->SetBinLabel( 2, "MC");
+  ax->SetBinLabel( 3, "V0");
+  ax->SetBinLabel( 4, "TPC");
+  ax->SetBinLabel( 5, "TRDin");
+  ax->SetBinLabel( 6, "TRDout");
+  ax->SetBinLabel( 7, "Barrel");
+  ax->SetBinLabel( 8, "BarrelMC");
+  ax->SetBinLabel( 9, "SA");
+  ax->SetBinLabel(10, "SAMC");
+  ax->SetBinLabel(11, "Kink");
+  ax->SetBinLabel(12, "KinkMC");
+  fContainer->AddAt(h, 0);
+  PostData(kMonitor, fContainer);
+}
+
+//____________________________________________________________________
+Bool_t AliTRDinfoGen::Load(const Char_t *file, const Char_t *dir, const Char_t *name)
+{
+// Load data from performance file
+
+  if(!TFile::Open(file)){
+    AliWarning(Form("Couldn't open file %s.", file));
+    return kFALSE;
+  }
+  if(dir){
+    if(!gFile->cd(dir)){
+      AliWarning(Form("Couldn't cd to %s in %s.", dir, file));
+      return kFALSE;
+    }
+  }
+  TObjArray *o(NULL);
+  const Char_t *tn=(name ? name : GetName());
+  if(!(o = (TObjArray*)gDirectory->Get(tn))){
+    AliWarning(Form("Missing histogram container %s.", tn));
+    return kFALSE;
+  }
+  fContainer = (TObjArray*)o->Clone(GetName());
+  gFile->Close();
+  return kTRUE;
 }
 
 //____________________________________________________________________
@@ -200,12 +270,22 @@ void AliTRDinfoGen::UserExec(Option_t *){
   //
 
   fESDev = dynamic_cast<AliESDEvent*>(InputEvent());
-  fMCev = MCEvent();
-
   if(!fESDev){
     AliError("Failed retrieving ESD event");
     return;
   }
+  if(!IsInitOCDB()){
+    // prepare OCDB access
+    AliCDBManager* ocdb = AliCDBManager::Instance();
+    ocdb->SetDefaultStorage(fOCDB.Data());
+    ocdb->SetRun(fESDev->GetRunNumber());
+    AliTRDtrackerV1::SetNTimeBins(AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS());
+    AliInfo(Form("OCDB :  Loc[%s] Run[%d] TB[%d]", fOCDB.Data(), ocdb->GetRun(), AliTRDtrackerV1::GetNTimeBins()));
+    SetInitOCDB();
+  }
+
+  // link MC if available
+  fMCev = MCEvent();
 
   // event selection : trigger cut
   if(UseLocalEvSelection() && fEvTrigger){ 
@@ -545,6 +625,20 @@ void AliTRDinfoGen::UserExec(Option_t *){
     ,nSA, nSAMC, fTracksSA->GetEntries()
     ,nKink, nKinkMC, fTracksKink->GetEntries()
   ));
+  // save track statistics
+  TH1 *h((TH1S*)fContainer->At(0));
+  h->Fill( 0., nTracksESD);
+  h->Fill( 1., nTracksMC);
+  h->Fill( 2., fV0List->GetEntries());
+  h->Fill( 3., nTPC);
+  h->Fill( 4., nTRDin);
+  h->Fill( 5., nTRDout);
+  h->Fill( 6., nBarrel);
+  h->Fill( 7., nBarrelMC);
+  h->Fill( 8., nSA);
+  h->Fill( 9., nSAMC);
+  h->Fill(10., nKink);
+  h->Fill(11., nKinkMC);
 
   PostData(kTracksBarrel, fTracksBarrel);
   PostData(kTracksSA, fTracksSA);
@@ -581,3 +675,4 @@ TTreeSRedirector* AliTRDinfoGen::DebugStream()
 }
 
 
+