]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
implement event mixing as for real analysis (MW)
authormiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Apr 2013 14:37:57 +0000 (14:37 +0000)
committermiweber <miweber@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Apr 2013 14:37:57 +0000 (14:37 +0000)
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskToyModel.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskToyModel.h

index 0cf9b578d5b297b9e45cb57d0877968de1148d78..65e0cc390a1f0addf88dc3dad7a86ef3ac41360b 100755 (executable)
@@ -15,6 +15,8 @@
 #include "AliAnalysisManager.h"\r
 #include "AliLog.h"\r
 \r
+#include "AliEventPoolManager.h"           \r
+\r
 #include "AliAnalysisTaskToyModel.h"\r
 #include "AliBalance.h"\r
 #include "AliBalancePsi.h"\r
@@ -35,7 +37,7 @@ AliAnalysisTaskToyModel::AliAnalysisTaskToyModel()
   fUseDebug(kFALSE),\r
   fBalance(0),\r
   fRunShuffling(kFALSE), fShuffledBalance(0),\r
-  fRunMixing(kFALSE), fMixedBalance(0),\r
+  fRunMixing(kFALSE), fMixedBalance(0), fPoolMgr(0),\r
   fList(0), fListBF(0), fListBFS(0), fListBFM(0),\r
   fHistEventStats(0),\r
   fHistNumberOfAcceptedParticles(0),\r
@@ -407,6 +409,50 @@ void AliAnalysisTaskToyModel::CreateOutputObjects() {
     fListBFM->Add(fMixedBalance->GetHistNnp());\r
   }\r
 \r
+  // Event Mixing\r
+  if(fRunMixing){\r
+    Int_t fMixingTracks = 2000;\r
+    Int_t trackDepth = fMixingTracks; \r
+    Int_t poolsize   = 1000;  // Maximum number of events, ignored in the present implemented of AliEventPoolManager\r
+    \r
+    // centrality bins\r
+    Double_t centralityBins[] = {0.,1.,2.,3.,4.,5.,7.,10.,20.,30.,40.,50.,60.,70.,80.,100.}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
+    Double_t* centbins        = centralityBins;\r
+    Int_t nCentralityBins     = sizeof(centralityBins) / sizeof(Double_t) - 1;\r
+\r
+    // multiplicity bins\r
+    Double_t multiplicityBins[] = {0,10,20,30,40,50,60,70,80,100,100000}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
+    Double_t* multbins        = multiplicityBins;\r
+    Int_t nMultiplicityBins     = sizeof(multiplicityBins) / sizeof(Double_t) - 1;\r
+    \r
+    // Zvtx bins\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
+    \r
+    // Event plane angle (Psi) bins\r
+    Double_t psiBins[] = {0.,45.,135.,215.,305.,360.}; // SHOULD BE DEDUCED FROM CREATED ALITHN!!!\r
+    Double_t* psibins     = psiBins;\r
+    Int_t nPsiBins     = sizeof(psiBins) / sizeof(Double_t) - 1;\r
+    \r
+    // // run the event mixing also in bins of event plane (statistics!)\r
+    // if(fRunMixingEventPlane){\r
+    //   if(fEventClass=="Multiplicity"){\r
+    //         fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins, nPsiBins, psibins);\r
+    //   }\r
+    //   else{\r
+    //         fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins, nPsiBins, psibins);\r
+    //   }\r
+    // }\r
+    // else{\r
+    //if(fEventClass=="Multiplicity"){\r
+    fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins);\r
+    //}\r
+    //else{\r
+    //fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins);\r
+    //}\r
+  }\r
+\r
   TH1::AddDirectory(oldStatus);\r
 }\r
 \r
@@ -461,14 +507,6 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
     fAzimuthalAngleProtons->SetParameter(5,fPentangularFlowProtons);\r
   }\r
 \r
