Event Mixing for Triggered BF analysis
authormiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 May 2012 12:16:18 +0000 (12:16 +0000)
committermiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 May 2012 12:16:18 +0000 (12:16 +0000)
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskTriggeredBF.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskTriggeredBF.h
PWGCF/EBYE/BalanceFunctions/AliBalanceTriggered.cxx
PWGCF/EBYE/BalanceFunctions/AliBalanceTriggered.h
PWGCF/EBYE/macros/AddTaskBalanceTriggered.C

index 6da8866..c1c6153 100755 (executable)
@@ -50,9 +50,11 @@ AliAnalysisTaskTriggeredBF::AliAnalysisTaskTriggeredBF(const char *name)
   fRunMixing(kFALSE),\r
   fMixingTracks(50000),\r
   fMixedBalance(0),\r
+  fPoolMgr(0),\r
   fList(0),\r
   fListTriggeredBF(0),\r
   fListTriggeredBFS(0),\r
+  fListTriggeredBFM(0),\r
   fHistListPIDQA(0),\r
   fHistEventStats(0),\r
   fHistCentStats(0),\r
@@ -103,6 +105,7 @@ AliAnalysisTaskTriggeredBF::AliAnalysisTaskTriggeredBF(const char *name)
   DefineOutput(1, TList::Class());\r
   DefineOutput(2, TList::Class());\r
   DefineOutput(3, TList::Class());\r
+  DefineOutput(4, TList::Class());\r
 }\r
 \r
 //________________________________________________________________________\r
@@ -271,15 +274,15 @@ void AliAnalysisTaskTriggeredBF::UserCreateOutputObjects() {
   Int_t trackDepth = fMixingTracks; \r
   Int_t poolsize   = 1000;  // Maximum number of events, ignored in the present implemented of AliEventPoolManager\r
    \r
-  Double_t centralityBins[] = {0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,90,100}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
-  Double_t* centbins = centralityBins;\r
-  Int_t nCentralityBins  = 26;\r
-\r
+  Double_t centralityBins[] = {0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,15.,20.,25.,30.,35.,40.,45.,50.,55.,60.,65.,70.,75.,80.,90.,100.}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
+  Double_t* centbins        = centralityBins;\r
+  Int_t nCentralityBins     = sizeof(centralityBins) / sizeof(Double_t) - 1;\r
   \r
   // bins for second buffer are shifted by 100 cm\r
-  Double_t vertexBins[] = {-10, -7, -5, -3, -1, 1, 3, 5, 7, 10}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
-  Double_t* vtxbins = vertexBins;\r
-  Int_t nVertexBins  = 9;\r
+  Double_t vertexBins[] = {-10., -7., -5., -3., -1., 1., 3., 5., 7., 10.}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
+  Double_t* vtxbins     = vertexBins;\r
+  Int_t nVertexBins     = sizeof(vertexBins) / sizeof(Double_t) - 1;\r
+  cout<<nCentralityBins<<" "<<nVertexBins<<endl;\r
 \r
   fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins);\r
 \r
@@ -352,7 +355,7 @@ void AliAnalysisTaskTriggeredBF::UserExec(Option_t *) {
          {\r
            \r
            Int_t nMix = pool->GetCurrentNEvents();\r
-           cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;\r
+           //cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;\r
            \r
            //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2);\r
            //((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());\r
@@ -363,17 +366,22 @@ void AliAnalysisTaskTriggeredBF::UserExec(Option_t *) {
            for (Int_t jMix=0; jMix<nMix; jMix++) \r
              {\r
                TObjArray* tracksMixed = pool->GetEvent(jMix);\r
-               fMixedBalance->FillBalance(fCentrality,tracksMixed); //NOW ONLY THE MIXED EVENT ITSELF IS FILLED --> DO ONE TRACK OF MAIN AND ONE OF MIXED (LIKE UEHISTOGRAMS!!!!)\r
+               fMixedBalance->FillBalance(fCentrality,tracksMain,tracksMixed); \r
              }\r
          }\r
-      }\r
+\r
+       // Update the Event pool\r
+       pool->UpdatePool(tracksMain);\r
+       //pool->PrintInfo();\r
+       \r
+      }//run mixing\r
     \r
     // calculate balance function\r
-    fBalance->FillBalance(fCentrality,tracksMain);//,chargeVectorMixed); // here comes the mixing... in some time\r
+    fBalance->FillBalance(fCentrality,tracksMain,NULL);\r
     \r
     // calculate shuffled balance function\r
     if(fRunShuffling && tracksShuffled != NULL) {\r
-       fShuffledBalance->FillBalance(fCentrality,tracksShuffled);\r
+      fShuffledBalance->FillBalance(fCentrality,tracksShuffled,NULL);\r
     }\r
     \r
   }//AOD analysis\r
index cceef25..a335d0d 100755 (executable)
@@ -207,7 +207,6 @@ class AliBFBasicParticle : public AliVParticle
     virtual Double_t Y()          const { AliFatal("Not implemented"); return 0; }\r
     \r
     virtual Short_t Charge()      const { return fCharge; }\r
