write only the complement in the case of hybrid tracks
[u/mrichter/AliRoot.git] / ANALYSIS / AliEPSelectionTask.cxx
index 2764442..2d6007b 100644 (file)
@@ -308,53 +308,54 @@ void AliEPSelectionTask::UserExec(Option_t */*option*/)
   }
   
     else if (fAnalysisInput.CompareTo("AOD")==0){
-    AliAODEvent *aod =  dynamic_cast<AliAODEvent*> (InputEvent());
+    AliVEvent* event = InputEvent();
+    AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
 
-    if (!(fRunNumber == aod->GetRunNumber())) {
-      fRunNumber = aod->GetRunNumber();
-      SetPhiDist();      
-    }
-  
-    if (fUseMCRP) {
-      AliAODMCHeader *headerH = dynamic_cast<AliAODMCHeader*>(aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
-      if (headerH) fRP = headerH->GetReactionPlaneAngle();
-    }
-  
     if (aod){
+      if (!(fRunNumber == aod->GetRunNumber())) {
+        fRunNumber = aod->GetRunNumber();
+        SetPhiDist();      
+      }
+
+      if (fUseMCRP) {
+       AliAODMCHeader *headerH = dynamic_cast<AliAODMCHeader*>(aod->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
+       if (headerH) fRP = headerH->GetReactionPlaneAngle();
+      }
+  
       esdEP = aod->GetHeader()->GetEventplaneP();
-      if(esdEP) {esdEP->Reset();} // reset eventplane if not NULL       
+      esdEP->Reset(); 
      
-    Int_t maxID = 0;
-    TObjArray* tracklist = GetAODTracksAndMaxID(aod,maxID);
+      Int_t maxID = 0;
+      TObjArray* tracklist = GetAODTracksAndMaxID(aod,maxID);
        
-    if (fSaveTrackContribution) {
-      esdEP->GetQContributionXArray()->Set(maxID+1);
-      esdEP->GetQContributionYArray()->Set(maxID+1);
-      esdEP->GetQContributionXArraysub1()->Set(maxID+1);
-      esdEP->GetQContributionYArraysub1()->Set(maxID+1);
-      esdEP->GetQContributionXArraysub2()->Set(maxID+1);
-      esdEP->GetQContributionYArraysub2()->Set(maxID+1);
-    }
+      if (fSaveTrackContribution) {
+       esdEP->GetQContributionXArray()->Set(maxID+1);
+       esdEP->GetQContributionYArray()->Set(maxID+1);
+       esdEP->GetQContributionXArraysub1()->Set(maxID+1);
+       esdEP->GetQContributionYArraysub1()->Set(maxID+1);
+       esdEP->GetQContributionXArraysub2()->Set(maxID+1);
+       esdEP->GetQContributionYArraysub2()->Set(maxID+1);
+      }
        
-    const int NT = tracklist->GetEntries();
+      const int NT = tracklist->GetEntries();
       
-  if (NT>4){
-    fQVector = new TVector2(GetQ(esdEP,tracklist));
-    fEventplaneQ = fQVector->Phi()/2.; 
-    GetQsub(qq1, qq2, tracklist, esdEP);
-    fQsub1 = new TVector2(qq1);
-    fQsub2 = new TVector2(qq2);
-    fQsubRes = (fQsub1->Phi()/2. - fQsub2->Phi()/2.);
+      if (NT>4){
+       fQVector = new TVector2(GetQ(esdEP,tracklist));
+       fEventplaneQ = fQVector->Phi()/2.; 
+       GetQsub(qq1, qq2, tracklist, esdEP);
+       fQsub1 = new TVector2(qq1);
+       fQsub2 = new TVector2(qq2);
+       fQsubRes = (fQsub1->Phi()/2. - fQsub2->Phi()/2.);
+       
+       esdEP->SetQVector(fQVector);
+       esdEP->SetEventplaneQ(fEventplaneQ);
+       esdEP->SetQsub(fQsub1,fQsub2);
+       esdEP->SetQsubRes(fQsubRes);
        
-    esdEP->SetQVector(fQVector);
-    esdEP->SetEventplaneQ(fEventplaneQ);
-    esdEP->SetQsub(fQsub1,fQsub2);
-    esdEP->SetQsubRes(fQsubRes);
+       fHOutEventplaneQ->Fill(fEventplaneQ);
+       fHOutsub1sub2->Fill(fQsub1->Phi()/2.,fQsub2->Phi()/2.);
+       fHOutNTEPRes->Fill(NT,fQsubRes);
        
-    fHOutEventplaneQ->Fill(fEventplaneQ);
-    fHOutsub1sub2->Fill(fQsub1->Phi()/2.,fQsub2->Phi()/2.);
-    fHOutNTEPRes->Fill(NT,fQsubRes);
-
        if (fUseMCRP) fHOutDiff->Fill(fEventplaneQ, fRP);
        
        for (int iter = 0; iter<NT;iter++){
@@ -592,7 +593,7 @@ Double_t AliEPSelectionTask::GetWeight(TObject* track1)
 {
   Double_t ptweight=1;
   AliVTrack* track = dynamic_cast<AliVTrack*>(track1);
-  if (fUsePtWeight) {      
+  if (fUsePtWeight && track) {      
     if (track->Pt()<2) ptweight=track->Pt();
     else ptweight=2;
   }