-  //TObjArray for the accepted particles\r
-  TObjArray *tracksMain = new TObjArray();\r
-  tracksMain->SetOwner(kTRUE);\r
-  TObjArray *tracksMixing = 0x0;\r
-  if(fRunMixing) {\r
-    tracksMixing = new TObjArray();\r
-    tracksMixing->SetOwner(kTRUE);\r
-  }\r
 \r
   for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {\r
     // vector holding the charges/kinematics of all tracks (charge,y,eta,phi,p0,p1,p2,pt,E)\r
@@ -478,6 +516,17 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
     //chargeVectorShuffle[i] = new vector<Double_t>;\r
     //chargeVector[i]        = new vector<Double_t>;\r
     //}\r
+\r
+    // TObjArray for the accepted particles \r
+    // (has to be done here, otherwise mxing with event pool does not work, overwriting pointers!)\r
+    TObjArray *tracksMain = new TObjArray();\r
+    tracksMain->SetOwner(kTRUE);\r
+    TObjArray *tracksMixing = 0x0;\r
+    if(fRunMixing) {\r
+      tracksMixing = new TObjArray();\r
+      tracksMixing->SetOwner(kTRUE);\r
+    }\r
+\r
     tracksMain->Clear();\r
     if(fRunMixing) tracksMixing->Clear();\r
     \r
@@ -798,10 +847,65 @@ void AliAnalysisTaskToyModel::Run(Int_t nEvents) {
     fHistNumberOfAcceptedParticles->Fill(gNumberOfAcceptedParticles);\r
     fHistReactionPlane->Fill(fReactionPlane);\r
 \r
+    // Event mixing \r
+    if (fRunMixing)\r
+      {\r
+       // 1. First get an event pool corresponding in mult (cent) and\r
+       //    zvertex to the current event. Once initialized, the pool\r
+       //    should contain nMix (reduced) events. This routine does not\r
+       //    pre-scan the chain. The first several events of every chain\r
+       //    will be skipped until the needed pools are filled to the\r
+       //    specified depth. If the pool categories are not too rare, this\r
+       //    should not be a problem. If they are rare, you could lose`\r
+       //    statistics.\r
+       \r
+       // 2. Collect the whole pool's content of tracks into one TObjArray\r
+       //    (bgTracks), which is effectively a single background super-event.\r
+       \r
+       // 3. The reduced and bgTracks arrays must both be passed into\r
+       //    FillCorrelations(). Also nMix should be passed in, so a weight\r
+       //    of 1./nMix can be applied.\r
+       \r
+       AliEventPool* pool = fPoolMgr->GetEventPool(1., 0.,fReactionPlane);\r
+      \r
+       if (!pool){\r
+         AliFatal(Form("No pool found for centrality = %f, zVtx = %f, psi = %f", 1, 0,fReactionPlane));\r
+       }\r
+       else{\r
+         \r
+         //pool->SetDebug(1);\r
+         \r
+         if (pool->IsReady() || pool->NTracksInPool() > 50000 / 10 || pool->GetCurrentNEvents() >= 5){ \r
+           \r
+           \r
+           Int_t nMix = pool->GetCurrentNEvents();\r
+           //cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << ", tracks in this event = "<<gNumberOfAcceptedParticles <<", event Plane = "<<fReactionPlane<<endl;\r
+           \r
+           //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2);\r
+           //((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());\r
+           //if (pool->IsReady())\r
+           //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3);\r
+           \r
+           // Fill mixed-event histos here  \r
+           for (Int_t jMix=0; jMix<nMix; jMix++) \r
+             {\r
+               TObjArray* tracksMixed = pool->GetEvent(jMix);\r
+               fMixedBalance->CalculateBalance(fReactionPlane,tracksMain,tracksMixed,1,1.,0.);\r
+             }\r
+         }\r
+         \r
+         // Update the Event pool\r
+         pool->UpdatePool(tracksMain);\r
+         //pool->PrintInfo();\r
+         \r
+       }//pool NULL check  \r
+      }//run mixing\r
+    \r
     //Calculate the balance function\r
     fBalance->CalculateBalance(fReactionPlane,tracksMain,NULL,1,1.,0.);\r
-    if(fRunMixing)\r
-      fMixedBalance->CalculateBalance(fReactionPlane,tracksMixing,NULL,1,1.,0.);\r
+    //if(fRunMixing)\r
+    //  fMixedBalance->CalculateBalance(fReactionPlane,tracksMixing,NULL,1,1.,0.);          \r
+\r
   }//event loop\r
 }      \r
 \r
index 3ef10297709cdf647f6a0856b45c7854fdb77992..3c9d715c9235c512b2b1168b3022ff2c81c1b9dc 100755 (executable)
@@ -12,6 +12,7 @@ class TH3F;
 class TF1;\r
 \r
 class AliBalancePsi;\r
+class AliEventPoolManager;\r
 \r
 class AliAnalysisTaskToyModel : public TObject {\r
  public:\r
@@ -154,6 +155,7 @@ class AliAnalysisTaskToyModel : public TObject {
   AliBalancePsi *fShuffledBalance; //BF object (shuffled)\r
   Bool_t fRunMixing;//run mixing or not\r
   AliBalancePsi *fMixedBalance; //BF object (mixed)\r
+  AliEventPoolManager*     fPoolMgr;         //! event pool manager\r
   TList *fList; //fList object\r
   TList *fListBF; //fList object\r
   TList *fListBFS; //fList object (shuffling)\r