AliPhysics  754e963 (754e963)
readOCDB_Temperature.C
Go to the documentation of this file.
1 #if !defined( __CINT__) || defined(__MAKECINT__)
2 #include <AliCDBEntry.h>
3 #include <AliCDBManager.h>
4 #include <AliCDBMetaData.h>
5 #include <AliDCSValue.h>
6 #include <AliEMCALPreprocessor.h>
7 #include <AliEMCALSensorTempArray.h>
8 #include <AliEMCALTriggerDCSConfig.h>
9 #include <AliEMCALTriggerSTUDCSConfig.h>
10 #include <AliEMCALTriggerTRUDCSConfig.h>
11 #include <AliLog.h>
12 #include <TDatime.h>
13 #include <TFile.h>
14 #include <TGrid.h>
15 #include <TMap.h>
16 #include <TNtuple.h>
17 #include <stdio.h>
18 #include "TInfo.h"
19 TInfo *readOCDB_Temperature(Int_t runNb = 286350, Bool_t debug=1);
20 void testOCDB_Temperature(Int_t runNb = 286350);
21 #endif
22 
23 #ifndef _tempfuncs_
24 #define _tempfuncs_
26 {
27  if (!gGrid)
28  TGrid::Connect("alien://");
29 
30  AliCDBManager* cdb = AliCDBManager::Instance();
31  if (cdb->GetDefaultStorage()==0)
32  cdb->SetDefaultStorage("raw://");
33  cdb->SetRun(runNb);
34 
35  AliCDBEntry *en=0;
36  try {
37  en=cdb->Get("EMCAL/Calib/Temperature/");
38  } catch (...) { ; }
39  if (!en) {
40  printf("no entry found for run %d!\n", runNb);
41  return 0;
42  }
43 
44  TInfo *info = new TInfo(runNb);
45 
46  AliEMCALSensorTempArray *arr = dynamic_cast< AliEMCALSensorTempArray *> (en->GetObject());
47  //arr->Print();
48  cout << " NumSensors " << arr->NumSensors()
49  << " GetFirstIdDCS() " << arr->GetFirstIdDCS()
50  << " GetLastIdDCS() " << arr->GetLastIdDCS()
51  << endl;
52 
53  // info for each sensor
54  const Int_t kNumSens = 160;
55  Int_t np[kNumSens] = {0};
56  Double_t min[kNumSens] = {0};
57  Double_t max[kNumSens] = {0};
58 
59  Double_t avTime = 0;
60  UInt_t fTime = -1;
61  UInt_t lTime = 0;
62  for (Int_t isensor=0; isensor<kNumSens; isensor++) {
63  AliEMCALSensorTemp *o = arr->GetSensor(isensor);
64  if (!o)
65  continue;
66 
67  UInt_t startt = o->GetStartTime();
68  UInt_t stopt = o->GetEndTime();
69 
70  if (debug)
71  cout << "Sensor " << isensor
72  << " " << o->GetStringID() << ":"
73  << " side " << o->GetSide()
74  << " sector " << o->GetSector()
75  << " num " << o->GetNum()
76  << " startTime " << startt
77  << " endTime " << stopt
78  << endl;
79 
80  np[isensor] = 0;
81  min[isensor] = +100;
82  max[isensor] = -100;
83 
84  AliSplineFit *f = o->GetFit();
85  if (f) {
86  np[isensor] = f->GetKnots();
87  if (debug)
88  cout << " np " << np[isensor] << endl;
89  Double_t *x = f->GetX();
90  Double_t *y0 = f->GetY0();
91  Double_t *y1 = f->GetY1();
92  for (Int_t i=0; i<np[isensor]; ++i) {
93  if (debug)
94  cout << " i " << i
95  << " x " << x[i]
96  << " y0 " << y0[i]
97  << " y1 " << y1[i]
98  << endl;
99 
100  if (min[isensor]>y0[i]) min[isensor]=y0[i];
101  if (max[isensor]<y0[i]) max[isensor]=y0[i];
102  }
103  } else {
104  TGraph *g = o->GetGraph();
105  if (g) {
106  np[isensor] = g->GetN();
107  if (debug)
108  cout << " np " << np[isensor] << endl;
109  Double_t *x = g->GetX();
110  Double_t *y0 = g->GetY();
111  for (Int_t i=0; i<np[isensor]; i++) {
112  if (debug)
113  cout << " i " << i
114  << " x " << x[i]
115  << " y0 " << y0[i]
116  << endl;
117  if (min[isensor]>y0[i]) min[isensor]=y0[i];
118  if (max[isensor]<y0[i]) max[isensor]=y0[i];
119  }
120  }
121  }
122 
123  if (np[isensor]>0) {
124  if (debug)
125  cout << "Min Temp: " << min[isensor] << " Max Temp: " << max[isensor] << endl;
126  info->Set(isensor, min[isensor], max[isensor]);
127  avTime += startt + stopt;
128  if (startt<fTime)
129  fTime=startt;
130  if (stopt>lTime)
131  lTime=stopt;
132  }
133 
134  if (0)
135  cout << "Tree: " << runNb
136  << " " << isensor
137  << " " << o->GetSide()
138  << " " << o->GetSector()
139  << " " << o->GetNum()
140  << " " << o->GetStartTime()
141  << " " << o->GetEndTime()
142  << " " << min[isensor]
143  << " " << max[isensor] << endl;
144  }
145  Int_t nv = info->Nvalid();
146  if (nv>0) {
147  avTime /= 2*nv;
148  info->SetTime(avTime,fTime,lTime);
149  }
150  return info;
151 }
152 
154 {
155  TInfo *i = readOCDB_Temperature(runNb,1);
156  i->Print();
157  return;
158 }
159 #endif
double Double_t
Definition: External.C:58
Definition: TInfo.h:10
Int_t Nvalid() const
Definition: TInfo.h:37
void Set(Int_t ns, Float_t min, Float_t max)
Definition: TInfo.h:39
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
void SetTime(UInt_t av, UInt_t f, UInt_t l)
Definition: TInfo.h:41
TInfo * readOCDB_Temperature(Int_t runNb=286350, Bool_t debug=1)
void Print(Option_t *option="") const
Definition: TInfo.cxx:66
void testOCDB_Temperature(Int_t runNb=286350)
bool Bool_t
Definition: External.C:53