StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcGasUtilities.cc
1 //
3 // $Id: StFtpcGasUtilities.cc,v 1.26 2010/04/27 13:50:25 jcs Exp $
4 //
5 // StFtpcGasUtilities
6 //
7 // Author: Janet Seyboth 10/30/2003
8 //
9 // Function: adjust pressure and ftpc gas temperature event by event
10 //
12 //
13 // $Log: StFtpcGasUtilities.cc,v $
14 // Revision 1.26 2010/04/27 13:50:25 jcs
15 // Use default temperatures for "2010-04-21 21:40:01" to "2010-04-26 17:19:00"
16 // when extra temperature readings were stuck
17 //
18 // Revision 1.25 2010/04/22 16:23:03 jcs
19 // From "2010-04-13 00:20:01" to "2010-04-19 20:39:00" the extra temperatures for both FTPC West
20 // and FTPC East were stuck. Use the default temperatures for all runs taken in this time period.
21 //
22 // Revision 1.24 2009/11/14 12:51:08 jcs
23 // added suggested parentheses to avoid warnings which appeared with system upgrade
24 //
25 // Revision 1.23 2007/12/13 21:04:52 jcs
26 // insert missing LOG_DEBUG statement
27 //
28 // Revision 1.22 2007/02/01 11:57:04 jcs
29 // move unessential output from INFO to DEBUG
30 //
31 // Revision 1.21 2007/01/15 07:49:22 jcs
32 // replace printf, cout and gMesMgr with Logger
33 //
34 // Revision 1.20 2006/07/21 08:42:44 jcs
35 // restore revision 1.18 code, this was applied to adjust radial step
36 //
37 // Revision 1.19 2006/07/19 11:59:39 jcs
38 // additional body temperatures now available starting with runNumber 5009073
39 //
40 // Revision 1.18 2006/06/23 07:56:55 jcs
41 // Starting in Y2006 use only the FTPC Extra Temperature readings plus an adjustment, if necessary, to determine the average gas temperature
42 //
43 // Revision 1.17 2005/03/30 11:40:35 jcs
44 // Calculate the average temperature correctly for year 2005+ runs when only one set of temperature readings (body or extra) is available
45 //
46 // Revision 1.16 2005/03/23 14:32:28 jcs
47 // additional changes for using body + extra temperatures starting with y2005
48 //
49 // Revision 1.15 2005/03/14 22:57:18 jcs
50 // clean up code
51 // use body + extra temperature readings starting with y2005
52 //
53 // Revision 1.14 2005/01/17 15:58:05 jcs
54 // use all 6 ftpc west body temperature readings for 2005 run
55 //
56 // Revision 1.13 2004/09/17 08:55:40 jcs
57 // add corrections for processing 2004 pp data
58 //
59 // Revision 1.12 2004/09/15 10:27:59 jcs
60 // correct error in averageTemperatureEast comment and output statement (body3,4,5 are used NOT 1,3,4)
61 //
62 // Revision 1.11 2004/07/20 18:30:17 jcs
63 // change temperature output information
64 //
65 // Revision 1.10 2004/07/18 14:12:45 jcs
66 // use adjustAverageWest/East from database
67 // always output temperature calculation information since this is a critical value for the FTPC
68 //
69 // Revision 1.9 2004/05/26 10:32:32 jcs
70 // For all runs on or after 2004-01-25, we use only three temperature readings per FTPC
71 // + and adjustment to compute the averageBodyTemperature
72 // (this change is provisional - the adjustment must be added to the database)
73 //
74 // Revision 1.8 2004/05/07 12:07:06 jcs
75 // remove double code in averageTemperatureEast
76 //
77 // Revision 1.7 2004/04/14 16:48:21 jcs
78 // turn off DEBUG
79 //
80 // Revision 1.6 2004/04/14 14:55:08 jcs
81 // temporarily turn on debug
82 // don't use flaky body temperature readings
83 //
84 // Revision 1.5 2004/03/11 22:26:26 jcs
85 // activate reading of additional body temperatures
86 //
87 // Revision 1.4 2004/03/09 20:58:00 jcs
88 // undo activation of additional body temperatures - they are not getting
89 // thru from offline database to here
90 //
91 // Revision 1.3 2004/03/09 20:22:27 jcs
92 // activate use of additional body temperatures for y2004
93 //
94 // Revision 1.2 2004/02/02 17:29:40 jcs
95 // dbDate test works for y2004, now only print message for DEBUG
96 //
97 // Revision 1.1 2003/11/13 14:12:17 jcs
98 // move pressure and gas corrections from StFtpcClusterMaker.cxx to StFtpcGasUtilities
99 //
100 //
102 
103 #include "StFtpcParamReader.hh"
104 #include "StFtpcDbReader.hh"
105 
106 #include "StFtpcGasUtilities.hh"
107 #include "StMessMgr.h"
108 
109 
110 StFtpcGasUtilities::StFtpcGasUtilities(StFtpcParamReader *paramReader,
111  StFtpcDbReader *dbReader,
112  StDetectorDbFTPCGas *gas,
113  St_ftpcTemps *temps)
114 {
115  mParam = paramReader;
116  mDb = dbReader;
117  mGas = gas;
118  mTemps = temps;
119 }
120 
121 
122 StFtpcGasUtilities::~StFtpcGasUtilities() {
123 }
124 
125 Int_t StFtpcGasUtilities::barometricPressure() {
126  if (mGas->getBarometricPressure() == mParam->normalizedNowPressure()) return kStOK;
127  if (mGas->getBarometricPressure() >= mDb->minPressure() && mGas->getBarometricPressure() <= mDb->maxPressure()) {
128  LOG_DEBUG <<"Change normalizedNowPressure from "<<mParam->normalizedNowPressure()<<" to "<<mGas->getBarometricPressure()<<endm;
129  mParam->setNormalizedNowPressure(mGas->getBarometricPressure());
130  return kStOK;
131  }
132  else {
133  LOG_WARN << "Invalid value ("<<mGas->getBarometricPressure()<<") from offline database for barometric pressure - using previous value ("<<mParam->normalizedNowPressure()<<")"<<endm;
134  return kStWarn;
135  }
136 }
137 
138 
139 Int_t StFtpcGasUtilities::averageTemperatureWest(Int_t dbDate, Int_t runNumber) {
140 
141  Int_t numberBodyTemperaturesWest = 0;
142  Float_t averageBodyTemperatureWest = 0.0;
143  Float_t averageGasTempWest = 0.0;
144 
145  // In 2010 from "2010-04-13 00:20:01" to "2010-04-19 20:39:00" and
146  // from "2010-04-21 21:40:01" to "2010-04-26 17:19:00"
147  // the extra temperatures for both FTPC West and FTPC East were stuck.
148  // Since one reading was propagated to the database for this whole time period,
149  // we decided to use the default temperatures for all runs
150  // taken in this time period.
151 
152  if ( ((dbDate >= 20100413 && runNumber > 11102099) && (dbDate <= 20100419 && runNumber < 11109080)) ||
153  ((dbDate >= 20100421 && runNumber > 1111068) && (dbDate <= 20100426 && runNumber < 11116056)) ) {
154  mParam->setGasTemperatureWest(mDb->defaultTemperatureWest() + mDb->adjustAverageWest());
155  LOG_WARN<<"FTPC West Extra temperatures bad for run number "<<runNumber<<" dbDate "<<dbDate<<" using defaultTemperatureWest = "<<mDb->defaultTemperatureWest()<<" + adjustAverageWest "<<mDb->adjustAverageWest()<<" = "<<mParam->gasTemperatureWest()<<endm;
156  return kStWarn;
157  }
158 
159 
160  // Starting Y2006, calculate FTPC West gas temperature from extra temperatures only
161  // and adjust with mDb->adjustAverageWest()
162  if ( dbDate >= 20051030 ) {
163 
164  ftpcTemps_st* tempT = mTemps->GetTable();
165 
166  Int_t numberExtraTempsWest = 0;
167  Float_t averageExtraTempsWest = 0.0;
168 
169  if (tempT->extra1West >= mDb->minGasTemperature() && tempT->extra1West <= mDb->maxGasTemperature() ) {
170  averageExtraTempsWest += tempT->extra1West;
171  numberExtraTempsWest++;
172  LOG_DEBUG<<" "<<tempT->extra1West<<"(extra1West)"<<endm;
173  }
174  //if (tempT->extra2West >= mDb->minGasTemperature() && tempT->extra2West <= mDb->maxGasTemperature() ) {
175  // averageExtraTempsWest += tempT->extra2West;
176  // numberExtraTempsWest++;
177  // LOG_DEBUG<<" + "<<tempT->extra2West<<"(extra2West)"<<endm;
178  //}
179  if (tempT->extra3West >= mDb->minGasTemperature() && tempT->extra3West <= mDb->maxGasTemperature() ) {
180  averageExtraTempsWest += tempT->extra3West;
181  numberExtraTempsWest++;
182  LOG_DEBUG<<" + "<<tempT->extra3West<<"(extra3West)"<<endm;
183  }
184  if (tempT->extra4West >= mDb->minGasTemperature() && tempT->extra4West <= mDb->maxGasTemperature() ) {
185  averageExtraTempsWest += tempT->extra4West;
186  numberExtraTempsWest++;
187  LOG_DEBUG<<" + "<<tempT->extra4West<<"(extra4West)"<<endm;
188  }
189  if (tempT->extra5West >= mDb->minGasTemperature() && tempT->extra5West <= mDb->maxGasTemperature() ) {
190  averageExtraTempsWest += tempT->extra5West;
191  numberExtraTempsWest++;
192  LOG_DEBUG<<" + "<<tempT->extra5West<<"(extra5West)"<<endm;
193  }
194  if (tempT->extra6West >= mDb->minGasTemperature() && tempT->extra6West <= mDb->maxGasTemperature() ) {
195  averageExtraTempsWest += tempT->extra6West;
196  numberExtraTempsWest++;
197  LOG_DEBUG<<" + "<<tempT->extra6West<<"(extra6West)"<<endm;
198  }
199  LOG_DEBUG<<" = "<<averageExtraTempsWest<<endm;
200 
201  // calculate average gas temperature west
202  if (numberExtraTempsWest > 0) {
203  LOG_DEBUG<<"setGasTemperatureWest = averageGasTempWest = "<<averageExtraTempsWest<<"/"<<numberExtraTempsWest<<" + "<<mDb->adjustAverageWest()<<" = "<<averageExtraTempsWest/numberExtraTempsWest + mDb->adjustAverageWest()<<endm;
204  averageGasTempWest = averageExtraTempsWest/numberExtraTempsWest;
205  mParam->setGasTemperatureWest(averageGasTempWest + mDb->adjustAverageWest());
206  return kStOK;
207  }
208  else {
209  LOG_WARN<<"No FTPC West Extra temperatures found for run number "<<runNumber<<"dbDate "<<dbDate<<" using defaultTemperatureWest = "<<mParam->gasTemperatureWest()<<endm;
210  return kStWarn;
211  }
212  }
213 
214  // For Y2005 calculate FTPC West gas temperature from body temperatures
215  // plus extra temperature readings
216  // (the extra temperature readings are available as of 2005-01-01)
217 
218  if ( dbDate >= 20050101 && dbDate < 20051030 ) {
219 
220  LOG_DEBUG<<" dbDate = "<<dbDate<<"(>2005-01-01) Use FTPC West body temperatures + FTPC West extra temperature readings 1,3-6 (2 is unstable in the year 2005 run)"<<endm;
221 
222  if (mGas->getBody1West() >= mDb->minGasTemperature() && mGas->getBody1West() <= mDb->maxGasTemperature()) {
223  averageBodyTemperatureWest += mGas->getBody1West();
224  numberBodyTemperaturesWest++;
225  LOG_DEBUG<<" "<<mGas->getBody1West()<<"(body1West)"<<endm;
226  }
227  if (mGas->getBody2West() >= mDb->minGasTemperature() && mGas->getBody2West()<= mDb->maxGasTemperature() ) {
228  averageBodyTemperatureWest += mGas->getBody2West();
229  numberBodyTemperaturesWest++;
230  LOG_DEBUG<<" + "<<mGas->getBody2West()<<"(body2West)"<<endm;
231  }
232  if (mGas->getBody3West() >= mDb->minGasTemperature() && mGas->getBody3West()<= mDb->maxGasTemperature() ) {
233  averageBodyTemperatureWest += mGas->getBody3West();
234  numberBodyTemperaturesWest++;
235  LOG_DEBUG<<" + "<<mGas->getBody3West()<<"(body3West)"<<endm;
236  }
237  if (mGas->getBody4West() >= mDb->minGasTemperature() && mGas->getBody4West() <= mDb->maxGasTemperature() ) {
238  averageBodyTemperatureWest += mGas->getBody4West();
239  numberBodyTemperaturesWest++;
240  LOG_DEBUG<<" + "<<mGas->getBody4West()<<"(body4West)"<<endm;
241  }
242  if (mGas->getBody5West() >= mDb->minGasTemperature() && mGas->getBody5West() <= mDb->maxGasTemperature() ) {
243  averageBodyTemperatureWest += mGas->getBody5West();
244  numberBodyTemperaturesWest++;
245  LOG_DEBUG<<" + "<<mGas->getBody5West()<<"(body5West)"<<endm;
246  }
247  if (mGas->getBody6West() >= mDb->minGasTemperature() && mGas->getBody6West() <= mDb->maxGasTemperature() ) {
248  averageBodyTemperatureWest += mGas->getBody6West();
249  numberBodyTemperaturesWest++;
250  LOG_DEBUG<<" + "<<mGas->getBody6West()<<"(body6West)"<<endm;
251  }
252  LOG_DEBUG<<" = "<<averageBodyTemperatureWest<<endm;
253 
254 
255  // calculate average body temperature west
256  if (numberBodyTemperaturesWest > 0) {
257  LOG_DEBUG<<"averageBodyTemperatureWest = "<<averageBodyTemperatureWest<<"/"<<numberBodyTemperaturesWest<<" = "<<averageBodyTemperatureWest/numberBodyTemperaturesWest<<endm;
258  }
259 
260  ftpcTemps_st* tempT = mTemps->GetTable();
261 
262  Int_t numberExtraTempsWest = 0;
263  Float_t averageExtraTempsWest = 0.0;
264 
265  if (tempT->extra1West >= mDb->minGasTemperature() && tempT->extra1West <= mDb->maxGasTemperature() ) {
266  averageExtraTempsWest += tempT->extra1West;
267  numberExtraTempsWest++;
268  LOG_DEBUG<<" "<<tempT->extra1West<<"(extra1West)"<<endm;
269  }
270  //if (tempT->extra2West >= mDb->minGasTemperature() && tempT->extra2West <= mDb->maxGasTemperature() ) {
271  // averageExtraTempsWest += tempT->extra2West;
272  // numberExtraTempsWest++;
273  // LOG_DEBUG<<" + "<<tempT->extra2West<<"(extra2West)"<<endm;
274  //}
275  if (tempT->extra3West >= mDb->minGasTemperature() && tempT->extra3West <= mDb->maxGasTemperature() ) {
276  averageExtraTempsWest += tempT->extra3West;
277  numberExtraTempsWest++;
278  LOG_DEBUG<<" + "<<tempT->extra3West<<"(extra3West)"<<endm;
279  }
280  if (tempT->extra4West >= mDb->minGasTemperature() && tempT->extra4West <= mDb->maxGasTemperature() ) {
281  averageExtraTempsWest += tempT->extra4West;
282  numberExtraTempsWest++;
283  LOG_DEBUG<<" + "<<tempT->extra4West<<"(extra4West)"<<endm;
284  }
285  if (tempT->extra5West >= mDb->minGasTemperature() && tempT->extra5West <= mDb->maxGasTemperature() ) {
286  averageExtraTempsWest += tempT->extra5West;
287  numberExtraTempsWest++;
288  LOG_DEBUG<<" + "<<tempT->extra5West<<"(extra5West)"<<endm;
289  }
290  if (tempT->extra6West >= mDb->minGasTemperature() && tempT->extra6West <= mDb->maxGasTemperature() ) {
291  averageExtraTempsWest += tempT->extra6West;
292  numberExtraTempsWest++;
293  LOG_DEBUG<<" + "<<tempT->extra6West<<"(extra6West)"<<endm;
294  }
295  LOG_DEBUG<<" = "<<averageExtraTempsWest<<endm;
296 
297  // calculate average extra temperature west
298  if (numberExtraTempsWest > 0) {
299  LOG_DEBUG<<"averageExtraTempsWest = "<<averageExtraTempsWest<<"/"<<numberExtraTempsWest<<" = "<<averageExtraTempsWest/numberExtraTempsWest<<endm;
300  }
301 
302  if ( (numberBodyTemperaturesWest + numberExtraTempsWest) > 0 ) {
303  LOG_DEBUG<<"setGasTemperatureWest = averageGasTempWest = ("<<averageBodyTemperatureWest<<" + "<<averageExtraTempsWest<<")/("<<numberBodyTemperaturesWest<<" + "<<numberExtraTempsWest<<") + "<<mDb->adjustAverageWest()<<" = "<<(averageBodyTemperatureWest+averageExtraTempsWest)/(numberBodyTemperaturesWest+numberExtraTempsWest) + mDb->adjustAverageWest()<<endm;
304  averageGasTempWest = (averageBodyTemperatureWest + averageExtraTempsWest)/(numberBodyTemperaturesWest + numberExtraTempsWest);
305  mParam->setGasTemperatureWest(averageGasTempWest + mDb->adjustAverageWest());
306  return kStOK;
307  }
308  else {
309  LOG_WARN<<"No FTPC West body temperatures or FTPC Extra temperatures found for run number "<<runNumber<<"dbDate "<<dbDate<<" using defaultTemperatureWest = "<<mParam->gasTemperatureWest()<<endm;
310  return kStWarn;
311  }
312  }
313 
314  // Year2004: from runs after run 5027147 on 2004-01-27 to the end of run on 2004-05-15, only Body1, Body3 and Body4 temperature readings are useable for FTPC West
315  // The averageBodyTemperatureWest must be adjusted since only 3 instead of 6 temperature readings are used
316  if ( runNumber > 5027147 && runNumber < 5136001 ) {
317  LOG_DEBUG<<"runNumber = "<<runNumber<<" > 5027147 && <= 5136001: only Body1, Body3 and Body4 are useable for FTPC West. The averageBodyTemperatureWest is adjusted by "<<mDb->adjustAverageWest()<<endm;
318  if (mGas->getBody1West() >= mDb->minGasTemperature() && mGas->getBody1West() <= mDb->maxGasTemperature() ) {
319  averageBodyTemperatureWest += mGas->getBody1West();
320  numberBodyTemperaturesWest++;
321  LOG_DEBUG<<" "<<mGas->getBody1West()<<"(body1West)"<<endm;
322  }
323  if (mGas->getBody3West() >= mDb->minGasTemperature() && mGas->getBody3West() <= mDb->maxGasTemperature() ) {
324  averageBodyTemperatureWest += mGas->getBody3West();
325  numberBodyTemperaturesWest++;
326  LOG_DEBUG<<" + "<<mGas->getBody3West()<<"(body3West)"<<endm;
327  }
328  if (mGas->getBody4West() >= mDb->minGasTemperature() && mGas->getBody4West() <= mDb->maxGasTemperature() ) {
329  averageBodyTemperatureWest += mGas->getBody4West();
330  numberBodyTemperaturesWest++;
331  LOG_DEBUG<<" + "<<mGas->getBody4West()<<"(body4West)"<<endm;
332  }
333  }
334 
335  else {
336  if (mGas->getBody1West() >= mDb->minGasTemperature() && mGas->getBody1West() <= mDb->maxGasTemperature()) {
337  averageBodyTemperatureWest += mGas->getBody1West();
338  numberBodyTemperaturesWest++;
339  LOG_DEBUG<<mGas->getBody1West()<<"(body1West)"<<endm;
340  }
341  if (mGas->getBody2West() >= mDb->minGasTemperature() && mGas->getBody2West()<= mDb->maxGasTemperature() ) {
342  averageBodyTemperatureWest += mGas->getBody2West();
343  numberBodyTemperaturesWest++;
344  LOG_DEBUG<<" + "<<mGas->getBody2West()<<"(body2West)"<<endm;
345  }
346  if (mGas->getBody3West() >= mDb->minGasTemperature() && mGas->getBody3West()<= mDb->maxGasTemperature() ) {
347  averageBodyTemperatureWest += mGas->getBody3West();
348  numberBodyTemperaturesWest++;
349  LOG_DEBUG<<" + "<<mGas->getBody3West()<<"(body3West)"<<endm;
350  }
351  if (mGas->getBody4West() >= mDb->minGasTemperature() && mGas->getBody4West() <= mDb->maxGasTemperature() ) {
352  averageBodyTemperatureWest += mGas->getBody4West();
353  numberBodyTemperaturesWest++;
354  LOG_DEBUG<<" + "<<mGas->getBody4West()<<"(body4West)"<<endm;
355  }
356  // from 2003-10-31 -> 2004-01-24 and as of 2004-04-04 there are 2 additional body temperature sensors
357  if ( (dbDate >= 20031031 && dbDate <= 20040124) || dbDate >= 20040404) {
358  LOG_DEBUG<<"(dbDate = "<<dbDate<<" >= 20031031 && <= 20040124 || >= 20040404 activate additional body temperature sensors) "<<endm;
359  if (mGas->getBody5West() >= mDb->minGasTemperature() && mGas->getBody5West() <= mDb->maxGasTemperature() ) {
360  averageBodyTemperatureWest += mGas->getBody5West();
361  numberBodyTemperaturesWest++;
362  LOG_DEBUG<<" + "<<mGas->getBody5West()<<"(body5West)"<<endm;
363  }
364  if (mGas->getBody6West() >= mDb->minGasTemperature() && mGas->getBody6West() <= mDb->maxGasTemperature() ) {
365  averageBodyTemperatureWest += mGas->getBody6West();
366  numberBodyTemperaturesWest++;
367  LOG_DEBUG<<" + "<<mGas->getBody6West()<<"(body6West)"<<endm;
368  }
369  }
370  }
371  LOG_DEBUG<<" = "<<averageBodyTemperatureWest<<endm;
372 
373  // calculate average body temperature west
374  if (numberBodyTemperaturesWest > 0) {
375  LOG_DEBUG<<"setGasTemperatureWest = "<<averageBodyTemperatureWest<<" (averageBodyTemperatureWest) + "<<mDb->adjustAverageWest()<<" (adjustAverageWest) = "<<averageBodyTemperatureWest + mDb->adjustAverageWest()<<endm;
376  averageBodyTemperatureWest = averageBodyTemperatureWest/numberBodyTemperaturesWest;
377  mParam->setGasTemperatureWest(averageBodyTemperatureWest + mDb->adjustAverageWest());
378  return kStOK;
379  }
380  // if no body temperature readings return warning
381  else {
382  LOG_WARN<<"No FTPC West body temperatures found for "<<dbDate<<" using defaultTemperatureWest = "<<mParam->gasTemperatureWest()<<endm;
383  return kStWarn;
384  }
385 }
386 
387 
388 Int_t StFtpcGasUtilities::averageTemperatureEast(Int_t dbDate, Int_t runNumber) {
389 
390  Int_t numberBodyTemperaturesEast = 0;
391  Float_t averageBodyTemperatureEast = 0.0;
392  Float_t averageGasTempEast = 0.0;
393 
394  // In 2010 from "2010-04-13 00:20:01" to "2010-04-19 20:39:00" and
395  // from "2010-04-21 21:40:01" to "2010-04-26 17:19:00"
396  // the extra temperatures for both FTPC West and FTPC East were stuck.
397  // Since one reading was propagated to the database for this whole time period,
398  // we decided to use the default temperatures for all runs
399  // taken in this time period.
400 
401  if ( ((dbDate >= 20100413 && runNumber > 11102099) && (dbDate <= 20100419 && runNumber < 11109080)) ||
402  ((dbDate >= 20100421 && runNumber > 1111068) && (dbDate <= 20100426 && runNumber < 11116056)) ) {
403  mParam->setGasTemperatureEast(mDb->defaultTemperatureEast() + mDb->adjustAverageEast());
404  LOG_WARN<<"FTPC East Extra temperatures bad for run number "<<runNumber<<" dbDate "<<dbDate<<" using defaultTemperatureEast = "<<mDb->defaultTemperatureEast()<<" + adjustAverageEast = "<<mDb->adjustAverageEast()<<" = "<<mParam->gasTemperatureEast()<<endm;
405  return kStWarn;
406  }
407 
408  // Starting Y2006, calculate FTPC East gas temperature from extra temperatures only
409  // and adjust with mDb->adjustAverageEast()
410 
411  if ( dbDate >= 20051030 ) {
412 
413  ftpcTemps_st* tempT = mTemps->GetTable();
414 
415  Int_t numberExtraTempsEast = 0;
416  Float_t averageExtraTempsEast = 0.0;
417 
418  if (tempT->extra1East >= mDb->minGasTemperature() && tempT->extra1East <= mDb->maxGasTemperature() ) {
419  averageExtraTempsEast += tempT->extra1East;
420  numberExtraTempsEast++;
421  LOG_DEBUG<<" "<<tempT->extra1East<<"(extra1East)"<<endm;
422  }
423  if (tempT->extra2East >= mDb->minGasTemperature() && tempT->extra2East <= mDb->maxGasTemperature() ) {
424  averageExtraTempsEast += tempT->extra2East;
425  numberExtraTempsEast++;
426  LOG_DEBUG<<" + "<<tempT->extra2East<<"(extra2East)"<<endm;
427  }
428  if (tempT->extra3East >= mDb->minGasTemperature() && tempT->extra3East <= mDb->maxGasTemperature() ) {
429  averageExtraTempsEast += tempT->extra3East;
430  numberExtraTempsEast++;
431  LOG_DEBUG<<" + "<<tempT->extra3East<<"(extra3East)"<<endm;
432  }
433  if (tempT->extra4East >= mDb->minGasTemperature() && tempT->extra4East <= mDb->maxGasTemperature() ) {
434  averageExtraTempsEast += tempT->extra4East;
435  numberExtraTempsEast++;
436  LOG_DEBUG<<" + "<<tempT->extra4East<<"(extra4East)"<<endm;
437  }
438  if (tempT->extra5East >= mDb->minGasTemperature() && tempT->extra5East <= mDb->maxGasTemperature() ) {
439  averageExtraTempsEast += tempT->extra5East;
440  numberExtraTempsEast++;
441  LOG_DEBUG<<" + "<<tempT->extra5East<<"(extra5East)"<<endm;
442  }
443  if (tempT->extra6East >= mDb->minGasTemperature() && tempT->extra6East <= mDb->maxGasTemperature() ) {
444  averageExtraTempsEast += tempT->extra6East;
445  numberExtraTempsEast++;
446  LOG_DEBUG<<" + "<<tempT->extra6East<<"(extra6East)"<<endm;
447  }
448  if (tempT->extra7East >= mDb->minGasTemperature() && tempT->extra7East <= mDb->maxGasTemperature() ) {
449  averageExtraTempsEast += tempT->extra7East;
450  numberExtraTempsEast++;
451  LOG_DEBUG<<" + "<<tempT->extra7East<<"(extra7East)"<<endm;
452  }
453  LOG_DEBUG<<" = "<<averageExtraTempsEast<<endm;
454 
455  // calculate average extra temperature east
456  if (numberExtraTempsEast > 0) {
457  LOG_DEBUG<<"setGasTemperatureEast = averageGasTempEast = "<<averageExtraTempsEast<<"/"<<numberExtraTempsEast<<" + "<<mDb->adjustAverageEast()<<" = "<<averageExtraTempsEast/numberExtraTempsEast + mDb->adjustAverageEast()<<endm;
458  averageGasTempEast = averageExtraTempsEast/numberExtraTempsEast;
459  mParam->setGasTemperatureEast(averageGasTempEast + mDb->adjustAverageEast());
460  return kStOK;
461  }
462  else {
463  LOG_WARN<<"No FTPC East Extra temperatures found for run number "<<runNumber<<"dbDate "<<dbDate<<" using defaultTemperatureEast = "<<mParam->gasTemperatureEast()<<endm;
464  return kStWarn;
465  }
466  }
467 
468  // For Y2005 calculate FTPC East gas temperature from body temperatures
469  // plus extra temperature readings
470  // (the extra temperature readings are available as of 2005-01-01)
471 
472  if ( dbDate >= 20050101 && dbDate < 20051030 ) {
473 
474  LOG_DEBUG<<" dbDate = "<<dbDate<<"(>2005-01-01) Use FTPC East body temperatures + FTPC East extra temperature readings 1-7"<<endm;
475 
476  if (mGas->getBody1East() >= mDb->minGasTemperature() && mGas->getBody1East() <= mDb->maxGasTemperature()) {
477  averageBodyTemperatureEast += mGas->getBody1East();
478  numberBodyTemperaturesEast++;
479  LOG_DEBUG<<" "<<mGas->getBody1East()<<"(body1East)"<<endm;
480  }
481  if (mGas->getBody2East() >= mDb->minGasTemperature() && mGas->getBody2East()<= mDb->maxGasTemperature() ) {
482  averageBodyTemperatureEast += mGas->getBody2East();
483  numberBodyTemperaturesEast++;
484  LOG_DEBUG<<" + "<<mGas->getBody2East()<<"(body2East)"<<endm;
485  }
486  if (mGas->getBody3East() >= mDb->minGasTemperature() && mGas->getBody3East()<= mDb->maxGasTemperature() ) {
487  averageBodyTemperatureEast += mGas->getBody3East();
488  numberBodyTemperaturesEast++;
489  LOG_DEBUG<<" + "<<mGas->getBody3East()<<"(body3East)"<<endm;
490  }
491  if (mGas->getBody4East() >= mDb->minGasTemperature() && mGas->getBody4East() <= mDb->maxGasTemperature() ) {
492  averageBodyTemperatureEast += mGas->getBody4East();
493  numberBodyTemperaturesEast++;
494  LOG_DEBUG<<" + "<<mGas->getBody4East()<<"(body4East)"<<endm;
495  }
496  if (mGas->getBody5East() >= mDb->minGasTemperature() && mGas->getBody5East() <= mDb->maxGasTemperature() ) {
497  averageBodyTemperatureEast += mGas->getBody5East();
498  numberBodyTemperaturesEast++;
499  LOG_DEBUG<<" + "<<mGas->getBody5East()<<"(body5East)"<<endm;
500  }
501  if (mGas->getBody6East() >= mDb->minGasTemperature() && mGas->getBody6East() <= mDb->maxGasTemperature() ) {
502  averageBodyTemperatureEast += mGas->getBody6East();
503  numberBodyTemperaturesEast++;
504  LOG_DEBUG<<" + "<<mGas->getBody6East()<<"(body6East)"<<endm;
505  }
506  LOG_DEBUG<<" = "<<averageBodyTemperatureEast<<endm;
507 
508  // calculate average body temperature east
509  if (numberBodyTemperaturesEast > 0) {
510  LOG_DEBUG<<"averageBodyTemperatureEast = "<<averageBodyTemperatureEast<<"/"<<numberBodyTemperaturesEast<<" = "<<averageBodyTemperatureEast/numberBodyTemperaturesEast<<endm;
511  }
512 
513  ftpcTemps_st* tempT = mTemps->GetTable();
514 
515  Int_t numberExtraTempsEast = 0;
516  Float_t averageExtraTempsEast = 0.0;
517 
518  if (tempT->extra1East >= mDb->minGasTemperature() && tempT->extra1East <= mDb->maxGasTemperature() ) {
519  averageExtraTempsEast += tempT->extra1East;
520  numberExtraTempsEast++;
521  LOG_DEBUG<<" "<<tempT->extra1East<<"(extra1East)"<<endm;
522  }
523  if (tempT->extra2East >= mDb->minGasTemperature() && tempT->extra2East <= mDb->maxGasTemperature() ) {
524  averageExtraTempsEast += tempT->extra2East;
525  numberExtraTempsEast++;
526  LOG_DEBUG<<" + "<<tempT->extra2East<<"(extra2East)"<<endm;
527  }
528  if (tempT->extra3East >= mDb->minGasTemperature() && tempT->extra3East <= mDb->maxGasTemperature() ) {
529  averageExtraTempsEast += tempT->extra3East;
530  numberExtraTempsEast++;
531  LOG_DEBUG<<" + "<<tempT->extra3East<<"(extra3East)"<<endm;
532  }
533  if (tempT->extra4East >= mDb->minGasTemperature() && tempT->extra4East <= mDb->maxGasTemperature() ) {
534  averageExtraTempsEast += tempT->extra4East;
535  numberExtraTempsEast++;
536  LOG_DEBUG<<" + "<<tempT->extra4East<<"(extra4East)"<<endm;
537  }
538  if (tempT->extra5East >= mDb->minGasTemperature() && tempT->extra5East <= mDb->maxGasTemperature() ) {
539  averageExtraTempsEast += tempT->extra5East;
540  numberExtraTempsEast++;
541  LOG_DEBUG<<" + "<<tempT->extra5East<<"(extra5East)"<<endm;
542  }
543  if (tempT->extra6East >= mDb->minGasTemperature() && tempT->extra6East <= mDb->maxGasTemperature() ) {
544  averageExtraTempsEast += tempT->extra6East;
545  numberExtraTempsEast++;
546  LOG_DEBUG<<" + "<<tempT->extra6East<<"(extra6East)"<<endm;
547  }
548  if (tempT->extra7East >= mDb->minGasTemperature() && tempT->extra7East <= mDb->maxGasTemperature() ) {
549  averageExtraTempsEast += tempT->extra7East;
550  numberExtraTempsEast++;
551  LOG_DEBUG<<" + "<<tempT->extra7East<<"(extra7East)"<<endm;
552  }
553  LOG_DEBUG<<" = "<<averageExtraTempsEast<<endm;
554 
555  // calculate average extra temperature east
556  if (numberExtraTempsEast > 0) {
557  LOG_DEBUG<<"averageExtraTempsEast = "<<averageExtraTempsEast<<"/"<<numberExtraTempsEast<<" = "<<averageExtraTempsEast/numberExtraTempsEast<<endm;
558  }
559 
560  // calculate average extra temperature east
561  if (numberExtraTempsEast > 0) {
562  LOG_DEBUG<<"setGasTemperatureEast = averageGasTempEast = ("<<averageBodyTemperatureEast<<" + "<<averageExtraTempsEast<<")/("<<numberBodyTemperaturesEast<<" + "<<numberExtraTempsEast<<") + "<<mDb->adjustAverageEast()<<" = "<<(averageBodyTemperatureEast+averageExtraTempsEast)/(numberBodyTemperaturesEast+numberExtraTempsEast) + mDb->adjustAverageEast()<<endm;
563  averageGasTempEast = (averageBodyTemperatureEast + averageExtraTempsEast)/(numberBodyTemperaturesEast + numberExtraTempsEast);
564  mParam->setGasTemperatureEast(averageGasTempEast + mDb->adjustAverageEast());
565  return kStOK;
566  }
567  else {
568  LOG_WARN<<"No FTPC East body temperatures or FTPC Extra temperatures found for run number "<<runNumber<<"dbDate "<<dbDate<<" using defaultTemperatureEast = "<<mParam->gasTemperatureEast()<<endm;
569  return kStWarn;
570  }
571  }
572 
573  // Year2004: from runs after run 5027147 on 2004-01-27 to run 5093053, the last run of the AuAu 62GeV run on 2004-04-02, only Body3, Body4 and Body5 temperature readings are useable for FTPC East
574  // The averageBodyTemperatureEast must be adjusted since only 3 instead of 6 temperature readings are used
575  if ( runNumber > 5027147 && runNumber <= 5093053 ) {
576  LOG_DEBUG<<"runNumber = "<<runNumber<<" > 5027147 && <= 5093053: only Body3, Body4 and Body5 are useable for FTPC East. The averageBodyTemperatureEast is adjusted by "<<mDb->adjustAverageEast()<<endm;
577  if (mGas->getBody3East() >= mDb->minGasTemperature() && mGas->getBody3East() <= mDb->maxGasTemperature() ) {
578  averageBodyTemperatureEast += mGas->getBody3East();
579  numberBodyTemperaturesEast++;
580  LOG_DEBUG<<" "<<mGas->getBody3East()<<"(body3East)"<<endm;
581  }
582  if (mGas->getBody4East() >= mDb->minGasTemperature() && mGas->getBody4East() <= mDb->maxGasTemperature() ) {
583  averageBodyTemperatureEast += mGas->getBody4East();
584  numberBodyTemperaturesEast++;
585  LOG_DEBUG<<" + "<<mGas->getBody4East()<<"(body4East)"<<endm;
586  }
587  if (mGas->getBody5East() >= mDb->minGasTemperature() && mGas->getBody5East() <= mDb->maxGasTemperature() ) {
588  averageBodyTemperatureEast += mGas->getBody5East();
589  numberBodyTemperaturesEast++;
590  LOG_DEBUG<<" + "<<mGas->getBody5East()<<"(body5East)"<<endm;
591  }
592  }
593 
594  else {
595 
596  if (mGas->getBody1East() >= mDb->minGasTemperature() && mGas->getBody1East() <= mDb->maxGasTemperature()) {
597  averageBodyTemperatureEast += mGas->getBody1East();
598  numberBodyTemperaturesEast++;
599  LOG_DEBUG<<mGas->getBody1East()<<"(body1East)"<<endm;
600  }
601  if (mGas->getBody2East() >= mDb->minGasTemperature() && mGas->getBody2East()<= mDb->maxGasTemperature() ) {
602  averageBodyTemperatureEast += mGas->getBody2East();
603  numberBodyTemperaturesEast++;
604  LOG_DEBUG<<" + "<<mGas->getBody2East()<<"(body2East)"<<endm;
605  }
606  if (mGas->getBody3East() >= mDb->minGasTemperature() && mGas->getBody3East()<= mDb->maxGasTemperature() ) {
607  averageBodyTemperatureEast += mGas->getBody3East();
608  numberBodyTemperaturesEast++;
609  LOG_DEBUG<<" + "<<mGas->getBody3East()<<"(body3East)"<<endm;
610  }
611  if (mGas->getBody4East() >= mDb->minGasTemperature() && mGas->getBody4East() <= mDb->maxGasTemperature() ) {
612  averageBodyTemperatureEast += mGas->getBody4East();
613  numberBodyTemperaturesEast++;
614  LOG_DEBUG<<" + "<<mGas->getBody4East()<<"(body4East)"<<endm;
615  }
616  // from 2003-10-31 -> 2004-01-24 and as of 2004-04-04 there are 2 additional body temperature sensors
617  if ( (dbDate >= 20031031 && dbDate <= 20040124) || dbDate >= 20040404 ) {
618  LOG_DEBUG<<"(dbDate = "<<dbDate<<" >= 20031031 && <= 20040124 || >= 20040404 activate additional body temperature sensors) ";
619  if (mGas->getBody5East() >= mDb->minGasTemperature() && mGas->getBody5East() <= mDb->maxGasTemperature() ) {
620  averageBodyTemperatureEast += mGas->getBody5East();
621  numberBodyTemperaturesEast++;
622  LOG_DEBUG<<" + "<<mGas->getBody5East()<<"(body5East)"<<endm;
623  }
624  if (mGas->getBody6East() >= mDb->minGasTemperature() && mGas->getBody6East() <= mDb->maxGasTemperature() ) {
625  averageBodyTemperatureEast += mGas->getBody6East();
626  numberBodyTemperaturesEast++;
627  LOG_DEBUG<<mGas->getBody6East()<<"(body6East)"<<endm;
628  }
629  }
630  }
631  LOG_DEBUG<<" = "<<averageBodyTemperatureEast<<endm;
632 
633  // calculate average body temperature east
634  if (numberBodyTemperaturesEast > 0) {
635  LOG_DEBUG<<"setGasTemperatureEast = "<<averageBodyTemperatureEast<<" (averageBodyTemperatureEast) + "<<mDb->adjustAverageEast()<<" (adjustAverageEast) = "<<averageBodyTemperatureEast + mDb->adjustAverageEast()<<endm;
636  averageBodyTemperatureEast = averageBodyTemperatureEast/numberBodyTemperaturesEast;
637  mParam->setGasTemperatureEast(averageBodyTemperatureEast + mDb->adjustAverageEast());
638  return kStOK;
639  }
640  // if no body temperature readings return warning
641  else {
642  LOG_WARN<<"No FTPC East body temperatures found for "<<dbDate<<" using defaultTemperatureEast = "<<mParam->gasTemperatureEast()<<endm;
643  return kStWarn;
644  }
645 }
646 
647 Int_t StFtpcGasUtilities::defaultTemperatureWest(Int_t dbDate,Bool_t SVT_On) {
648  if ( !SVT_On) {
649  mParam->setGasTemperatureWest(mDb->defaultTemperatureWest());
650  LOG_WARN<<"No valid body temperatures available for FTPC West; Initialize to defaultTemperatureWest (for dbDate = "<<dbDate<<" SVT off) = "<<mParam->gasTemperatureWest()<<endm;
651  }
652  if (SVT_On) {
653  if (dbDate < 20021105) {
654  // for year 2001 data (AuAu,pp) FTPC west gas temperature is higher when SVT on
655  mParam->setGasTemperatureWest(mDb->defaultTemperatureWest() + mDb->temperatureDifference());
656  LOG_WARN<<"No valid body temperatures available for FTPC West; Initialize to mDb->defaultTemperatureWest() + mDb->temperatureDifference() (for year2001 data,SVT on) = "<<mParam->gasTemperatureWest()<<endm;
657  }
658  if (dbDate >= 20021105) {
659  // starting in year 2003,the FTPC west gas temperature is not effected by SVT
660  mParam->setGasTemperatureWest(mDb->defaultTemperatureWest());
661  LOG_WARN<<"No valid body temperatures available for FTPC West; Initialize to mDb->defaultTemperatureWest() (as of year2003, SVT on) = "<<mParam->gasTemperatureWest()<<endm;
662  }
663  }
664  return kStOK;
665 }
666 
667 Int_t StFtpcGasUtilities::defaultTemperatureEast(Int_t dbDate,Bool_t SVT_On) {
668  if ( !SVT_On) {
669  mParam->setGasTemperatureEast(mDb->defaultTemperatureEast());
670  LOG_WARN<<"No valid body temperatures available for FTPC East; Initialize to defaultTemperatureEast (for dbDate = "<<dbDate<<" SVT off) = "<<mParam->gasTemperatureEast()<<endm;
671  }
672  if (SVT_On) {
673  if (dbDate < 20021105) {
674  // for year 2001 data (dAu,pp) FTPC east gas temperature is not effected by SVT
675  mParam->setGasTemperatureEast(mDb->defaultTemperatureEast());
676  LOG_WARN<<"No valid body temperatures available for FTPC East; Initialize to mDb->defaultTemperatureEast() (for year2001 data, SVT on) = "<<mParam->gasTemperatureEast()<<endm;
677  }
678  if (dbDate >= 20021105) {
679  // starting in year 2003 data the FTPC east gas temperature is higher when SVT on
680  mParam->setGasTemperatureEast(mDb->defaultTemperatureEast() + mDb->temperatureDifference());
681  LOG_WARN<<"No valid body temperatures available for FTPC East; Initialize to mDb->defaultTemperatureEast() + mDb->temperatureDifference() (as of year2003,SVT on) = "<<mParam->gasTemperatureEast()<<endm;
682  }
683  }
684  return kStOK;
685  }
Definition: Stypes.h:42
Definition: Stypes.h:40