Fix by Ruben
[u/mrichter/AliRoot.git] / ZDC / AliZDCChMap.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 ///////////////////////////////////////////////////////////////
17 //                                                           //
18 // Class for ZDC calibration -> ADC channels mapping         //
19 // author: Chiara Oppedisano                                 //
20 //                                                           //
21 ///////////////////////////////////////////////////////////////
22
23 #include "AliZDCChMap.h"
24
25 ClassImp(AliZDCChMap)
26
27 //________________________________________________________________
28 AliZDCChMap::AliZDCChMap():
29 TNamed()
30 {
31   Reset();
32 }
33
34 //________________________________________________________________
35 AliZDCChMap::AliZDCChMap(const char* name):
36 TNamed()
37 {
38   // Constructor
39   TString namst = "Calib_";
40   namst += name;
41   SetName(namst.Data());
42   SetTitle(namst.Data());
43   Reset();
44   int const kNModules = 10;
45   int const kNChannels = 48;
46   int const kNScChannels = 32;
47   for(Int_t i=0; i<kNModules; i++){
48     for(Int_t j=0; j<3; j++) fModuleMap[i][j] = 0;
49   }
50   for(Int_t i=0; i<kNChannels; i++){
51     fADCModule[i] = -1;
52     fADCChannel[i] = -1;
53     fDetector[i] = -1;
54     fSector[i] = -1;
55     fADCSignalCode[i] = -1;
56   }
57   for(Int_t i=0; i<kNScChannels; i++){
58     fScalerChannel[i] = -1;
59     fScDetector[i] = -1;
60     fScSector[i] = -1;
61     fScSignalCode[i] = -1;
62     //
63     fTDCChannel[i] = -1;
64     fTDCSignalCode[i] = -1;
65   }
66   
67   
68 }
69
70 //________________________________________________________________
71 AliZDCChMap::AliZDCChMap(const AliZDCChMap& calibda) :
72   TNamed(calibda)
73 {
74   // Copy constructor
75   SetName(calibda.GetName());
76   SetTitle(calibda.GetName());
77   Reset();
78   int const kNModules = 10;
79   int const kNChannels = 48;
80   int const kNScChannels = 32;
81   for(Int_t i=0; i<kNModules; i++){
82      for(Int_t j=0; j<3; j++) fModuleMap[i][j] = calibda.GetModuleMap(i,j);
83   }
84   for(int t=0; t<kNChannels; t++){
85      fADCModule[t]  = calibda.GetADCModule(t);
86      fADCChannel[t] = calibda.GetADCChannel(t);
87      fDetector[t]   = calibda.GetDetector(t);
88      fSector[t]     = calibda.GetSector(t);
89      fADCSignalCode[t]  = calibda.GetADCSignalCode(t);
90      if(t<kNScChannels){
91        fScalerChannel[t] = calibda.GetScChannel(t);
92        fScDetector[t]    = calibda.GetScDetector(t);
93        fScSector[t]      = calibda.GetScSector(t);
94        fScSignalCode[t]  = calibda.GetScSignalCode(t);
95        //
96        fTDCChannel[t] = calibda.GetTDCChannel(t);
97        fTDCSignalCode[t] = calibda.GetTDCChannel(t);
98      }
99   }
100 }
101
102 //________________________________________________________________
103 AliZDCChMap &AliZDCChMap::operator =(const AliZDCChMap& calibda)
104 {
105 // assignment operator
106   SetName(calibda.GetName());
107   SetTitle(calibda.GetName());
108   Reset();
109   int const kNModules = 10;
110   int const kNChannels = 48;
111   int const kNScChannels = 32;
112   for(Int_t i=0; i<kNModules; i++){
113      for(Int_t j=0; j<3; j++) fModuleMap[i][j] = calibda.GetModuleMap(i,j);
114   }
115   for(int t=0; t<kNChannels; t++){
116      fADCModule[t]  = calibda.GetADCModule(t);
117      fADCChannel[t] = calibda.GetADCChannel(t);
118      fDetector[t]   = calibda.GetDetector(t);
119      fSector[t]     = calibda.GetSector(t);
120      fADCSignalCode[t]  = calibda.GetADCSignalCode(t);
121      if(t<kNScChannels){
122        fScalerChannel[t] = calibda.GetScChannel(t);
123        fScDetector[t]    = calibda.GetScDetector(t);
124        fScSector[t]      = calibda.GetScSector(t);
125        fScSignalCode[t]  = calibda.GetScSignalCode(t);
126        //
127        fTDCChannel[t] = calibda.GetTDCChannel(t);
128        fTDCSignalCode[t] = calibda.GetTDCChannel(t);
129      }
130   }
131
132   return *this;
133 }
134
135 //________________________________________________________________
136 AliZDCChMap::~AliZDCChMap()
137 {
138 }
139
140 //________________________________________________________________
141 void AliZDCChMap::Reset()
142 {
143   // Reset
144   memset(fADCModule,0,48*sizeof(Int_t));
145   memset(fADCChannel,0,48*sizeof(Int_t));
146   memset(fDetector,0,48*sizeof(Int_t));
147   memset(fSector,0,48*sizeof(Int_t));
148   memset(fADCSignalCode,0,48*sizeof(Int_t));
149   memset(fScalerChannel,0,32*sizeof(Int_t));
150   memset(fScDetector,0,32*sizeof(Int_t));
151   memset(fScSector,0,32*sizeof(Int_t));
152   memset(fScSignalCode,0,32*sizeof(Int_t));
153   memset(fTDCChannel,0,32*sizeof(Int_t));
154   memset(fTDCSignalCode,0,32*sizeof(Int_t));
155 }                                                                                       
156
157
158 //________________________________________________________________
159 void  AliZDCChMap::Print(Option_t *) const
160 {
161    // Printing of calibration object
162    printf("\n\n\t ******************* AliZDCChMap object *******************\n\n");
163    for(Int_t i=0; i<10; i++){
164      printf("  ******** GEO %d mod. type %d #ch. %d\n",
165       fModuleMap[i][0],fModuleMap[i][1],fModuleMap[i][2]);     
166    } 
167    printf("\n");
168    for(Int_t i=0; i<48; i++) 
169      printf(" ADC - mod. %d ch. %d signal %d -> detector %d sector %d\n",
170       fADCModule[i], fADCChannel[i], fADCSignalCode[i], fDetector[i], fSector[i]);
171    printf("\n");
172    for(Int_t i=0; i<32; i++)
173      if(fScalerChannel[i]!=-1)
174        printf(" SCALER - ch. %d signal %d\n",
175         fScalerChannel[i], fScSignalCode[i]);
176    printf("\n");
177    for(Int_t i=0; i<32; i++) 
178      if(fTDCChannel[i]!=-1)
179        printf(" TDC - ch. %d signal %d\n",
180         fTDCChannel[i], fTDCSignalCode[i]);
181    printf("\n\t **********************************************************\n\n");
182  
183