]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDCalibSampleRate.cxx
When Pt is bad defined (ex. no field), the multiple scattering effect is calculated...
[u/mrichter/AliRoot.git] / FMD / AliFMDCalibSampleRate.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    AliFMDCalibSampleRate.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 the sample rate (that is, how many times the
24 // ATLRO's sample each VA1 channel).  In principle these can be
25 // controlled per half ring, but in real life it's most likely that
26 // this value will be the same for all detectors.  This value must be
27 // retrived from DCS or the like. 
28 //
29 #include "AliFMDCalibSampleRate.h"      // ALIFMDCALIBGAIN_H
30 // #include "AliFMDParameters.h"           // ALIFMDPARAMETERS_H
31 // #include <AliLog.h>
32 #include "TString.h"
33 #include "AliFMDDebug.h" // Better debug macros
34 #include <iostream>
35
36 //____________________________________________________________________
37 ClassImp(AliFMDCalibSampleRate)
38 #if 0
39   ; // This is here to keep Emacs for indenting the next line
40 #endif
41
42 //____________________________________________________________________
43 AliFMDCalibSampleRate::AliFMDCalibSampleRate()
44   : fRates(AliFMDMap::kMaxDetectors, AliFMDMap::kMaxRings, 2, 1)
45   // fRates(3)
46 {
47   // CTOR 
48   fRates.Reset(1);
49 }
50
51 //____________________________________________________________________
52 AliFMDCalibSampleRate::AliFMDCalibSampleRate(const AliFMDCalibSampleRate& o)
53   : TObject(o), fRates(o.fRates)
54 {
55   // Copy ctor 
56 }
57
58 //____________________________________________________________________
59 AliFMDCalibSampleRate&
60 AliFMDCalibSampleRate::operator=(const AliFMDCalibSampleRate& o)
61 {
62   // Assignment operator 
63   fRates     = o.fRates;
64   return (*this);
65 }
66
67 //____________________________________________________________________
68 void
69 AliFMDCalibSampleRate::Set(UShort_t det, Char_t ring, 
70                            UShort_t sector, UShort_t, UShort_t rate)
71 {
72   // Set values.  Strip argument is ignored 
73   UInt_t nSec  = (ring == 'I' ? 10 : 20);
74   UInt_t board = sector / nSec;
75   fRates(det, ring, board, 0) = rate;
76   
77 }
78
79 //____________________________________________________________________
80 UShort_t
81 AliFMDCalibSampleRate::Rate(UShort_t det, Char_t ring, 
82                             UShort_t sec, UShort_t) const
83 {
84   // Get the sample rate 
85   UInt_t   nSec  = (ring == 'I' ? 10 : 20);
86   UInt_t   board = sec / nSec;
87   UShort_t ret   = fRates(det, ring, board, 0);
88   AliFMDDebug(15, ("Getting sample rate for FMD%d%c[%2d,0] (board %d): %d", 
89                    det, ring, sec, board, ret));
90   return ret;
91 }
92 //____________________________________________________________________
93 void 
94 AliFMDCalibSampleRate::WriteToFile(std::ostream &outFile, Bool_t* detectors)
95 {
96   outFile.write("# SampleRate \n",14);
97   for(Int_t det=1;det<=3;det++) {
98     if (detectors && !detectors[det-1]) { 
99       continue;
100     }
101     UShort_t FirstRing = (det == 1 ? 1 : 0);
102     for (UShort_t ir = FirstRing; ir < 2; ir++) {
103       Char_t   ring = (ir == 0 ? 'O' : 'I');
104       // UShort_t nsec = (ir == 0 ? 40  : 20);
105       
106       for(UShort_t board = 0; board < 2;  board++)  {
107         outFile << det                     << ','
108                 << ring                    << ','
109                 << board                   << ','
110                 << Rate(det,ring,board)    << "\n";
111           
112
113       }
114     }
115   }
116  
117       
118 }
119 //____________________________________________________________________
120 void 
121 AliFMDCalibSampleRate::ReadFromFile(std::istream &inFile)
122 {
123   TString line;
124   Bool_t readData=kFALSE;
125
126   while(line.ReadLine(inFile)) {
127     if(line.Contains("samplerate",TString::kIgnoreCase)) {
128       readData = kTRUE;
129       break;
130     }
131     
132   }
133   
134   UShort_t det, board;
135   Char_t ring;
136   UShort_t sampleRate;
137   Int_t thisline = inFile.tellg();
138   Char_t c[3];
139   
140   while( readData ) {
141     thisline = inFile.tellg();
142     line.ReadLine(inFile);
143     if(line.Contains("# ",TString::kIgnoreCase)) {
144       readData = kFALSE;
145       continue;
146     }
147     
148     inFile.seekg(thisline);
149     inFile     >> det          >> c[0]
150                >> ring         >> c[1]
151                >> board        >> c[2]
152                >> sampleRate;
153     
154     UInt_t nSec  = (ring == 'I' ? 10 : 20);
155     UShort_t sector = board*nSec;
156     Set(det,ring,sector,0,sampleRate);
157     
158     
159   }
160   
161   inFile.seekg(0);
162  
163   
164 }
165
166 //____________________________________________________________________
167 //
168 // EOF
169 //