1 /*************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *************************************************************************
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
23 //////////////////////////////////////////////////////////////////////
25 // Digits classes for the FMD
32 // - ADC count in this channel
39 // - Total energy deposited in the strip
40 // - ADC count in this channel
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.
46 // +-----------------+
47 // | AliFMDBaseDigit |
48 // +-----------------+
53 // +-------------+ +--------------+
54 // | AliFMDDigit | | AliFMDSDigit |
55 // +-------------+ +--------------+
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
63 // Latest changes by Christian Holm Christensen
65 //////////////////////////////////////////////////////////////////////
67 #include "AliFMDBaseDigit.h" // ALIFMDDIGIT_H
68 #include "AliFMDStripIndex.h"
69 #include "Riostream.h" // ROOT_Riostream
70 // #include <TString.h>
71 // #include <AliLog.h>
72 #include "AliFMDDebug.h" // Better debug macros
74 //====================================================================
75 ClassImp(AliFMDBaseDigit)
77 ; // This is here to keep Emacs from indenting the next line
80 //____________________________________________________________________
81 AliFMDBaseDigit::AliFMDBaseDigit()
93 //____________________________________________________________________
94 AliFMDBaseDigit::AliFMDBaseDigit(UShort_t detector,
106 // Creates a base data digit object
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)
116 //____________________________________________________________________
117 AliFMDBaseDigit::AliFMDBaseDigit(Int_t* tracks,
130 // Creates a base data digit object
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)
141 //____________________________________________________________________
143 AliFMDBaseDigit::Print(Option_t* /* option*/) const
145 // Print digit to standard out
146 cout << ClassName() << ": " << GetName() << flush;
149 //____________________________________________________________________
151 AliFMDBaseDigit::GetName() const
153 // Get the name of a FMD digit.
155 fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip);
158 #define fMaxStrips 512
159 #define fMaxSectors 40
162 //____________________________________________________________________
164 AliFMDBaseDigit::Hash() const
166 // Calculate a hash value based on the detector coordinates.
168 return AliFMDStripIndex::Pack(fDetector, fRing, fSector, fStrip);
170 size_t ringi = (fRing == 'I' || fRing == 'i' ? 0 : 1);
171 return fStrip + fMaxStrips *
172 (fSector + fMaxSectors * (ringi + fMaxRings * (fDetector - 1)));
177 //____________________________________________________________________
179 AliFMDBaseDigit::Compare(const TObject* o) const
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.
185 // Returns -1, if this object's detector coordinates are smaller
186 // than passed object's detector coordinates.
188 // Returns 0, if this object's detector coordinates is the same as
189 // passed object's detector coordinates.
191 // Returns 1, if this object's detector coordinates are larger
192 // than passed object's detector coordinates.
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;
203 //____________________________________________________________________
205 AliFMDBaseDigit::AddTrack(Int_t track)
208 // Add a track referenc
211 // trackno The track number
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;
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",
220 ClassName(), GetName(), track));
223 //____________________________________________________________________
225 AliFMDBaseDigit::GetNTrack() const
228 // Get the number of track references (max 3)
232 // Number of valid track references.
234 for (Int_t i = 3; i > 0; i--)
235 if (fTracks[i-1] != -1) return i;
240 //____________________________________________________________________