]>
Commit | Line | Data |
---|---|---|
c0b68f8e | 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 AliHLTITSClusterHistoComponent.cxx | |
19 | @author Gaute Ovrebekk | |
f44c9362 | 20 | @brief Component for plotting charge in clusters |
c0b68f8e | 21 | */ |
22 | ||
23 | #if __GNUC__>= 3 | |
24 | using namespace std; | |
25 | #endif | |
26 | ||
27 | #include "AliHLTITSClusterHistoComponent.h" | |
28 | #include "AliHLTITSClusterDataFormat.h" | |
29 | #include "AliCDBEntry.h" | |
30 | #include "AliCDBManager.h" | |
f44c9362 | 31 | #include "AliGeomManager.h" |
c0b68f8e | 32 | #include "AliITSRecPoint.h" |
91edcbad | 33 | #include "TMath.h" |
c0b68f8e | 34 | #include <TFile.h> |
35 | #include <TString.h> | |
36 | #include "TObjString.h" | |
37 | #include "TObjArray.h" | |
38 | ||
c0b68f8e | 39 | /** ROOT macro for the implementation of ROOT specific class methods */ |
40 | ClassImp(AliHLTITSClusterHistoComponent) | |
41 | ||
42 | AliHLTITSClusterHistoComponent::AliHLTITSClusterHistoComponent() | |
f44c9362 | 43 | : |
44 | fXY(NULL), | |
91edcbad | 45 | fPhieta(NULL), |
c0b68f8e | 46 | fCharge(NULL), |
47 | fPlotCharge(kFALSE), | |
0b26a583 | 48 | fPlotXYPhiEta(kTRUE) |
c0b68f8e | 49 | { |
50 | // see header file for class documentation | |
51 | // or | |
52 | // refer to README to build package | |
53 | // or | |
54 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
c0b68f8e | 55 | } |
56 | ||
f44c9362 | 57 | AliHLTITSClusterHistoComponent::~AliHLTITSClusterHistoComponent(){ |
c0b68f8e | 58 | // see header file for class documentation |
59 | } | |
60 | ||
61 | // Public functions to implement AliHLTComponent's interface. | |
62 | // These functions are required for the registration process | |
63 | ||
f44c9362 | 64 | const char* AliHLTITSClusterHistoComponent::GetComponentID(){ |
c0b68f8e | 65 | // see header file for class documentation |
c0b68f8e | 66 | return "ITSClusterHisto"; |
67 | } | |
68 | ||
f44c9362 | 69 | void AliHLTITSClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){ |
c0b68f8e | 70 | // see header file for class documentation |
71 | list.clear(); | |
8ce2efb0 | 72 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD ); |
73 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD ); | |
74 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD ); | |
c0b68f8e | 75 | } |
76 | ||
f44c9362 | 77 | AliHLTComponentDataType AliHLTITSClusterHistoComponent::GetOutputDataType(){ |
c0b68f8e | 78 | // see header file for class documentation |
79 | return kAliHLTDataTypeHistogram; | |
c0b68f8e | 80 | } |
81 | ||
f44c9362 | 82 | void AliHLTITSClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){ |
c0b68f8e | 83 | // see header file for class documentation |
84 | // XXX TODO: Find more realistic values. | |
f44c9362 | 85 | constBase = 5000; |
86 | inputMultiplier = 2; | |
c0b68f8e | 87 | } |
88 | ||
f44c9362 | 89 | AliHLTComponent* AliHLTITSClusterHistoComponent::Spawn(){ |
c0b68f8e | 90 | // see header file for class documentation |
91 | return new AliHLTITSClusterHistoComponent; | |
92 | } | |
93 | ||
f44c9362 | 94 | int AliHLTITSClusterHistoComponent::DoInit( int argc, const char** argv ){ |
95 | // see header file for class documentation | |
96 | ||
97 | if(AliGeomManager::GetGeometry()==NULL){ | |
98 | AliGeomManager::LoadGeometry(); | |
99 | } | |
100 | ||
101 | fPlotCharge = kFALSE; | |
102 | fPlotXYPhiEta = kTRUE; | |
c0b68f8e | 103 | |
f44c9362 | 104 | if(fPlotCharge) fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000); |
0b26a583 | 105 | if(fPlotXYPhiEta){ |
f44c9362 | 106 | fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80); |
107 | Char_t name[50]; | |
108 | Char_t title[50]; | |
109 | fPhieta = new TH2F*[6]; | |
110 | for (Int_t iLay=0;iLay<6;iLay++){ | |
111 | sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1); | |
112 | sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1); | |
113 | fPhieta[iLay]=new TH2F(name,title,60,-1.5,1.5,60,0.,2*TMath::Pi()); | |
114 | fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity"); | |
115 | fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]"); | |
116 | } | |
0b26a583 | 117 | } |
c0b68f8e | 118 | |
119 | int iResult=0; | |
120 | TString configuration=""; | |
121 | TString argument=""; | |
f44c9362 | 122 | |
123 | for(int i=0; i<argc && iResult>=0; i++){ | |
c0b68f8e | 124 | argument=argv[i]; |
125 | if (!configuration.IsNull()) configuration+=" "; | |
126 | configuration+=argument; | |
127 | } | |
128 | ||
f44c9362 | 129 | if(!configuration.IsNull()){ |
c0b68f8e | 130 | iResult=Configure(configuration.Data()); |
131 | } | |
132 | ||
133 | return iResult; | |
134 | } | |
135 | ||
f44c9362 | 136 | int AliHLTITSClusterHistoComponent::DoDeinit(){ |
c0b68f8e | 137 | // see header file for class documentation |
138 | if(fCharge!=NULL) delete fCharge; | |
0b26a583 | 139 | if(fXY!=NULL) { |
f44c9362 | 140 | delete fXY; |
141 | for(Int_t i=0;i<6;i++) delete fPhieta[5-i]; | |
0b26a583 | 142 | } |
c0b68f8e | 143 | return 0; |
144 | } | |
145 | ||
f44c9362 | 146 | int AliHLTITSClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){ |
147 | // see header file for class documentation | |
148 | ||
0b26a583 | 149 | static Int_t event = 0; |
150 | event++; | |
c0b68f8e | 151 | int TotalSpacePoint = 0; |
152 | ||
153 | const AliHLTComponentBlockData* iter = NULL; | |
154 | ||
f44c9362 | 155 | if(!IsDataEvent()) return 0; |
156 | ||
157 | for(iter = GetFirstInputBlock(kAliHLTDataTypeClusters); iter != NULL; iter = GetNextInputBlock()){ | |
c0b68f8e | 158 | |
f44c9362 | 159 | if(iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSPD) && |
160 | iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSDD) && | |
161 | iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSSD)) | |
162 | continue; | |
8ce2efb0 | 163 | |
f44c9362 | 164 | const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr; |
165 | Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt; | |
166 | TotalSpacePoint += nSpacepoint; | |
167 | AliHLTITSSpacePointData *clusters = (AliHLTITSSpacePointData*) clusterData->fSpacePoints; | |
c0b68f8e | 168 | |
f44c9362 | 169 | for(int i=0;i<nSpacepoint;i++){ |
170 | ||
171 | Int_t lab[4] = {0,0,0,0}; | |
172 | Float_t hit[6] = {0,0,0,0,0,0}; | |
173 | Int_t info[3] = {0,0,0}; | |
174 | ||
175 | lab[0] = clusters[i].fTracks[0]; | |
176 | lab[1] = clusters[i].fTracks[1]; | |
177 | lab[2] = clusters[i].fTracks[2]; | |
178 | lab[3] = clusters[i].fIndex; | |
179 | hit[0] = clusters[i].fY; | |
180 | hit[1] = clusters[i].fZ; | |
181 | hit[2] = clusters[i].fSigmaY2; | |
182 | hit[3] = clusters[i].fSigmaZ2; | |
183 | hit[4] = clusters[i].fQ; | |
184 | hit[5] = clusters[i].fSigmaYZ; | |
185 | info[0] = clusters[i].fNy; | |
186 | info[1] = clusters[i].fNz; | |
187 | info[2] = clusters[i].fLayer; | |
188 | ||
189 | Float_t xyz[3]; | |
190 | AliITSRecPoint recpoint(lab,hit,info); | |
191 | recpoint.GetGlobalXYZ(xyz); | |
192 | Int_t layer = recpoint.GetLayer(); | |
193 | ||
194 | if(fPlotXYPhiEta){ | |
195 | fXY->Fill(xyz[0],xyz[1]); | |
196 | Float_t rad=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); | |
197 | Float_t theta=TMath::ATan2(rad,xyz[2]); | |
198 | Float_t eta=-1*TMath::Log(TMath::Tan(theta/2.0)); | |
199 | Float_t phi=TMath::ATan2(xyz[1],xyz[0]); | |
200 | if(phi<0.0){phi=2 * TMath::Pi() - TMath::Abs(phi);} | |
201 | fPhieta[layer]->Fill(eta,phi); | |
202 | } | |
203 | if(fPlotCharge) fCharge->Fill(recpoint.GetQ()); | |
c0b68f8e | 204 | } |
205 | } | |
206 | ||
207 | if(fPlotCharge){ | |
f44c9362 | 208 | AliHLTUInt32_t fSpecification = 0x0; |
209 | PushBack( (TObject*) fCharge,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification); | |
c0b68f8e | 210 | } |
0b26a583 | 211 | if(fPlotXYPhiEta){ |
f44c9362 | 212 | AliHLTUInt32_t fSpecification = 0x0; |
213 | PushBack( (TObject*) fXY,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification); | |
214 | for(Int_t ii=0;ii<6;ii++) PushBack( (TObject*) fPhieta[ii],kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification); | |
c0b68f8e | 215 | } |
216 | ||
f44c9362 | 217 | HLTDebug("ITSClusterHisto found %d Total Spacepoints", TotalSpacePoint); |
c0b68f8e | 218 | |
219 | return 0; | |
220 | } | |
221 | ||
f44c9362 | 222 | int AliHLTITSClusterHistoComponent::Configure(const char* arguments){ |
223 | // see header file for class documentation | |
224 | ||
c0b68f8e | 225 | int iResult=0; |
226 | ||
227 | if (!arguments) return iResult; | |
228 | ||
229 | TString allArgs=arguments; | |
230 | TString argument; | |
231 | ||
232 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
233 | ||
234 | if (pTokens) { | |
235 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
236 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
237 | if (argument.IsNull()) continue; | |
238 | ||
239 | if (argument.CompareTo("-plot-all")==0) { | |
240 | HLTInfo("Ploting all historgams"); | |
0b26a583 | 241 | fPlotXYPhiEta = kTRUE; |
c0b68f8e | 242 | fPlotCharge = kTRUE; |
243 | continue; | |
244 | } | |
245 | ||
246 | else if (argument.CompareTo("-plot-xy")==0) { | |
247 | HLTInfo("Ploting Global XY"); | |
0b26a583 | 248 | fPlotXYPhiEta = kTRUE; |
c0b68f8e | 249 | continue; |
250 | } | |
251 | ||
c0b68f8e | 252 | else if (argument.CompareTo("-plot-charge")==0) { |
253 | HLTInfo("Ploting charge of clusters"); | |
254 | fPlotCharge = kTRUE; | |
255 | continue; | |
256 | } | |
257 | ||
258 | else { | |
259 | HLTError("unknown argument %s", argument.Data()); | |
260 | iResult=-EINVAL; | |
261 | break; | |
262 | } | |
263 | } | |
264 | delete pTokens; | |
265 | } | |
266 | ||
91edcbad | 267 | if(!fCharge && fPlotCharge){fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000);} |
0b26a583 | 268 | if(!fXY && fPlotXYPhiEta){ |
269 | fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80); | |
270 | Char_t name[50]; | |
271 | Char_t title[50]; | |
272 | fPhieta = new TH2F*[6]; | |
273 | for (Int_t iLay=0;iLay<6;iLay++) { | |
274 | sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1); | |
275 | sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1); | |
276 | fPhieta[iLay]=new TH2F(name,title,30,-1.5,1.5,200,0.,2*TMath::Pi()); | |
277 | fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity"); | |
278 | fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]"); | |
279 | } | |
280 | } | |
c0b68f8e | 281 | |
282 | return iResult; | |
283 | } | |
284 | ||
f44c9362 | 285 | int AliHLTITSClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId){ |
c0b68f8e | 286 | // see header file for class documentation |
287 | int iResult=0; | |
288 | ||
289 | const char* path="HLT/ConfigITS/HistoComponent"; | |
290 | const char* defaultNotify=""; | |
291 | if (cdbEntry) { | |
292 | path=cdbEntry; | |
293 | defaultNotify=" (default)"; | |
294 | } | |
295 | if (path) { | |
296 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
297 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); | |
298 | if (pEntry) { | |
299 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
300 | if (pString) { | |
301 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
302 | iResult=Configure(pString->GetString().Data()); | |
303 | } else { | |
304 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
305 | } | |
306 | } else { | |
307 | HLTError("can not fetch object \"%s\" from CDB", path); | |
308 | } | |
309 | } | |
310 | ||
311 | return iResult; | |
312 | } |