]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDCalibStripRange.cxx
Coding violations corrected.
[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(std::ostream &outFile, Bool_t* detectors)
102 {
103   outFile.write("# StripRange \n",14);
104   for(Int_t det=1;det<=3;det++) {
105     if (detectors && !detectors[det-1]) { 
106       continue;
107     }
108     UShort_t FirstRing = (det == 1 ? 1 : 0);
109     for (UShort_t ir = FirstRing; ir < 2; ir++) {
110       Char_t   ring = (ir == 0 ? 'O' : 'I');
111       for(UShort_t board =0; board < 2;  board++)  {
112         outFile << det                     << ','
113                 << ring                    << ','
114                 << board                   << ','
115                 << Min(det,ring,board)     << ','
116                 << Max(det,ring,board)     << "\n";
117           
118
119       }
120     }
121   }
122  
123       
124 }
125 //____________________________________________________________________
126 void 
127 AliFMDCalibStripRange::ReadFromFile(std::istream &inFile)
128 {
129   TString line;
130   Bool_t readData=kFALSE;
131
132   while(line.ReadLine(inFile)) {
133     if(line.Contains("striprange",TString::kIgnoreCase)) {
134       readData = kTRUE;
135       break;
136     }
137     
138   }
139   
140   UShort_t det, board;
141   Char_t ring;
142   UShort_t min, max;
143   
144   Int_t thisline = inFile.tellg();
145   Char_t c[4];
146   
147   while( readData ) {
148     thisline = inFile.tellg();
149     line.ReadLine(inFile);
150    
151       if(line.Contains("# ",TString::kIgnoreCase)) {
152         readData = kFALSE;
153         continue;
154       }
155     
156     inFile.seekg(thisline);
157     inFile     >> det          >> c[0]
158                >> ring         >> c[1]
159                >> board        >> c[2]
160                >> min          >> c[3]
161                >> max;
162     
163     UInt_t nSec  = (ring == 'I' ? 10 : 20);
164     UShort_t sector = board*nSec;
165     Set(det,ring,sector,0,min,max);
166    
167   }
168   
169   inFile.seekg(0);
170  
171   
172 }
173
174 //____________________________________________________________________
175 //
176 // EOF
177 //