]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/FMDbase/AliFMDCalibStripRange.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / FMD / FMDbase / AliFMDCalibStripRange.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 /* $Id$ */
16 /** @file    AliFMDCalibStripRange.cxx
17     @author  Christian Holm Christensen <cholm@nbi.dk>
18     @date    Sun Mar 26 18:31:09 2006
19     @brief   Per digitizer card pulser calibration 
20 */
21 //____________________________________________________________________
22 //                                                                          
23 // This class stores which strips are read-out.  
24 // In principle this can be set for each half-ring.   
25 // However, in real life, all the detectors will probably read out all
26 // strips, and dead areas can be handled off-line. 
27 // This information comes from DCS or the like.
28 //
29 // IMPORTANT:  The member function WriteToFile writes out the entries
30 // in the format 
31 //
32 //     det,ring,id,min,max
33 //
34 // Here, id is a number from 0 to 1, which represents the division in
35 // half-rings.  The mapping is as follows: 
36 //
37 //  Inner rings:              Outer Rings
38 //    id   Sectors   Board     id   Sectors   Board 
39 //   ----+---------+-------   ----+---------+-------
40 //     0 |  0 -  9 |  0x10     0  |  0 - 19 |  0x11
41 //     1 | 10 - 19 |  0x0      1  | 20 - 39 |  0x1
42 //
43 // The same mapping is used in the ReadFromFile member function
44 //
45 #include <iostream>
46 #include "AliFMDCalibStripRange.h"      // ALIFMDCALIBGAIN_H
47 #include "TString.h"
48 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
49
50 //____________________________________________________________________
51 ClassImp(AliFMDCalibStripRange)
52 #if 0
53   ; // This is here to keep Emacs for indenting the next line
54 #endif
55
56 //____________________________________________________________________
57 AliFMDCalibStripRange::AliFMDCalibStripRange()
58   : fRanges(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
59   // fRanges(3)
60 {
61   // CTOR 
62   fRanges.Reset(1);
63 }
64
65 //____________________________________________________________________
66 AliFMDCalibStripRange::AliFMDCalibStripRange(const AliFMDCalibStripRange& o)
67   : TObject(o), fRanges(o.fRanges)
68 {
69   // Copy CTOR 
70 }
71
72 //____________________________________________________________________
73 AliFMDCalibStripRange&
74 AliFMDCalibStripRange::operator=(const AliFMDCalibStripRange& o)
75 {
76   // Assignement operator
77   fRanges     = o.fRanges;
78   return (*this);
79 }
80
81 //____________________________________________________________________
82 void
83 AliFMDCalibStripRange::Set(UShort_t det, Char_t ring, 
84                            UShort_t sector, UShort_t, UShort_t min, 
85                            UShort_t max)
86 {
87   // Set the min and max for a half-ring 
88   UInt_t nSec  = (ring == 'I' ? 10 : 20);
89   UInt_t board = sector / nSec;
90   fRanges(det, ring, board, 0) = ((max & 0x7f) << 8) + (min & 0x7f);
91 }
92
93 //____________________________________________________________________
94 UShort_t
95 AliFMDCalibStripRange::Min(UShort_t det, Char_t ring, 
96                            UShort_t sec, UShort_t) const
97 {
98   // Get the min for a half-ring 
99   UInt_t nSec  = (ring == 'I' ? 10 : 20);
100   UInt_t board = sec / nSec;
101  
102   return (fRanges(det, ring, board, 0) & 0x7f);
103 }
104
105 //____________________________________________________________________
106 UShort_t
107 AliFMDCalibStripRange::Max(UShort_t det, Char_t ring, 
108                            UShort_t sec, UShort_t) const
109 {
110   // Get the max for a half-ring 
111   UInt_t nSec  = (ring == 'I' ? 10 : 20);
112   UInt_t board = sec / nSec;
113   return ((fRanges(det, ring, board, 0) >> 8) & 0x7f);
114 }
115 //____________________________________________________________________
116 void 
117 AliFMDCalibStripRange::WriteToFile(std::ostream &outFile, Bool_t* detectors)
118 {
119   outFile.write("# StripRange \n",14);
120   for(Int_t det=1;det<=3;det++) {
121     if (detectors && !detectors[det-1]) { 
122       continue;
123     }
124     UShort_t FirstRing = (det == 1 ? 1 : 0);
125     for (UShort_t ir = FirstRing; ir < 2; ir++) {
126       Char_t   ring = (ir == 0 ? 'O' : 'I');
127       UInt_t   nSec = (ring == 'I' ? 10 : 20);
128       for(UShort_t board =0; board < 2;  board++)  {
129         UShort_t sector = board*nSec;
130         outFile << det                     << ','
131                 << ring                    << ','
132                 << board                   << ','
133                 << Min(det,ring,sector)    << ','
134                 << Max(det,ring,sector)    << "\n";
135           
136
137       }
138     }
139   }
140  
141       
142 }
143 //____________________________________________________________________
144 void 
145 AliFMDCalibStripRange::ReadFromFile(std::istream &inFile)
146 {
147   TString line;
148   Bool_t readData=kFALSE;
149
150   while(line.ReadLine(inFile)) {
151     if(line.Contains("striprange",TString::kIgnoreCase)) {
152       readData = kTRUE;
153       break;
154     }
155     
156   }
157   
158   UShort_t det, board;
159   Char_t ring;
160   UShort_t min, max;
161   
162   Int_t thisline = inFile.tellg();
163   Char_t c[4];
164   
165   while( readData ) {
166     thisline = inFile.tellg();
167     line.ReadLine(inFile);
168    
169       if(line.Contains("# ",TString::kIgnoreCase)) {
170         readData = kFALSE;
171         continue;
172       }
173     
174     inFile.seekg(thisline);
175     inFile     >> det          >> c[0]
176                >> ring         >> c[1]
177                >> board        >> c[2]
178                >> min          >> c[3]
179                >> max;
180     
181     UInt_t nSec  = (ring == 'I' ? 10 : 20);
182     UShort_t sector = board*nSec;
183     Set(det,ring,sector,0,min,max);
184    
185   }
186   
187   inFile.seekg(0);
188  
189   
190 }
191
192 //____________________________________________________________________
193 //
194 // EOF
195 //