]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCKryptonClusterFinderComponent.cxx
db3dd3490d6fa0c510cc7b8b7415ab1dc7e6273e
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCKryptonClusterFinderComponent.cxx
1 // $Id$
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: Kenneth Aamodt                                        *
8  *                  Kalliopi Kanaki                                       *
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   AliHLTTPCKryptonClusterFinderComponent.cxx
21     @author Kenneth Aamodt, Kalliopi Kanaki
22     @date   
23     @brief  The TPC krypton cluster finder processing component
24 */
25
26 // see header file for class documentation                                   //
27 // or                                                                        //
28 // refer to README to build package                                          //
29 // or                                                                        //
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt                          //
31
32 #if __GNUC__>= 3
33 using namespace std;
34 #endif
35 #include "AliHLTTPCKryptonClusterFinderComponent.h"
36 #include "AliHLTTPCDigitReaderDecoder.h"
37 #include "AliHLTTPCKryptonClusterFinder.h"
38 #include "AliHLTTPCSpacePointData.h"
39 #include "AliHLTTPCClusterDataFormat.h"
40 #include "AliHLTTPCTransform.h"
41 #include "AliHLTTPCClusters.h"
42 #include "AliHLTTPCDefinitions.h"
43 #include "AliCDBEntry.h"
44 #include "AliCDBManager.h"
45 #include "TH1F.h"
46
47 #include <cstdlib>
48 #include <cerrno>
49 #include "TString.h"
50 #include "TObjString.h"
51 #include <sys/time.h>
52
53 AliHLTTPCKryptonClusterFinderComponent gAliHLTTPCKryptonClusterFinderComponent;
54
55 /** ROOT macro for the implementation of ROOT specific class methods */
56 ClassImp(AliHLTTPCKryptonClusterFinderComponent)
57
58 AliHLTTPCKryptonClusterFinderComponent::AliHLTTPCKryptonClusterFinderComponent()
59   :
60   fKryptonClusterFinder(NULL),
61   fReader(NULL),
62   fSpecification(0)
63 {
64   // see header file for class documentation
65   // or
66   // refer to README to build package
67   // or
68   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69 }
70
71 AliHLTTPCKryptonClusterFinderComponent::~AliHLTTPCKryptonClusterFinderComponent()
72 {
73   // see header file for class documentation
74 }
75
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
78
79 const char* AliHLTTPCKryptonClusterFinderComponent::GetComponentID()
80 {
81   // see header file for class documentation
82     return "TPCKryptonClusterFinder";
83 }
84
85 void AliHLTTPCKryptonClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
86 {
87   // see header file for class documentation
88   list.clear(); 
89   list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
90 }
91
92 AliHLTComponentDataType AliHLTTPCKryptonClusterFinderComponent::GetOutputDataType()
93 {
94   // see header file for class documentation
95   return kAliHLTDataTypeHistogram;
96 }
97
98 int AliHLTTPCKryptonClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
99
100 {
101   // see header file for class documentation
102   tgtList.clear();
103   tgtList.push_back(kAliHLTDataTypeHistogram);
104   return tgtList.size();
105 }
106
107 void AliHLTTPCKryptonClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
108 {
109   // see header file for class documentation
110   // XXX TODO: Find more realistic values.  
111   constBase = 0;
112   inputMultiplier = (100 * 0.4);
113 }
114
115 AliHLTComponent* AliHLTTPCKryptonClusterFinderComponent::Spawn()
116 {
117   // see header file for class documentation
118   return new AliHLTTPCKryptonClusterFinderComponent();
119 }
120         
121 int AliHLTTPCKryptonClusterFinderComponent::DoInit( int argc, const char** argv )
122 {
123   // see header file for class documentation
124   if ( fKryptonClusterFinder )
125     return EINPROGRESS;
126
127   fKryptonClusterFinder = new AliHLTTPCKryptonClusterFinder();
128
129   Int_t i = 0;
130
131   while ( i < argc ) {      
132
133     //No arguments so far
134
135     Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
136     return EINVAL;
137
138   }
139
140   fReader = new AliHLTTPCDigitReaderDecoder();
141   fKryptonClusterFinder->SetReader(fReader);
142  
143   return 0;
144 }
145
146 int AliHLTTPCKryptonClusterFinderComponent::DoDeinit()
147 {
148   // see header file for class documentation
149
150   if ( fKryptonClusterFinder )
151     delete fKryptonClusterFinder;
152   fKryptonClusterFinder = NULL;
153  
154   if ( fReader )
155     delete fReader;
156   fReader = NULL;
157     
158   return 0;
159 }
160
161 int AliHLTTPCKryptonClusterFinderComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData){
162   // see header file for class documentation
163
164   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
165
166   //  == init iter (pointer to datablock)
167   const AliHLTComponentBlockData* iter = NULL;
168
169   Int_t slice, patch, row[2];
170
171   unsigned long maxPoints = 0;
172
173   for (iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
174
175     HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", 
176             evtData.fEventID, evtData.fEventID,
177             DataType2Text(iter->fDataType).c_str(), 
178             DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
179
180     if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
181       HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", 
182                  DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
183                  DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
184     }      
185      
186     if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) &&
187          iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
188       
189     fSpecification = iter->fSpecification;
190       
191     slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
192     patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
193     row[0] = AliHLTTPCTransform::GetFirstRow( patch );
194     row[1] = AliHLTTPCTransform::GetLastRow( patch );
195
196
197     fKryptonClusterFinder->SetPatch(patch);
198
199     fKryptonClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
200
201     fKryptonClusterFinder->InitializeHistograms();
202         
203     fKryptonClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
204       
205     fKryptonClusterFinder->FindRowClusters();
206
207     fKryptonClusterFinder->FindKryptonClusters();
208
209   }
210   MakeHistosPublic();
211   return 0;
212 }
213
214 int AliHLTTPCKryptonClusterFinderComponent::Configure(const char* arguments) { 
215 // see header file for class documentation
216   
217   int iResult=0;
218   if (!arguments) return iResult;
219   HLTInfo("parsing configuration string \'%s\'", arguments);
220   /*
221   TString allArgs=arguments;
222   TString argument;
223   int bMissingParam=0;
224
225   TObjArray* pTokens=allArgs.Tokenize(" ");
226   if (pTokens) {
227     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
228       argument=((TObjString*)pTokens->At(i))->GetString();
229       if (argument.IsNull()) continue;
230      
231       if (argument.CompareTo("-apply-noisemap")==0) {
232         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
233         HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
234         
235       } 
236       else if (argument.CompareTo("-plot-side-c")==0) {
237         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
238         HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
239         
240       } 
241       else if (argument.CompareTo("-plot-side-a")==0) {
242         if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
243         HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
244         
245       } 
246       else {
247         HLTError("unknown argument %s", argument.Data());
248         iResult=-EINVAL;
249         break;
250       }
251     } // end for
252   
253     delete pTokens;
254   
255   } // end if pTokens
256   
257   if (bMissingParam) {
258     HLTError("missing parameter for argument %s", argument.Data());
259     iResult=-EINVAL;
260   }
261   */
262   return iResult;
263 }
264
265 int AliHLTTPCKryptonClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
266 {
267   // see header file for class documentation
268   const char* path="HLT/ConfigTPC";
269   if (cdbEntry) path=cdbEntry;
270   if (path) {
271     HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
272     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
273     if (pEntry) {
274       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
275       if (pString) {
276         HLTInfo("received configuration object: %s", pString->GetString().Data());
277       } else {
278         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
279       }
280     } else {
281       HLTError("can not fetch object \"%s\" from CDB", path);
282     }
283   }
284   return 0;
285 }
286
287 void AliHLTTPCKryptonClusterFinderComponent::MakeHistosPublic() {
288 // see header file for class documentation
289   
290   TObjArray histos;
291   fKryptonClusterFinder->GetHistogramObjectArray(histos);
292   TIter iterator(&histos);
293
294   while(TObject* pObj=iterator.Next()){
295       
296        PushBack(pObj,kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
297
298        //fKryptonClusterFinder->GetHistogramObjectArray(histos);
299        //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification); 
300   }
301 }