]>
Commit | Line | Data |
---|---|---|
02d01bbf | 1 | /************************************************************************** |
9be2600f | 2 | * This file is property of and copyright by the ALICE HLT Project * |
3 | * ALICE Experiment at CERN, All rights reserved. * | |
02d01bbf | 4 | * * |
9be2600f | 5 | * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * |
6 | * for The ALICE HLT Project. * | |
02d01bbf | 7 | * * |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /** @file AliHLTTPCCalibPedestalComponent.cxx | |
18 | @author Jochen Thaeder | |
19 | @date | |
20 | @brief A pedestal calibration component for the TPC. | |
21 | */ | |
22 | ||
6a8e0bb4 | 23 | // see header file for class documentation |
24 | // or | |
25 | // refer to README to build package | |
26 | // or | |
27 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
28 | ||
02d01bbf | 29 | #if __GNUC__>= 3 |
30 | using namespace std; | |
31 | #endif | |
32 | ||
33 | #include "AliHLTTPCLogging.h" | |
34 | #include "AliHLTTPCTransform.h" | |
35 | ||
36 | #include "AliHLTTPCCalibPedestalComponent.h" | |
37 | ||
38 | #include "AliRawDataHeader.h" | |
39 | #include "AliRawReaderMemory.h" | |
40 | #include "AliTPCRawStream.h" | |
41 | ||
42 | #include "AliTPCCalibPedestal.h" | |
43 | ||
44 | #include <stdlib.h> | |
45 | #include <errno.h> | |
46 | #include "TString.h" | |
47 | ||
672f8b8c | 48 | /** ROOT macro for the implementation of ROOT specific class methods */ |
02d01bbf | 49 | ClassImp(AliHLTTPCCalibPedestalComponent) |
50 | ||
51 | AliHLTTPCCalibPedestalComponent::AliHLTTPCCalibPedestalComponent() | |
52 | : | |
53 | fRawReader(NULL), | |
54 | fRawStream(NULL), | |
55 | fCalibPedestal(NULL), | |
9d9ffd37 | 56 | fRCUFormat(kFALSE), |
57 | fMinPatch(5), | |
58 | fMaxPatch(0), | |
59 | fSpecification(0) , | |
60 | fEnableAnalysis(kFALSE) { | |
02d01bbf | 61 | // see header file for class documentation |
62 | // or | |
63 | // refer to README to build package | |
64 | // or | |
65 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
66 | } | |
67 | ||
9d9ffd37 | 68 | AliHLTTPCCalibPedestalComponent::~AliHLTTPCCalibPedestalComponent() { |
02d01bbf | 69 | // see header file for class documentation |
70 | } | |
71 | ||
72 | // Public functions to implement AliHLTComponent's interface. | |
73 | // These functions are required for the registration process | |
74 | ||
9d9ffd37 | 75 | const char* AliHLTTPCCalibPedestalComponent::GetComponentID() { |
02d01bbf | 76 | // see header file for class documentation |
9d9ffd37 | 77 | |
02d01bbf | 78 | return "TPCCalibPedestal"; |
79 | } | |
80 | ||
9d9ffd37 | 81 | void AliHLTTPCCalibPedestalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { |
02d01bbf | 82 | // see header file for class documentation |
9d9ffd37 | 83 | |
02d01bbf | 84 | list.clear(); |
85 | list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType ); | |
86 | } | |
87 | ||
9d9ffd37 | 88 | AliHLTComponentDataType AliHLTTPCCalibPedestalComponent::GetOutputDataType() { |
02d01bbf | 89 | // see header file for class documentation |
9d9ffd37 | 90 | |
02d01bbf | 91 | return AliHLTTPCDefinitions::fgkCalibPedestalDataType; |
92 | } | |
93 | ||
9d9ffd37 | 94 | void AliHLTTPCCalibPedestalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { |
02d01bbf | 95 | // see header file for class documentation |
9d9ffd37 | 96 | |
02d01bbf | 97 | // XXX TODO: Find more realistic values. |
98 | constBase = 0; | |
99 | inputMultiplier = (2.0); | |
100 | } | |
101 | ||
9d9ffd37 | 102 | AliHLTComponent* AliHLTTPCCalibPedestalComponent::Spawn() { |
02d01bbf | 103 | // see header file for class documentation |
9d9ffd37 | 104 | |
02d01bbf | 105 | return new AliHLTTPCCalibPedestalComponent(); |
106 | } | |
107 | ||
9d9ffd37 | 108 | |
109 | Int_t AliHLTTPCCalibPedestalComponent::ScanArgument( Int_t argc, const char** argv ) { | |
02d01bbf | 110 | // see header file for class documentation |
9d9ffd37 | 111 | |
112 | Int_t iResult = 0; | |
113 | TString argument = ""; | |
114 | TString parameter = ""; | |
115 | ||
116 | if ( !argc ) | |
117 | return -EINVAL; | |
118 | ||
119 | argument = argv[iResult]; | |
02d01bbf | 120 | |
9d9ffd37 | 121 | if ( argument.IsNull() ) |
122 | return -EINVAL; | |
02d01bbf | 123 | |
9d9ffd37 | 124 | // -rcuformat |
125 | if ( argument.CompareTo("-rcuformat") == 0 ) { | |
126 | ||
127 | if ( ++iResult >= argc ) { | |
128 | iResult = -EPROTO; | |
129 | } | |
130 | else { | |
131 | parameter = argv[1]; | |
132 | if ( parameter.CompareTo("old") == 0 ) { | |
02d01bbf | 133 | fRCUFormat = kTRUE; |
9d9ffd37 | 134 | HLTInfo( "RCU Format is set to old." ); |
02d01bbf | 135 | } |
9d9ffd37 | 136 | else if ( parameter.CompareTo("new") == 0 ) { |
02d01bbf | 137 | fRCUFormat = kFALSE; |
9d9ffd37 | 138 | HLTInfo( "RCU Format is set to new." ); |
02d01bbf | 139 | } |
140 | else { | |
9d9ffd37 | 141 | HLTError( "Cannot convert rcu format specifier '%s'.", argv[1] ); |
142 | iResult = -EPROTO; | |
02d01bbf | 143 | } |
9d9ffd37 | 144 | } |
145 | } | |
146 | else if ( argument.CompareTo("-enableanalysis") == 0 ) { | |
147 | HLTInfo( "Analysis before shipping data to FXS enabled." ); | |
148 | fEnableAnalysis = kTRUE; | |
149 | } | |
150 | else { | |
151 | iResult = -EINVAL; | |
152 | } | |
02d01bbf | 153 | |
9d9ffd37 | 154 | return iResult; |
155 | } | |
02d01bbf | 156 | |
9d9ffd37 | 157 | Int_t AliHLTTPCCalibPedestalComponent::InitCalibration() { |
158 | // see header file for class documentation | |
02d01bbf | 159 | |
02d01bbf | 160 | // ** Create pedestal calibration |
161 | if ( fCalibPedestal ) | |
162 | return EINPROGRESS; | |
163 | ||
164 | fCalibPedestal = new AliTPCCalibPedestal(); | |
165 | ||
166 | // ** Create AliRoot Memory Reader | |
167 | if (fRawReader) | |
168 | return EINPROGRESS; | |
169 | ||
02d01bbf | 170 | fRawReader = new AliRawReaderMemory(); |
02d01bbf | 171 | |
172 | return 0; | |
173 | } | |
174 | ||
9d9ffd37 | 175 | Int_t AliHLTTPCCalibPedestalComponent::DeinitCalibration() { |
02d01bbf | 176 | // see header file for class documentation |
177 | ||
178 | if ( fRawReader ) | |
179 | delete fRawReader; | |
180 | fRawReader = NULL; | |
181 | ||
182 | if ( fCalibPedestal ) | |
183 | delete fCalibPedestal; | |
184 | fCalibPedestal = NULL; | |
185 | ||
186 | return 0; | |
187 | } | |
188 | ||
189 | /* | |
02d01bbf | 190 | * --- setter for rcuformat need in AliTPCCalibPedestal class |
191 | */ | |
ed504011 | 192 | Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, |
193 | AliHLTComponentTriggerData& /*trigData*/ ) { | |
02d01bbf | 194 | // see header file for class documentation |
195 | ||
196 | const AliHLTComponentBlockData* iter = NULL; | |
02d01bbf | 197 | |
83fec083 | 198 | AliHLTUInt8_t slice=0, patch=0; |
6a8e0bb4 | 199 | Int_t ddlId = 0; |
02d01bbf | 200 | |
201 | // ** Loop over all input blocks and specify which data format should be read - only select Raw Data | |
ed504011 | 202 | iter = GetFirstInputBlock( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC); |
02d01bbf | 203 | |
204 | while ( iter != NULL ) { | |
205 | ||
206 | // ** Print Debug output which data format was received | |
017efeea | 207 | // char tmp1[14], tmp2[14]; |
ed504011 | 208 | // DataType2Text( iter->fDataType, tmp1 ); |
209 | // DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); | |
210 | // HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
211 | // evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
02d01bbf | 212 | |
213 | // ** Get DDL ID in order to tell the memory reader which slice/patch to use | |
214 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
215 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
216 | ||
6a8e0bb4 | 217 | if (patch < 2) ddlId = 768 + (2 * slice) + patch; |
218 | else ddlId = 838 + (4*slice) + patch; | |
02d01bbf | 219 | |
6a8e0bb4 | 220 | HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, ddlId ); |
02d01bbf | 221 | |
222 | // ** Get min and max patch, used for output specification | |
9d9ffd37 | 223 | if ( patch < fMinPatch ) fMinPatch = patch; |
224 | if ( patch > fMaxPatch ) fMaxPatch = patch; | |
02d01bbf | 225 | |
226 | // ** Init TPCRawStream | |
227 | fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); | |
6a8e0bb4 | 228 | fRawReader->SetEquipmentID(ddlId); |
02d01bbf | 229 | |
230 | fRawStream = new AliTPCRawStream( fRawReader ); | |
231 | fRawStream->SetOldRCUFormat( fRCUFormat ); | |
232 | ||
233 | // ** Process actual Pedestal Calibration - Fill histograms | |
234 | fCalibPedestal->ProcessEvent( fRawStream ); | |
235 | ||
236 | // ** Delete TPCRawStream | |
237 | if ( fRawStream ) | |
238 | delete fRawStream; | |
239 | fRawStream = NULL; | |
240 | ||
241 | // ** Get next input block, with the same specification as defined in GetFirstInputBlock() | |
242 | iter = GetNextInputBlock(); | |
243 | ||
244 | } // while ( iter != NULL ) { | |
9d9ffd37 | 245 | |
246 | // ** Get output specification | |
247 | fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, fMinPatch, fMaxPatch ); | |
248 | ||
249 | // ** PushBack data to shared memory ... | |
250 | PushBack( (TObject*) fCalibPedestal, AliHLTTPCDefinitions::fgkCalibPedestalDataType, fSpecification); | |
02d01bbf | 251 | |
9d9ffd37 | 252 | return 0; |
253 | } // Int_t AliHLTTPCCalibPedestalComponent::ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { | |
02d01bbf | 254 | |
9d9ffd37 | 255 | |
ed504011 | 256 | Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, |
257 | AliHLTComponentTriggerData& /*trigData*/ ) { | |
9d9ffd37 | 258 | // see header file for class documentation |
259 | ||
260 | if ( fEnableAnalysis ) | |
261 | fCalibPedestal->Analyse(); | |
02d01bbf | 262 | |
9d9ffd37 | 263 | // ** PushBack data to FXS ... |
264 | PushToFXS( (TObject*) fCalibPedestal, "TPC", "Pedestal" ) ; | |
02d01bbf | 265 | |
266 | return 0; | |
9d9ffd37 | 267 | } // Int_t AliHLTTPCCalibPedestalComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) { |
268 | ||
269 |