adding HLT as subdetector
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessor.cxx
CommitLineData
54472e4f 1/**************************************************************************
2 * Copyright(c) 2007, 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
72df5829 16
54472e4f 17#include "AliTPCPreprocessor.h"
18
19#include "AliCDBMetaData.h"
20#include "AliDCSValue.h"
21#include "AliLog.h"
22#include "AliTPCSensorTempArray.h"
18eade96 23#include "AliTPCDBPressure.h"
54472e4f 24
25#include <TTimeStamp.h>
26
18eade96 27const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
28const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
72df5829 29
54472e4f 30//
31// This class is the SHUTTLE preprocessor for the TPC detector.
f7f602cc 32// It contains several components, this far the part containing
54472e4f 33// temperatures is implemented
34//
35
36ClassImp(AliTPCPreprocessor)
37
38//______________________________________________________________________________________________
6d07bf74 39AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
40 AliPreprocessor("TPC",shuttle),
18eade96 41 fTemp(0), fPressure(0), fConfigOK(kTRUE)
54472e4f 42{
43 // constructor
44}
72df5829 45//______________________________________________________________________________________________
46// AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) :
47// AliPreprocessor(org),
18eade96 48// fTemp(0), fPressure(0), fConfigOK(kTRUE)
72df5829 49// {
50// // copy constructor not implemented
f7f602cc 51// // -- missing underlying copy constructor in AliPreprocessor
52//
72df5829 53// Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 54//
55// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
72df5829 56// }
54472e4f 57
58//______________________________________________________________________________________________
59AliTPCPreprocessor::~AliTPCPreprocessor()
60{
61 // destructor
62
63 delete fTemp;
18eade96 64 delete fPressure;
54472e4f 65}
72df5829 66//______________________________________________________________________________________________
67AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
68{
69 Fatal("operator =", "assignment operator not implemented");
70 return *this;
71}
72
54472e4f 73
74//______________________________________________________________________________________________
75void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
76 UInt_t endTime)
77{
78 // Creates AliTestDataDCS object
79
80 AliPreprocessor::Initialize(run, startTime, endTime);
81
82 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
83 TTimeStamp(startTime).AsString(),
84 TTimeStamp(endTime).AsString()));
85
18eade96 86 // Temperature sensors
87
f7f602cc 88 TTree *confTree = 0;
89 AliCDBEntry* entry = GetFromOCDB("Config", "Temperature");
90 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 91 if ( confTree==0 ) {
92 AliError(Form("Temperature Config OCDB entry missing.\n"));
93 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
94 fConfigOK = kFALSE;
f7f602cc 95 return;
18eade96 96 }
97 fTemp = new AliTPCSensorTempArray(fStartTime, fEndTime, confTree);
98 fTemp->SetValCut(kValCutTemp);
99 fTemp->SetDiffCut(kDiffCutTemp);
f7f602cc 100
18eade96 101 // Pressure sensors
f7f602cc 102
103 confTree=0;
104 entry=0;
105 entry = GetFromOCDB("Config", "Pressure");
106 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 107 if ( confTree==0 ) {
108 AliError(Form("Pressure Config OCDB entry missing.\n"));
109 Log("AliTPCPreprocsessor: Pressure Config OCDB entry missing.\n");
110 fConfigOK = kFALSE;
f7f602cc 111 return;
18eade96 112 }
113 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, confTree);
18eade96 114
54472e4f 115}
116
117//______________________________________________________________________________________________
118UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
119{
120 // Fills data into TPC calibrations objects
121
18eade96 122 if (!dcsAliasMap) return 9;
123 if (!fConfigOK) return 9;
54472e4f 124
125 // Amanda servers provide information directly through dcsAliasMap
126
127 // Temperature sensors are processed by AliTPCCalTemp
72df5829 128
18eade96 129
54472e4f 130 UInt_t tempResult = MapTemperature(dcsAliasMap);
131 UInt_t result=tempResult;
18eade96 132
133 // Pressure sensors
134
135 UInt_t pressureResult = MapPressure(dcsAliasMap);
136 result += pressureResult;
f7f602cc 137
54472e4f 138 // Other calibration information will be retrieved through FXS files
139 // examples:
140 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
141 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
142 //
143 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
144 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
145
146
147 return result;
148}
149//______________________________________________________________________________________________
150UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
151{
152
153 // extract DCS temperature maps. Perform fits to save space
154
72df5829 155 UInt_t result=0;
54472e4f 156 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
157 if (map) {
158 fTemp->MakeSplineFit(map);
159 AliInfo(Form("Temperature values extracted, fits performed.\n"));
160 } else {
161 AliError(Form("No temperature map extracted.\n"));
162 Log("AliTPCPreprocsessor: no temperature map extracted. \n");
72df5829 163 result=9;
54472e4f 164 }
165 delete map;
166 // Now store the final CDB file
167
72df5829 168 if ( result == 0 ) {
169 AliCDBMetaData metaData;
54472e4f 170 metaData.SetBeamPeriod(0);
171 metaData.SetResponsible("Haavard Helstrup");
172 metaData.SetComment("Preprocessor AliTPC data base entries.");
173
72df5829 174 result = Store("Calib", "Temperature", fTemp, &metaData, 0, 0);
175 if ( result == 1 ) {
176 result = 0;
177 } else {
178 result = 1;
179 } // revert to new return code conventions
180 }
54472e4f 181
182 return result;
183}
18eade96 184//______________________________________________________________________________________________
185UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
186{
187
188 // extract DCS temperature maps. Perform fits to save space
189
190 UInt_t result=0;
191 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
192 if (map) {
193 fPressure->MakeSplineFit(map);
194 AliInfo(Form("Pressure values extracted, fits performed.\n"));
195 } else {
196 AliError(Form("No atmospheric pressure map extracted.\n"));
197 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
198 result=9;
199 }
200 delete map;
201 // Now store the final CDB file
202
203 if ( result == 0 ) {
204 AliCDBMetaData metaData;
205 metaData.SetBeamPeriod(0);
206 metaData.SetResponsible("Haavard Helstrup");
207 metaData.SetComment("Preprocessor AliTPC data base entries.");
208
209 result = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
210 if ( result == 1 ) {
211 result = 0;
212 } else {
213 result = 1;
214 } // revert to new return code conventions
215 }
216
217 return result;
218}