a macro with TPC,ITS, ITSSPD vertex, global vertex and v0's
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventPoolOTF.cxx
index a4b8fdc..f9aaece 100644 (file)
 #include "AliEventTagCuts.h"
 #include "AliTagAnalysis.h"
 
+#include <TMath.h>
+#include <TChain.h>
+#include <TGridResult.h>
+
 ClassImp(AliEventPoolOTF)
 
 
@@ -41,31 +45,41 @@ AliEventPoolOTF::AliEventPoolOTF():
     fLHCCuts(0),
     fDetectorCuts(0),
     fEventCuts(0),
+    fGridTags(0),
+    fChain(0),
     fTagDirectory(0),
-    fMultMin(0),
-    fMultMax(0),
-    fMultStep(0),
-    fMultiplicity(),
-    fBinNumber(0)
+    fValueMin(),
+    fValueMax(),
+    fValueStep(),
+    fValue(),    
+    fBinNumber(0),
+    fNoMore(0)
+
 {
   // Default constructor
+    InitArrays();
 }
 
 AliEventPoolOTF::AliEventPoolOTF(const char* name, const char* title):
     AliVEventPool(name, title),
-    fTagAnalysis(new AliTagAnalysis("AOD")),
+    fTagAnalysis(new AliTagAnalysis(title)),
     fRunCuts(new AliRunTagCuts()),
     fLHCCuts(new AliLHCTagCuts()),
     fDetectorCuts(new AliDetectorTagCuts()),
     fEventCuts(new AliEventTagCuts()),
+    fGridTags(0),
+    fChain(0),
     fTagDirectory("."),
-    fMultMin(0),
-    fMultMax(0),
-    fMultStep(0),
-    fMultiplicity(),
-    fBinNumber(0)
+    fValueMin(),
+    fValueMax(),
+    fValueStep(),
+    fValue(),    
+    fBinNumber(0),
+    fNoMore(0)
+
 {
   // Constructor
+    InitArrays();
 }
 
 
@@ -76,14 +90,18 @@ AliEventPoolOTF::AliEventPoolOTF(const AliEventPoolOTF& obj):
     fLHCCuts(0),
     fDetectorCuts(0),
     fEventCuts(0),
+    fGridTags(0),
+    fChain(0),
     fTagDirectory(0),
-    fMultMin(0),
-    fMultMax(0),
-    fMultStep(0),
-    fMultiplicity(),
-    fBinNumber(0)
+    fValueMin(),
+    fValueMax(),
+    fValueStep(),
+    fValue(),    
+    fBinNumber(0),
+    fNoMore(0)
 {
     // Copy constructor
+    InitArrays();
 }
 
 AliEventPoolOTF& AliEventPoolOTF::operator=(const AliEventPoolOTF& other)
@@ -97,23 +115,59 @@ AliEventPoolOTF& AliEventPoolOTF::operator=(const AliEventPoolOTF& other)
 void AliEventPoolOTF::Init()
 {
     //
-    fTagAnalysis->ChainLocalTags(fTagDirectory);
-    fMultiplicity = fMultMin;
+    if (!fGridTags) {
+       fTagAnalysis->ChainLocalTags(fTagDirectory);
+    } else {
+       fTagAnalysis->ChainGridTags(fGridTags);
+    }
+    
+    
+    for (Int_t i = 0; i < 4; i++) fValue[i] = fValueMin[i];    
 }
 
 TChain* AliEventPoolOTF::GetNextChain()
 {
     //
-    TChain* chain = 0;
+    if (fChain) {
+       delete fChain;
+       fChain = 0;
+    }
+
     fBinNumber++;
-    Int_t mmax = fMultiplicity + fMultStep - 1;
-    if (mmax > fMultMax) {
+    if (fNoMore) {
        return 0;
     } else {
-       fEventCuts->SetMultiplicityRange(fMultiplicity, mmax);
-       chain = fTagAnalysis->QueryTags(fRunCuts, fLHCCuts, fDetectorCuts, fEventCuts);
-       fMultiplicity += fMultStep;
-       return chain;
+    printf("Current bin (lower) %13.3f %13.3f %13.3f %13.3f %13.3f \n", fValue[kMultiplicity], fValue[kZVertex], fValue[kEventPlane],fValue[kLeadingParticleEta],fValue[kLeadingParticlePhi]);
+    printf("Current bin (upper) %13.3f %13.3f %13.3f %13.3f %13.3f \n", fValue[kMultiplicity] + fValueStep[kMultiplicity], 
+          fValue[kZVertex]      + fValueStep[kZVertex], 
+          fValue[kEventPlane]   + fValueStep[kEventPlane],
+          fValue[kLeadingParticleEta]   + fValueStep[kLeadingParticleEta],
+           fValue[kLeadingParticlePhi]   + fValueStep[kLeadingParticlePhi]
+    
+          );
+
+       fEventCuts->SetMultiplicityRange(Int_t(fValue[kMultiplicity]) , Int_t(fValue[kMultiplicity] + fValueStep[kMultiplicity]));
+       fEventCuts->SetPrimaryVertexZRange(fValue[kZVertex] , fValue[kZVertex] + fValueStep[kZVertex]);
+        fEventCuts->SetEtaLeadingParticleRange(fValue[kLeadingParticleEta] , fValue[kLeadingParticleEta] + fValueStep[kLeadingParticleEta]);
+        fEventCuts->SetPhiLeadingParticleRange(fValue[kLeadingParticlePhi] , fValue[kLeadingParticlePhi] + fValueStep[kLeadingParticlePhi]);
+        fEventCuts->SetEventPlaneAngleRange(fValue[kEventPlane] , fValue[kEventPlane] + fValueStep[kEventPlane]);
+    
+       fChain = fTagAnalysis->QueryTags(fRunCuts, fLHCCuts, fDetectorCuts, fEventCuts);
+//
+//      Next bin 
+//
+       for (Int_t i = 5; i >= 0; i--) 
+       {
+           fValue[i] += fValueStep[i];
+           if (i > 0  && fValue[i] >= fValueMax[i]) {
+               fValue[i] = fValueMin[i];
+           } else if (i == 0 && fValue[i] >= fValueMax[i]) {
+               fNoMore = kTRUE;
+           } else {
+               break;
+           }
+       }
+       return fChain;
     }
 }
 
@@ -125,6 +179,20 @@ void  AliEventPoolOTF::GetCurrentBin(Float_t* /*bin*/)
 Int_t AliEventPoolOTF::GetDimension()
 {
     //
-    return (1);
+    return (5);
 }
 
+void AliEventPoolOTF::InitArrays()
+{
+    // Initializes the pool axis
+    
+    SetMultiplicityBinning(0, 20000, 20000);
+    SetZVertexBinning(-1000., 1000., 2000.);
+    SetEventPlaneBinning(-1000., 1000., 2000.);
+    SetEventPlaneBinning(-1000., 1000., 2000.);
+    SetLeadingParticleEtaBinning(-13.0, 13.0, 26.); 
+    SetLeadingParticlePhiBinning(-13.0, 13.0, 26.);   
+    for (Int_t i = 0; i < 4; i++) fValue[i] = fValueMin[i];
+}
+
+