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