]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/Calib/AliAnalysisTaskPt.cxx
o add Reset function to CalPad and CalROC o Add functionality to AliTPCdataQA - Reset...
[u/mrichter/AliRoot.git] / TPC / Calib / AliAnalysisTaskPt.cxx
index e742d2c61be60b02f3502b553e3c406cb6b6dab1..8e81dd8c758bbb8b5d5700330a3a0e18f5156b13 100644 (file)
@@ -8,14 +8,13 @@
 #include "AliAnalysisManager.h"
 
 #include "AliESDEvent.h"
-#include "AliVVevent.h"
-#include "AliVVtrack.h"
 #include "AliESDtrackCuts.h"
 #include "AliVEventHandler.h"
 #include "AliTPCseed.h"
 #include "AliTPCclusterMI.h"
 #include "AliVfriendEvent.h"
 #include "AliVfriendTrack.h"
+#include "AliESDInputHandler.h"
 
 #include "AliAnalysisTaskPt.h"
 
@@ -48,7 +47,8 @@ void AliAnalysisTaskPt::ConnectInputData(Option_t *)
   TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
   if (!tree) {
     Printf("ERROR: Could not read chain from input slot 0");
-  } else {
+  } 
+  else {
     // Disable all branches and enable only the needed ones
     // The next two lines are different when data produced as AliESDEvent is read
     /*
@@ -57,15 +57,37 @@ void AliAnalysisTaskPt::ConnectInputData(Option_t *)
     */
 
     AliVEventHandler *esdH = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+    TString classInputHandler = esdH->ClassName();
+
+    Printf("----> AliAnalysisTaskPt: ClassName of handler = %s", classInputHandler.Data());
 
     if (!esdH) {
       Printf("ERROR: Could not get ESDInputHandler");
-    } else {
+    } 
+    else {
       Printf("----> AliAnalysisTaskPt::ConnectInputData Getting the event from handler %p", esdH);
-      //fESD = dynamic_cast<AliESDEvent*>(esdH->GetEvent());
-      fESD = esdH->GetVVEvent();
-      if (fUseFriends){        
-       fESDfriend = esdH->GetVFriendEvent();
+      fESD = esdH->GetEvent();
+      if (fUseFriends){
+       Printf("...We have to use the friends...");
+       if (classInputHandler.Contains("HLT")) { // we are running in HLT
+         fESDfriend = esdH->GetVfriendEvent();
+       }
+       else { /// we are running offline
+         if (esdH && esdH->GetTree()) {
+           Printf("...We got the tree...");
+           if (esdH->GetTree()->GetBranch("ESDfriend.")){
+             Printf("Yu-huuuu!!! friend branch found");
+             fESDfriend = ((AliESDInputHandler*)esdH)->GetESDfriend();
+           }
+           else {
+             Printf("No friend branch found");
+           }
+         }
+       }       
+       Printf("and the result is: fESDfriend = %p", fESDfriend);
+      }
+      else {
+       Printf("The friends are not requested");
       }
     }
     if (!fESD) {
@@ -136,11 +158,26 @@ void AliAnalysisTaskPt::Exec(Option_t *)
     Printf("ERROR: fESD not available");
     return;
   }
-  if (!fESDfriend) {
-    Printf("ERROR: fESDfriend not available");
-      if (fUseFriends){
+
+  /*
+  if (fUseFriends){
+    Printf("In Exec: ...We have to use the friends...");
+    fESDfriend = fESD->FindFriend();
+    Printf("...and we got friends = %p", fESDfriend);
+    if (!fESDfriend) {
+      Printf("ERROR: fESDfriend not available");
        return;
-      }
+    }
+  }
+  */
+
+  if (fUseFriends){
+    Printf("In Exec: ...We have to use the friends...");
+    Printf("...and we got friends = %p", fESDfriend);
+    if (!fESDfriend) {
+      Printf("ERROR: fESDfriend not available");
+       return;
+    }
   }
 
   Int_t nESDtracks = fESD->GetNumberOfTracks();
@@ -154,30 +191,35 @@ void AliAnalysisTaskPt::Exec(Option_t *)
 
   // Track loop to fill a pT spectrum
   for (Int_t iTracks = 0; iTracks < nESDtracks; iTracks++) {
-    Printf("Checking track %d: Note that with Flat, the GetTrack is not yet implemented!!!", iTracks);
-    const AliVVtrack* track = fESD->GetVVTrack(iTracks);
+    Printf("Checking track %d", iTracks);
+    const AliVTrack* track = dynamic_cast<AliVTrack*>(fESD->GetTrack(iTracks));
     if (!track) {
       Printf("ERROR: Could not receive track %d", iTracks);
       continue;
     }
-    Printf("track %d has pt = %f", iTracks, track->GetPt());
-    fHistPt->Fill(track->GetPt());
+    Printf("track %d has pt = %f", iTracks, track->Pt());
+    fHistPt->Fill(track->Pt());
     fHistNTPCCl->Fill(track->GetTPCNcls());
   } //track loop 
 
 
   if (fUseFriends){
+    Printf("In the loop over the friends");
     // Friend Track loop
     for (Int_t iFriend = 0; iFriend < nESDfriendtracks; iFriend++) {
-      //Printf("Getting friend %d", iFriend);
+      Printf("Getting friend %d", iFriend);
       const AliVfriendTrack* friendTrack = fESDfriend->GetTrack(iFriend);
       if (!friendTrack) {
        Printf("ERROR: Could not receive track %d", iFriend);
        continue;
       }
+      else {
+       Printf("friend track = %p", friendTrack);
+      }
       
       AliTPCseed seed;
       Int_t err = friendTrack->GetTPCseed( seed );
+      Printf("err = %d", err);
       if( err==0 ){
        Printf("Found TPC seed" );
        for (Int_t irow = 0; irow < 160; irow++){