]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/icepack/IceGOM.cxx
Adding a commented line demsostrating how to switch off
[u/mrichter/AliRoot.git] / RALICE / icepack / IceGOM.cxx
1 /*******************************************************************************
2  * Copyright(c) 2003, IceCube Experiment at the South Pole. All rights reserved.
3  *
4  * Author: The IceCube RALICE-based Offline 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.
12  * The authors make no claims about the suitability of this software for
13  * any purpose. It is provided "as is" without express or implied warranty.
14  *******************************************************************************/
15
16 // $Id$
17
18 ///////////////////////////////////////////////////////////////////////////
19 // Class IceGOM
20 // Signal/Hit handling of a generic IceCube Optical Module (GOM).
21 // Basically this class provides an IceCube tailored user interface
22 // to the functionality of the class AliDevice.
23 // This class is meant to provide a base class for more specific OM's
24 // (i.e. Amanda analog OM's or IceCube digital OM's).
25 // To specifically address Amanda OM's, In-ice DOM's or IceTop DOM's
26 // please refer to the derived classes IceAOM, IceIDOM and IceTDOM resp.
27 //
28 // Example :
29 // =========
30 //
31 // Creation and filling of a generic Icecube module with fictituous data
32 // ---------------------------------------------------------------------
33 //
34 // For further functionality please refer to AliDevice, AliSignal and AliAttrib.
35 //
36 // IceGOM m;
37 // m.SetUniqueID(123);
38 // m.SetNameTitle("OM123","Generic IceCube module");
39 //
40 // // Indicate status (e.g. version of readout electronics)
41 // // via a user definable status word.
42 // Int_t stat=20031;
43 // m.SetStatus(stat);
44 //
45 // Float_t pos[3]={1,2,3};
46 // m.SetPosition(pos,"car");
47 //
48 // // The starting unique signal ID.
49 // // In this example it will be increased automatically
50 // // whenever a new signal is created.
51 // Int_t sid=10;
52 //
53 // AliSignal s;
54 //
55 // s.SetSlotName("ADC",1);
56 // s.SetSlotName("LE",2);
57 // s.SetSlotName("TOT",3);
58 //
59 // s.Reset();
60 // s.SetName("OM123 Hit 1");
61 // s.SetUniqueID(sid++);
62 // s.SetSignal(100,"ADC");
63 // s.SetSignal(-100,"LE");
64 // s.SetSignal(-1000,"TOT");
65 // m.AddHit(s);
66 //
67 // s.Reset();
68 // s.SetName("OM123 Hit 2");
69 // s.SetUniqueID(sid++);
70 // s.SetSignal(110,"ADC");
71 // s.SetSignal(-101,"LE");
72 // s.SetSignal(1001,"TOT");
73 // m.AddHit(s);
74 //
75 // s.Reset();
76 // s.SetName("OM123 Hit 3");
77 // s.SetUniqueID(sid++);
78 // s.SetSignal(120,"ADC");
79 // s.SetSignal(-102,"LE");
80 // s.SetSignal(-1002,"TOT");
81 // m.AddHit(s);
82 //
83 // // Provide module data overview
84 // m.Data();
85 //
86 // // Accessing the 3rd stored hit
87 // AliSignal* sx=m.GetHit(3);
88 // if (sx) sx->Data();
89 //
90 // // Explicit hit selection via unique ID
91 // AliSignal* sx=m.GetIdHit(12);
92 // if (sx) sx->Data();
93 //
94 // // Obtain the minimum and maximum recorded TOT value 
95 // Float_t vmin,vmax;
96 // m.GetExtremes(vmin,vmax,"TOT");
97 // cout << " Extreme values : vmin = " << vmin << " vmax = " << vmax << endl;
98 // 
99 // // Ordered hits w.r.t. decreasing TOT
100 // TObjArray* ordered=m.SortHits("TOT",-1);
101 // Int_t  nhits=0;
102 // if (ordered) nhits=ordered->GetEntries();
103 // for (Int_t i=0; i<nhits; i++)
104 // {
105 //  AliSignal* sx=(AliSignal*)ordered->At(i);
106 //  if (sx) sx->Data();
107 // }
108 //
109 //--- Author: Nick van Eijndhoven 23-jun-2004 Utrecht University
110 //- Modified: NvE $Date$ Utrecht University
111 ///////////////////////////////////////////////////////////////////////////
112
113 #include "IceGOM.h"
114 #include "Riostream.h"
115  
116 ClassImp(IceGOM) // Class implementation to enable ROOT I/O
117  
118 IceGOM::IceGOM() : AliDevice()
119 {
120 // Default constructor.
121 }
122 ///////////////////////////////////////////////////////////////////////////
123 IceGOM::~IceGOM()
124 {
125 // Default destructor.
126 }
127 ///////////////////////////////////////////////////////////////////////////
128 IceGOM::IceGOM(const IceGOM& m) : AliDevice(m)
129 {
130 // Copy constructor.
131 }
132 ///////////////////////////////////////////////////////////////////////////
133 Int_t IceGOM::GetString(Int_t id) const
134 {
135 // Provide the corresponding string number for this module.
136 // Note : Amanda string numbers will have negative values.
137 //
138 // In case the user has specified the input argument id>0,
139 // the string number corresponding to this id for the current module class
140 // will be returned.
141 // Otherwise the string number corresponding with the current
142 // module will be returned.
143 //
144 // The default value is id=0;
145
146  Int_t omid=GetUniqueID();
147  if (id>0) omid=id;
148
149  if (omid<=0) return 0;
150
151  Int_t string=0;
152  if (InheritsFrom("IceAOM"))
153  {
154   if (omid<=20) return -1;
155   if (omid>=21 && omid<=40) return -2;
156   if (omid>=41 && omid<=60) return -3;
157   if (omid>=61 && omid<=86) return -4;
158   if (omid>=87 && omid<=122) return -5;
159   if (omid>=123 && omid<=158) return -6;
160   if (omid>=159 && omid<=194) return -7;
161   if (omid>=195 && omid<=230) return -8;
162   if (omid>=231 && omid<=266) return -9;
163   if (omid>=267 && omid<=302) return -10;
164   if (omid>=303 && omid<=344) return -11;
165   if (omid>=345 && omid<=386) return -12;
166   if (omid>=387 && omid<=428) return -13;
167   if (omid>=429 && omid<=470) return -14;
168   if (omid>=471 && omid<=512) return -15;
169   if (omid>=513 && omid<=554) return -16;
170   if (omid>=555 && omid<=596) return -17;
171   if (omid>=597 && omid<=638) return -18;
172   if (omid>=639 && omid<=680) return -19;
173
174   // OM681 is a special case on string 18
175   if (omid==681) return -18;
176  }
177  else
178  {
179   string=omid/100;
180  }
181
182  return string;
183 }
184 ///////////////////////////////////////////////////////////////////////////
185 Int_t IceGOM::GetLevel(Int_t id) const
186 {
187 // Provide the corresponding level on the string for this module.
188 // Level=j indicates the j-th module on the string, where j=1
189 // corresponds to the module at the top of the string.
190 //
191 // In case the user has specified the input argument id>0,
192 // the string number corresponding to this id for the current module class
193 // will be returned.
194 // Otherwise the string number corresponding with the current
195 // module will be returned.
196 //
197 // The default value is id=0;
198 //              
199 // Note : level 61,62,63,64 indicates IceTop DOM's.
200
201  Int_t omid=GetUniqueID();
202  if (id>0) omid=id;
203
204  if (omid<=0) return 0;
205
206  Int_t level=0;
207  if (InheritsFrom("IceAOM"))
208  {
209   if (omid<=20) return omid;
210   if (omid>=21 && omid<=40) return (omid-20);
211   if (omid>=41 && omid<=60) return (omid-40);
212   if (omid>=61 && omid<=86) return (omid-60);
213   if (omid>=87 && omid<=122) return (omid-86);
214   if (omid>=123 && omid<=158) return (omid-122);
215   if (omid>=159 && omid<=194) return (omid-158);
216   if (omid>=195 && omid<=230) return (omid-194);
217   if (omid>=231 && omid<=266) return (omid-230);
218   if (omid>=267 && omid<=302) return (omid-266);
219   if (omid>=303 && omid<=344) return (omid-302);
220   if (omid>=345 && omid<=386) return (omid-344);
221   if (omid>=387 && omid<=428) return (omid-386);
222   if (omid>=429 && omid<=470) return (omid-428);
223   if (omid>=471 && omid<=512) return (omid-470);
224   if (omid>=513 && omid<=554) return (omid-512);
225   if (omid>=555 && omid<=596) return (omid-554);
226   if (omid>=597 && omid<=638) return (omid-596);
227   if (omid>=639 && omid<=680) return (omid-638);
228
229   // OM681 is physically the 4th module on string 18
230   // but the database convention is to regard it as
231   // a module at the bottom of string 18
232   if (omid==681) return 43;
233  }
234  else
235  {
236   level=omid%100;
237  }
238
239  return level;
240 }
241 ///////////////////////////////////////////////////////////////////////////
242 Int_t IceGOM::GetOMId(Int_t string,Int_t level) const
243 {
244 // Provide OM identifier based on the string and level indicators.
245 // This memberfunction makes use of the inheritance info, which means
246 // that for Amanda OM's one may either use negative or positive string numbers.
247
248  Int_t omid=0;
249  Int_t s=0,l=0;
250  if (InheritsFrom("IceAOM"))
251  {
252   for (Int_t i=1; i<=681; i++)
253   {
254    s=GetString(i);
255    l=GetLevel(i);
256    if (abs(s)==abs(string) && l==level) return i;
257   }
258  }
259  else
260  {
261   omid=100*string+level;
262  }
263
264  return omid;
265 }
266 ///////////////////////////////////////////////////////////////////////////
267 TObject* IceGOM::Clone(const char* name) const
268 {
269 // Make a deep copy of the current object and provide the pointer to the copy.
270 // This memberfunction enables automatic creation of new objects of the
271 // correct type depending on the object type, a feature which may be very useful
272 // for containers like AliEvent when adding objects in case the
273 // container owns the objects. This feature allows e.g. AliEvent
274 // to store either IceGOM objects or objects derived from IceGOM
275 // via tha AddDevice memberfunction, provided these derived classes also have
276 // a proper Clone memberfunction. 
277
278  IceGOM* m=new IceGOM(*this);
279  if (name)
280  {
281   if (strlen(name)) m->SetName(name);
282  }
283  return m;
284 }
285 ///////////////////////////////////////////////////////////////////////////