2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Gaute Ovrebekk <ovrebekk@ift.uib.no> *
7 //* for The ALICE HLT Project. *
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 //**************************************************************************
18 /** @file AliHLTITSClusterHistoComponent.cxx
19 @author Gaute Ovrebekk
20 @brief Component for plotting charge in clusters
27 #include "AliHLTITSClusterHistoComponent.h"
28 #include "AliHLTITSClusterDataFormat.h"
29 #include "AliCDBEntry.h"
30 #include "AliCDBManager.h"
31 #include "AliGeomManager.h"
32 #include "AliITSRecPoint.h"
36 #include "TObjString.h"
37 #include "TObjArray.h"
39 /** ROOT macro for the implementation of ROOT specific class methods */
40 ClassImp(AliHLTITSClusterHistoComponent)
42 AliHLTITSClusterHistoComponent::AliHLTITSClusterHistoComponent()
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 AliHLTITSClusterHistoComponent::~AliHLTITSClusterHistoComponent(){
59 // see header file for class documentation
62 // Public functions to implement AliHLTComponent's interface.
63 // These functions are required for the registration process
65 const char* AliHLTITSClusterHistoComponent::GetComponentID(){
66 // see header file for class documentation
67 return "ITSClusterHisto";
70 void AliHLTITSClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
71 // see header file for class documentation
73 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD );
74 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD );
75 list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD );
78 AliHLTComponentDataType AliHLTITSClusterHistoComponent::GetOutputDataType(){
79 // see header file for class documentation
80 return kAliHLTDataTypeHistogram;
83 void AliHLTITSClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
84 // see header file for class documentation
85 // XXX TODO: Find more realistic values.
86 constBase = fOutputSize;
90 AliHLTComponent* AliHLTITSClusterHistoComponent::Spawn(){
91 // see header file for class documentation
92 return new AliHLTITSClusterHistoComponent;
95 int AliHLTITSClusterHistoComponent::DoInit( int argc, const char** argv ){
96 // see header file for class documentation
98 if(AliGeomManager::GetGeometry()==NULL){
99 AliGeomManager::LoadGeometry();
102 fPlotCharge = kFALSE;
103 fPlotXYPhiEta = kTRUE;
105 if(fPlotCharge) fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000);
107 fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);
110 fPhieta = new TH2F*[6];
111 for (Int_t iLay=0;iLay<6;iLay++){
112 sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1);
113 sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1);
114 fPhieta[iLay]=new TH2F(name,title,60,-1.5,1.5,60,0.,2*TMath::Pi());
115 fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity");
116 fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
121 TString configuration="";
124 for(int i=0; i<argc && iResult>=0; i++){
126 if (!configuration.IsNull()) configuration+=" ";
127 configuration+=argument;
130 if(!configuration.IsNull()){
131 iResult=Configure(configuration.Data());
137 int AliHLTITSClusterHistoComponent::DoDeinit(){
138 // see header file for class documentation
139 if(fCharge!=NULL) delete fCharge;
142 for(Int_t i=0;i<6;i++) delete fPhieta[5-i];
147 int AliHLTITSClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
148 // see header file for class documentation
150 static Int_t event = 0;
152 int TotalSpacePoint = 0;
154 const AliHLTComponentBlockData* iter = NULL;
156 AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
157 if(!IsDataEvent(&eventType) && eventType!=gkAliEventTypeEndOfRun) {
158 // publish the histograms at the end of run
162 for(iter = GetFirstInputBlock(kAliHLTDataTypeClusters); eventType!=gkAliEventTypeEndOfRun && iter != NULL; iter = GetNextInputBlock()){
164 if(iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSPD) &&
165 iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSDD) &&
166 iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSSD))
169 const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr;
170 Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
171 TotalSpacePoint += nSpacepoint;
172 AliHLTITSSpacePointData *clusters = (AliHLTITSSpacePointData*) clusterData->fSpacePoints;
174 for(int i=0;i<nSpacepoint;i++){
176 Int_t lab[4] = {0,0,0,0};
177 Float_t hit[6] = {0,0,0,0,0,0};
178 Int_t info[3] = {0,0,0};
180 lab[0] = clusters[i].fTracks[0];
181 lab[1] = clusters[i].fTracks[1];
182 lab[2] = clusters[i].fTracks[2];
183 lab[3] = clusters[i].fIndex;
184 hit[0] = clusters[i].fY;
185 hit[1] = clusters[i].fZ;
186 hit[2] = clusters[i].fSigmaY2;
187 hit[3] = clusters[i].fSigmaZ2;
188 hit[4] = clusters[i].fQ;
189 hit[5] = clusters[i].fSigmaYZ;
190 info[0] = clusters[i].fNy;
191 info[1] = clusters[i].fNz;
192 info[2] = clusters[i].fLayer;
195 AliITSRecPoint recpoint(lab,hit,info);
196 recpoint.GetGlobalXYZ(xyz);
197 Int_t layer = recpoint.GetLayer();
200 fXY->Fill(xyz[0],xyz[1]);
201 Float_t rad=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
202 Float_t theta=TMath::ATan2(rad,xyz[2]);
203 Float_t eta=-1*TMath::Log(TMath::Tan(theta/2.0));
204 Float_t phi=TMath::ATan2(xyz[1],xyz[0]);
205 if(phi<0.0){phi=2 * TMath::Pi() - TMath::Abs(phi);}
206 fPhieta[layer]->Fill(eta,phi);
208 if(fPlotCharge) fCharge->Fill(recpoint.GetQ());
213 AliHLTUInt32_t fSpecification = 0x0;
214 if (PushBack( (TObject*) fCharge,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
215 fOutputSize+=GetLastObjectSize();
219 AliHLTUInt32_t fSpecification = 0x0;
220 if (PushBack( (TObject*) fXY,kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
221 fOutputSize+=GetLastObjectSize();
223 for(Int_t ii=0;ii<6;ii++)
224 if (PushBack( (TObject*) fPhieta[ii],kAliHLTDataTypeHistogram|kAliHLTDataOriginITS,fSpecification)==-ENOSPC) {
225 fOutputSize+=GetLastObjectSize();
229 HLTDebug("ITSClusterHisto found %d Total Spacepoints", TotalSpacePoint);
234 int AliHLTITSClusterHistoComponent::Configure(const char* arguments){
235 // see header file for class documentation
239 if (!arguments) return iResult;
241 TString allArgs=arguments;
244 TObjArray* pTokens=allArgs.Tokenize(" ");
247 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
248 argument=((TObjString*)pTokens->At(i))->GetString();
249 if (argument.IsNull()) continue;
251 if (argument.CompareTo("-plot-all")==0) {
252 HLTInfo("Ploting all historgams");
253 fPlotXYPhiEta = kTRUE;
258 else if (argument.CompareTo("-plot-xy")==0) {
259 HLTInfo("Ploting Global XY");
260 fPlotXYPhiEta = kTRUE;
264 else if (argument.CompareTo("-plot-charge")==0) {
265 HLTInfo("Ploting charge of clusters");
271 HLTError("unknown argument %s", argument.Data());
279 if(!fCharge && fPlotCharge){fCharge = new TH1F("fCharge","Total Charge of clusters",2000,0,2000);}
280 if(!fXY && fPlotXYPhiEta){
281 fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);
284 fPhieta = new TH2F*[6];
285 for (Int_t iLay=0;iLay<6;iLay++) {
286 sprintf(name,"Phi_vs_Eta_ITS_Layer%d",iLay+1);
287 sprintf(title,"Phi vs Eta - ITS Layer %d",iLay+1);
288 fPhieta[iLay]=new TH2F(name,title,30,-1.5,1.5,200,0.,2*TMath::Pi());
289 fPhieta[iLay]->GetXaxis()->SetTitle("Pseudorapidity");
290 fPhieta[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
297 int AliHLTITSClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId){
298 // see header file for class documentation
301 const char* path="HLT/ConfigITS/HistoComponent";
302 const char* defaultNotify="";
305 defaultNotify=" (default)";
308 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
309 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
311 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
313 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
314 iResult=Configure(pString->GetString().Data());
316 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
319 HLTError("can not fetch object \"%s\" from CDB", path);