]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDCalibStripRange.cxx
Updated list of files (cmake)
[u/mrichter/AliRoot.git] / FMD / 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 #include "iostream"
30 #include "AliFMDCalibStripRange.h"      // ALIFMDCALIBGAIN_H
31 #include "TString.h"
32 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
33
34 //____________________________________________________________________
35 ClassImp(AliFMDCalibStripRange)
36 #if 0
37   ; // This is here to keep Emacs for indenting the next line
38 #endif
39
40 //____________________________________________________________________
41 AliFMDCalibStripRange::AliFMDCalibStripRange()
42   : fRanges(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
43   // fRanges(3)
44 {
45   // CTOR 
46   fRanges.Reset(1);
47 }
48
49 //____________________________________________________________________
50 AliFMDCalibStripRange::AliFMDCalibStripRange(const AliFMDCalibStripRange& o)
51   : TObject(o), fRanges(o.fRanges)
52 {
53   // Copy CTOR 
54 }
55
56 //____________________________________________________________________
57 AliFMDCalibStripRange&
58 AliFMDCalibStripRange::operator=(const AliFMDCalibStripRange& o)
59 {
60   // Assignement operator
61   fRanges     = o.fRanges;
62   return (*this);
63 }
64
65 //____________________________________________________________________
66 void
67 AliFMDCalibStripRange::Set(UShort_t det, Char_t ring, 
68                            UShort_t sector, UShort_t, UShort_t min, 
69                            UShort_t max)
70 {
71   // Set the min and max for a half-ring 
72   UInt_t nSec  = (ring == 'I' ? 10 : 20);
73   UInt_t board = sector / nSec;
74   fRanges(det, ring, board, 0) = ((max & 0x7f) << 8) + (min & 0x7f);
75 }
76
77 //____________________________________________________________________
78 UShort_t
79 AliFMDCalibStripRange::Min(UShort_t det, Char_t ring, 
80                            UShort_t sec, UShort_t) const
81 {
82   // Get the min for a half-ring 
83   UInt_t nSec  = (ring == 'I' ? 10 : 20);
84   UInt_t board = sec / nSec;
85  
86   return (fRanges(det, ring, board, 0) & 0x7f);
87 }
88
89 //____________________________________________________________________
90 UShort_t
91 AliFMDCalibStripRange::Max(UShort_t det, Char_t ring, 
92                            UShort_t sec, UShort_t) const
93 {
94   // Get the max for a half-ring 
95   UInt_t nSec  = (ring == 'I' ? 10 : 20);
96   UInt_t board = sec / nSec;
97   return ((fRanges(det, ring, board, 0) >> 8) & 0x7f);
98 }
99 //____________________________________________________________________
100 void 
101 AliFMDCalibStripRange::WriteToFile(ofstream &outFile)
102 {
103   outFile.write("# StripRange \n",14);
104   for(Int_t det=1;det<=3;det++) {
105     UShort_t FirstRing = (det == 1 ? 1 : 0);
106     for (UShort_t ir = FirstRing; ir < 2; ir++) {
107       Char_t   ring = (ir == 0 ? 'O' : 'I');
108       for(UShort_t board =0; board < 2;  board++)  {
109         outFile << det                     << ','
110                 << ring                    << ','
111                 << board                   << ','
112                 << Min(det,ring,board)     << ','
113                 << Max(det,ring,board)     << "\n";
114           
115
116       }
117     }
118   }
119  
120       
121 }
122 //____________________________________________________________________
123 void 
124 AliFMDCalibStripRange::ReadFromFile(ifstream &inFile)
125 {
126   TString line;
127   Bool_t readData=kFALSE;
128
129   while(line.ReadLine(inFile)) {
130     if(line.Contains("striprange",TString::kIgnoreCase)) {
131       readData = kTRUE;
132       break;
133     }
134     
135   }
136   
137   UShort_t det, board;
138   Char_t ring;
139   UShort_t min, max;
140   
141   Int_t thisline = inFile.tellg();
142   Char_t c[4];
143   
144   while( readData ) {
145     thisline = inFile.tellg();
146     line.ReadLine(inFile);
147    
148       if(line.Contains("# ",TString::kIgnoreCase)) {
149         readData = kFALSE;
150         continue;
151       }
152     
153     inFile.seekg(thisline);
154     inFile     >> det          >> c[0]
155                >> ring         >> c[1]
156                >> board        >> c[2]
157                >> min          >> c[3]
158                >> max;
159     
160     UInt_t nSec  = (ring == 'I' ? 10 : 20);
161     UShort_t sector = board*nSec;
162     Set(det,ring,sector,0,min,max);
163    
164   }
165   
166   inFile.seekg(0);
167  
168   
169 }
170
171 //____________________________________________________________________
172 //
173 // EOF
174 //