]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/GammaConv/AliV0ReaderV1.cxx
Minor fix for warning about destructor call for TF1 in SetModulationFit
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliV0ReaderV1.cxx
index 109d355307a17238fd77433cb3bb6ac1c9f82530..e9a2765f5ed78a714717e0ba9f7880b5f003294d 100644 (file)
@@ -1,14 +1,14 @@
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                                                                * 
- * Authors: Svein Lindal, Daniel Lohner                                                          *
- * Version 1.0                                                                                                 *
- *                                                                                                                       *
- *                                                                         *
- * based on: on older version (see aliroot up to v5-04-42-AN)              *
- *           AliV0Reader.cxx                                               *
- *           Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin              *
- *                                                                         *
+ *                                                                       *
+ * Authors: Svein Lindal, Daniel Lohner                                          *
+ * Version 1.0                                                           *
+ *                                                                       *
+ *                                                                        *
+ * based on: on older version (see aliroot up to v5-04-42-AN)             *
+ *           AliV0Reader.cxx                                              *
+ *           Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin             *
+ *                                                                        *
  * Permission to use, copy, modify and distribute this software and its          *
  * documentation strictly for non-commercial purposes is hereby granted          *
  * without fee, provided that the above copyright notice appears in all          *
@@ -73,6 +73,7 @@ AliV0ReaderV1::AliV0ReaderV1(const char *name) : AliAnalysisTaskSE(name),
     fCreateAOD(kFALSE),
     fDeltaAODBranchName("GammaConv"),
     fDeltaAODFilename("AliAODGammaConversion.root"),
+    fRelabelAODs(kFALSE),
     fEventIsSelected(kFALSE),
     fPeriodName("")
 {
@@ -135,11 +136,9 @@ AliV0ReaderV1 &AliV0ReaderV1::operator=(const AliV0ReaderV1 &ref){
 void AliV0ReaderV1::Init()
 {
     // Initialize function to be called once before analysis
-
     if(fConversionCuts==NULL){
        if(fConversionCuts==NULL)AliError("No Cut Selection initialized");
     }
-
     if(fCreateAOD){kUseAODConversionPhoton=kTRUE;}
 
     if(fConversionGammas != NULL){
@@ -154,7 +153,6 @@ void AliV0ReaderV1::Init()
            fConversionGammas = new TClonesArray("AliKFConversionPhoton",100);}
     }
     fConversionGammas->Delete();//Reset the TClonesArray
-
 }
 
 //________________________________________________________________________
@@ -175,10 +173,9 @@ void AliV0ReaderV1::UserCreateOutputObjects()
     }
 
 }
-
 //________________________________________________________________________
-void AliV0ReaderV1::UserExec(Option_t *){
-
+Bool_t AliV0ReaderV1::Notify()
+{
    if (fPeriodName.CompareTo("") == 0){
       AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
       if(man) {
@@ -194,22 +191,42 @@ void AliV0ReaderV1::UserExec(Option_t *){
                   fPeriodName = testObjString->GetString();
                   i = arr->GetEntriesFast();
                }
-            }     
-//             cout << fileName.Data() << "\t" <<fPeriodName.Data() << endl;
+            }
          }
       }
+      if(!fConversionCuts->GetDoEtaShift()) return kTRUE; // No Eta Shift requested, continue
+      if(fConversionCuts->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
+         fConversionCuts->GetCorrectEtaShiftFromPeriod(fPeriodName);
+         fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
+         return kTRUE;
+      }
+      else{
+         printf(" Gamma Conversion Reader %s :: Eta Shift Manually Set to %f \n\n",
+                (fConversionCuts->GetCutNumber()).Data(),fConversionCuts->GetEtaShift());
+         fConversionCuts->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once   
+      }
    }
 
+   return kTRUE;
+}
+//________________________________________________________________________
+void AliV0ReaderV1::UserExec(Option_t *option){
+
     // Check if correctly initialized
     if(!fConversionGammas)Init();
 
     // User Exec
     fEventIsSelected=ProcessEvent(fInputEvent,fMCEvent);
+
+    // AOD Output
+    FillAODOutput();
+
 }
 
 //________________________________________________________________________
 Bool_t AliV0ReaderV1::ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent)
 {
+
     //Reset the TClonesArray
     fConversionGammas->Delete();
 
@@ -236,9 +253,6 @@ Bool_t AliV0ReaderV1::ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent)
        GetAODConversionGammas();
     }
 
-    // AOD Output
-    FillAODOutput();
-
     return kTRUE;
 }
 ///________________________________________________________________________
