]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Minor modifications in the code
authorpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jul 2008 10:16:00 +0000 (10:16 +0000)
committerpchrist <pchrist@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 8 Jul 2008 10:16:00 +0000 (10:16 +0000)
PWG2/AliAnalysisTaskProtons.cxx
PWG2/AliAnalysisTaskProtons.h
PWG2/runProtonAnalysis.C

index a0e2cf26640000634d4a4e35002bc751182e8d6d..028c140e176f525892309db25e75be7de9784336 100644 (file)
@@ -1,7 +1,9 @@
 #include "TChain.h"
 #include "TTree.h"
+#include "TString.h"
 #include "TList.h"
 #include "TH2F.h"
+#include "TH1I.h"
 #include "TF1.h"
 #include "TCanvas.h"
 #include "TLorentzVector.h"
@@ -17,7 +19,7 @@
 #include "AliMCEvent.h"
 #include "AliStack.h"
 
-#include "AliProtonAnalysis.h"
+#include "PWG2spectra/SPECTRA/AliProtonAnalysis.h"
 #include "AliAnalysisTaskProtons.h"
 
 // Analysis task creating a the 2d y-p_t spectrum of p and antip
 
 ClassImp(AliAnalysisTaskProtons)
 
-//________________________________________________________________________
-AliAnalysisTaskProtons::AliAnalysisTaskProtons() 
-: AliAnalysisTask(), fESD(0), fAOD(0), fMC(0),fAnalysisType("ESD"), 
-  fList(0), fAnalysis(0), 
-  fElectronFunction(0), fMuonFunction(0),
-  fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
-  fFunctionUsed(kFALSE) { 
+//________________________________________________________________________ 
+AliAnalysisTaskProtons::AliAnalysisTaskProtons()
+  : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"),
+    fList(0), fAnalysis(0),
+    fElectronFunction(0), fMuonFunction(0),
+    fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
+    fFunctionUsed(kFALSE) {
   //Dummy constructor
+                                                                                                   
 }
 
 //________________________________________________________________________
 AliAnalysisTaskProtons::AliAnalysisTaskProtons(const char *name) 
-: AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"), 
+: AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"),
   fList(0), fAnalysis(0), 
   fElectronFunction(0), fMuonFunction(0),
   fPionFunction(0), fKaonFunction(0), fProtonFunction(0),
@@ -60,37 +63,34 @@ void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
   if (!tree) {
     Printf("ERROR: Could not read chain from input slot 0");
   } else {
-    // Disable all branches and enable only the needed ones
-    // The next two lines are different when data produced as AliESDEvent is read
     if(fAnalysisType == "ESD") {
-      // In train mode branches can be disabled at the level of ESD handler (M.G.)
-      // tree->SetBranchStatus("*", kFALSE);
-      tree->SetBranchStatus("*Tracks.*", kTRUE);
-
-      AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+      tree->SetBranchStatus("*", kFALSE);
+      tree->SetBranchStatus("Tracks.*", kTRUE);
       
+      AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+     
       if (!esdH) {
        Printf("ERROR: Could not get ESDInputHandler");
       } else
        fESD = esdH->GetEvent();
     }
     else if(fAnalysisType == "AOD") {
-      AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
-      
-      if (!aodH) {
-       Printf("ERROR: Could not get AODInputHandler");
-      } else
-       fAOD = aodH->GetEvent();
+     AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+     
+     if (!aodH) {
+       Printf("ERROR: Could not get AODInputHandler");
+     } else
+       fAOD = aodH->GetEvent();
     }
     else if(fAnalysisType == "MC") {
-      AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
-      if (!mcH) {
-       Printf("ERROR: Could not retrieve MC event handler");
-      }
-      else
-       fMC = mcH->MCEvent();
+     AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+     if (!mcH) {
+       Printf("ERROR: Could not retrieve MC event handler");
+     }
+     else
+       fMC = mcH->MCEvent();
     }
-    else 
+    else
       Printf("Wrong analysis type: Only ESD, AOD and MC types are allowed!");
   }
 }
