]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGDQ/dielectron/AliDielectronMixingHandler.cxx
including switch to set on/off iso-track core removal, cleaning and bug fix
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronMixingHandler.cxx
index 1109455c5675c256a6abd2acfc124ebb954229a2..3ddf07b23bea839a837196b4b13c9938f78e3d4c 100644 (file)
@@ -48,7 +48,9 @@ AliDielectronMixingHandler::AliDielectronMixingHandler() :
   fAxes(kMaxCuts),
   fMixType(kOSonly),
   fMixIncomplete(kTRUE),
-  fMoveToSameVertex(kFALSE)
+  fMoveToSameVertex(kFALSE),
+  fSkipFirstEvt(kFALSE),
+  fPID(0x0)
 {
   //
   // Default Constructor
@@ -67,7 +69,9 @@ AliDielectronMixingHandler::AliDielectronMixingHandler(const char* name, const c
   fAxes(kMaxCuts),
   fMixType(kOSonly),
   fMixIncomplete(kTRUE),
-  fMoveToSameVertex(kFALSE)
+  fMoveToSameVertex(kFALSE),
+  fSkipFirstEvt(kFALSE),
+  fPID(0x0)
 {
   //
   // Named Constructor
@@ -85,6 +89,7 @@ AliDielectronMixingHandler::~AliDielectronMixingHandler()
   // Default Destructor
   //
   fAxes.Delete();
+  delete fPID;
 }
 
 //________________________________________________________________
@@ -137,15 +142,11 @@ void AliDielectronMixingHandler::Fill(const AliVEvent *ev, AliDielectron *diele)
   //check if there are tracks available
   if (diele->GetTrackArray(0)->GetEntriesFast()==0 && diele->GetTrackArray(1)->GetEntriesFast()==0) return;
 
-  //find mixing bin
-  Double_t values[AliDielectronVarManager::kNMaxValues]={0.};
-  AliDielectronVarManager::Fill(ev,values);
-
   TString dim;
-  Int_t bin=FindBin(values,&dim);
+  Int_t bin=FindBin(AliDielectronVarManager::GetData(),&dim);
 
   //add mixing bin to event data
-  values[AliDielectronVarManager::kMixingBin] = bin;
+  AliDielectronVarManager::SetValue(AliDielectronVarManager::kMixingBin,bin);
 
   if (bin<0){
     AliDebug(5,Form("Bin outside range: %s",dim.Data()));
@@ -156,17 +157,28 @@ void AliDielectronMixingHandler::Fill(const AliVEvent *ev, AliDielectron *diele)
   TClonesArray *poolp=static_cast<TClonesArray*>(fArrPools.At(bin));
   if (!poolp){
     AliDebug(10,Form("New pool at %d (%s)\n",bin,dim.Data()));
-    poolp=new(fArrPools[bin]) TClonesArray("AliDielectronEvent",fDepth);
+    poolp=new(fArrPools[bin]) TClonesArray("AliDielectronEvent",1);
   }
   TClonesArray &pool=*poolp;
 
+  // clear the current pool if its size was reached by last event
+  // clear before fill new event into it
+  // NOTE: clear not directly after DoMixing, because you may want to use the ME
+  // in the internal train by other configs/tasks
+  // reset the event pool size to 1 (this keeps the physical memory consumption low)
+  if(pool.GetEntriesFast()==fDepth)  {
+    pool.Clear("C");
+    pool.ExpandCreate(1);
+  }
+
   AliDebug(10,Form("new event at %d: %d",bin,pool.GetEntriesFast()));
   AliDielectronEvent *event=new(pool[pool.GetEntriesFast()]) AliDielectronEvent();
-  if(ev->IsA() == AliAODEvent::Class()) event->SetAOD();
+  if(ev->IsA() == AliAODEvent::Class()) event->SetAOD(TMath::Max(diele->GetTrackArray(0)->GetEntriesFast(),diele->GetTrackArray(1)->GetEntriesFast()));
   else event->SetESD();
 
+  event->SetProcessID(fPID);
   event->SetTracks(*diele->GetTrackArray(0), *diele->GetTrackArray(1), *diele->GetPairArray(1));
-  event->SetEventData(values);
+  event->SetEventData(AliDielectronVarManager::GetData());
 
   // check if pool depth is reached.
   if (pool.GetEntriesFast()<fDepth) return;
@@ -179,9 +191,7 @@ void AliDielectronMixingHandler::Fill(const AliVEvent *ev, AliDielectron *diele)
     diele->fHistos->Fill("Mixing","Stats",0);
     diele->fHistos->Fill("Mixing","CompletePools",bin);
   }
-  
-  //clear the current pool
-  pool.Clear("C");
+
 }
 
 //______________________________________________
@@ -200,11 +210,21 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
   for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues; ++i)
     values[i]=AliDielectronVarManager::GetValue((AliDielectronVarManager::ValueTypes)i);
 
