- Adding check and flagging for HG present
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterInfo.cxx
CommitLineData
faa8d921 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
18//-----------------------------------------------------------------------------
19/// \class AliMUONClusterInfo
20///
21/// Class to summarize ESD data at cluster
22///
23/// \author Philippe Pillot, Subatech
24//-----------------------------------------------------------------------------
25
26#include "AliMUONClusterInfo.h"
27
28#include "AliLog.h"
29
30#include <Riostream.h>
31
32/// \cond CLASSIMP
33ClassImp(AliMUONClusterInfo)
34/// \endcond
35
36//_____________________________________________________________________________
37AliMUONClusterInfo::AliMUONClusterInfo()
38: TObject(),
41c52850 39 fRunId(0),
faa8d921 40 fEventId(0),
41 fZ(0.),
42 fClusterId(0),
43 fClusterX(0.),
44 fClusterY(0.),
45 fClusterXErr(0.),
46 fClusterYErr(0.),
47 fClusterChi2(0.),
48 fClusterCharge(0.),
49 fTrackId(0),
50 fTrackX(0.),
51 fTrackY(0.),
52 fTrackThetaX(0.),
53 fTrackThetaY(0.),
54 fTrackP(0.),
55 fTrackXErr(0.),
56 fTrackYErr(0.),
57 fTrackChi2(0.),
58 fTrackCharge(0),
41c52850 59 fTrackNHits(0),
60 fTrackChamberHitMap(0),
faa8d921 61 fNPads(0),
62 fPads(new TClonesArray("AliMUONPadInfo",10))
63{
64 /// default constructor
65}
66
67//_____________________________________________________________________________
68AliMUONClusterInfo::AliMUONClusterInfo (const AliMUONClusterInfo& clusterInfo)
69: TObject(clusterInfo),
41c52850 70 fRunId(clusterInfo.fRunId),
faa8d921 71 fEventId(clusterInfo.fEventId),
72 fZ(clusterInfo.fZ),
73 fClusterId(clusterInfo.fClusterId),
74 fClusterX(clusterInfo.fClusterX),
75 fClusterY(clusterInfo.fClusterY),
76 fClusterXErr(clusterInfo.fClusterXErr),
77 fClusterYErr(clusterInfo.fClusterYErr),
78 fClusterChi2(clusterInfo.fClusterChi2),
79 fClusterCharge(clusterInfo.fClusterCharge),
80 fTrackId(clusterInfo.fTrackId),
81 fTrackX(clusterInfo.fTrackX),
82 fTrackY(clusterInfo.fTrackY),
83 fTrackThetaX(clusterInfo.fTrackThetaX),
84 fTrackThetaY(clusterInfo.fTrackThetaY),
85 fTrackP(clusterInfo.fTrackP),
86 fTrackXErr(clusterInfo.fTrackXErr),
87 fTrackYErr(clusterInfo.fTrackYErr),
88 fTrackChi2(clusterInfo.fTrackChi2),
89 fTrackCharge(clusterInfo.fTrackCharge),
41c52850 90 fTrackNHits(clusterInfo.fTrackNHits),
91 fTrackChamberHitMap(clusterInfo.fTrackChamberHitMap),
faa8d921 92 fNPads(clusterInfo.fNPads),
93 fPads(new TClonesArray("AliMUONPadInfo",clusterInfo.fNPads))
94{
95 /// Copy constructor
96 AliMUONPadInfo *pad = (AliMUONPadInfo*) clusterInfo.fPads->First();
97 while (pad) {
98 new ((*fPads)[fPads->GetEntriesFast()]) AliMUONPadInfo(*pad);
99 pad = (AliMUONPadInfo*) clusterInfo.fPads->After(pad);
100 }
101}
102
103//_____________________________________________________________________________
104AliMUONClusterInfo& AliMUONClusterInfo::operator=(const AliMUONClusterInfo& clusterInfo)
105{
106 /// Equal operator
107 if (this == &clusterInfo) return *this;
108
109 TObject::operator=(clusterInfo); // don't forget to invoke the base class' assignment operator
110
41c52850 111 fRunId = clusterInfo.fRunId;
faa8d921 112 fEventId = clusterInfo.fEventId;
113 fZ = clusterInfo.fZ;
114 fClusterId = clusterInfo.fClusterId;
115 fClusterX = clusterInfo.fClusterX;
116 fClusterY = clusterInfo.fClusterY;
117 fClusterXErr = clusterInfo.fClusterXErr;
118 fClusterYErr = clusterInfo.fClusterYErr;
119 fClusterChi2 = clusterInfo.fClusterChi2;
120 fClusterCharge = clusterInfo.fClusterCharge;
121 fTrackId = clusterInfo.fTrackId;
122 fTrackX = clusterInfo.fTrackX;
123 fTrackY = clusterInfo.fTrackY;
124 fTrackThetaX = clusterInfo.fTrackThetaX;
125 fTrackThetaY = clusterInfo.fTrackThetaY;
126 fTrackP = clusterInfo.fTrackP;
127 fTrackXErr = clusterInfo.fTrackXErr;
128 fTrackYErr = clusterInfo.fTrackYErr;
129 fTrackChi2 = clusterInfo.fTrackChi2;
130 fTrackCharge = clusterInfo.fTrackCharge;
41c52850 131 fTrackNHits = clusterInfo.fTrackNHits;
132 fTrackChamberHitMap = clusterInfo.fTrackChamberHitMap;
faa8d921 133 fNPads = clusterInfo.fNPads;
134
135 fPads->Clear("C");
136 AliMUONPadInfo *pad = (AliMUONPadInfo*) clusterInfo.fPads->First();
137 while (pad) {
138 new ((*fPads)[fPads->GetEntriesFast()]) AliMUONPadInfo(*pad);
139 pad = (AliMUONPadInfo*) clusterInfo.fPads->After(pad);
140 }
141
142 return *this;
143}
144
145//__________________________________________________________________________
146AliMUONClusterInfo::~AliMUONClusterInfo()
147{
148 /// Destructor
149 delete fPads;
150}
151
152//__________________________________________________________________________
153void AliMUONClusterInfo::Clear(Option_t* opt)
154{
155 /// Clear arrays
156 fPads->Clear(opt);
157 fNPads = 0;
158}
159
160//_____________________________________________________________________________
161void AliMUONClusterInfo::Print(Option_t* option) const
162{
163 /// print cluster info content
164 /// print also pad info if option=FULL
165
166 // global info
167 cout<<Form("eventID=%d", GetEventId())<<endl;
168
169 // cluster info
170 cout<<Form("- clusterID=%u (ch=%d, det=%d, index=%d)",
171 GetClusterId(), GetChamberId(), GetDetElemId(), GetClusterIndex())<<endl;
172
173 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), sigma=(%8.5f, %8.5f, 0.0)",
174 GetClusterX(), GetClusterY(), GetZ(), GetClusterXErr(), GetClusterYErr())<<endl;
175
176 cout<<Form(" charge=%5.2f, chi2=%5.2f", GetClusterCharge(), GetClusterChi2())<<endl;
177
178 // track info
179 cout<<Form("- trackID=%u", GetTrackId())<<endl;
180
181 cout<<Form(" position=(%5.2f, %5.2f, %5.2f), angles=(%5.2f, %5.2f), momentum=%5.2f",
182 GetTrackX(), GetTrackY(), GetZ(), GetTrackThetaX(), GetTrackThetaY(), GetTrackP())<<endl;
183
184 cout<<Form(" sigma_XY=(%8.5f, %8.5f), charge=%d, chi2=%5.2f",
185 GetTrackXErr(), GetTrackYErr(), GetTrackCharge(), GetTrackChi2())<<endl;
186
187 // pad info
188 if (strstr(option,"FULL")) {
189 AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
190 while (pad) {
191 pad->Print("FULL");
192 pad = (AliMUONPadInfo*) fPads->After(pad);
193 }
194 }
195
196}
197
41c52850 198Double_t AliMUONClusterInfo::GetClusterCharge(Int_t iPlaneType) const
199{
200 Double_t lClusterChargeC = 0.;
201 if (!fPads) {
202 lClusterChargeC = GetClusterCharge()/2.;
203 }
204 else {
205 AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
206 while (pad) {
207 if (pad->GetPadPlaneType()==iPlaneType) lClusterChargeC += pad->GetPadCharge();
208 pad = (AliMUONPadInfo*) fPads->After(pad);
209 }
210 }
211 return lClusterChargeC;
212}
213
214Int_t AliMUONClusterInfo::GetNPads(Int_t iPlaneType) const
215{
216 Int_t iNPads = 0;
217
218 if (!fPads) {
219 iNPads = GetNPads();
220 }
221 else {
222 AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
223 while (pad) {
224 if (pad->GetPadPlaneType()==iPlaneType) {
225 iNPads++;
226 }
227 pad = (AliMUONPadInfo*) fPads->After(pad);
228 }
229 }
230 return iNPads;
231}
232
233Int_t AliMUONClusterInfo::GetNPadsX(Int_t iPlaneType) const
234{
235 Int_t iNPadsX = 0;
236 Double_t lPadXMin = 10000.;
237 Double_t lPadXMax = -10000.;
238 Int_t nChangedMin = 0;
239 Int_t nChangedMax = 0;
240
241 if (!fPads) {
242 iNPadsX = GetNPads();
243 }
244 else {
245 AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
246 while (pad) {
247 if (pad->GetPadPlaneType()==iPlaneType) {
248 if (pad->GetPadX()<lPadXMin){
249 lPadXMin = pad->GetPadX();
250 nChangedMin++;
251 }
252 if (pad->GetPadX()>lPadXMax){
253 lPadXMax = pad->GetPadX();
254 nChangedMax++;
255 }
256 }
257 pad = (AliMUONPadInfo*) fPads->After(pad);
258 }
259 iNPadsX = TMath::Max(nChangedMin+nChangedMax-1,0);
260 }
261 return iNPadsX;
262}
263
264Int_t AliMUONClusterInfo::GetNPadsY(Int_t iPlaneType) const
265{
266 Int_t iNPadsY = 0;
267 Double_t lPadYMin = 10000.;
268 Double_t lPadYMax = -10000.;
269 Int_t nChangedMin = 0;
270 Int_t nChangedMax = 0;
271
272 if (!fPads) {
273 iNPadsY = GetNPads();
274 }
275 else {
276 AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
277 while (pad) {
278 if (pad->GetPadPlaneType()==iPlaneType) {
279 if (pad->GetPadY()<lPadYMin){
280 lPadYMin = pad->GetPadY();
281 nChangedMin++;
282 }
283 if (pad->GetPadY()>lPadYMax){
284 lPadYMax = pad->GetPadY();
285 nChangedMax++;
286 }
287 }
288 pad = (AliMUONPadInfo*) fPads->After(pad);
289 }
290 iNPadsY = TMath::Max(nChangedMin+nChangedMax-1,0);
291 }
292 return iNPadsY;
293}
294