-    virtual Short_t SetCharge(Short_t charge)   { fCharge = charge; }\r
     virtual Int_t   GetLabel()    const { AliFatal("Not implemented"); return 0; }\r
     // PID\r
     virtual Int_t   PdgCode()     const { AliFatal("Not implemented"); return 0; }      \r
index 3a1dbe6..4aa0661 100644 (file)
@@ -245,7 +245,7 @@ void AliBalanceTriggered::InitHistograms() {
 }
 
 //____________________________________________________________________//
-void AliBalanceTriggered::FillBalance(Float_t fCentrality,TObjArray *particles) {
+void AliBalanceTriggered::FillBalance(Float_t fCentrality,TObjArray *particles, TObjArray *particlesMixed) {
   // Calculates the balance function
 
  
@@ -256,54 +256,87 @@ void AliBalanceTriggered::FillBalance(Float_t fCentrality,TObjArray *particles)
     InitHistograms();
   }
 
-  Int_t gNtrack = particles->GetEntriesFast();
   Double_t trackVarsSingle[nTrackVarsSingle];
   Double_t trackVarsPair[nTrackVarsPair];
 
+  if (!particles){
+    AliWarning("particles TObjArray is NULL pointer --> return");
+    return;
+  }
+  
+  // define end of particle loops
+  Int_t iMax = particles->GetEntriesFast();
+  Int_t jMax = iMax;
+  if (particlesMixed)
+    jMax = particlesMixed->GetEntriesFast();
+
+  // Eta() is extremely time consuming, therefore cache it for the inner loop here:
+  TObjArray* particlesSecond = (particlesMixed) ? particlesMixed : particles;
+
+  TArrayF secondEta(jMax);
+  TArrayF secondPhi(jMax);
+  TArrayF secondPt(jMax);
+
+  for (Int_t i=0; i<jMax; i++){
+    secondEta[i] = ((AliVParticle*) particlesSecond->At(i))->Eta();
+    secondPhi[i] = ((AliVParticle*) particlesSecond->At(i))->Phi();
+    secondPt[i]  = ((AliVParticle*) particlesSecond->At(i))->Pt();
+  }
+  
   // 1st particle loop
-  for(Int_t i = 0; i < gNtrack;i++){
-
-    AliVParticle* firstParticle = (AliVParticle*) particles->At(i);
-
-    Short_t  charge = (Short_t) firstParticle->Charge();
-    trackVarsSingle[0]    =  firstParticle->Eta(); //eta
-    trackVarsSingle[1]    =  firstParticle->Phi(); //phi
-    trackVarsSingle[2]    =  firstParticle->Pt();  //pt trigger
-    trackVarsSingle[3]    =  fCentrality;          //centrality (really as variable here????)
-    
-    //fill single particle histograms
-    if(charge > 0)  fHistP->Fill(trackVarsSingle,0,1.); 
-    else            fHistN->Fill(trackVarsSingle,0,1.); 
-
-    // 2nd particle loop (only for j < i for non double counting in the same pT region)
-    // --> SAME pT region for trigger and assoc: NO double counting with this
-    // --> DIFF pT region for trigger and assoc: Missing assoc. particles with j > i to a trigger i 
-    //                          --> can be handled afterwards by using assoc. as trigger as well ?!
+  for (Int_t i=0; i<iMax; i++)
+    {
+      
+      AliVParticle* firstParticle = (AliVParticle*) particles->At(i);
 
-    for(Int_t j = 0; j < i; j++) {
+      // some optimization
+      Float_t firstEta = firstParticle->Eta();
+      Float_t firstPhi = firstParticle->Phi();
+      Float_t firstPt  = firstParticle->Pt();
 
-      AliVParticle* secondParticle = (AliVParticle*) particles->At(j);
       
-      Short_t charge2 = (Short_t) secondParticle->Charge();
-      trackVarsPair[0]    =  firstParticle->Eta() - secondParticle->Eta();  // delta eta
-      trackVarsPair[1]    =  firstParticle->Phi() - secondParticle->Phi();  // delta phi
-      if (trackVarsPair[1] > 180)   // delta phi between -180 and 180 
-       trackVarsPair[1] -= 360;
-      if (trackVarsPair[1] <  - 180) 
-       trackVarsPair[1] += 360;
-      trackVarsPair[2]    =  firstParticle->Pt();  // pt
-      trackVarsPair[3]    =  secondParticle->Pt();  // pt trigger
-      trackVarsPair[4]    =  fCentrality;             // centrality
-
-      if( charge > 0 && charge2 < 0)  fHistPN->Fill(trackVarsPair,0,1.); 
-      else if( charge < 0 && charge2 > 0)  fHistNP->Fill(trackVarsPair,0,1.); 
-      else if( charge > 0 && charge2 > 0)  fHistPP->Fill(trackVarsPair,0,1.); 
-      else if( charge < 0 && charge2 < 0)  fHistNN->Fill(trackVarsPair,0,1.); 
-      else AliWarning("Wrong charge combination!");
+      Short_t  charge = (Short_t) firstParticle->Charge();
+      trackVarsSingle[0]    =  firstEta;    //eta
+      trackVarsSingle[1]    =  firstPhi;    //phi
+      trackVarsSingle[2]    =  firstPt;     //pt trigger
+      trackVarsSingle[3]    =  fCentrality; //centrality 
+      
+      //fill single particle histograms
+      if(charge > 0)  fHistP->Fill(trackVarsSingle,0,1.); 
+      else            fHistN->Fill(trackVarsSingle,0,1.);  
+
       
-    }//end of 2nd particle loop
-  }//end of 1st particle loop
+      // 2nd particle loop (only for j < i for non double counting in the same pT region)
+      // --> SAME pT region for trigger and assoc: NO double counting with this
+      // --> DIFF pT region for trigger and assoc: Missing assoc. particles with j > i to a trigger i 
+      //                          --> can be handled afterwards by using assoc. as trigger as well ?!     
+      for(Int_t j = 0; j < i; j++) {   // or go to full here (everything prepared)?
+       
+       if (particlesMixed && jMax < i)  // if the mixed track number is smaller than the main event one (could be done better if one loops over all tracks)
+         break;
+
+       AliVParticle* secondParticle = (AliVParticle*) particlesSecond->At(j);
+
+       Short_t charge2 = (Short_t) secondParticle->Charge();
+       trackVarsPair[0]    =  firstEta - secondEta[j];  // delta eta
+       trackVarsPair[1]    =  firstPhi = secondPhi[j];  // delta phi
+       if (trackVarsPair[1] > 180)   // delta phi between -180 and 180 
+         trackVarsPair[1] -= 360;
+       if (trackVarsPair[1] <  - 180) 
+         trackVarsPair[1] += 360;
+       
+       trackVarsPair[2]    =  firstPt;      // pt trigger
+       trackVarsPair[3]    =  secondPt[j];  // pt
+       trackVarsPair[4]    =  fCentrality;  // centrality
+       
+       if( charge > 0 && charge2 < 0)  fHistPN->Fill(trackVarsPair,0,1.); 
+       else if( charge < 0 && charge2 > 0)  fHistNP->Fill(trackVarsPair,0,1.); 
+       else if( charge > 0 && charge2 > 0)  fHistPP->Fill(trackVarsPair,0,1.); 
+       else if( charge < 0 && charge2 < 0)  fHistNN->Fill(trackVarsPair,0,1.); 
+       else AliWarning("Wrong charge combination!");
+       
+      }//end of 2nd particle loop
+    }//end of 1st particle loop
 }  
 
 
