]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCClusterHistoComponent.cxx
When Pt is bad defined (ex. no field), the multiple scattering effect is calculated...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterHistoComponent.cxx
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: Gaute Ovrebekk <ovrebekk@ift.uib.no>                  *
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   AliHLTTPCClusterHistoComponent.cxx
19     @author Gaute Ovrebekk
20     @brief  Component for ploting charge in clusters
21 */
22
23 #if __GNUC__>= 3
24 using namespace std;
25 #endif
26
27 #include "AliHLTTPCClusterHistoComponent.h"
28 #include "AliHLTTPCTransform.h"
29 #include "AliHLTTPCClusterDataFormat.h"
30 #include "AliHLTTPCTrackletDataFormat.h"
31 #include "AliHLTTPCMemHandler.h"
32 #include "AliHLTTPCDefinitions.h"
33 #include "AliCDBEntry.h"
34 #include "AliCDBManager.h"
35 #include <TFile.h>
36 #include <TString.h>
37 #include "TObjString.h"
38 #include "TObjArray.h"
39
40 //#include "AliHLTTPC.h"
41 //#include <stdlib.h>
42 //#include <cerrno>
43
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp(AliHLTTPCClusterHistoComponent)
46
47 AliHLTTPCClusterHistoComponent::AliHLTTPCClusterHistoComponent()
48 :
49 fTotalClusterChargeOROCAll(NULL),                     
50   fTotalClusterChargeIROCAll(NULL),                   
51   fTotalClusterChargeROCSelection(NULL),               
52   fTotalClusterChargePartitionSelection(NULL),         
53   fQMaxPartitionAll(NULL),                             
54   fQMaxROCAll(NULL),                              
55   fNumberOfClusters(NULL),                        
56   fPlotChargeOROCAll(kTRUE),   
57   fPlotChargeIROCAll(kTRUE),
58   fPlotChargeROCSel(kFALSE), 
59   fPlotChargePartSel(kFALSE),
60   fPlotQmaxPartAll(kTRUE),  
61   fPlotQmaxROCAll(kTRUE),   
62   fPlotNClusters(kTRUE)    
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
72 AliHLTTPCClusterHistoComponent::~AliHLTTPCClusterHistoComponent()
73 {
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* AliHLTTPCClusterHistoComponent::GetComponentID()
81 {
82   // see header file for class documentation
83   
84   return "TPCClusterHisto";
85 }
86
87 void AliHLTTPCClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
88 {
89   // see header file for class documentation
90   list.clear();
91   list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
92 }
93
94 AliHLTComponentDataType AliHLTTPCClusterHistoComponent::GetOutputDataType()
95 {
96   // see header file for class documentation
97   return kAliHLTDataTypeHistogram;
98
99 }
100
101 void AliHLTTPCClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
102 {
103   // see header file for class documentation
104   // XXX TODO: Find more realistic values.
105   constBase = 80000;
106   inputMultiplier = 1;
107 }
108
109 AliHLTComponent* AliHLTTPCClusterHistoComponent::Spawn()
110 {
111   // see header file for class documentation
112   return new AliHLTTPCClusterHistoComponent;
113 }
114
115 int AliHLTTPCClusterHistoComponent::DoInit( int argc, const char** argv )
116 {
117   //  HLTFatal("Initializing with log fatal");
118   //  cout<<"Initializing with cout"<<endl;
119   
120   fPlotChargeOROCAll=kTRUE;   
121   fPlotChargeIROCAll=kTRUE;
122   fPlotChargeROCSel=kFALSE; 
123   fPlotChargePartSel=kFALSE;
124   fPlotQmaxPartAll=kTRUE;  
125   fPlotQmaxROCAll=kTRUE;   
126   fPlotNClusters=kTRUE;
127    
128   if(fPlotChargeOROCAll){fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);}
129   if(fPlotChargeIROCAll){fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);}
130   if(fPlotChargeROCSel){fTotalClusterChargeROCSelection = new TH1F("fTotalClusterChargeROCSelection","Total Charge of clusters in selection ROC",4000,0,4000);}
131   if(fPlotChargePartSel){fTotalClusterChargePartitionSelection = new TH1F("fTotalClusterChargePartitionSelection","Total Charge of clusters in sel Part",4000,0,4000);}
132   if(fPlotQmaxPartAll){fQMaxPartitionAll = new TH1F("fQMaxPartitionAll","QMax for All Partitions",216,0,216);}
133   if(fPlotQmaxROCAll){fQMaxROCAll = new TH1F("fQMaxROCAll","QMax for All Partitions",72,0,72);}
134   if(fPlotNClusters){fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",1,0,1);}
135
136   int iResult=0;
137   TString configuration="";
138   TString argument="";
139   for (int i=0; i<argc && iResult>=0; i++) {
140     argument=argv[i];
141     if (!configuration.IsNull()) configuration+=" ";
142     configuration+=argument;
143   }
144   
145   if (!configuration.IsNull()) {
146     iResult=Configure(configuration.Data());
147   }  
148
149   return iResult; 
150 }
151   
152 int AliHLTTPCClusterHistoComponent::DoDeinit()
153 {
154   // see header file for class documentation
155   if(fTotalClusterChargeOROCAll!=NULL) delete fTotalClusterChargeOROCAll;
156   if(fTotalClusterChargeIROCAll!=NULL) delete fTotalClusterChargeIROCAll;     
157   if(fQMaxPartitionAll!=NULL) delete fQMaxPartitionAll;
158   if(fQMaxROCAll!=NULL) delete fQMaxROCAll;
159   return 0;
160 }
161
162 int AliHLTTPCClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
163 {
164   
165   int TotalSpacePoint = 0;
166   
167   const AliHLTComponentBlockData* iter = NULL;
168   
169   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
170     return 0;
171   
172   fQMaxPartitionAll->Reset();
173   fQMaxROCAll->Reset();
174
175   for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
176     
177     Int_t thisrow=-1,thissector=-1,row=-1;
178     
179     AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
180     AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
181     row = AliHLTTPCTransform::GetFirstRow(patch); 
182     AliHLTTPCTransform::Slice2Sector(slice,row,thissector,thisrow);
183     
184     HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
185     
186     const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) iter->fPtr;
187     Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
188     TotalSpacePoint += nSpacepoint;
189     //HLTInfo("KryptonHisto found %d Spacepoints in slice %d patch %d", nSpacepoint, slice, patch);
190     AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
191     
192     UInt_t tmpQPart = 0;//,tmpQROC = -1;
193     
194     for(int i=0;i<nSpacepoint;i++){
195       if(fPlotChargeOROCAll){
196         if(thissector>=36){
197           fTotalClusterChargeOROCAll->Fill(clusters[i].fCharge);
198         }
199       }
200       if(fPlotChargeIROCAll){
201         if(thissector<=35){
202           fTotalClusterChargeIROCAll->Fill(clusters[i].fCharge);
203         }
204       }
205       if(fPlotChargeROCSel){
206         
207       }
208       if(fPlotChargePartSel){
209         
210       }
211       if(fPlotQmaxPartAll){
212         if(clusters[i].fQMax>tmpQPart){
213           fQMaxPartitionAll->SetBinContent(patch+6*slice,clusters[i].fQMax);
214           tmpQPart=clusters[i].fQMax;
215         }
216       }
217       if(fPlotQmaxROCAll){
218         if(clusters[i].fQMax>fQMaxROCAll->GetBinContent(thissector)){
219           fQMaxROCAll->SetBinContent(thissector,clusters[i].fQMax);
220           //      tmpQROC=clusters[i].fQMax;
221         }
222       }
223     }
224     if(fPlotNClusters){
225       fNumberOfClusters->Fill(nSpacepoint);
226     }
227   }
228   
229   //delete til dodeinit
230   if(fPlotChargeOROCAll){
231     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,2,5);
232     PushBack( (TObject*) fTotalClusterChargeOROCAll,kAliHLTDataTypeHistogram,fSpecification);
233   }
234   if(fPlotChargeIROCAll){
235     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,1);
236     PushBack( (TObject*) fTotalClusterChargeIROCAll,kAliHLTDataTypeHistogram,fSpecification);
237   }
238   if(fPlotChargeROCSel){
239     
240     
241   }
242   if(fPlotChargePartSel){
243     
244     
245   }
246   if(fPlotQmaxPartAll){
247     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
248     PushBack( (TObject*) fQMaxPartitionAll,kAliHLTDataTypeHistogram,fSpecification);
249     //delete fQMaxPartitionAll;
250   }
251   if(fPlotQmaxROCAll){
252     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
253     PushBack( (TObject*) fQMaxROCAll,kAliHLTDataTypeHistogram,fSpecification);
254     //delete fQMaxROCAll;
255   }
256   if(fPlotNClusters){
257     
258     
259   }
260   
261   HLTInfo("KryptonHisto found %d Total Spacepoints", TotalSpacePoint);
262   
263   return 0;
264 }
265
266 int AliHLTTPCClusterHistoComponent::Configure(const char* arguments)
267 {
268   
269   int iResult=0;
270   if (!arguments) return iResult;
271   
272   TString allArgs=arguments;
273   TString argument;
274   
275   TObjArray* pTokens=allArgs.Tokenize(" ");
276   
277   if (pTokens) {
278     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
279       argument=((TObjString*)pTokens->At(i))->GetString();
280       if (argument.IsNull()) continue;
281       
282       if (argument.CompareTo("-plot-all")==0) {
283         HLTInfo("Ploting charge of all clusters");
284         //fPlotAll = kTRUE;
285         continue;
286       }
287       
288       else if (argument.CompareTo("-plot-trackclusters")==0) {
289         HLTInfo("Ploting charge of clusters used on a track");
290         //fPlotAll = kFALSE;
291         continue;
292       }
293       else {
294         HLTError("unknown argument %s", argument.Data());
295         iResult=-EINVAL;
296         break;
297       }
298     }
299     delete pTokens;
300   }
301   
302   //if hvis det eksisterer
303   if(fPlotChargeOROCAll){fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);}
304   if(fPlotChargeIROCAll){fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);}
305   if(fPlotChargeROCSel){fTotalClusterChargeROCSelection = new TH1F("fTotalClusterChargeROCSelection","Total Charge of clusters in selection ROC",4000,0,4000);}
306   if(fPlotChargePartSel){fTotalClusterChargePartitionSelection = new TH1F("fTotalClusterChargePartitionSelection","Total Charge of clusters in sel Part",4000,0,4000);}
307   if(fPlotQmaxPartAll){fQMaxPartitionAll = new TH1F("fQMaxPartitionAll","QMax for All Partitions",216,0,216);}
308   if(fPlotQmaxROCAll){fQMaxROCAll = new TH1F("fQMaxROCAll","QMax for All Partitions",72,0,72);}
309   if(fPlotNClusters){fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",100,0,100);}
310
311   return iResult;
312 }
313
314 int AliHLTTPCClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
315 {
316   // see header file for class documentation
317   int iResult=0;
318   const char* path="HLT/ConfigTPC/KryptonHistoComponent";
319   const char* defaultNotify="";
320   if (cdbEntry) {
321     path=cdbEntry;
322     defaultNotify=" (default)";
323   }
324   if (path) {
325     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
326     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
327     if (pEntry) {
328       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
329       if (pString) {
330         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
331         iResult=Configure(pString->GetString().Data());
332       } else {
333         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
334       }
335     } else {
336       HLTError("can not fetch object \"%s\" from CDB", path);
337     }
338   }
339
340   return iResult;
341 }