]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDBaseDigit.cxx
Possibility to run over AOD/ESD.
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDigit.cxx
CommitLineData
09b6c804 1/*************************************************************************
02a27b50 2 * Copyright(c) 2004, 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. *
09b6c804 14 *************************************************************************
15 * $Id$ */
16/**
17 * @file AliFMDBaseDigit.cxx
18 * @author Christian Holm Christensen <cholm@nbi.dk>
19 * @date Mon Mar 27 12:37:41 2006
20 * @brief Digits for the FMD
21 * @ingroup FMD_base
22 */
02a27b50 23//////////////////////////////////////////////////////////////////////
24//
25// Digits classes for the FMD
26//
27// Digits consists of
28// - Detector #
29// - Ring ID
30// - Sector #
31// - Strip #
32// - ADC count in this channel
33//
34// Digits consists of
35// - Detector #
36// - Ring ID
37// - Sector #
38// - Strip #
39// - Total energy deposited in the strip
40// - ADC count in this channel
41//
42// As the Digits and SDigits have so much in common, the classes
43// AliFMDDigit and AliFMDSDigit are implemented via a base
44// class AliFMDBaseDigit.
45///
46// +-----------------+
47// | AliFMDBaseDigit |
48// +-----------------+
49// ^
50// |
51// +------------+
52// | |
53// +-------------+ +--------------+
54// | AliFMDDigit | | AliFMDSDigit |
55// +-------------+ +--------------+
56//
57// (Note, that I'd really would have liked to implement AliFMDHit as a
58// derived class from some base class - say AliFMDStrip, and the Digit
59// classes would (eventually) have derived from that as well.
60// However, ROOT doesn't do well with multiple inheritance, so I chose
61// not to anyway).
62//
63// Latest changes by Christian Holm Christensen
64//
65//////////////////////////////////////////////////////////////////////
66
67#include "AliFMDBaseDigit.h" // ALIFMDDIGIT_H
faf80567 68#include "AliFMDStripIndex.h"
02a27b50 69#include "Riostream.h" // ROOT_Riostream
97e94238 70// #include <TString.h>
f95a63c4 71// #include <AliLog.h>
72#include "AliFMDDebug.h" // Better debug macros
02a27b50 73
74//====================================================================
75ClassImp(AliFMDBaseDigit)
76#if 0
77 ; // This is here to keep Emacs from indenting the next line
78#endif
79
80//____________________________________________________________________
81AliFMDBaseDigit::AliFMDBaseDigit()
82 : fDetector(0),
83 fRing('\0'),
84 fSector(0),
b5ee4425 85 fStrip(0),
86 fName("")
09b6c804 87{
88 //
89 // CTOR
90 //
91}
02a27b50 92
93//____________________________________________________________________
94AliFMDBaseDigit::AliFMDBaseDigit(UShort_t detector,
b5ee4425 95 Char_t ring,
96 UShort_t sector,
97 UShort_t strip)
faf80567 98 : AliDigit(),
99 fDetector(detector),
02a27b50 100 fRing(ring),
101 fSector(sector),
b5ee4425 102 fStrip(strip),
103 fName("")
02a27b50 104{
105 //
106 // Creates a base data digit object
107 //
108 // Parameters
109 //
110 // detector Detector # (1, 2, or 3)
111 // ring Ring ID ('I' or 'O')
112 // sector Sector # (For inner/outer rings: 0-19/0-39)
113 // strip Strip # (For inner/outer rings: 0-511/0-255)
114}
115
faf80567 116//____________________________________________________________________
117AliFMDBaseDigit::AliFMDBaseDigit(Int_t* tracks,
118 UShort_t detector,
119 Char_t ring,
120 UShort_t sector,
121 UShort_t strip)
122 : AliDigit(tracks),
123 fDetector(detector),
124 fRing(ring),
125 fSector(sector),
126 fStrip(strip),
127 fName("")
128{
129 //
130 // Creates a base data digit object
131 //
132 // Parameters
133 //
134 // tracks Array of 3 track labels
135 // detector Detector # (1, 2, or 3)
136 // ring Ring ID ('I' or 'O')
137 // sector Sector # (For inner/outer rings: 0-19/0-39)
138 // strip Strip # (For inner/outer rings: 0-511/0-255)
139}
140
02a27b50 141//____________________________________________________________________
142void
143AliFMDBaseDigit::Print(Option_t* /* option*/) const
144{
145 // Print digit to standard out
faf80567 146 cout << ClassName() << ": " << GetName() << flush;
02a27b50 147}
148
149//____________________________________________________________________
150const char*
151AliFMDBaseDigit::GetName() const
152{
153 // Get the name of a FMD digit.
154 if (fName.IsNull())
155 fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip);
156 return fName.Data();
157}
158#define fMaxStrips 512
159#define fMaxSectors 40
160#define fMaxRings 2
161
162//____________________________________________________________________
163ULong_t
164AliFMDBaseDigit::Hash() const
165{
6169f936 166 // Calculate a hash value based on the detector coordinates.
faf80567 167#if 1
168 return AliFMDStripIndex::Pack(fDetector, fRing, fSector, fStrip);
169#else
02a27b50 170 size_t ringi = (fRing == 'I' || fRing == 'i' ? 0 : 1);
171 return fStrip + fMaxStrips *
172 (fSector + fMaxSectors * (ringi + fMaxRings * (fDetector - 1)));
faf80567 173#endif
02a27b50 174}
175
176
177//____________________________________________________________________
178Int_t
179AliFMDBaseDigit::Compare(const TObject* o) const
180{
6169f936 181 // Compare to other digit. If the passed pointer to TObject does
182 // not point to an object of class AliFMDBaseDigit (or one of it's
183 // derived classes), then a fatal exception is made.
184 //
185 // Returns -1, if this object's detector coordinates are smaller
186 // than passed object's detector coordinates.
187 //
188 // Returns 0, if this object's detector coordinates is the same as
189 // passed object's detector coordinates.
190 //
191 // Returns 1, if this object's detector coordinates are larger
192 // than passed object's detector coordinates.
02a27b50 193 if (!o)
194 AliFatal("Can not compare to NULL!");
195 if (o->IsA() != AliFMDBaseDigit::Class())
196 AliFatal(Form("Cannot compare to a %s object", o->ClassName()));
197 // AliFMDBaseDigit* of = static_cast<AliFMDBaseDigit*>(o);
198 if (Hash() == o->Hash()) return 0;
199 if (Hash() < o->Hash()) return -1;
200 return 1;
201}
202
faf80567 203//____________________________________________________________________
204void
205AliFMDBaseDigit::AddTrack(Int_t track)
206{
09b6c804 207 //
208 // Add a track referenc
209 //
210 // Parameters:
211 // trackno The track number
212 //
faf80567 213 if (fTracks[0] == -1) fTracks[0] = track;
214 else if (fTracks[1] == -1) fTracks[1] = track;
215 else if (fTracks[2] == -1) fTracks[2] = track;
216 else
2180cab3 217 AliFMDDebug(1, ("While adding track label to %s for %s: "
218 "All 3 track labels used, can't add "
219 "reference to track %d",
faf80567 220 ClassName(), GetName(), track));
221}
222
223//____________________________________________________________________
224UShort_t
225AliFMDBaseDigit::GetNTrack() const
226{
09b6c804 227 //
228 // Get the number of track references (max 3)
229 //
230 //
231 // Return:
232 // Number of valid track references.
233 //
faf80567 234 for (Int_t i = 3; i > 0; i--)
235 if (fTracks[i-1] != -1) return i;
236 return 0;
237}
238
02a27b50 239
240//____________________________________________________________________
241//
242// EOF
243//