Added handling of background correction and event selection correction with different...
authorhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Aug 2009 13:15:26 +0000 (13:15 +0000)
committerhdalsgaa <hdalsgaa@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 21 Aug 2009 13:15:26 +0000 (13:15 +0000)
FMD/analysis/AliFMDAnaParameters.cxx
FMD/analysis/AliFMDAnaParameters.h
FMD/analysis/AliFMDAnalysisTaskCollector.cxx
FMD/analysis/AliFMDAnalysisTaskGenerateCorrection.cxx

index fcaedcb..58279ad 100644 (file)
@@ -67,12 +67,13 @@ AliFMDAnaParameters::AliFMDAnaParameters() :
   fEventSelectionEfficiency(0),
   fCorner1(4.2231, 26.6638),
   fCorner2(1.8357, 27.9500),
-  fEnergyPath("$ALICE_ROOT/FMD/Correction/EnergyDistribution/energydistributions.root"),
-  fBackgroundPath("$ALICE_ROOT/FMD/Correction/Background/background.root"),
-  fEventSelectionEffPath("$ALICE_ROOT/FMD/Correction/EventSelectionEfficiency/eventselectionefficiency.root"),
+  fEnergyPath("$ALICE_ROOT/FMD/Correction/EnergyDistribution"),
+  fBackgroundPath("$ALICE_ROOT/FMD/Correction/Background"),
+  fEventSelectionEffPath("$ALICE_ROOT/FMD/Correction/EventSelectionEfficiency"),
   fProcessPrimary(kFALSE),
   fProcessHits(kFALSE),
-  fTrigger(kMB1)
+  fTrigger(kMB1),
+  fEnergy(k10000)
 {
   
   
@@ -81,6 +82,20 @@ AliFMDAnaParameters::AliFMDAnaParameters() :
   // Default constructor 
 }
 //____________________________________________________________________
