]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCAnalysisTaskcalib.cxx
Adding stream level and debug streamer to the base class
[u/mrichter/AliRoot.git] / TPC / AliTPCAnalysisTaskcalib.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 ///////////////////////////////////////////////////////////////////////////////
18 //                                                                           //
19 // blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa //
20 //                                                                           //
21 ///////////////////////////////////////////////////////////////////////////////
22 #include "AliTPCAnalysisTaskcalib.h"
23 #include "TChain.h"
24 #include "AliTPCcalibBase.h"
25 #include "AliESDEvent.h"
26 #include "AliESDfriend.h"
27 #include "AliESDfriendTrack.h"
28 #include "AliTPCseed.h"
29 #include "AliESDInputHandler.h"
30 #include "AliAnalysisManager.h"
31
32 ClassImp(AliTPCAnalysisTaskcalib)
33
34 AliTPCAnalysisTaskcalib::AliTPCAnalysisTaskcalib(const char *name) 
35   :AliAnalysisTask(name,""),
36    fCalibJobs(0),
37    fESD(0),
38    fESDfriend(0)
39 {
40   //
41   // Constructor
42   //
43   DefineInput(0, TChain::Class());
44   DefineOutput(0, TObjArray::Class());
45 }
46
47 AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
48   //
49   // destructor
50   //
51 }
52
53 void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
54   //
55   // Exec function
56   // Loop over tracks and call  Process function
57   if (!fESD) {
58     Printf("ERROR: fESD not available");
59     return;
60   }
61   fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
62   if (!fESDfriend) {
63     Printf("ERROR: fESDfriend not available");
64     return;
65   }
66   Int_t n=fESD->GetNumberOfTracks();
67   for (Int_t i=0;i<n;++i) {
68     AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
69     TObject *calibObject=0;
70     AliTPCseed *seed=0;
71     for (Int_t j=0;(calibObject=friendTrack->GetCalibObject(j));++j)
72       if ((seed=dynamic_cast<AliTPCseed*>(calibObject)))
73         break;
74     if (seed)
75       Process(seed);
76   }
77   PostData(0,&fCalibJobs);
78 }
79
80 void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
81   //
82   //
83   //
84   TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
85   if (!tree) {
86     Printf("ERROR: Could not read chain from input slot 0");
87   } 
88   else {
89     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
90     if (!esdH) {
91       Printf("ERROR: Could not get ESDInputHandler");
92     } 
93     else {
94       fESD = esdH->GetEvent();
95       Printf("*** CONNECTED NEW EVENT ****");
96     }
97   }
98 }
99
100 void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
101   //
102   //
103   //
104 }
105 void AliTPCAnalysisTaskcalib::Terminate(Option_t */*option*/) {
106   TIterator *i=fCalibJobs.MakeIterator();
107   AliTPCcalibBase *job;
108   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
109     job->Terminate();
110 }
111
112 // we could have been living inside a master class...
113 void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
114   TIterator *i=fCalibJobs.MakeIterator();
115   AliTPCcalibBase *job;
116   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
117     job->Process(event);
118 }
119
120 void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
121   TIterator *i=fCalibJobs.MakeIterator();
122   AliTPCcalibBase *job;
123   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
124     job->Process(track);
125 }
126
127 Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
128   TIterator *i=fCalibJobs.MakeIterator();
129   AliTPCcalibBase *job;
130   Long64_t n=0;
131   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
132     n+=job->Merge(li);
133   return n;
134 }
135
136 void AliTPCAnalysisTaskcalib::Analyze() {
137   TIterator *i=fCalibJobs.MakeIterator();
138   AliTPCcalibBase *job;
139   while ((job=dynamic_cast<AliTPCcalibBase*>(i->Next())))
140     job->Analyze();
141 }