]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG/FLOW/Tasks/AliFlowEvent.cxx
fix typo in partial derivative which is used to calculate correlated errors
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliFlowEvent.cxx
index cc5c546a58043b2a2bffa1b5b1b66c1b709f9b1b..1a5c7a6eeec37e54174e5d2d58b0604c83829cbb 100644 (file)
@@ -53,7 +53,7 @@ ClassImp(AliFlowEvent)
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent():
-  AliFlowEventSimple(), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -72,7 +72,7 @@ AliFlowEvent::AliFlowEvent():
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent(Int_t n):
-  AliFlowEventSimple(n), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(n), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -89,7 +89,7 @@ AliFlowEvent::AliFlowEvent(Int_t n):
 
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent(const AliFlowEvent& event):
-  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(event), fApplyRecentering(event.fApplyRecentering), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // copy constructor 
     for(Int_t i(0); i < 9; i++) {
@@ -112,7 +112,7 @@ AliFlowEvent& AliFlowEvent::operator=(const AliFlowEvent& event)
 
   fApplyRecentering = event.fApplyRecentering; 
   fCachedRun = event.fCachedRun; 
-  fCurrentCentrality = event.fCurrentCentrality;
+  fVZEROcentralityBin = event.fVZEROcentralityBin;
   for(Int_t i(0); i < 9; i++) {
       for(Int_t j(0); j < 2; j++) {
           for(Int_t k(0); k < 2; k++) {
@@ -197,7 +197,7 @@ void AliFlowEvent::SetMCReactionPlaneAngle(const AliMCEvent* mcEvent)
 AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -254,7 +254,7 @@ AliFlowEvent::AliFlowEvent( const AliMCEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20),  fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20),  fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -314,7 +314,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliAODEvent* anInput,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -397,7 +397,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                             KineSource anOption,
                             const AliCFManager* rpCFManager,
                             const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -495,7 +495,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const AliMultiplicity* anInputTracklets,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -571,7 +571,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
                            const AliCFManager* poiCFManager,
                             Bool_t hybrid):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -628,10 +628,11 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
         const AliESDVertex *vertexSPD = esd->GetPrimaryVertexSPD();
         const AliESDVertex *vertexTPC = esd->GetPrimaryVertexTPC();
 
+        AliExternalTrackParam copy(*tpcTrack);
         if(hybrid)
-          tpcTrack->PropagateToDCA(vertexSPD,esd->GetMagneticField(),100.,dca,cov);
+          copy.PropagateToDCA(vertexSPD,esd->GetMagneticField(),100.,dca,cov);
         else
-          tpcTrack->PropagateToDCA(vertexTPC,esd->GetMagneticField(),100.,dca,cov);
+          copy.PropagateToDCA(vertexTPC,esd->GetMagneticField(),100.,dca,cov);
 
 //        dca3D = TMath::Sqrt(TMath::Power(dca[0],2)+TMath::Power(dca[1],2));   FIXME unused variable
 
@@ -665,7 +666,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* esd,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const TH2F* anInputFMDhist,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(-1), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -702,7 +703,7 @@ AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
       //marking the particles used for the particle of interest (POI) selection:
       if(poiOK && poiCFManager)
        {
-          IncrementNumberOfPOIs(1);
+    IncrementNumberOfPOIs(1);
          pTrack->SetForPOISelection(kTRUE);
          pTrack->SetSource(AliFlowTrack::kFromESD);
        }
@@ -800,24 +801,24 @@ void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
       TObject* particle = rpCuts->GetInputObject(i);
 
       Bool_t rp = rpCuts->IsSelected(particle,i);
-      Int_t poiClass = poiCuts->IsSelected(particle,i);
+      Bool_t poi = poiCuts->IsSelected(particle,i);
 
-      if (!(rp||poiClass>0)) continue;
+      if (!(rp||poi)) continue;
 
       //make new AliFlowTrack
       if (rp)
       {
         pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
         if (!pTrack) continue;
-        pTrack->TagRP(); IncrementNumberOfPOIs(0);
-        if (poiClass>0) {pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);}
+        pTrack->Tag(0); IncrementNumberOfPOIs(0);
+        if (poi) {pTrack->Tag(1); IncrementNumberOfPOIs(1);}
         if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
       }
-      else if (poiClass>0)
+      else if (poi)
       {
         pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
         if (!pTrack) continue;
-        pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
+        pTrack->Tag(1); IncrementNumberOfPOIs(1);
         if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
       }
       fNumberOfTracks++;
@@ -831,12 +832,12 @@ void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
     for (Int_t i=0; i<poiCuts->GetNumberOfInputObjects(); i++)
     {
       TObject* particle = poiCuts->GetInputObject(i);
-      Int_t poiClass = poiCuts->IsSelected(particle,i);
-      if (poiClass<=0) continue;
+      Bool_t poi = poiCuts->IsSelected(particle,i);
+      if (!poi) continue;
       pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
       if (!pTrack) continue;
-      pTrack->Tag(poiClass);
-      IncrementNumberOfPOIs(poiClass);
+      pTrack->Tag(1);
+      IncrementNumberOfPOIs(1);
       fNumberOfTracks++;
       if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
     }
@@ -845,11 +846,11 @@ void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
     for (Int_t i=0; i<numberOfInputObjects; i++)
       {
       TObject* particle = rpCuts->GetInputObject(i);
-      Int_t rp = rpCuts->IsSelected(particle,i);
-      if (rp<1) continue;
+      Bool_t rp = rpCuts->IsSelected(particle,i);
+      if (!rp) continue;
       pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
       if (!pTrack) continue;
-      pTrack->TagRP();
+      pTrack->Tag(0);
       IncrementNumberOfPOIs(0);
       fNumberOfTracks++;
       if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
@@ -864,19 +865,8 @@ void AliFlowEvent::InsertTrack(AliFlowTrack *track) {
   *pTrack = *track;
   if (track->GetNDaughters()>0)
   {
-    fMothersCollection->Add(track);
+    fMothersCollection->Add(pTrack);
   }
-  //pTrack->SetPt( track->Pt() );
-  //pTrack->SetPhi( track->Phi() );
-  //pTrack->SetEta( track->Eta() );
-  //pTrack->SetWeight( track->Weight() );
-  //pTrack->SetCharge( track->Charge() );
-  //pTrack->SetMass( track->Mass() );
-  //pTrack->SetForRPSelection( track->InRPSelection() );
-  //pTrack->SetForPOISelection( track->InPOISelection() );
-  //if(track->InSubevent(0)) pTrack->SetForSubevent(0);
-  //if(track->InSubevent(1)) pTrack->SetForSubevent(1);
-  //pTrack->SetID( track->GetID() );
   return;
 }
 
@@ -900,7 +890,7 @@ AliFlowTrack* AliFlowEvent::ReuseTrack(Int_t i)
 //-----------------------------------------------------------------------
 AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
                             AliFlowTrackCuts* poiCuts ):
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -915,80 +905,7 @@ AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
     }
   //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
   //the input data needs to be attached to the cuts