+char* AliFMDAnaParameters::GetPath(const char* species) {
+  
+  char* path ;
+  
+  if(species == fgkBackgroundID)
+    path = Form("%s/%s_%d.root",fBackgroundPath.Data(),fgkBackgroundID,fEnergy);
+  if(species == fgkEnergyDistributionID)
+    path = Form("%s/%s_%d.root",fEnergyPath.Data(),fgkEnergyDistributionID,fEnergy);
+  if(species == fgkEventSelectionEffID)
+    path = Form("%s/%s_%d_%d.root",fEventSelectionEffPath.Data(),fgkEventSelectionEffID,fEnergy,fTrigger);
+
+  return path;
+}
+//____________________________________________________________________
 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
 {
   // Initialize the parameters manager.  We need to get stuff from the
@@ -98,7 +113,8 @@ void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
 void AliFMDAnaParameters::InitBackground() {
   
   //AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
-  TFile* fin = TFile::Open(fBackgroundPath.Data());
+  
+  TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
   
   if (!fin) return;
   
@@ -111,7 +127,7 @@ void AliFMDAnaParameters::InitBackground() {
 
 void AliFMDAnaParameters::InitEnergyDists() {
   
-  TFile* fin = TFile::Open(fEnergyPath.Data());
+  TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
   //AliCDBEntry*   edist = GetEntry(fgkEnergyDists);
   if (!fin) return;
   
@@ -126,8 +142,8 @@ void AliFMDAnaParameters::InitEnergyDists() {
 void AliFMDAnaParameters::InitEventSelectionEff() {
   
   //AliCDBEntry*   background = GetEntry(fgkBackgroundCorrection);
-  TFile* fin = TFile::Open(fEventSelectionEffPath.Data());
-  
+  TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
+                           
   if (!fin) return;
   
   fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
index 2f10113..4d8063e 100644 (file)
@@ -59,6 +59,8 @@ public:
   
   enum Trigger { kMB1 = 0, kMB2, kSPDFASTOR };
   
+  enum Energy { k900 , k10000, k14000 };
+  
   /** Singleton access
       @return  single to */
   static AliFMDAnaParameters* Instance();
@@ -99,6 +101,8 @@ public:
   void     SetTriggerDefinition(Trigger trigger) {fTrigger = trigger;}
   Trigger  GetTriggerDefinition() {return fTrigger;}
   Bool_t   IsEventTriggered(AliESDEvent* esd);
+  void     SetEnergy(Energy energy) {fEnergy = energy;}
+  char*    GetPath(const char* species);
 protected:
   
   AliFMDAnaParameters();
@@ -116,7 +120,8 @@ protected:
       fEventSelectionEffPath(o.fEventSelectionEffPath),
       fProcessPrimary(o.fProcessPrimary),
       fProcessHits(o.fProcessHits),
-      fTrigger(o.fTrigger)
+      fTrigger(o.fTrigger),
+      fEnergy(o.fEnergy)
   {}
   AliFMDAnaParameters& operator=(const AliFMDAnaParameters&) { return *this; }
   virtual ~AliFMDAnaParameters() {}
@@ -155,6 +160,7 @@ protected:
   Bool_t   fProcessPrimary;
   Bool_t   fProcessHits; 
   Trigger  fTrigger;
+  Energy   fEnergy;
   
   ClassDef(AliFMDAnaParameters,0) // Manager of parameters
 };
index 1317a71..d2dbf39 100644 (file)
@@ -230,7 +230,7 @@ void AliFMDAnalysisTaskCollector::ReadFromFile(const Char_t* filename, Bool_t st
   fin.Close();
   
   if(store) {
-    TFile fcalib("$ALICE_ROOT/FMD/Correction/EnergyDistribution/energydistributions.root","RECREATE");
+    TFile fcalib(pars->GetPath(pars->GetEdistID() ),"RECREATE");
     EnergyDist->Write(AliFMDAnaParameters::GetEdistID());
     fcalib.Close();
   }
index d56831a..d484e57 100644 (file)
@@ -114,7 +114,8 @@ void AliFMDAnalysisTaskGenerateCorrection::UserCreateOutputObjects()
   TH1F* hEventsAll    = new TH1F("EventsAll","EventsAll",fNvtxBins,0,fNvtxBins);
   //  TH1F* hTriggered    = new TH1F("Triggered","Triggered",fNvtxBins,0,fNvtxBins);
   // TH1F* hTriggeredAll = new TH1F("TriggeredAll","TriggeredAll",fNvtxBins,0,fNvtxBins);
-  
+  hEventsSelected->Sumw2();
+  hEventsAll->Sumw2();
   fListOfHits.Add(hEventsSelected);
   fListOfPrimaries.Add(hEventsAll);
   
@@ -269,7 +270,25 @@ void AliFMDAnalysisTaskGenerateCorrection::GenerateCorrection() {
   TH1F* hEventsSelected    = (TH1F*)fListOfHits.FindObject("EventsSelected");
   TH1F* hEventsAll         = (TH1F*)fListOfPrimaries.FindObject("EventsAll");
   
-  hEventsSelected->Divide(hEventsAll);
+  //hEventsSelected->Divide(hEventsSelected,hEventsAll,1,1,"B");
+  
+  for(Int_t i = 1; i<=hEventsSelected->GetNbinsX(); i++) {
+    if(hEventsSelected->GetBinContent(i) == 0 )
+      continue;
+    Float_t a    = hEventsSelected->GetBinContent(i);
+    Float_t da   = hEventsSelected->GetBinError(i);
+    Float_t sum  = hEventsAll->GetBinContent(i);
+    Float_t dsum = hEventsAll->GetBinError(i);
+    Float_t b    = sum-a;
+    Float_t db   = TMath::Sqrt(TMath::Power(da,2) + TMath::Power(dsum,2));
+    
+    Float_t cor  = a / sum;
+    Float_t ecor = TMath::Sqrt(TMath::Power(b*da,2) + TMath::Power(a*db,2)) / TMath::Power(sum,2);
+    
+    hEventsSelected->SetBinContent(i,cor);
+    hEventsSelected->SetBinError(i,ecor);
+    
+  }
   
   fEventSelectionEff->SetCorrection(hEventsSelected);
   
@@ -287,6 +306,17 @@ void AliFMDAnalysisTaskGenerateCorrection::GenerateCorrection() {
        TH2F* hPrimary  = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",ring,vertexBin));
        TH2F* hCorrection = (TH2F*)hHits->Clone(Form("FMD%d%c_vtxbin_%d_correction",det,ring,vertexBin));
        hCorrection->Divide(hPrimary);
+       /*for(Int_t i = 1; i<=hCorrection->GetNbinsX();i++)  {
+         for(Int_t j=1; j<=hCorrection->GetNbinsY();j++) {
+           if(hCorrection()->GetBinContent(i,j) == 0)
+             continue;
+           Float_t a = h 
+           
+           
+         }
+       }
+       */
+       
        hCorrection->SetTitle(hCorrection->GetName());
        fListOfCorrection.Add(hCorrection);
        fBackground->SetBgCorrection(det,ring,vertexBin,hCorrection);
@@ -302,7 +332,7 @@ void AliFMDAnalysisTaskGenerateCorrection::GenerateCorrection() {
 }
 //_____________________________________________________________________
 void AliFMDAnalysisTaskGenerateCorrection::ReadFromFile(const Char_t* filename, Bool_t storeInOCDB, Int_t /*runNo*/) {
-
+  
   TFile infile(filename);
   TH1F* hVertex = (TH1F*)infile.Get("VertexBins");
   fZvtxCut = hVertex->GetXaxis()->GetXmax();
@@ -354,12 +384,12 @@ void AliFMDAnalysisTaskGenerateCorrection::ReadFromFile(const Char_t* filename,
   fVertexBins.Write();
   
   fout.Close();
-  
+  AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
   if(storeInOCDB) {
-    TFile fbg("$ALICE_ROOT/FMD/Correction/Background/background.root","RECREATE");
+    TFile fbg(pars->GetPath(pars->GetBackgroundID()),"RECREATE");
     fBackground->Write(AliFMDAnaParameters::GetBackgroundID());
     fbg.Close();
-    TFile feselect("$ALICE_ROOT/FMD/Correction/EventSelectionEfficiency/eventselectionefficiency.root","RECREATE");
+    TFile feselect(pars->GetPath(pars->GetEventSelectionEffID()),"RECREATE");
     fEventSelectionEff->Write(AliFMDAnaParameters::GetEventSelectionEffID());
     feselect.Close();