]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCAnalysisTaskcalib.cxx
Adding task encapsulated TPC calibration components using tracks (Marian)
[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 {
39   //
40   // Constructor
41   //
42   DefineInput(0, TChain::Class());
43   DefineOutput(0, TObjArray::Class());
44 }
45
46 AliTPCAnalysisTaskcalib::~AliTPCAnalysisTaskcalib() {
47   //
48   // destructor
49   //
50 }
51
52 void AliTPCAnalysisTaskcalib::Exec(Option_t *) {
53   //
54   // Exec function
55   // Loop over tracks and call  Process function
56   if (!fESD) {
57     Printf("ERROR: fESD not available");
58     return;
59   }
60   fESDfriend=static_cast<AliESDfriend*>(fESD->FindListObject("AliESDfriend"));
61   if (!fESDfriend) {
62     Printf("ERROR: fESDfriend not available");
63     return;
64   }
65   Int_t n=fESD->GetNumberOfTracks();
66   for (Int_t i=0;i<n;++i) {
67     AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(i);
68     TObject *calibObject;
69     AliTPCseed *seed=0;
70     for (Int_t j=0;calibObject=friendTrack->GetCalibObject(j);++j)
71       if (seed=dynamic_cast<AliTPCseed*>(calibObject))
72         break;
73     if (seed)
74       Process(seed);
75   }
76   PostData(0,&fCalibJobs);
77 }
78
79 void AliTPCAnalysisTaskcalib::ConnectInputData(Option_t *) {
80   //
81   //
82   //
83   TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
84   if (!tree) {
85     Printf("ERROR: Could not read chain from input slot 0");
86   } 
87   else {
88     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
89     if (!esdH) {
90       Printf("ERROR: Could not get ESDInputHandler");
91     } 
92     else {
93       fESD = esdH->GetEvent();
94       Printf("*** CONNECTED NEW EVENT ****");
95     }
96   }
97 }
98
99 void AliTPCAnalysisTaskcalib::CreateOutputObjects() {
100   //
101   //
102   //
103 }
104 void AliTPCAnalysisTaskcalib::Terminate(Option_t *option) {
105 }
106
107 // we could have been living inside a master class...
108 void AliTPCAnalysisTaskcalib::Process(AliESDEvent *event) {
109   TIterator *i=fCalibJobs.MakeIterator();
110   AliTPCcalibBase *job;
111   while (job=dynamic_cast<AliTPCcalibBase*>(i->Next()))
112     job->Process(event);
113 }
114
115 void AliTPCAnalysisTaskcalib::Process(AliTPCseed *track) {
116   TIterator *i=fCalibJobs.MakeIterator();
117   AliTPCcalibBase *job;
118   while (job=dynamic_cast<AliTPCcalibBase*>(i->Next()))
119     job->Process(track);
120 }
121
122 Long64_t AliTPCAnalysisTaskcalib::Merge(TCollection *li) {
123   TIterator *i=fCalibJobs.MakeIterator();
124   AliTPCcalibBase *job;
125   Long64_t n=0;
126   while (job=dynamic_cast<AliTPCcalibBase*>(i->Next()))
127     n+=job->Merge(li);
128   return n;
129 }
130
131 void AliTPCAnalysisTaskcalib::Analyze() {
132   TIterator *i=fCalibJobs.MakeIterator();
133   AliTPCcalibBase *job;
134   while (job=dynamic_cast<AliTPCcalibBase*>(i->Next()))
135     job->Analyze();
136 }