@@ -99,15 +99,18 @@ void AliAnalysisTaskProtons::ConnectInputData(Option_t *) {
 void AliAnalysisTaskProtons::CreateOutputObjects() {
   // Create histograms
   // Called once
+  //Prior probabilities
   Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05};
-
+  
+  //proton analysis object
   fAnalysis = new AliProtonAnalysis();
   fAnalysis->InitHistograms(10,-1.0,1.0,30,0.1,3.1);
+
   if(fAnalysisType == "ESD") {
-    //Use of TPConly tracks
+    //Use of TPConly tracks                                                                                                                                                      
     fAnalysis->UseTPCOnly();
 
-    //TPC related cuts
+    //TPC related cuts       
     fAnalysis->SetMinTPCClusters(50);
     fAnalysis->SetMaxChi2PerTPCCluster(3.5);
     fAnalysis->SetMaxCov11(2.0);
@@ -117,11 +120,12 @@ void AliAnalysisTaskProtons::CreateOutputObjects() {
     fAnalysis->SetMaxCov55(2.0);
     fAnalysis->SetMaxSigmaToVertex(2.5);
     fAnalysis->SetTPCRefit();
-    
-    //ITS related cuts - to be used in the case of the analysis of global tracks
-    //fAnalysis->SetMinITSClusters(5);
-    //fAnalysis->SetITSRefit();
+
+    //ITS related cuts - to be used in the case of the analysis of global tracks                                                                                                
+    //fAnalysis->SetMinITSClusters(5);                                                                                                                                          
+    //fAnalysis->SetITSRefit();                                                                                                                                                  
   }
+
   if(fFunctionUsed)
     fAnalysis->SetPriorProbabilityFunctions(fElectronFunction,
                                            fMuonFunction,
@@ -132,9 +136,9 @@ void AliAnalysisTaskProtons::CreateOutputObjects() {
     fAnalysis->SetPriorProbabilities(partFrac);
 
   fList = new TList();
-  fList->Add(fAnalysis->GetProtonYPtHistogram()); 
-  fList->Add(fAnalysis->GetAntiProtonYPtHistogram()); 
-  fList->Add(fAnalysis->GetEventHistogram()); 
+  fList->Add(fAnalysis->GetProtonYPtHistogram());
+  fList->Add(fAnalysis->GetAntiProtonYPtHistogram());
+  fList->Add(fAnalysis->GetEventHistogram());
 }
 
 //________________________________________________________________________
@@ -147,11 +151,11 @@ void AliAnalysisTaskProtons::Exec(Option_t *) {
       Printf("ERROR: fESD not available");
       return;
     }
-  
+
     Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks());
     fAnalysis->Analyze(fESD);
-  }//ESD analysis
-
+  }//ESD analysis              
+  
   else if(fAnalysisType == "AOD") {
     if (!fAOD) {
       Printf("ERROR: fAOD not available");
@@ -160,14 +164,14 @@ void AliAnalysisTaskProtons::Exec(Option_t *) {
     
     Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks());
     fAnalysis->Analyze(fAOD);
-  }//AOD analysis
-
+  }//AOD analysis                                                                                                                                                                
+  
   else if(fAnalysisType == "MC") {
     if (!fMC) {
       Printf("ERROR: Could not retrieve MC event");
       return;
     }
-    
+
     AliStack* stack = fMC->Stack();
     if (!stack) {
       Printf("ERROR: Could not retrieve the stack");
@@ -175,7 +179,7 @@ void AliAnalysisTaskProtons::Exec(Option_t *) {
     }
     Printf("Proton MC analysis task: There are %d primaries in this event", stack->GetNprimary());
     fAnalysis->Analyze(stack);
-  }//MC analysis
+  }//MC analysis                      
 
   // Post output data.
   PostData(0, fList);
@@ -195,12 +199,12 @@ void AliAnalysisTaskProtons::Terminate(Option_t *) {
   TH2F *fHistYPtProtons = (TH2F *)fList->At(0);
   TH2F *fHistYPtAntiProtons = (TH2F *)fList->At(1);
     
-  TCanvas *c2 = new TCanvas("c2","p-\bar{p}",200,0,800,400);
-  c2->SetFillColor(10); c2->SetHighLightColor(10); c2->Divide(2,1);
+  TCanvas *c1 = new TCanvas("c1","p-\bar{p}",200,0,800,400);
+  c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,1);
 
-  c2->cd(1)->SetLeftMargin(0.15); c2->cd(1)->SetBottomMargin(0.15);  
+  c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetBottomMargin(0.15);  
   if (fHistYPtProtons) fHistYPtProtons->DrawCopy("colz");
-  c2->cd(2)->SetLeftMargin(0.15); c2->cd(2)->SetBottomMargin(0.15);  
+  c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetBottomMargin(0.15);  
   if (fHistYPtAntiProtons) fHistYPtAntiProtons->DrawCopy("colz");
 }
 
index 050950f7e727827c8634f7cfcae4f72c3eb0cf4d..73a4baacf0844c3de17a6c9fd5936e7a3f404183 100644 (file)
@@ -3,7 +3,6 @@
 
 // Analysis task creating a the 2d y-p_t spectrum of p and antip
 // Author: Panos Cristakoglou
-
 class TString;
 class TList;
 class AliESDEvent;
