]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HBTAN/AliHBTAnalysis.cxx
Updated to the new way AOD stores particles
[u/mrichter/AliRoot.git] / HBTAN / AliHBTAnalysis.cxx
index a4e5723806bf70ca84ed9e67de543188e1a0dfda..a216f8b2554282f84e2de96b61b35d2762920e23 100644 (file)
@@ -58,14 +58,17 @@ AliHBTAnalysis::AliHBTAnalysis():
   fTrackMonitorFunctions ( new AliHBTMonOneParticleFctn* [fgkFctnArraySize]),    
   fParticleAndTrackMonitorFunctions ( new AliHBTMonTwoParticleFctn* [fgkFctnArraySize]),    
   fBkgEventCut(0x0),
+  fPartBuffer(0x0),
+  fTrackBuffer(0x0),
   fBufferSize(2),
   fDisplayMixingInfo(fgkDefaultMixingInfo),
   fIsOwner(kFALSE),
-  fPartBuffer(0x0),
-  fTrackBuffer(0x0),
   fProcessOption(kSimulatedAndReconstructed),
   fNoCorrfctns(kFALSE),
-  fOutputFileName(0x0)
+  fOutputFileName(0x0),
+  fVertexX(0.0),
+  fVertexY(0.0),
+  fVertexZ(0.0)
  {
    //default constructor
    
@@ -89,14 +92,17 @@ AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
   fTrackMonitorFunctions(0x0),
   fParticleAndTrackMonitorFunctions(0x0),
   fBkgEventCut(0x0),
+  fPartBuffer(0x0),
+  fTrackBuffer(0x0),
   fBufferSize(fgkDefaultBufferSize),
   fDisplayMixingInfo(fgkDefaultMixingInfo),
   fIsOwner(kFALSE),
-  fPartBuffer(0x0),
-  fTrackBuffer(0x0),
   fProcessOption(kSimulatedAndReconstructed),
   fNoCorrfctns(kFALSE),
-  fOutputFileName(0x0)
+  fOutputFileName(0x0),
+  fVertexX(0.0),
+  fVertexY(0.0),
+  fVertexZ(0.0)
  {
 //copy constructor
    Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
@@ -141,12 +147,39 @@ Int_t AliHBTAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
   //Processes one event
   if (fProcEvent == 0x0)
    {
-     Error("ProcessEvent","Analysis option not specified");
+     Error("ProcessEvent","Analysis <<%s>> option not specified.",GetName());
      return 1;
    }
-  if ( Pass(aodrec,aodsim) ) return 0;
+  if ( Rejected(aodrec,aodsim) ) 
+   {
+//     Double_t x = 0, y = 0, z = 0;
+//     aodrec->GetPrimaryVertex(x,y,z);
+//     Info("ProcessEvent","Event has vertex at %f %f %f",x,y,z);
+     Info("ProcessEvent","Nch is %d",aodsim->GetNumberOfCharged());
+     Info("ProcessEvent","%s: Event cut rejected this event",GetName());
+     return 0;
+   } 
+  
+  //Move event to the apparent vertex -> must be after the event cut
+  //It is important for any cut that use any spacial coordiantes, 
+  //f.g. anti-merging cut in order to preserve the same bahavior of variables (f.g. distance between tracks)
+  Double_t dvx = 0, dvy = 0, dvz = 0;
+  if (aodrec)
+   {
+     Double_t pvx,pvy,pvz;
+     aodrec->GetPrimaryVertex(pvx,pvy,pvz);
+     
+     dvx = fVertexX - pvx;
+     dvy = fVertexY - pvy;
+     dvz = fVertexZ - pvz;
+     aodrec->Move(dvx,dvy,dvz);
+   }  
+  
+  Int_t result = (this->*fProcEvent)(aodrec,aodsim);
+
+  if (aodrec) aodrec->Move(-dvx,-dvy,-dvz);//move event back to the same spacial coordinates
   
-  return  (this->*fProcEvent)(aodrec,aodsim);
+  return  result;
 }
 /*************************************************************************************/ 
 
@@ -161,6 +194,7 @@ Int_t AliHBTAnalysis::Finish()
 void AliHBTAnalysis::DeleteFunctions()
 {
  //Deletes all functions added to analysis
  UInt_t ii;
  for(ii = 0;ii<fNParticleFunctions;ii++)
   { 
@@ -243,11 +277,13 @@ Int_t AliHBTAnalysis::Init()
     case kReconstructed:
       if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecNonId;
       else fProcEvent = &AliHBTAnalysis::ProcessRec;
+      SetCutsOnRec();
       break;
 
     case kSimulated:
       if (nonid) fProcEvent = &AliHBTAnalysis::ProcessSimNonId;
       else fProcEvent = &AliHBTAnalysis::ProcessSim;
+      SetCutsOnSim();
       break;
 
     case kSimulatedAndReconstructed:
@@ -342,7 +378,7 @@ Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
 
   if ( !partEvent || !trackEvent ) 
    {
-     Error("ProcessRecAndSim","Can not get event");
+     Error("ProcessRecAndSim","<<%s>> Can not get event",GetName());
      return 1;
    }
 
@@ -367,7 +403,7 @@ Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
 
      part1= partEvent->GetParticle(j);
      track1= trackEvent->GetParticle(j);
-
+     
      Bool_t firstcut = (this->*fkPass1)(part1,track1);
      if (fBufferSize != 0) 
        if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
@@ -375,8 +411,8 @@ Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
           //accepted by any cut
           // we have to copy because reader keeps only one event
 
-          partEvent1->AddParticle(new AliAODParticle(*part1));
-          trackEvent1->AddParticle(new AliAODParticle(*track1));
+          partEvent1->AddParticle(part1);
+          trackEvent1->AddParticle(track1);
         }
 
      if (firstcut) continue;
@@ -527,15 +563,15 @@ Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
 
      part1= partEvent->GetParticle(j);
 
-     Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
+     Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(part1);
 
      if (fBufferSize != 0) 
-       if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE ) )
+       if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(part1) == kFALSE ) )
         {
           //accepted by any cut
           // we have to copy because reader keeps only one event
 
-          partEvent1->AddParticle(new AliAODParticle(*part1));
+          partEvent1->AddParticle(part1);
         }
 
      if (firstcut) continue;
