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