@@ -26,11 +25,11 @@ class AliAnalysisTaskProtons : public AliAnalysisTask {
   virtual void   Terminate(Option_t *);
 
   void SetType(const char* type) {fAnalysisType = type;}
-  void SetPriorProbabilityFunctions(TF1 *felectrons, 
-                                   TF1 *fmuons,
-                                   TF1 *fpions,
-                                   TF1 *fkaons,
-                                   TF1 *fprotons) {
+  void SetPriorProbabilityFunctions(TF1 *felectrons,
+                                    TF1 *fmuons,
+                                    TF1 *fpions,
+                                    TF1 *fkaons,
+                                    TF1 *fprotons) {
     fFunctionUsed = kTRUE;
     fElectronFunction = felectrons;
     fMuonFunction = fmuons;
@@ -40,25 +39,26 @@ class AliAnalysisTaskProtons : public AliAnalysisTask {
   }
   
  private:
-  AliESDEvent *fESD;    //ESD object
-  AliAODEvent *fAOD;    //AOD object
-  AliMCEvent  *fMC;     //MC object
-  TString fAnalysisType;//"ESD", "AOD" or "MC"
-
-  TList  *fList; //TList output object
-
-  AliProtonAnalysis *fAnalysis; //analysis object
-
-  TF1 *fElectronFunction; //TF1 for e
-  TF1 *fMuonFunction; //TF1 for mu
-  TF1 *fPionFunction; //TF1 for pi
-  TF1 *fKaonFunction; //TF1 for K
-  TF1 *fProtonFunction; //TF1 for p
-
-  Bool_t fFunctionUsed; //kTRUE if Functions are used
+  AliESDEvent *fESD;    //ESD object                                                                                 
+  AliAODEvent *fAOD;    //AOD object                                                                                  
+  AliMCEvent  *fMC;     //MC object                                                                                   
+  
+  TString fAnalysisType;//"ESD", "AOD" or "MC"                                                                        
 
-  AliAnalysisTaskProtons(const AliAnalysisTaskProtons&); // not implemented
-  AliAnalysisTaskProtons& operator=(const AliAnalysisTaskProtons&); // not implemented
+  TList  *fList; //TList output object                                                                                
+  
+  AliProtonAnalysis *fAnalysis; //analysis object                                                                     
+  
+  TF1 *fElectronFunction; //TF1 for e                                                                                 
+  TF1 *fMuonFunction; //TF1 for mu                                                                                    
+  TF1 *fPionFunction; //TF1 for pi                                                                                    
+  TF1 *fKaonFunction; //TF1 for K                                                                                     
+  TF1 *fProtonFunction; //TF1 for p                                                                                   
+  
+  Bool_t fFunctionUsed; //kTRUE if Functions are used                                                                 
+  
+  AliAnalysisTaskProtons(const AliAnalysisTaskProtons&); // not implemented                                           
+  AliAnalysisTaskProtons& operator=(const AliAnalysisTaskProtons&); // not implemented                                 
   
   ClassDef(AliAnalysisTaskProtons, 1); // example of analysis
 };
index c5b1098e1827484d9d35f79555014cb519abe797..d0fea9d7ed14387201ed0aa98c128843490f1746 100644 (file)
@@ -5,8 +5,10 @@ void runProtonAnalysis() {
   //runLocal();
   //runInteractive();
   //runBatch();
-  runProof("/PWG0/COMMON/run30000X_10TeV_0.5T",200000);
-
+  
+  runProof("ESD",200000,"/PWG0/COMMON/run30000X_10TeV_0.5T"); //use data sets
+  //runProof("ESD",200); //use ascii files
+  
   timer.Stop();
   timer.Print();
 }
@@ -307,9 +309,14 @@ void runBatch() {
 }
 
 //_________________________________________________//
-void runProof(const char* dataset = 0x0, Int_t stats = 0) {
+void runProof(const char* mode = "ESD", Int_t stats = 0, const char* dataset = 0x0) {
   TStopwatch timer;
   timer.Start();
+  
+  TString smode = mode;
+  TString outputFilename = "Protons."; outputFilename += mode;
+  outputFilename += ".root";
+
   printf("****** Connect to PROOF *******\n");
   TProof::Open("proof://lxb6046.cern.ch"); 
   gProof->SetParallel();
@@ -334,10 +341,15 @@ void runProof(const char* dataset = 0x0, Int_t stats = 0) {
   // Make the analysis manager
   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
   AliVEventHandler* esdH = new AliESDInputHandler;
-  mgr->SetInputEventHandler(esdH);  
+  mgr->SetInputEventHandler(esdH);
+  if(smode == "MC") {
+    AliMCEventHandler *mc = new AliMCEventHandler();
+    mgr->SetMCtruthEventHandler(mc);
+  }
   //____________________________________________//
   // 1st Proton task
   AliAnalysisTaskProtons *taskProtons = new AliAnalysisTaskProtons("TaskProtons");
+  taskProtons->SetType(mode);
   /*TFile *f = TFile::Open("PriorProb/PriorProbabilities.root ");
   TF1 *fitElectrons = (TF1 *)f->Get("fitElectrons");
   TF1 *fitMuons = (TF1 *)f->Get("fitMuons");
@@ -355,9 +367,9 @@ void runProof(const char* dataset = 0x0, Int_t stats = 0) {
   AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
                                                           TChain::Class(),AliAnalysisManager::kInputContainer);
   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1", 
-                                                           TList::Class(),AliAnalysisManager::kOutputCont
-                                                           "Protons.ESD.root");
-  
+                                                           TList::Class(),AliAnalysisManager::kOutputContainer,
+                                                           outputFilename.Data());
+
   //____________________________________________//
   mgr->ConnectInput(taskProtons,0,cinput1);
   mgr->ConnectOutput(taskProtons,0,coutput1);