-  //we have two cases, if we're cutting the same collection of tracks
-  //(same param type) then we can have tracks that are both rp and poi
-  //in the other case we want to have two exclusive sets of rps and pois
-  //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
-  //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
-  //TAKEN TWICE
-
-  if (!rpCuts || !poiCuts) return;
-  AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
-  AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
-
-  if (sourceRP==sourcePOI)
-  {
-    //loop over tracks
-    Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObjects; i++)
-    {
-      //get input object (particle)
-      TObject* particle = rpCuts->GetInputObject(i);
-
-      Bool_t rp = rpCuts->IsSelected(particle,i);
-      Int_t poiClass = poiCuts->IsSelected(particle,i);
-      
-      if (!(rp||poiClass>0)) continue;
-
-      //make new AliFLowTrack
-      AliFlowTrack* pTrack = NULL;
-      if (rp)
-      {
-        pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
-        if (!pTrack) continue;
-        pTrack->TagRP(); IncrementNumberOfPOIs(0);
-        if (poiClass>0) {pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);}
-      }
-      else
-      if (poiClass>0)
-      {
-        pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
-        if (!pTrack) continue;
-        pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
-      }
-      TrackAdded();
-    }//end of while (i < numberOfTracks)
-  }
-  else if (sourceRP!=sourcePOI)
-  {
-    //here we have two different sources of particles, so we fill
-    //them independently
-    AliFlowTrack* pTrack = NULL;
-    //RP
-    Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObjects; i++)
-    {
-      TObject* particle = rpCuts->GetInputObject(i);
-      Bool_t rp = rpCuts->IsSelected(particle,i);
-      if (!rp) continue;
-      pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
-      if (!pTrack) continue;
-      pTrack->TagRP(); IncrementNumberOfPOIs(0);
-      TrackAdded();
-    }
-    //POI
-    numberOfInputObjects = poiCuts->GetNumberOfInputObjects();
-    for (Int_t i=0; i<numberOfInputObjects; i++)
-    {
-      TObject* particle = poiCuts->GetInputObject(i);
-      Int_t poiClass = poiCuts->IsSelected(particle,i);
-      if (poiClass<=0) continue;
-      pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
-      if (!pTrack) continue;
-      pTrack->Tag(poiClass); IncrementNumberOfPOIs(poiClass);
-      TrackAdded();
-    }
-  }
+  Fill(rpCuts,poiCuts);
 }
 
 //-------------------------------------------------------------------//
