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