Make the Scan method public
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterInfo.cxx
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 using std::cout;
33 using std::endl;
34 /// \cond CLASSIMP
35 ClassImp(AliMUONClusterInfo)
36 /// \endcond
37
38 //_____________________________________________________________________________
39 AliMUONClusterInfo::AliMUONClusterInfo()
40 : TObject(),
41   fRunId(0),
42   fEventId(0),
43   fZ(0.),
44   fClusterId(0),
45   fClusterX(0.),
46   fClusterY(0.),
47   fClusterXErr(0.),
48   fClusterYErr(0.),
49   fClusterChi2(0.),
50   fClusterCharge(0.),
51   fTrackId(0),
52   fTrackX(0.),
53   fTrackY(0.),
54   fTrackThetaX(0.),
55   fTrackThetaY(0.),
56   fTrackP(0.),
57   fTrackXErr(0.),
58   fTrackYErr(0.),
59   fTrackChi2(0.),
60   fTrackCharge(0),
61   fTrackNHits(0),
62   fTrackChamberHitMap(0),
63   fNPads(0),
64   fPads(new TClonesArray("AliMUONPadInfo",10))
65 {
66   /// default constructor
67 }
68
69 //_____________________________________________________________________________
70 AliMUONClusterInfo::AliMUONClusterInfo(TRootIOCtor* /*rio*/)
71 : TObject(),
72 fRunId(0),
73 fEventId(0),
74 fZ(0.),
75 fClusterId(0),
76 fClusterX(0.),
77 fClusterY(0.),
78 fClusterXErr(0.),
79 fClusterYErr(0.),
80 fClusterChi2(0.),
81 fClusterCharge(0.),
82 fTrackId(0),
83 fTrackX(0.),
84 fTrackY(0.),
85 fTrackThetaX(0.),
86 fTrackThetaY(0.),
87 fTrackP(0.),
88 fTrackXErr(0.),
89 fTrackYErr(0.),
90 fTrackChi2(0.),
91 fTrackCharge(0),
92 fTrackNHits(0),
93 fTrackChamberHitMap(0),
94 fNPads(0),
95 fPads(0x0)
96 {
97   /// I/O constructor
98 }
99
100 //_____________________________________________________________________________
101 AliMUONClusterInfo::AliMUONClusterInfo (const AliMUONClusterInfo& clusterInfo)
102 : TObject(clusterInfo),
103   fRunId(clusterInfo.fRunId),
104   fEventId(clusterInfo.fEventId),
105   fZ(clusterInfo.fZ),
106   fClusterId(clusterInfo.fClusterId),
107   fClusterX(clusterInfo.fClusterX),
108   fClusterY(clusterInfo.fClusterY),
109   fClusterXErr(clusterInfo.fClusterXErr),
110   fClusterYErr(clusterInfo.fClusterYErr),
111   fClusterChi2(clusterInfo.fClusterChi2),
112   fClusterCharge(clusterInfo.fClusterCharge),
113   fTrackId(clusterInfo.fTrackId),
114   fTrackX(clusterInfo.fTrackX),
115   fTrackY(clusterInfo.fTrackY),
116   fTrackThetaX(clusterInfo.fTrackThetaX),
117   fTrackThetaY(clusterInfo.fTrackThetaY),
118   fTrackP(clusterInfo.fTrackP),
119   fTrackXErr(clusterInfo.fTrackXErr),
120   fTrackYErr(clusterInfo.fTrackYErr),
121   fTrackChi2(clusterInfo.fTrackChi2),
122   fTrackCharge(clusterInfo.fTrackCharge),
123   fTrackNHits(clusterInfo.fTrackNHits),
124   fTrackChamberHitMap(clusterInfo.fTrackChamberHitMap),
125   fNPads(clusterInfo.fNPads),
126   fPads(new TClonesArray("AliMUONPadInfo",clusterInfo.fNPads))
127 {
128   /// Copy constructor
129   AliMUONPadInfo *pad = (AliMUONPadInfo*) clusterInfo.fPads->First();
130   while (pad) {
131     new ((*fPads)[fPads->GetEntriesFast()]) AliMUONPadInfo(*pad);
132     pad = (AliMUONPadInfo*) clusterInfo.fPads->After(pad);
133   }
134 }
135
136 //_____________________________________________________________________________
137 AliMUONClusterInfo& AliMUONClusterInfo::operator=(const AliMUONClusterInfo& clusterInfo)
138 {
139   /// Equal operator
140   if (this == &clusterInfo) return *this;
141   
142   TObject::operator=(clusterInfo); // don't forget to invoke the base class' assignment operator
143   
144   fRunId = clusterInfo.fRunId;
145   fEventId = clusterInfo.fEventId;
146   fZ = clusterInfo.fZ;
147   fClusterId = clusterInfo.fClusterId;
148   fClusterX = clusterInfo.fClusterX;
149   fClusterY = clusterInfo.fClusterY;
150   fClusterXErr = clusterInfo.fClusterXErr;
151   fClusterYErr = clusterInfo.fClusterYErr;
152   fClusterChi2 = clusterInfo.fClusterChi2;
153   fClusterCharge = clusterInfo.fClusterCharge;
154   fTrackId = clusterInfo.fTrackId;
155   fTrackX = clusterInfo.fTrackX;
156   fTrackY = clusterInfo.fTrackY;
157   fTrackThetaX = clusterInfo.fTrackThetaX;
158   fTrackThetaY = clusterInfo.fTrackThetaY;
159   fTrackP = clusterInfo.fTrackP;
160   fTrackXErr = clusterInfo.fTrackXErr;
161   fTrackYErr = clusterInfo.fTrackYErr;
162   fTrackChi2 = clusterInfo.fTrackChi2;
163   fTrackCharge = clusterInfo.fTrackCharge;
164   fTrackNHits = clusterInfo.fTrackNHits;
165   fTrackChamberHitMap = clusterInfo.fTrackChamberHitMap;
166   fNPads = clusterInfo.fNPads;
167   
168   fPads->Clear("C");
169   AliMUONPadInfo *pad = (AliMUONPadInfo*) clusterInfo.fPads->First();
170   while (pad) {
171     new ((*fPads)[fPads->GetEntriesFast()]) AliMUONPadInfo(*pad);
172     pad = (AliMUONPadInfo*) clusterInfo.fPads->After(pad);
173   }
174   
175   return *this;
176 }
177
178 //__________________________________________________________________________
179 AliMUONClusterInfo::~AliMUONClusterInfo()
180 {
181   /// Destructor
182   delete fPads;
183 }
184
185 //__________________________________________________________________________
186 void AliMUONClusterInfo::Clear(Option_t* opt)
187 {
188   /// Clear arrays
189   fPads->Clear(opt);
190   fNPads = 0;
191 }
192
193 //_____________________________________________________________________________
194 void AliMUONClusterInfo::Print(Option_t* option) const
195 {
196   /// print cluster info content
197   /// print also pad info if option=FULL
198   
199   // global info
200   cout<<Form("eventID=%d", GetEventId())<<endl;
201   
202   // cluster info
203   cout<<Form("- clusterID=%u (ch=%d, det=%d, index=%d)",
204              GetClusterId(), GetChamberId(), GetDetElemId(), GetClusterIndex())<<endl;
205   
206   cout<<Form("    position=(%5.2f, %5.2f, %5.2f), sigma=(%8.5f, %8.5f, 0.0)",
207              GetClusterX(), GetClusterY(), GetZ(), GetClusterXErr(), GetClusterYErr())<<endl;
208   
209   cout<<Form("    charge=%5.2f, chi2=%5.2f", GetClusterCharge(), GetClusterChi2())<<endl;
210   
211   // track info
212   cout<<Form("- trackID=%u", GetTrackId())<<endl;
213   
214   cout<<Form("    position=(%5.2f, %5.2f, %5.2f), angles=(%5.2f, %5.2f), momentum=%5.2f",
215              GetTrackX(), GetTrackY(), GetZ(), GetTrackThetaX(), GetTrackThetaY(), GetTrackP())<<endl;
216   
217   cout<<Form("    sigma_XY=(%8.5f, %8.5f), charge=%d, chi2=%5.2f",
218              GetTrackXErr(), GetTrackYErr(), GetTrackCharge(), GetTrackChi2())<<endl;
219   
220   // pad info
221   if (strstr(option,"FULL")) {
222     AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
223     while (pad) {
224       pad->Print("FULL");
225       pad = (AliMUONPadInfo*) fPads->After(pad);
226     }
227   }
228   
229 }
230
231 Double_t AliMUONClusterInfo::GetClusterCharge(Int_t iPlaneType) const
232 {
233   Double_t lClusterChargeC = 0.;
234   if (!fPads) {
235     lClusterChargeC = GetClusterCharge()/2.;
236   }
237   else {
238     AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
239     while (pad) {
240       if (pad->GetPadPlaneType()==iPlaneType) lClusterChargeC += pad->GetPadCharge();
241       pad = (AliMUONPadInfo*) fPads->After(pad);
242     }    
243   }
244   return lClusterChargeC;
245 }
246
247 Int_t AliMUONClusterInfo::GetNPads(Int_t iPlaneType) const
248 {
249   Int_t iNPads = 0;
250
251   if (!fPads) {
252     iNPads = GetNPads();
253   }
254   else {
255     AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
256     while (pad) {
257       if (pad->GetPadPlaneType()==iPlaneType) {
258         iNPads++;
259       }
260       pad = (AliMUONPadInfo*) fPads->After(pad);
261     }   
262   }
263   return iNPads;
264 }
265
266 Int_t AliMUONClusterInfo::GetNPadsX(Int_t iPlaneType) const
267 {
268   Int_t iNPadsX = 0;
269   Double_t lPadXMin = 10000.;
270   Double_t lPadXMax = -10000.;
271   Int_t nChangedMin = 0;
272   Int_t nChangedMax = 0;
273
274   if (!fPads) {
275     iNPadsX = GetNPads();
276   }
277   else {
278     AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
279     while (pad) {
280       if (pad->GetPadPlaneType()==iPlaneType) {
281         if (pad->GetPadX()<lPadXMin){
282           lPadXMin = pad->GetPadX();
283           nChangedMin++;
284         }
285         if (pad->GetPadX()>lPadXMax){
286           lPadXMax = pad->GetPadX();
287           nChangedMax++;
288         }  
289       }    
290       pad = (AliMUONPadInfo*) fPads->After(pad);
291     }    
292     iNPadsX = TMath::Max(nChangedMin+nChangedMax-1,0);
293   }
294   return iNPadsX;
295 }
296
297 Int_t AliMUONClusterInfo::GetNPadsY(Int_t iPlaneType) const
298 {
299   Int_t iNPadsY = 0;
300   Double_t lPadYMin = 10000.;
301   Double_t lPadYMax = -10000.;
302   Int_t nChangedMin = 0;
303   Int_t nChangedMax = 0;
304
305   if (!fPads) {
306     iNPadsY = GetNPads();
307   }
308   else {
309     AliMUONPadInfo *pad = (AliMUONPadInfo*) fPads->First();
310     while (pad) {
311       if (pad->GetPadPlaneType()==iPlaneType) {
312         if (pad->GetPadY()<lPadYMin){
313           lPadYMin = pad->GetPadY();
314           nChangedMin++;
315         }
316         if (pad->GetPadY()>lPadYMax){
317           lPadYMax = pad->GetPadY();
318           nChangedMax++;
319         }  
320       }    
321       pad = (AliMUONPadInfo*) fPads->After(pad);
322     }    
323     iNPadsY = TMath::Max(nChangedMin+nChangedMax-1,0);
324   }
325   return iNPadsY;
326 }
327