]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGDQ/dielectron/AliDielectronMixingHandler.cxx
ync gsi and aliroot trunk
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronMixingHandler.cxx
index 21a4eeca24e234ec735d5d4e3a750f40e7a8b2f5..1109455c5675c256a6abd2acfc124ebb954229a2 100644 (file)
@@ -136,14 +136,17 @@ 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];
+  Double_t values[AliDielectronVarManager::kNMaxValues]={0.};
   AliDielectronVarManager::Fill(ev,values);
 
   TString dim;
   Int_t bin=FindBin(values,&dim);
 
+  //add mixing bin to event data
+  values[AliDielectronVarManager::kMixingBin] = bin;
+
   if (bin<0){
     AliDebug(5,Form("Bin outside range: %s",dim.Data()));
     return;
@@ -159,10 +162,12 @@ void AliDielectronMixingHandler::Fill(const AliVEvent *ev, AliDielectron *diele)
 
   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();
+  else event->SetESD();
 
   event->SetTracks(*diele->GetTrackArray(0), *diele->GetTrackArray(1), *diele->GetPairArray(1));
   event->SetEventData(values);
-  
+
   // check if pool depth is reached.
   if (pool.GetEntriesFast()<fDepth) return;
 
@@ -185,7 +190,7 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
   //
   // perform the mixing
   //
-  
+
   //buffer track arrays and copy them back afterwards
   TObjArray arrTrDummy[4];
   for (Int_t i=0; i<4; ++i) arrTrDummy[i]=diele->fTracks[i];
@@ -214,7 +219,6 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
       
       //setup track arrays
       AliDielectronEvent *ev2=static_cast<AliDielectronEvent*>(pool.At(i2));
-
       ev1P.Reset();
       ev1N.Reset();
       TIter ev2P(ev2->GetTrackArrayP());
@@ -250,9 +254,9 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
         ev2P.Reset();
         ev2N.Reset();
       }
-      
+
       //mixing of ev1- ev2+ (pair type4). This is common for all mixing types
-      while ( (o=ev1N()) ) diele->fTracks[1].Add(o);
+      while ( (o=ev1N()) ) diele->fTracks[1].Add(o); 
       while ( (o=ev2P()) ) diele->fTracks[2].Add(o);
       diele->FillPairArrays(1,2);
       
@@ -273,6 +277,7 @@ void AliDielectronMixingHandler::DoMixing(TClonesArray &pool, AliDielectron *die
         while ( (o=ev2N()) ) diele->fTracks[2].Add(o);
         diele->FillPairArrays(1,2);
       }
+
     }
   }
 
@@ -296,10 +301,10 @@ void AliDielectronMixingHandler::MixRemaining(AliDielectron *diele)
   //Check if there was any processed data and it is requested to mix incomplete bins
   if (!diele || !diele->PairArray(0) || !fMixIncomplete ) return;
 
-
+  AliDielectronVarManager::SetEvent(0x0);
   for (Int_t ipool=0; ipool<fArrPools.GetSize(); ++ipool){
     TClonesArray *poolp=static_cast<TClonesArray*>(fArrPools.At(ipool));
-    if (!poolp) continue;
+    if (!poolp || !poolp->GetEntriesFast() || !poolp->At(0)) continue;
     //clear the arrays before the final processing"
     AliDebug(10,Form("Incomplete: Bin %d (%d)\n",ipool,poolp->GetEntriesFast()));
     diele->ClearArrays();
@@ -307,10 +312,23 @@ void AliDielectronMixingHandler::MixRemaining(AliDielectron *diele)
 
     // increase counter for incomplete bins
     if (diele->fHistos) {
+      //buffer event data and set event data using the first event in this pool
+      Double_t values[AliDielectronVarManager::kNMaxValues]={0};
+      for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues; ++i)
+        values[i]=AliDielectronVarManager::GetValue((AliDielectronVarManager::ValueTypes)i);
+      
+      AliDielectronEvent *ev1=static_cast<AliDielectronEvent*>(poolp->At(0));
+      //use event data from the first event all events are in the same mixing bin anyhow...
+      AliDielectronVarManager::SetEventData(ev1->GetEventData());
+      
+      // fill the histograms
       diele->FillHistograms(0x0, kTRUE);
       diele->fHistos->Fill("Mixing","Stats",1);
       diele->fHistos->Fill("Mixing","InCompletePools",ipool);
       diele->fHistos->Fill("Mixing","Entries_InCompletePools",poolp->GetEntriesFast());
+      
+      //set back global event values
+      AliDielectronVarManager::SetEventData(values);
     }
     
   }
@@ -324,9 +342,7 @@ void AliDielectronMixingHandler::Init(const AliDielectron *diele)
   // initialise event buffers
   //
 
-  Int_t size=1;
-  for (Int_t i=0; i<fAxes.GetEntriesFast(); ++i)
-    size*=((static_cast<TVectorD*>(fAxes.At(i)))->GetNrows()-1);
+  Int_t size=GetNumberOfBins();
 
   AliDebug(10,Form("Creating a pool array with size %d \n",size));
 
@@ -358,6 +374,18 @@ void AliDielectronMixingHandler::Init(const AliDielectron *diele)
   AliDebug(10,values.Data());
 }
 
+//______________________________________________
+Int_t AliDielectronMixingHandler::GetNumberOfBins() const
+{
+  //
+  // return the number of bins this mixing handler has
+  //
+  Int_t size=1;
+  for (Int_t i=0; i<fAxes.GetEntriesFast(); ++i)
+    size*=((static_cast<TVectorD*>(fAxes.At(i)))->GetNrows()-1);
+  return size;
+}
+
 //______________________________________________
 Int_t AliDielectronMixingHandler::FindBin(const Double_t values[], TString *dim)
 {
@@ -384,8 +412,8 @@ Int_t AliDielectronMixingHandler::FindBin(const Double_t values[], TString *dim)
 
     Int_t pos=TMath::BinarySearch(nRows,bins->GetMatrixArray(),val);
     bin+=sizeAdd*pos;
-    if (dim) (*dim)+=Form("%s: %f; ",AliDielectronVarManager::GetValueName(fEventCuts[i]),val);
-    sizeAdd*=nRows;
+    if (dim) (*dim)+=Form("%s: %f (%d); ",AliDielectronVarManager::GetValueName(fEventCuts[i]),val,pos);
+    sizeAdd*=(nRows-1);
   }
 
   return bin;
@@ -415,11 +443,12 @@ void AliDielectronMixingHandler::MoveToSameVertex(AliVTrack * const vtrack, cons
     //translation
     Double_t vt[3] = {vMix[0]-vFirst[0],vMix[1]-vFirst[1],vMix[2]-vFirst[2]};
     //rotate to the track frame
-    track->Global2LocalPosition(vt,track->GetAlpha());
+//     track->Global2LocalPosition(vt,track->GetAlpha());
 
     //add to track position
-    x        = x       -vt[0];
-    param[0] = param[0]-vt[1];
+//     x        = x       -vt[0];
+//     param[0] = param[0]-vt[1];
+//     param[1] = param[1]-vt[2];
     param[1] = param[1]-vt[2];
     
     //set updated track information