]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCCalibSignalComponent.cxx
Adding fClusterMap and fSharedMap of TPC clusters for the tracks
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCalibSignalComponent.cxx
1
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
8  *                  Sorina Popescu <sorina.popescu@cern.ch                *
9  *                  for The ALICE HLT Project.                            *
10  *                                                                        *
11  * Permission to use, copy, modify and distribute this software and its   *
12  * documentation strictly for non-commercial purposes is hereby granted   *
13  * without fee, provided that the above copyright notice appears in all   *
14  * copies and that both the copyright notice and this permission notice   *
15  * appear in the supporting documentation. The authors make no claims     *
16  * about the suitability of this software for any purpose. It is          *
17  * provided "as is" without express or implied warranty.                  *
18  **************************************************************************/
19
20 /** @file   AliHLTTPCCalibSignalComponent.cxx
21     @author Jochen Thaeder, Sorina Popescu
22     @date   8 may 2007
23     @brief  HLT pulser calibration component for the TPC.
24 */
25
26 #if __GNUC__>= 3
27 using namespace std;
28 #endif
29
30 #include "AliHLTTPCLogging.h"
31 #include "AliHLTTPCTransform.h"
32
33 #include "AliHLTTPCCalibSignalComponent.h"
34
35 #include "AliRawDataHeader.h"
36 #include "AliRawReaderMemory.h"
37 #include "AliTPCRawStream.h"
38
39 #include "AliTPCCalibSignal.h"
40
41 #include <stdlib.h>
42 #include <errno.h>
43 #include "TString.h"
44
45 // this is a global object used for automatic component registration, do not use this
46 AliHLTTPCCalibSignalComponent gAliHLTTPCCalibSignalComponent;
47
48 ClassImp(AliHLTTPCCalibSignalComponent)
49
50 AliHLTTPCCalibSignalComponent::AliHLTTPCCalibSignalComponent()
51   :
52   fRawReader(NULL),
53   fRawStream(NULL),
54   fCalibSignal(NULL),
55   fRCUFormat(kFALSE)
56 {
57   // see header file for class documentation
58   // or
59   // refer to README to build package
60   // or
61   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 }
63
64 AliHLTTPCCalibSignalComponent::AliHLTTPCCalibSignalComponent(const AliHLTTPCCalibSignalComponent&)
65   :
66   fRawReader(NULL),
67   fRawStream(NULL),
68   fCalibSignal(NULL),
69   fRCUFormat(kFALSE)
70 {
71   // see header file for class documentation
72   HLTFatal("copy constructor to be tested");
73 }
74
75 AliHLTTPCCalibSignalComponent& AliHLTTPCCalibSignalComponent::operator=(const AliHLTTPCCalibSignalComponent&)
76
77   // see header file for class documentation
78   HLTFatal("assignment operator to be tested");
79   return *this;
80 }       
81
82 AliHLTTPCCalibSignalComponent::~AliHLTTPCCalibSignalComponent()
83 {
84   // see header file for class documentation
85 }
86
87 // Public functions to implement AliHLTComponent's interface.
88 // These functions are required for the registration process
89
90 const char* AliHLTTPCCalibSignalComponent::GetComponentID()
91 {
92   // see header file for class documentation
93   return "TPCCalibSignal";
94 }
95
96 void AliHLTTPCCalibSignalComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
97 {
98   // see header file for class documentation
99   list.clear(); 
100   list.push_back( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
101 }
102
103 AliHLTComponentDataType AliHLTTPCCalibSignalComponent::GetOutputDataType()
104 {
105   // see header file for class documentation
106   return AliHLTTPCDefinitions::fgkCalibSignalDataType;
107 }
108
109 void AliHLTTPCCalibSignalComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
110 {
111   // see header file for class documentation
112   // XXX TODO: Find more realistic values.  
113   constBase = 0;
114   inputMultiplier = (2.0);
115 }
116
117 AliHLTComponent* AliHLTTPCCalibSignalComponent::Spawn()
118 {
119   // see header file for class documentation
120   return new AliHLTTPCCalibSignalComponent();
121 }  
122
123 Int_t AliHLTTPCCalibSignalComponent::DoInit( int argc, const char** argv )
124 {
125   // see header file for class documentation
126   
127   // ** Interprete commandline arguments
128   Int_t i = 0;
129   Char_t* cpErr;
130
131   while ( i < argc ) {      
132     
133     // -- rcu format option-- default in constructor: kFALSE => use new data format
134     if ( !strcmp( argv[i], "rcuformat" ) ) {
135       if ( argc <= i+1 ) {
136         HLTError( "Missing RCU format - RCU format not specified" );
137         return ENOTSUP;
138       }
139       
140       // Decodes the rcu format --  options: "old" or "new"
141       if ( !strcmp( argv[i+1], "old" ) ) {
142         fRCUFormat = kTRUE;
143       }
144       else if ( !strcmp( argv[i+1], "new" ) ) {
145         fRCUFormat = kFALSE;
146       }
147       else {
148         HLTError( "Missing RCU format - Cannot convert rcu format  specifier '%s'.", argv[i+1] );
149         return EINVAL;
150       }
151       
152       i += 2;
153       continue;
154     }
155
156     HLTError( "Unknown Option - Unknown option '%s'", argv[i] );
157     return EINVAL;
158     
159   }
160   
161   // ** Create Signal calibration
162   if ( fCalibSignal )
163     return EINPROGRESS;
164   
165   fCalibSignal = new AliTPCCalibSignal();
166
167   // **  Create AliRoot Memory Reader
168   if (fRawReader)
169     return EINPROGRESS;
170
171 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) 
172   fRawReader = new AliRawReaderMemory();
173 #else
174   HLTFatal("AliRawReader  not available - check your build");
175   return -ENODEV;
176 #endif
177
178   return 0;
179 }
180
181 Int_t AliHLTTPCCalibSignalComponent::DoDeinit()
182 {
183   // see header file for class documentation
184
185   if ( fRawReader )
186     delete fRawReader;
187   fRawReader = NULL;
188
189   if ( fCalibSignal )
190     delete fCalibSignal;
191   fCalibSignal = NULL;
192
193   return 0;
194 }
195
196 /*
197  * --- will be changing with the Calibration Processor, -> Split DoEvent into 2 functions:
198  *    --- > Process event
199  *    --- > Ship Data to FXS
200  * --- setter for rcuformat need in AliTPCCalibSignal class
201  */
202 Int_t AliHLTTPCCalibSignalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
203   // see header file for class documentation
204
205   const AliHLTComponentBlockData* iter = NULL;
206   AliHLTUInt32_t spec = 0;
207
208   Int_t slice, patch;
209   Int_t minPatch = 5;
210   Int_t maxPatch = 0;
211   Int_t DDLid = 0;
212  
213   //--------same as for pedestal
214
215   // ** Loop over all input blocks and specify which data format should be read
216   iter = GetFirstInputBlock( AliHLTTPCDefinitions::fgkDDLPackedRawDataType );
217   
218   while ( iter != NULL ) {
219     
220     // ** Print Debug output which data format was received
221     char tmp1[14], tmp2[14];
222     DataType2Text( iter->fDataType, tmp1 );
223     DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 );
224
225     HLTDebug ( "Event received - Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
226
227     // ** Get DDL ID in order to tell the memory reader which slice/patch to use
228     slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
229     patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
230
231     if (patch < 2) DDLid = 768 + (2 * slice) + patch;
232     else DDLid = 838 + (4*slice) + patch;
233
234     // ---------
235     
236     HLTDebug ( "Input Raw Data - Slice/Patch: %d/%d - EquipmentID : %d.", slice, patch, DDLid );
237     
238     // ** Get the  min and max patch, used in the output specfication
239     if ( patch < minPatch ) minPatch =  patch;
240     if ( patch > maxPatch ) maxPatch =  patch;
241
242     // ** Init TPCRawStream
243     fRawReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
244     fRawReader->SetEquipmentID(DDLid);
245
246     fRawStream = new AliTPCRawStream( fRawReader );
247     fRawStream->SetOldRCUFormat( fRCUFormat );
248
249     fCalibSignal->ProcessEvent( fRawStream );
250   
251     if ( fRawStream )
252       delete fRawStream;
253     fRawStream = NULL;    
254
255     //-----------
256     // ** Get next input block, with the same specification as defined in GetFirstInputBlock()
257     iter = GetNextInputBlock();
258
259   } //  while ( iter != NULL ) {
260   
261   // !!! HIGHLY DEBUG !!!
262   // fCalibSignal->DumpToFile("Signal.root");
263   // !!! HIGHLY DEBUG !!!
264
265   // ** Call only at END of RUN event
266   //  fCalibSignal->Analyse();
267   
268   // ** PushBack data to shared memory ... 
269
270   spec = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
271   PushBack( (TObject*) fCalibSignal, AliHLTTPCDefinitions::fgkCalibSignalDataType, spec);
272   
273   return 0;
274 } // Int_t AliHLTTPCCalibSignalComponent::DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData ) {
275 //-------------