index dda88b4..f84204d 100644 (file)
@@ -55,7 +55,7 @@ class AliBalanceTriggered : public TObject {
   AliTHn *GetHistNnn() { return fHistNN;}
 
   // Fill balance function histograms
-  void FillBalance(Float_t fCentrality,TObjArray* particles);
+  void FillBalance(Float_t fCentrality,TObjArray* particles,TObjArray* particlesMixed);
  
   // Get the balance function histogram 
   TH1D *GetBalanceFunctionHistogram1D(Int_t var, Double_t pTMinTrigger, Double_t pTMaxTrigger, Double_t pTMin, Double_t pTMax, Double_t centrMin, Double_t centrMax);
index 5ba46a0..5d2070d 100644 (file)
@@ -8,7 +8,7 @@ Double_t gMinAcceptedProbability = 0.7;
 \r
 //_________________________________________________________//\r
 AliAnalysisTaskTriggeredBF *AddTaskBalanceTriggered(Double_t centrMin=0.,\r
-                                                Double_t centrMax=100.,\r
+                                                Double_t centrMax=80.,\r
                                                 Bool_t gRunShuffling=kFALSE,\r
                                                 Bool_t gRunMixing=kFALSE,\r
                                                 TString centralityEstimator="V0M",\r
@@ -97,7 +97,6 @@ AliAnalysisTaskTriggeredBF *AddTaskBalanceTriggered(Double_t centrMin=0.,
       bfm = new AliBalanceTriggered();\r
       bfm->SetAnalysisLevel(analysisType);\r
       bfm->InitHistograms();\r
-      bfm->SetMixingTracks(50000)\r
     }\r
   }\r
   else{\r
@@ -110,7 +109,10 @@ AliAnalysisTaskTriggeredBF *AddTaskBalanceTriggered(Double_t centrMin=0.,
   AliAnalysisTaskTriggeredBF *taskTriggeredBF = new AliAnalysisTaskTriggeredBF("TaskTriggeredBF");\r
   taskTriggeredBF->SetAnalysisObject(bf);\r
   if(gRunShuffling) taskTriggeredBF->SetShufflingObject(bfs);\r
-  if(gRunMixing) taskTriggeredBF->SetMixingObject(bfm);\r
+  if(gRunMixing){\r
+    taskTriggeredBF->SetMixingObject(bfm);\r
+    taskTriggeredBF->SetMixingTracks(50000);\r
+  }\r
 \r
   taskTriggeredBF->SetCentralityPercentileRange(centrMin,centrMax);\r
   if(analysisType == "AOD") {\r