changing access to data types of AliHLTTPCDefinition
[u/mrichter/AliRoot.git] / HLT / TPCLib / calibration / AliHLTTPCCalibTimeGainComponent.cxx
CommitLineData
33a4976d 1// $Id$
2/**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTTPCCalibTimeGainComponent.cxx
19 @author Kalliopi Kanaki
20 @date 2009-07-08
21 @brief A calibration component for the TPC gain variation vs. time.
22*/
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
30#if __GNUC__>= 3
31using namespace std;
32#endif
33
34#include "AliHLTTPCCalibTimeGainComponent.h"
33a4976d 35#include "AliHLTTPCDefinitions.h"
8d53dca2 36#include "AliHLTReadoutList.h"
1151db47 37
8677d183 38#include "AliESDEvent.h"
1151db47 39#include "AliESDtrack.h"
40
41#include "AliTPCcalibTimeGain.h"
42#include "AliTPCseed.h"
43
44#include "TObjArray.h"
45#include "TString.h"
46
33a4976d 47#include <cstdlib>
48#include <cerrno>
1151db47 49
33a4976d 50
51ClassImp(AliHLTTPCCalibTimeGainComponent) // ROOT macro for the implementation of ROOT specific class methods
52
53AliHLTTPCCalibTimeGainComponent::AliHLTTPCCalibTimeGainComponent()
54 :
55 fCalibTimeGain(NULL),
56 fESDEvent(NULL),
8677d183 57 fSeedArray(NULL),
33a4976d 58 fMinPartition(5),
59 fMaxPartition(0),
60 fMinSlice(35),
61 fMaxSlice(0),
62 fSpecification(0) ,
63 fEnableAnalysis(kTRUE)
64{
65 // see header file for class documentation
66 // or
67 // refer to README to build package
68 // or
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70}
71
72AliHLTTPCCalibTimeGainComponent::~AliHLTTPCCalibTimeGainComponent() {
73// see header file for class documentation
74}
75
76const char* AliHLTTPCCalibTimeGainComponent::GetComponentID() {
77// see header file for class documentation
78
79 return "TPCCalibTimeGain";
80}
81
82void AliHLTTPCCalibTimeGainComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
83// see header file for class documentation
84
85 list.clear();
1151db47 86 list.push_back( kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC ); // output of TPCCalibSeedMaker
87 list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut ); // output of global esd converter
33a4976d 88}
89
90AliHLTComponentDataType AliHLTTPCCalibTimeGainComponent::GetOutputDataType() {
91// see header file for class documentation
92
37250d7e 93 return AliHLTTPCDefinitions::CalibCEDataType()|kAliHLTDataOriginOut;
33a4976d 94}
95
96void AliHLTTPCCalibTimeGainComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
97// see header file for class documentation
98
99 constBase = 0;
100 inputMultiplier = (2.0); // to be estimated
101}
102
103AliHLTComponent* AliHLTTPCCalibTimeGainComponent::Spawn() {
104// see header file for class documentation
105
106 return new AliHLTTPCCalibTimeGainComponent();
107}
108
109
110Int_t AliHLTTPCCalibTimeGainComponent::ScanArgument( Int_t argc, const char** argv ) {
111// see header file for class documentation
112
113 Int_t iResult = 0;
114 TString argument = "";
115 TString parameter = "";
116
117 if(!argc) return -EINVAL;
118
119 argument = argv[iResult];
120
121 if(argument.IsNull()) return -EINVAL;
122
123 if( argument.CompareTo("-enable-analysis") == 0 ){
124 HLTInfo( "Analysis before shipping data to FXS enabled." );
125 fEnableAnalysis = kTRUE;
126 }
127 else {
128 iResult = -EINVAL;
129 }
130
131 return iResult;
132}
133
134Int_t AliHLTTPCCalibTimeGainComponent::InitCalibration() {
135// see header file for class documentation
136
137 if(fCalibTimeGain) return EINPROGRESS;
1151db47 138 //fCalibTimeGain = new AliTPCcalibTimeGain();
139 fCalibTimeGain = new AliTPCcalibTimeGain("calibTimeGain","time dependent gain calibration",-2, 2, 1);
33a4976d 140 return 0;
141}
142
143Int_t AliHLTTPCCalibTimeGainComponent::DeinitCalibration() {
144// see header file for class documentation
145
1151db47 146 if(fCalibTimeGain) delete fCalibTimeGain; fCalibTimeGain = NULL;
33a4976d 147
148 return 0;
149}
150
151Int_t AliHLTTPCCalibTimeGainComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){
152// see header file for class documentation
153
154 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
155
1151db47 156 TObject *iter = NULL;
8677d183 157
1151db47 158 //--------------- loop over the TObjArray output of AliTPCseed objects (output of TPCSeedMaker) -------------------//
8677d183 159
1151db47 160 for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); iter != NULL; iter = (TObject*)GetNextInputObject()){
161
162 if(GetDataType(iter) != (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTPC)) continue;
163 fSeedArray = dynamic_cast<TObjArray*>(iter);
164 }
165
166 //----------- loop over output of global esd converter ----------------//
167
168 for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = (TObject*)GetNextInputObject()){
169
170 if(GetDataType(iter) != (kAliHLTDataTypeESDObject | kAliHLTDataOriginOut)) continue;
8677d183 171
1151db47 172 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
173 AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
33a4976d 174
175 if( partition < fMinPartition ) fMinPartition = partition;
176 if( partition > fMaxPartition ) fMaxPartition = partition;
177 if( slice < fMinSlice ) fMinSlice = slice;
178 if( slice > fMaxSlice ) fMaxSlice = slice;
8677d183 179
1151db47 180 fESDEvent = dynamic_cast<AliESDEvent*>(iter);
8677d183 181 fESDEvent->CreateStdContent();
1151db47 182
183 HLTDebug("# Seeds: %i\n", fSeedArray->GetEntriesFast());
184
185 for(Int_t i=0; i<fSeedArray->GetEntriesFast(); i++){
186
187 AliTPCseed *seed = (AliTPCseed*)fSeedArray->UncheckedAt(i);
188 if(!seed) continue;
189 AliESDtrack *esd = fESDEvent->GetTrack(i);
190 AliTPCseed *seedCopy = new AliTPCseed(*seed, kTRUE);
191 esd->AddCalibObject(seedCopy);
192 }
33a4976d 193 }
1151db47 194
8677d183 195 fCalibTimeGain->Process(fESDEvent);
196
33a4976d 197 fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( fMinSlice, fMaxSlice, fMinPartition, fMaxPartition );
37250d7e 198 PushBack( (TObject*) fCalibTimeGain, AliHLTTPCDefinitions::CalibCEDataType()| kAliHLTDataOriginOut, fSpecification);
33a4976d 199
200 return 0;
201}
202
203Int_t AliHLTTPCCalibTimeGainComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){
204 // see header file for class documentation
205
8677d183 206 if(fEnableAnalysis) fCalibTimeGain->Analyze();
8d53dca2 207 static AliHLTReadoutList rdList(AliHLTReadoutList::kTPC);
89413559 208 PushToFXS( (TObject*) fCalibTimeGain, "TPC", "TimeGain", &rdList ) ;
33a4976d 209
210 return 0;
211}
212
213