@@ -551,9 +587,9 @@ Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
         if (part1->GetUID() == part2->GetUID()) continue;
         partpair->SetParticles(part1,part2);
 
-           if(fPairCut->Pass(partpair)) //check pair cut
+           if(fPairCut->Rejected(partpair)) //check pair cut
             { //do not meets crietria of the 
-              if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
+              if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
               else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
             }
            else
@@ -586,9 +622,9 @@ Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
                 part2= partEvent2->GetParticle(l);
                 partpair->SetParticles(part1,part2);
 
-                if( fPairCut->Pass(partpair) ) //check pair cut
+                if( fPairCut->Rejected(partpair) ) //check pair cut
                   { //do not meets crietria of the 
-                    if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) )
+                    if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) )
                       continue;
                     else 
                      {
@@ -650,15 +686,15 @@ Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
 
      track1= trackEvent->GetParticle(j);
 
-     Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(track1);
+     Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(track1);
 
      if (fBufferSize != 0) 
-       if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(track1) == kFALSE ) )
+       if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(track1) == kFALSE ) )
         {
           //accepted by any cut
           // we have to copy because reader keeps only one event
 
-          trackEvent1->AddParticle(new AliAODParticle(*track1));
+          trackEvent1->AddParticle(track1);
         }
 
      if (firstcut) continue;
@@ -674,9 +710,9 @@ Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
         if (track1->GetUID() == track2->GetUID()) continue;
         trackpair->SetParticles(track1,track2);
 
-           if(fPairCut->Pass(trackpair)) //check pair cut
+           if(fPairCut->Rejected(trackpair)) //check pair cut
             { //do not meets crietria of the 
-              if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
+              if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
               else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
             }
            else
@@ -709,9 +745,9 @@ Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
                 track2= trackEvent2->GetParticle(l);
                 trackpair->SetParticles(track1,track2);
 
-                if( fPairCut->Pass(trackpair) ) //check pair cut
+                if( fPairCut->Rejected(trackpair) ) //check pair cut
                   { //do not meets crietria of the 
-                    if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) )
+                    if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) )
                       continue;
                     else 
                      {
@@ -1616,8 +1652,8 @@ void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpar
      
      if (in2)
       {
-        outpart2->AddParticle(new AliAODParticle(*part));
-        outtrack2->AddParticle(new AliAODParticle(*track));
+        outpart2->AddParticle(part);
+        outtrack2->AddParticle(track);
         continue;
       }
    }
@@ -1643,8 +1679,8 @@ void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
      in1 = in2 = kTRUE;
      part = in->GetParticle(i);
      
-     if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
-     if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
+     if ( cut1->Rejected(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
+     if ( cut2->Rejected(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
      
      if (gDebug)//to be removed in real analysis     
      if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
@@ -1696,6 +1732,19 @@ Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
 }
 /*************************************************************************************/ 
 
+void AliHBTAnalysis::SetApparentVertex(Double_t x, Double_t y, Double_t z)
+{ 
+  //Sets apparent vertex
+  // All events have to be moved to the same vertex position in order to
+  // to be able to comare any space positions (f.g. anti-merging)
+  // This method defines this position
+  
+  fVertexX = x;
+  fVertexY = y;
+  fVertexZ = z;
+}
+/*************************************************************************************/ 
+
 void AliHBTAnalysis::PressAnyKey()
 { 
  //small utility function that helps to make comfortable macros