@@ -997,7 +914,7 @@ AliFlowEvent::AliFlowEvent( AliFlowTrackCuts* rpCuts,
 AliFlowEvent::AliFlowEvent( const AliESDEvent* anInput,
                            const AliESDPmdTrack *pmdtracks,
                            const AliCFManager* poiCFManager ):
-  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fCurrentCentrality(-1)
+  AliFlowEventSimple(20), fApplyRecentering(kFALSE), fCachedRun(-1), fVZEROcentralityBin(-1)
 {
     // constructor
     for(Int_t i(0); i < 9; i++) {
@@ -1140,25 +1057,25 @@ void AliFlowEvent::Get2Qsub(AliFlowVector* Qarray, Int_t n, TList *weightsList,
     Double_t Qycrms(1);        
     
     if( n == 2) {       // second order symmetry
-        Qxamean = fMeanQ[fCurrentCentrality][1][0];
-        Qxarms  = fWidthQ[fCurrentCentrality][1][0];
-        Qyamean = fMeanQ[fCurrentCentrality][1][1];
-        Qyarms  = fWidthQ[fCurrentCentrality][1][1];
-
-        Qxcmean = fMeanQ[fCurrentCentrality][0][0];
-        Qxcrms  = fWidthQ[fCurrentCentrality][0][0];
-        Qycmean = fMeanQ[fCurrentCentrality][0][1];
-        Qycrms  = fWidthQ[fCurrentCentrality][0][1];   
+        Qxamean = fMeanQ[fVZEROcentralityBin][1][0];
+        Qxarms  = fWidthQ[fVZEROcentralityBin][1][0];
+        Qyamean = fMeanQ[fVZEROcentralityBin][1][1];
+        Qyarms  = fWidthQ[fVZEROcentralityBin][1][1];
+
+        Qxcmean = fMeanQ[fVZEROcentralityBin][0][0];
+        Qxcrms  = fWidthQ[fVZEROcentralityBin][0][0];
+        Qycmean = fMeanQ[fVZEROcentralityBin][0][1];
+        Qycrms  = fWidthQ[fVZEROcentralityBin][0][1];  
     } else if (n == 3) {        // third order symmetry
-        Qxamean = fMeanQv3[fCurrentCentrality][1][0];
-        Qxarms  = fWidthQv3[fCurrentCentrality][1][0];
-        Qyamean = fMeanQv3[fCurrentCentrality][1][1];
-        Qyarms  = fWidthQv3[fCurrentCentrality][1][1];
+        Qxamean = fMeanQv3[fVZEROcentralityBin][1][0];
+        Qxarms  = fWidthQv3[fVZEROcentralityBin][1][0];
+        Qyamean = fMeanQv3[fVZEROcentralityBin][1][1];
+        Qyarms  = fWidthQv3[fVZEROcentralityBin][1][1];
   
-        Qxcmean = fMeanQv3[fCurrentCentrality][0][0];
-        Qxcrms  = fWidthQv3[fCurrentCentrality][0][0];
-        Qycmean = fMeanQv3[fCurrentCentrality][0][1];
-        Qycrms  = fWidthQv3[fCurrentCentrality][0][1]; 
+        Qxcmean = fMeanQv3[fVZEROcentralityBin][0][0];
+        Qxcrms  = fWidthQv3[fVZEROcentralityBin][0][0];
+        Qycmean = fMeanQv3[fVZEROcentralityBin][0][1];
+        Qycrms  = fWidthQv3[fVZEROcentralityBin][0][1];        
     }
     // do the correction    
     Double_t QxaCor = (Qxa - Qxamean)/Qxarms;
@@ -1204,15 +1121,15 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts(AliFlowTrackCuts* cuts) {
     if(!cuts->GetEvent()) return; // coverity. we need to know the event to get the runnumber and centrlaity
     // get the vzero centrality percentile (cc dependent calibration)
     Float_t v0Centr(cuts->GetEvent()->GetCentrality()->GetCentralityPercentile("V0M"));
-    if(v0Centr < 5) fCurrentCentrality = 0;
-    else if(v0Centr < 10) fCurrentCentrality = 1;
-    else if(v0Centr < 20) fCurrentCentrality = 2;
-    else if(v0Centr < 30) fCurrentCentrality = 3;
-    else if(v0Centr < 40) fCurrentCentrality = 4;
-    else if(v0Centr < 50) fCurrentCentrality = 5;
-    else if(v0Centr < 60) fCurrentCentrality = 6;
-    else if(v0Centr < 70) fCurrentCentrality = 7;
-    else fCurrentCentrality = 8;
+    if(v0Centr < 5) fVZEROcentralityBin = 0;
+    else if(v0Centr < 10) fVZEROcentralityBin = 1;
+    else if(v0Centr < 20) fVZEROcentralityBin = 2;
+    else if(v0Centr < 30) fVZEROcentralityBin = 3;
+    else if(v0Centr < 40) fVZEROcentralityBin = 4;
+    else if(v0Centr < 50) fVZEROcentralityBin = 5;
+    else if(v0Centr < 60) fVZEROcentralityBin = 6;
+    else if(v0Centr < 70) fVZEROcentralityBin = 7;
+    else fVZEROcentralityBin = 8;
 
     // if this event is from the same run as the previous event
     // we can use the cached calibration values, no need to re-open the 
@@ -1414,3 +1331,10 @@ void AliFlowEvent::SetVZEROCalibrationForTrackCuts2011(AliFlowTrackCuts* cuts)
 } 
 //_____________________________________________________________________________
 
+void AliFlowEvent::ClearFast()
+{
+  //clear the event without releasing any memory
+  AliFlowEventSimple::ClearFast();
+  fApplyRecentering=0;
+  fCachedRun=0;
+}