-  for (Int_t i1=0; i1<pool.GetEntriesFast(); ++i1){
+
+  // use event data from the first event
+  // all events are in the same mixing bin anyhow...
+  // optionally use only the event data from the first event and no tracks of it,
+  // by this you should get ride of event plane - leg correlations in the mixing
+  // but you loose the 1st event in the mixing statistics
+  AliDielectronEvent *ev0=static_cast<AliDielectronEvent*>(pool.At(0));
+  AliDielectronVarManager::SetEventData(ev0->GetEventData());
+  Int_t firstEvt=(fSkipFirstEvt ? 1 : 0);
+
+  for (Int_t i1=firstEvt; i1<pool.GetEntriesFast(); ++i1){
     AliDielectronEvent *ev1=static_cast<AliDielectronEvent*>(pool.At(i1));
     //use event data from the first event
     //both events are in the same mixing bin anyhow...
-    AliDielectronVarManager::SetEventData(ev1->GetEventData());
+    if( !fSkipFirstEvt ) AliDielectronVarManager::SetEventData(ev1->GetEventData());
 
     TObject *o=0x0;
     TIter ev1P(ev1->GetTrackArrayP());
@@ -292,19 +312,18 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
 }
 
 //______________________________________________
-void AliDielectronMixingHandler::MixRemaining(AliDielectron *diele)
+Bool_t AliDielectronMixingHandler::MixRemaining(AliDielectron *diele, Int_t ipool)
 {
   //
   // mix all pools even if they are incomplete
   //
 
   //Check if there was any processed data and it is requested to mix incomplete bins
-  if (!diele || !diele->PairArray(0) || !fMixIncomplete ) return;
+  if (!diele || !fMixIncomplete ) return 0;
 
   AliDielectronVarManager::SetEvent(0x0);
-  for (Int_t ipool=0; ipool<fArrPools.GetSize(); ++ipool){
     TClonesArray *poolp=static_cast<TClonesArray*>(fArrPools.At(ipool));
-    if (!poolp || !poolp->GetEntriesFast() || !poolp->At(0)) continue;
+    if (!poolp || !poolp->GetEntriesFast() || !poolp->At(0)) return 0;
     //clear the arrays before the final processing"
     AliDebug(10,Form("Incomplete: Bin %d (%d)\n",ipool,poolp->GetEntriesFast()));
     diele->ClearArrays();
@@ -327,11 +346,10 @@ void AliDielectronMixingHandler::MixRemaining(AliDielectron *diele)
       diele->fHistos->Fill("Mixing","InCompletePools",ipool);
       diele->fHistos->Fill("Mixing","Entries_InCompletePools",poolp->GetEntriesFast());
       
-      //set back global event values
-      AliDielectronVarManager::SetEventData(values);
+      //set back global event values (this would mean set back to zero)
+      //AliDielectronVarManager::SetEventData(values);
     }
-    
-  }
+    return 1;
 }
 
 
@@ -341,15 +359,14 @@ void AliDielectronMixingHandler::Init(const AliDielectron *diele)
   //
   // initialise event buffers
   //
-
   Int_t size=GetNumberOfBins();
 
   AliDebug(10,Form("Creating a pool array with size %d \n",size));
 
-  fArrPools.Expand(size);
+  if(diele && diele->DoEventProcess()) fArrPools.Expand(size);
 
   //add statics histogram if we have a histogram manager
-  if (diele && diele->fHistos) {
+  if (diele && diele->fHistos && diele->DoEventProcess()) {
     diele->fHistos->AddClass("Mixing");
     diele->fHistos->UserHistogram("Mixing","Stats","Mixing Statistics;;#called bins",2,0,2);
     TH1* h=diele->fHistos->GetHistogram("Mixing","Stats");
@@ -370,6 +387,10 @@ void AliDielectronMixingHandler::Init(const AliDielectron *diele)
       values+=Form("%.2f, ",(*bins)[irow]);
     }
   }
+  
+  if (!fPID){
+    fPID=TProcessID::AddProcessID();
+  }
 
   AliDebug(10,values.Data());
 }