@@ -284,7 +298,6 @@ const AliExternalTrackParam *AliV0ReaderV1::GetExternalTrackParam(AliESDv0 *fCur
 Bool_t AliV0ReaderV1::ProcessESDV0s()
 {
     // Process ESD V0s for conversion photon reconstruction
-
     AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(fInputEvent);
 
     AliKFConversionPhoton *fCurrentMotherKFCandidate=NULL;
@@ -295,16 +308,20 @@ Bool_t AliV0ReaderV1::ProcessESDV0s()
            AliESDv0 *fCurrentV0=(AliESDv0*)(fESDEvent->GetV0(currentV0Index));
            if(!fCurrentV0){
                printf("Requested V0 does not exist");
-               continue;}
+               continue;
+            }
 
            fCurrentMotherKFCandidate=ReconstructV0(fCurrentV0,currentV0Index);
 
            if(fCurrentMotherKFCandidate){
-
                // Add Gamma to the TClonesArray
 
                if(kUseAODConversionPhoton){
                    new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(fCurrentMotherKFCandidate);
+                               AliAODConversionPhoton * currentConversionPhoton = (AliAODConversionPhoton*)(fConversionGammas->At(fConversionGammas->GetEntriesFast()-1));
+                               currentConversionPhoton->SetMass(fCurrentMotherKFCandidate->M());
+                               currentConversionPhoton->SetMassToZero();
+                               
                }
                else{
                    new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliKFConversionPhoton(*fCurrentMotherKFCandidate);
@@ -372,11 +389,11 @@ AliKFConversionPhoton *AliV0ReaderV1::ReconstructV0(AliESDv0 *fCurrentV0,Int_t c
     // Reconstruct Gamma
 
     if(fUseConstructGamma){
-       fCurrentMotherKF = new AliKFConversionPhoton();
-       fCurrentMotherKF->ConstructGamma(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle);
+                       fCurrentMotherKF = new AliKFConversionPhoton();
+                       fCurrentMotherKF->ConstructGamma(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle);
     }else{
-       fCurrentMotherKF = new AliKFConversionPhoton(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle);
-       fCurrentMotherKF->SetMassConstraint(0,0);
+                       fCurrentMotherKF = new AliKFConversionPhoton(fCurrentNegativeKFParticle,fCurrentPositiveKFParticle);
+                       fCurrentMotherKF->SetMassConstraint(0,0.0001);
     }
 
     // Set Track Labels
@@ -471,7 +488,7 @@ Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackPar
 
    // Double_t u[3] = {pPlus[0]+pMinus[0],pPlus[1]+pMinus[1],pPlus[2]+pMinus[2]};
    // Double_t normu = sqrt( (u[0]*u[0]) + (u[1]*u[1]) + (u[2]*u[2]) );
-   
+
    // u[0] = u[0] / normu;
    // u[1] = u[1] / normu;
    // u[2] = u[2] / normu;
@@ -491,7 +508,7 @@ Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackPar
    // v[0] = (pPlus[1]*pMinus[2]) - (pPlus[2]*pMinus[1]);
    // v[1] = (pPlus[2]*pMinus[0]) - (pPlus[0]*pMinus[2]);
    // v[2] = (pPlus[0]*pMinus[1]) - (pPlus[1]*pMinus[0]);
-   
+
    // Double_t w[3] = {0,0,0}; // u X v
    // w[0] = (u[1]*v[2]) - (u[2]*v[1]);
    // w[1] = (u[2]*v[0]) - (u[0]*v[2]);
@@ -718,6 +735,7 @@ Bool_t AliV0ReaderV1::GetAODConversionGammas(){
            for(Int_t i=0;i<fInputGammas->GetEntriesFast();i++){
               gamma=dynamic_cast<AliAODConversionPhoton*>(fInputGammas->At(i));
               if(gamma){
+                 if(fRelabelAODs)RelabelAODPhotonCandidates(gamma);
                  if(fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){
                     new((*fConversionGammas)[fConversionGammas->GetEntriesFast()]) AliAODConversionPhoton(*gamma);}
               }
@@ -745,7 +763,40 @@ void AliV0ReaderV1::FindDeltaAODBranchName(){
        }
     }
 }
-
+//________________________________________________________________________
+void AliV0ReaderV1::RelabelAODPhotonCandidates(AliAODConversionPhoton *PhotonCandidate){
+
+   // Relabeling For AOD Event
+   // ESDiD -> AODiD
+   // MCLabel -> AODMCLabel
+   Bool_t AODLabelPos = kFALSE;
+   Bool_t AODLabelNeg = kFALSE;
+      
+   for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
+      AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
+      if(!AODLabelPos){
+         if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
+            PhotonCandidate->SetMCLabelPositive(abs(tempDaughter->GetLabel()));
+            PhotonCandidate->SetLabelPositive(i);
+            AODLabelPos = kTRUE;
+         }
+      }
+      if(!AODLabelNeg){
+         if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
+            PhotonCandidate->SetMCLabelNegative(abs(tempDaughter->GetLabel()));
+            PhotonCandidate->SetLabelNegative(i);
+            AODLabelNeg = kTRUE;
+         }
+      }
+      if(AODLabelNeg && AODLabelPos){
+         return;
+      }
+   }
+   if(!AODLabelPos || !AODLabelNeg){
+      AliError(Form("NO AOD Daughters Found Pos: %i %i Neg: %i %i",AODLabelPos,PhotonCandidate->GetTrackLabelPositive(),AODLabelNeg,PhotonCandidate->GetTrackLabelNegative()));
+   }
+   
+}
 
 //________________________________________________________________________
 void AliV0ReaderV1::Terminate(Option_t *)