]>
Commit | Line | Data |
---|---|---|
d47d42ee | 1 | /* |
7ce80437 | 2 | .x ~/NimStyle.C |
3 | .x ~/rootlogon.C | |
4 | ||
d47d42ee | 5 | gSystem->AddIncludePath("-I$ALICE_ROOT/TPC"); |
e2914767 | 6 | |
e2914767 | 7 | |
8 | ||
7ce80437 | 9 | .L $ALICE_ROOT/TPC/CalibMacros/CalibEnv.C+ |
d47d42ee | 10 | Init(); |
e2914767 | 11 | CalibEnv("listAll.txt"); |
7ce80437 | 12 | GetTree(); |
13 | ||
e79211e8 | 14 | TFile f("dcsTime.root") |
d47d42ee | 15 | |
7ce80437 | 16 | // |
17 | // if you want to use alien OCDB | |
18 | // | |
19 | gSystem->Load("libXrdClient.so"); | |
20 | gSystem->Load("libNetx.so"); | |
21 | if (!gGrid) TGrid::Connect("alien://",0,0,"t"); | |
22 | ||
23 | ||
e2914767 | 24 | |
d47d42ee | 25 | */ |
26 | ||
27 | #include <iostream> | |
28 | #include <fstream> | |
5312f439 | 29 | #include <stdio.h> |
d47d42ee | 30 | #include <AliCDBManager.h> |
31 | #include <AliCDBEntry.h> | |
32 | #include <AliLog.h> | |
33 | #include <AliMagF.h> | |
34 | #include "AliTPCcalibDB.h" | |
35 | #include "AliTPCAltroMapping.h" | |
36 | #include "AliTPCExB.h" | |
37 | #include "AliTPCCalROC.h" | |
38 | #include "AliTPCCalPad.h" | |
39 | #include "AliTPCSensorTempArray.h" | |
40 | #include "AliGRPObject.h" | |
41 | #include "AliTPCTransform.h" | |
42 | #include "TFile.h" | |
43 | #include "TKey.h" | |
44 | #include "TObjArray.h" | |
45 | #include "TObjString.h" | |
46 | #include "TString.h" | |
47 | #include "AliTPCCalPad.h" | |
5312f439 | 48 | #include "AliTPCROC.h" |
49 | #include "AliTPCParam.h" | |
d47d42ee | 50 | #include "AliTPCCalibPulser.h" |
51 | #include "AliTPCCalibPedestal.h" | |
52 | #include "AliTPCCalibCE.h" | |
53 | #include "AliTPCExBFirst.h" | |
54 | #include "TTreeStream.h" | |
55 | #include "AliTPCTempMap.h" | |
5312f439 | 56 | #include "TVectorD.h" |
57 | #include "TMatrixD.h" | |
d47d42ee | 58 | |
7ce80437 | 59 | |
60 | TTree * dcsTree=0; | |
61 | ||
d47d42ee | 62 | void ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS); |
5312f439 | 63 | void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC); |
64 | void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions, | |
65 | TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions, | |
66 | Int_t &nonMaskedZero); | |
67 | void ProcessPulser(Int_t &nMasked, Int_t &nonMaskedZero); | |
6fb51ca4 | 68 | void GetProductionInfo(Int_t run, Int_t &nalien, Int_t &nRawAlien, Int_t &nlocal, Int_t &nRawLocal); |
5312f439 | 69 | |
d47d42ee | 70 | void Init(){ |
71 | // | |
72 | // | |
73 | // | |
162637e4 | 74 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
75 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Parameters","local://$ALICE_ROOT/OCDB"); | |
e6970ab5 | 76 | AliCDBManager::Instance()->SetSpecificStorage("GRP/GRP/Data","local:///lustre/alice/alien/alice/data/2008/LHC08d/OCDB/"); |
77 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Temperature","local:///lustre/alice/alien/alice/data/2008/LHC08d/OCDB/"); | |
78 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/HighVoltage","local:///lustre/alice/alien/alice/data/2008/LHC08d/OCDB/"); | |
79 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Goofie","local:///lustre/alice/alien/alice/data/2008/LHC08d/OCDB/"); | |
d47d42ee | 80 | AliCDBManager::Instance()->SetRun(1); |
e2914767 | 81 | } |
82 | ||
d47d42ee | 83 | |
e2914767 | 84 | void InitAlien(const char *path="LHC08b"){ |
85 | // | |
86 | // | |
87 | // | |
88 | TString alpath="alien://folder=/alice/data/2008/"; | |
89 | alpath+=path; | |
90 | alpath+="/OCDB"; | |
7ce80437 | 91 | |
162637e4 | 92 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
93 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Parameters","local://$ALICE_ROOT/OCDB"); | |
e2914767 | 94 | AliCDBManager::Instance()->SetSpecificStorage("GRP/GRP/Data",alpath.Data()); |
95 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Temperature",alpath.Data()); | |
96 | AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Goofie",alpath.Data()); | |
97 | AliCDBManager::Instance()->SetRun(1); | |
d47d42ee | 98 | } |
99 | ||
100 | ||
101 | void CalibEnv(const char * runList){ | |
102 | // | |
103 | // | |
7ce80437 | 104 | // |
e79211e8 | 105 | AliTPCcalibDB * calibDB = AliTPCcalibDB::Instance(); |
d47d42ee | 106 | ifstream in; |
107 | in.open(runList); | |
108 | Int_t irun=0; | |
e79211e8 | 109 | TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root"); |
d47d42ee | 110 | // for (Int_t irun=startRun; irun<stopRun; irun++){ |
111 | while(in.good()) { | |
112 | in >> irun; | |
113 | if (irun==0) continue; | |
e2914767 | 114 | printf("Processing run %d ...\n",irun); |
5312f439 | 115 | AliTPCcalibDB::Instance()->SetRun(irun); |
d47d42ee | 116 | AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun); |
117 | if (!sensorPressure) continue; | |
118 | AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun); | |
119 | AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray); | |
120 | AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun); | |
121 | // | |
122 | Int_t startTime = sensorPressure->GetStartTime(); | |
123 | Int_t endTime = sensorPressure->GetEndTime(); | |
6fb51ca4 | 124 | Int_t startTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeStart(); |
125 | Int_t stopTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeEnd(); | |
d47d42ee | 126 | Int_t dtime = TMath::Max((endTime-startTime)/20,10*60); |
5312f439 | 127 | //CE data processing - see ProcessCEdata function for description of the results |
128 | TVectorD fitResultsA, fitResultsC; | |
129 | ProcessCEdata("gx++gy++lx++lx**2",fitResultsA,fitResultsC); | |
130 | //noise data Processing - see ProcessNoiseData function for description of the results | |
131 | TVectorD vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions; | |
132 | Int_t nonMaskedZero=0; | |
133 | ProcessNoiseData(vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions, nonMaskedZero); | |
e6970ab5 | 134 | //L3 data |
5312f439 | 135 | Float_t bz=AliTPCcalibDB::GetBz(irun); |
136 | Char_t l3pol=AliTPCcalibDB::GetL3Polarity(irun); | |
137 | //calibration Pulser data processing | |
138 | Int_t nMasked=0; | |
139 | Int_t nOffChannels=0; | |
140 | ProcessPulser(nMasked,nOffChannels); | |
141 | //production information | |
6fb51ca4 | 142 | Int_t nalien=0,nRawAlien=0,nlocal=0,nRawLocal=0; |
e6970ab5 | 143 | // GetProductionInfo(irun, nalien, nRawAlien, nlocal,nRawLocal); |
5312f439 | 144 | //run type |
145 | TObjString runType(AliTPCcalibDB::GetRunType(irun).Data()); | |
146 | ||
d47d42ee | 147 | for (Int_t itime=startTime; itime<endTime; itime+=dtime){ |
148 | // | |
5312f439 | 149 | TTimeStamp tstamp(itime); |
e79211e8 | 150 | Float_t valuePressure = calibDB->GetPressure(tstamp,irun,0); |
151 | Float_t valuePressure2 = calibDB->GetPressure(tstamp,irun,1); | |
5312f439 | 152 | //temperature fits |
d47d42ee | 153 | TLinearFitter * fitter = 0; |
154 | TVectorD vecTemp[10]; | |
e79211e8 | 155 | for (Int_t itype=0; itype<5; itype++) |
5312f439 | 156 | for (Int_t iside=0; iside<2; iside++){ |
157 | fitter= tempMap->GetLinearFitter(itype,iside,tstamp); | |
158 | if (!fitter) continue; | |
159 | fitter->Eval(); | |
160 | fitter->GetParameters(vecTemp[itype+iside*5]); | |
161 | delete fitter; | |
162 | } | |
163 | //measured skirt temperatures | |
164 | TVectorD vecSkirtTempA(18); | |
165 | TVectorD vecSkirtTempC(18); | |
166 | Int_t nsenTemp=tempArray->NumSensors(); | |
167 | for (Int_t isenTemp=0;isenTemp<nsenTemp;++isenTemp){ | |
168 | AliTPCSensorTemp *senTemp=(AliTPCSensorTemp*)tempArray->GetSensorNum(isenTemp); | |
169 | if (senTemp->GetType()!=3) continue; | |
170 | if (TMath::Sqrt(senTemp->GetX()*senTemp->GetX()+senTemp->GetY()*senTemp->GetY())<100) continue; //only skirt, outer FC vessel | |
171 | Double_t val=senTemp->GetValue(tstamp); | |
172 | if (senTemp->GetSide()==0) | |
173 | vecSkirtTempA[senTemp->GetSector()]=val; | |
174 | else | |
175 | vecSkirtTempC[senTemp->GetSector()]=val; | |
176 | } | |
d47d42ee | 177 | |
178 | TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS; | |
5312f439 | 179 | if (goofieArray){ |
180 | vecGoofie.ResizeTo(goofieArray->NumSensors()); | |
181 | ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS); | |
182 | // | |
183 | for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){ | |
184 | AliDCSSensor *gsensor = goofieArray->GetSensor(isensor); | |
185 | if (gsensor){ | |
186 | vecGoofie[isensor] = gsensor->GetValue(tstamp); | |
187 | } | |
188 | } | |
d47d42ee | 189 | } |
e79211e8 | 190 | Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,irun,0); |
191 | Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,irun,1); | |
e2914767 | 192 | // |
5312f439 | 193 | TVectorD voltagesIROC(36); |
194 | TVectorD voltagesOROC(36); | |
7ce80437 | 195 | for(Int_t j=1; j<36; j++) voltagesIROC[j-1] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,tstamp); |
196 | for(Int_t j=36; j<72; j++) voltagesOROC[j-36] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,tstamp); | |
197 | Double_t voltIROC = TMath::Median(36, voltagesIROC.GetMatrixArray()); | |
198 | Double_t voltOROC = TMath::Median(36, voltagesOROC.GetMatrixArray()); | |
199 | // | |
5312f439 | 200 | Float_t coverIA=AliTPCcalibDB::GetCoverVoltage(irun,0,itime); |
201 | Float_t coverIC=AliTPCcalibDB::GetCoverVoltage(irun,18,itime); | |
202 | Float_t coverOA=AliTPCcalibDB::GetCoverVoltage(irun,36,itime); | |
203 | Float_t coverOC=AliTPCcalibDB::GetCoverVoltage(irun,54,itime); | |
204 | Float_t skirtA=AliTPCcalibDB::GetSkirtVoltage(irun,0,itime); | |
205 | Float_t skirtC=AliTPCcalibDB::GetSkirtVoltage(irun,18,itime); | |
206 | Float_t ggOffA=AliTPCcalibDB::GetGGoffsetVoltage(irun,0,itime); | |
207 | Float_t ggOffC=AliTPCcalibDB::GetGGoffsetVoltage(irun,18,itime); | |
208 | ||
209 | ||
210 | ||
e2914767 | 211 | //tempMap->GetLinearFitter(0,0,itime); |
e6970ab5 | 212 | (*pcstream)<<"dcs"<< |
5312f439 | 213 | "run="<<irun<< |
214 | "time="<<itime<< | |
6fb51ca4 | 215 | "startTimeGRP="<<startTimeGRP<< |
216 | "stopTimeGRP="<<stopTimeGRP<< | |
5312f439 | 217 | //run type |
218 | "runType.="<<&runType<< | |
219 | // voltage setting | |
220 | "VIROC.="<<&voltagesIROC<< | |
221 | "VOROC.="<<&voltagesOROC<< | |
222 | "medianVIROC="<<voltIROC<< | |
223 | "medianVOROC="<<voltOROC<< | |
7ce80437 | 224 | "coverIA=" << coverIA << |
225 | "coverIC=" << coverIC << | |
226 | "coverOA=" << coverOA << | |
227 | "coverOC=" << coverOC << | |
228 | "skirtA=" << skirtA << | |
229 | "skirtC=" << skirtC << | |
230 | "ggOffA=" << ggOffA << | |
231 | "ggOffC=" << ggOffC << | |
5312f439 | 232 | // |
233 | "ptrel0="<<ptrelative0<< // deltaTP/TP - A side | |
234 | "ptrel1="<<ptrelative1<< // deltaTP/TPC - C side | |
235 | "goofie.="<<&vecGoofie<< | |
236 | "goofieE.="<<&vecEntries<< | |
237 | "goofieMean.="<<&vecMean<< | |
238 | "goofieMedian.="<<&vecMedian<< | |
239 | "goofieRMS.="<<&vecRMS<< | |
240 | // | |
241 | "press="<<valuePressure<< | |
242 | "press2="<<valuePressure2<< | |
243 | "temp00.="<<&vecTemp[0]<< | |
244 | "temp10.="<<&vecTemp[1]<< | |
245 | "temp20.="<<&vecTemp[2]<< | |
246 | "temp30.="<<&vecTemp[3]<< | |
247 | "temp40.="<<&vecTemp[4]<< | |
248 | "temp01.="<<&vecTemp[5]<< | |
249 | "temp11.="<<&vecTemp[6]<< | |
250 | "temp21.="<<&vecTemp[7]<< | |
251 | "temp31.="<<&vecTemp[8]<< | |
252 | "temp41.="<<&vecTemp[9]<< | |
253 | "tempSkirtA.="<<&vecSkirtTempA<< | |
e6970ab5 | 254 | "tempSkirtC.="<<&vecSkirtTempC<< |
5312f439 | 255 | //noise data |
256 | "meanNoise.="<<&vNoiseMean<< | |
257 | "meanNoiseSen.="<<&vNoiseMeanSenRegions<< | |
258 | "rmsNoise.="<<&vNoiseRMS<< | |
259 | "rmsNoiseSen.="<<&vNoiseRMSSenRegions<< | |
260 | "zeroNoise="<<nonMaskedZero<< | |
261 | //pulser data | |
262 | "nMasked="<<nMasked<< //should perhaps go to altro data | |
263 | "nOffPulser="<<nOffChannels<< | |
264 | //ce data | |
265 | "CEfitA.="<<&fitResultsA<< | |
266 | "CEfitC.="<<&fitResultsC<< | |
267 | // b field | |
268 | "Bz="<< bz << | |
269 | "L3polarity="<<l3pol<< | |
270 | // production information | |
271 | "nalien="<<nalien<< | |
6fb51ca4 | 272 | "nRawAlien="<<nRawAlien<< |
5312f439 | 273 | "nlocal="<<nlocal<< |
6fb51ca4 | 274 | "nRawLocal="<<nRawLocal<< |
5312f439 | 275 | "\n"; |
d47d42ee | 276 | } |
277 | } | |
278 | delete pcstream; | |
279 | } | |
280 | ||
281 | ||
282 | void ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){ | |
283 | /* | |
7ce80437 | 284 | |
d47d42ee | 285 | 1 TPC_ANODE_I_A00_STAT |
286 | 2 TPC_DVM_CO2 | |
287 | 3 TPC_DVM_DriftVelocity | |
288 | 4 TPC_DVM_FCageHV | |
289 | 5 TPC_DVM_GainFar | |
290 | 6 TPC_DVM_GainNear | |
291 | 7 TPC_DVM_N2 | |
292 | 8 TPC_DVM_NumberOfSparks | |
293 | 9 TPC_DVM_PeakAreaFar | |
294 | 10 TPC_DVM_PeakAreaNear | |
295 | 11 TPC_DVM_PeakPosFar | |
296 | 12 TPC_DVM_PeakPosNear | |
297 | 13 TPC_DVM_PickupHV | |
298 | 14 TPC_DVM_Pressure | |
299 | 15 TPC_DVM_T1_Over_P | |
300 | 16 TPC_DVM_T2_Over_P | |
301 | 17 TPC_DVM_T_Over_P | |
302 | 18 TPC_DVM_TemperatureS1 | |
303 | */ | |
304 | // | |
305 | // | |
306 | // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS; | |
307 | Double_t kEpsilon=0.0000000001; | |
308 | Double_t kBig=100000000000.; | |
309 | Int_t nsensors = goofieArray->NumSensors(); | |
310 | vecEntries.ResizeTo(nsensors); | |
311 | vecMedian.ResizeTo(nsensors); | |
312 | vecMean.ResizeTo(nsensors); | |
313 | vecRMS.ResizeTo(nsensors); | |
314 | TVectorF values; | |
315 | for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){ | |
316 | AliDCSSensor *gsensor = goofieArray->GetSensor(isensor); | |
317 | if (gsensor && gsensor->GetGraph()){ | |
318 | Int_t npoints = gsensor->GetGraph()->GetN(); | |
319 | // filter zeroes | |
320 | values.ResizeTo(npoints); | |
321 | Int_t nused =0; | |
322 | for (Int_t ipoint=0; ipoint<npoints; ipoint++){ | |
7ce80437 | 323 | if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon && |
324 | TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){ | |
325 | values[nused]=gsensor->GetGraph()->GetY()[ipoint]; | |
326 | nused++; | |
327 | } | |
d47d42ee | 328 | } |
329 | // | |
7ce80437 | 330 | vecEntries[isensor]= nused; |
d47d42ee | 331 | if (nused>1){ |
7ce80437 | 332 | vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray()); |
333 | vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray()); | |
334 | vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray()); | |
d47d42ee | 335 | } |
336 | } | |
337 | } | |
338 | } | |
339 | ||
5312f439 | 340 | void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC) |
341 | { | |
342 | // | |
343 | // Process the CE data for this run | |
344 | // the return TVectorD arrays contian the results of the fit | |
345 | // | |
346 | const Float_t irocToffset=0.2; | |
e6970ab5 | 347 | const Float_t tMaxLimit=1.5; |
5312f439 | 348 | //retrieve CE and ALTRO data |
349 | AliTPCCalPad *cet0=AliTPCcalibDB::Instance()->GetCETmean(); | |
350 | if (!cet0){ | |
351 | TString fitString(fitFormula); | |
352 | fitString.ReplaceAll("++","#"); | |
353 | Int_t ndim=fitString.CountChar('#')+1; | |
354 | fitResultsA.ResizeTo(ndim); | |
355 | fitResultsC.ResizeTo(ndim); | |
356 | return; | |
357 | } | |
358 | AliTPCCalPad padT0(*cet0); | |
359 | AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked(); | |
360 | //create outlier map | |
361 | AliTPCCalPad out("out","out"); | |
362 | //loop over all channels | |
363 | for (UInt_t iroc=0;iroc<padT0.kNsec;++iroc){ | |
364 | AliTPCCalROC *rocData=padT0.GetCalROC(iroc); | |
365 | AliTPCCalROC *rocMasked=padMasked->GetCalROC(iroc); | |
366 | AliTPCCalROC *rocOut=out.GetCalROC(iroc); | |
367 | if (!rocData) continue; | |
368 | //add time offset to IROCs | |
369 | if (iroc<AliTPCROC::Instance()->GetNInnerSector()) | |
370 | rocData->Add(irocToffset); | |
371 | //select outliers | |
372 | for (UInt_t ichannel=0;ichannel<rocData->GetNchannels();++ichannel){ | |
373 | if (rocMasked && rocMasked->GetValue(ichannel)) rocOut->SetValue(ichannel,1); | |
374 | Float_t valTmean=rocData->GetValue(ichannel); | |
375 | if (valTmean==0) rocOut->SetValue(ichannel,1); //exclude values that are exactly 0 | |
376 | if (TMath::Abs(valTmean)>tMaxLimit) rocOut->SetValue(ichannel,1); // exclude channels with too large variations | |
377 | } | |
378 | } | |
379 | //perform fit | |
380 | TMatrixD dummy; | |
381 | Float_t chi2A,chi2C; | |
382 | padT0.GlobalSidesFit(&out,fitFormula,fitResultsA,fitResultsC,dummy,dummy,chi2A,chi2C); | |
383 | } | |
384 | ||
385 | void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions, | |
386 | TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions, | |
387 | Int_t &nonMaskedZero) | |
388 | { | |
389 | // | |
390 | // process noise data | |
391 | // vNoiseMean/RMS contains the Mean/RMS noise of the complete TPC [0], IROCs only [1], | |
392 | // OROCs small pads [2] and OROCs large pads [3] | |
393 | // vNoiseMean/RMSsenRegions constains the same information, but only for the sensitive regions (edge pads, corners, IROC spot) | |
394 | // | |
395 | ||
396 | //set proper size and reset | |
397 | const UInt_t infoSize=4; | |
398 | vNoiseMean.ResizeTo(infoSize); | |
399 | vNoiseMeanSenRegions.ResizeTo(infoSize); | |
400 | vNoiseRMS.ResizeTo(infoSize); | |
401 | vNoiseRMSSenRegions.ResizeTo(infoSize); | |
402 | vNoiseMean.Zero(); | |
403 | vNoiseMeanSenRegions.Zero(); | |
404 | vNoiseRMS.Zero(); | |
405 | vNoiseRMSSenRegions.Zero(); | |
406 | //counters | |
407 | TVectorD c(infoSize); | |
408 | TVectorD cs(infoSize); | |
409 | //tpc parameters | |
410 | AliTPCParam par; | |
411 | par.Update(); | |
412 | //retrieve noise and ALTRO data | |
413 | AliTPCCalPad *noise=AliTPCcalibDB::Instance()->GetPadNoise(); | |
e6970ab5 | 414 | if (!noise) return; |
5312f439 | 415 | AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked(); |
416 | //create IROC, OROC1, OROC2 and sensitive region masks | |
417 | for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){ | |
418 | AliTPCCalROC *noiseROC=noise->GetCalROC(isec); | |
419 | UInt_t nrows=noiseROC->GetNrows(); | |
420 | for (UInt_t irow=0;irow<nrows;++irow){ | |
421 | UInt_t npads=noiseROC->GetNPads(irow); | |
422 | for (UInt_t ipad=0;ipad<npads;++ipad){ | |
423 | Int_t masked=(Int_t)padMasked->GetCalROC(isec)->GetValue(irow,ipad); | |
424 | Float_t noiseVal=noiseROC->GetValue(irow,ipad); | |
e6970ab5 | 425 | if (masked) { |
426 | // printf("masked\n"); | |
427 | continue; // don't use inactive pads | |
428 | } | |
5312f439 | 429 | //check if noise==0 |
e6970ab5 | 430 | if (noiseVal==0) { |
431 | ++nonMaskedZero; | |
432 | continue; | |
433 | } | |
434 | //check for nan | |
435 | if ( !(noiseVal<100000000000) ){ | |
436 | printf ("Warning: nan detected in (sec,row,pad - val): %02d,%02d,%03d - %.1f\n",isec,irow,ipad,noiseVal); | |
437 | continue; | |
438 | } | |
5312f439 | 439 | Int_t cpad=(Int_t)ipad-(Int_t)npads/2; |
440 | Int_t masksen=1; // sensitive pards are not masked (0) | |
441 | if (ipad<2||npads-ipad-1<2) masksen=0; //don't mask edge pads (sensitive) | |
442 | if (isec<AliTPCROC::Instance()->GetNInnerSector()){ | |
443 | //IROCs | |
444 | if (irow>19&&irow<46){ | |
445 | if (TMath::Abs(cpad)<7) masksen=0; //IROC spot | |
446 | } | |
447 | Int_t type=1; | |
448 | vNoiseMean[type]+=noiseVal; | |
449 | vNoiseRMS[type]+=noiseVal*noiseVal; | |
450 | ++c[type]; | |
451 | if (!masksen){ | |
452 | vNoiseMeanSenRegions[type]+=noiseVal; | |
453 | vNoiseRMSSenRegions[type]+=noiseVal*noiseVal; | |
454 | ++cs[type]; | |
455 | } | |
456 | } else { | |
457 | //OROCs | |
458 | //define sensive regions | |
459 | if ((nrows-irow-1)<3) masksen=0; //last three rows in OROCs are sensitive | |
460 | if ( irow>75 ){ | |
461 | Int_t padEdge=(Int_t)TMath::Min(ipad,npads-ipad); | |
462 | if (padEdge<((((Int_t)irow-76)/4+1))*2) masksen=0; //OROC outer corners are sensitive | |
463 | } | |
464 | if ((Int_t)irow<par.GetNRowUp1()){ | |
465 | //OROC1 | |
466 | Int_t type=2; | |
467 | vNoiseMean[type]+=noiseVal; | |
468 | vNoiseRMS[type]+=noiseVal*noiseVal; | |
469 | ++c[type]; | |
470 | if (!masksen){ | |
471 | vNoiseMeanSenRegions[type]+=noiseVal; | |
472 | vNoiseRMSSenRegions[type]+=noiseVal*noiseVal; | |
473 | ++cs[type]; | |
474 | } | |
475 | }else{ | |
476 | //OROC2 | |
477 | Int_t type=3; | |
478 | vNoiseMean[type]+=noiseVal; | |
479 | vNoiseRMS[type]+=noiseVal*noiseVal; | |
480 | ++c[type]; | |
481 | if (!masksen){ | |
482 | vNoiseMeanSenRegions[type]+=noiseVal; | |
483 | vNoiseRMSSenRegions[type]+=noiseVal*noiseVal; | |
484 | ++cs[type]; | |
485 | } | |
486 | } | |
487 | } | |
488 | //whole tpc | |
489 | Int_t type=0; | |
490 | vNoiseMean[type]+=noiseVal; | |
491 | vNoiseRMS[type]+=noiseVal*noiseVal; | |
492 | ++c[type]; | |
493 | if (!masksen){ | |
494 | vNoiseMeanSenRegions[type]+=noiseVal; | |
495 | vNoiseRMSSenRegions[type]+=noiseVal*noiseVal; | |
496 | ++cs[type]; | |
497 | } | |
498 | }//end loop pads | |
499 | }//end loop rows | |
500 | }//end loop sectors (rocs) | |
501 | ||
502 | //calculate mean and RMS | |
503 | const Double_t verySmall=0.0000000001; | |
504 | for (UInt_t i=0;i<infoSize;++i){ | |
505 | Double_t mean=0; | |
506 | Double_t rms=0; | |
507 | Double_t meanSen=0; | |
508 | Double_t rmsSen=0; | |
509 | ||
510 | if (c[i]>verySmall){ | |
e6970ab5 | 511 | // printf ("i: %d - m: %.3f, c: %.0f, r: %.3f\n",i,vNoiseMean[i],c[i],vNoiseRMS[i]); |
5312f439 | 512 | mean=vNoiseMean[i]/c[i]; |
513 | rms=vNoiseRMS[i]; | |
514 | rms=TMath::Sqrt(TMath::Abs(rms/c[i]-mean*mean)); | |
515 | } | |
516 | vNoiseMean[i]=mean; | |
517 | vNoiseRMS[i]=rms; | |
518 | ||
519 | if (cs[i]>verySmall){ | |
520 | meanSen=vNoiseMeanSenRegions[i]/cs[i]; | |
521 | rmsSen=vNoiseRMSSenRegions[i]; | |
522 | rmsSen=TMath::Sqrt(TMath::Abs(rmsSen/cs[i]-meanSen*meanSen)); | |
523 | } | |
524 | vNoiseMeanSenRegions[i]=meanSen; | |
525 | vNoiseRMSSenRegions[i]=rmsSen; | |
526 | } | |
527 | } | |
528 | ||
529 | void ProcessPulser(Int_t &nMasked, Int_t &nonMaskedZero) | |
530 | { | |
531 | // | |
532 | // Process the Pulser information | |
533 | // | |
534 | ||
e6970ab5 | 535 | //reset counters to error number |
536 | nonMaskedZero=-100; | |
537 | nMasked=-100; | |
5312f439 | 538 | //retrieve pulser and ALTRO data |
539 | AliTPCCalPad *pulserTmean=AliTPCcalibDB::Instance()->GetPulserTmean(); | |
6fb51ca4 | 540 | if (!pulserTmean) return; |
e6970ab5 | 541 | //reset counters |
542 | nonMaskedZero=0; | |
543 | nMasked=0; | |
5312f439 | 544 | // AliTPCCalPad *pulserTrms=AliTPCcalibDB::Instance()->GetPulserTrms(); |
545 | // AliTPCCalPad *pulserQmean=AliTPCcalibDB::Instance()->GetPulserQmean(); | |
546 | AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked(); | |
547 | //create IROC, OROC1, OROC2 and sensitive region masks | |
548 | for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){ | |
549 | AliTPCCalROC *tmeanROC=pulserTmean->GetCalROC(isec); | |
6fb51ca4 | 550 | if (!tmeanROC) continue; |
5312f439 | 551 | // AliTPCCalROC *trmsROC=pulserTrms->GetCalROC(isec); |
552 | // AliTPCCalROC *qmeanROC=pulserQmean->GetCalROC(isec); | |
553 | Float_t tmeanMedian=tmeanROC->GetMedian(); | |
554 | UInt_t nrows=tmeanROC->GetNrows(); | |
555 | for (UInt_t irow=0;irow<nrows;++irow){ | |
556 | UInt_t npads=tmeanROC->GetNPads(irow); | |
557 | for (UInt_t ipad=0;ipad<npads;++ipad){ | |
558 | Int_t masked=(Int_t)padMasked->GetCalROC(isec)->GetValue(irow,ipad); | |
559 | Float_t tmeanVal=tmeanROC->GetValue(irow,ipad); | |
560 | // Float_t trmsVal =trmsROC->GetValue(irow,ipad); | |
561 | // Float_t qmeanVal=qmeanROC->GetValue(irow,ipad); | |
562 | if (masked){ | |
563 | ++nMasked; | |
564 | continue; // don't use inactive pads | |
565 | } | |
566 | if ( TMath::Abs(tmeanVal-tmeanMedian)>1.5 ) ++nonMaskedZero; | |
567 | } | |
568 | } | |
569 | } | |
570 | } | |
571 | ||
6fb51ca4 | 572 | void GetProductionInfo(Int_t run, Int_t &nalien, Int_t &nRawAlien, Int_t &nlocal, Int_t &nRawLocal){ |
5312f439 | 573 | // |
574 | // find number of ESDs in central and local production for run | |
575 | // | |
576 | ||
577 | nalien=0; | |
6fb51ca4 | 578 | nRawAlien=0; |
5312f439 | 579 | nlocal=0; |
6fb51ca4 | 580 | nRawLocal=0; |
5312f439 | 581 | TString sNlines; |
582 | FILE *pipe = 0x0; | |
583 | //find number of ESDs in alien | |
584 | TString command="alien_find /alice/data/2009 "; | |
585 | command += Form("%09d",run); | |
586 | command += " | grep AliESDs.root | wc -l"; | |
6fb51ca4 | 587 | sNlines = gSystem->GetFromPipe(command.Data()); |
5312f439 | 588 | nalien=sNlines.Atoi(); |
6fb51ca4 | 589 | //find number of raw files on alien |
590 | command="alien_find /alice/data/2009 "; | |
591 | command += Form("%09d",run); | |
592 | command += " | grep raw | grep -v tag | wc -l"; | |
593 | sNlines = gSystem->GetFromPipe(command.Data()); | |
594 | nRawAlien=sNlines.Atoi(); | |
5312f439 | 595 | //find number of ESDs local |
6fb51ca4 | 596 | command="find /lustre/alice/alien/alice/data/2009 -name AliESDs.root | grep "; |
5312f439 | 597 | command += Form("%09d",run); |
6fb51ca4 | 598 | command += " | wc -l"; |
599 | sNlines = gSystem->GetFromPipe(command.Data()); | |
5312f439 | 600 | nlocal=sNlines.Atoi(); |
6fb51ca4 | 601 | //find number of local raw data files |
602 | command="find /lustre/alice/alien/alice/data/2009 -name \"*.root\" | grep "; | |
603 | command += Form("%09d",run); | |
604 | command += " | grep raw | grep -v tag | wc -l"; | |
605 | sNlines = gSystem->GetFromPipe(command.Data()); | |
606 | nRawLocal=sNlines.Atoi(); | |
5312f439 | 607 | } |
e2914767 | 608 | |
609 | void FilterMag(const char * runList){ | |
610 | // | |
611 | // | |
612 | // | |
613 | // AliTPCcalibDB * calibDB = AliTPCcalibDB::Instance(); | |
614 | ifstream in; | |
615 | in.open(runList); | |
616 | Int_t irun=0; | |
617 | while(in.good()) { | |
618 | in >> irun; | |
619 | if (irun==0) continue; | |
620 | AliGRPObject *grp = AliTPCcalibDB::GetGRP(irun); | |
621 | Float_t current = -1; | |
622 | Float_t bz = -1; | |
5312f439 | 623 | // Float_t press = 0; |
e2914767 | 624 | if (grp){ |
625 | current = grp->GetL3Current((AliGRPObject::Stats)0); | |
626 | bz = 5*current/30000.; | |
627 | printf("Run%d\tL3 current%f\tBz\t%f\n",irun,current,bz); | |
628 | } | |
629 | else{ | |
630 | printf("Run%d\tL3 current%f\tBz\t%f\n",irun,current,bz); | |
631 | } | |
632 | } | |
7ce80437 | 633 | |
634 | } | |
635 | ||
636 | ||
637 | void GetTree(){ | |
638 | TFile *fdcs = new TFile("dcsTime.root"); | |
5312f439 | 639 | dcsTree = (TTree*)fdcs->Get("dcs"); |
7ce80437 | 640 | // |
641 | // mean temp A | |
5312f439 | 642 | |
7ce80437 | 643 | dcsTree->Draw("temp30.fElements[0]"); |
5312f439 | 644 | |
e2914767 | 645 | } |
646 | ||
7ce80437 | 647 | void GetNominalValues(){ |
648 | // | |
649 | if (!dcsTree) return; | |
650 | } | |
651 | ||
652 | ||
653 | ||
654 | ||
d47d42ee | 655 | /* |
656 | ||
657 | AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(62084); | |
658 | entry = AliCDBManager::Instance()->Get("TPC/Calib/Temperature",run); | |
659 | AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)entry->GetObject(); | |
660 | AliTPCSensorTempArray * tempArray = (AliTPCSensorTempArray *)AliTPCcalibDB::Instance()->GetTemperatureSensor(62084) | |
661 | AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray); | |
e79211e8 | 662 | TLinearFitter * fitter = tempMap->GetLinearFitter(0,0,tempArray->GetStartTime()); |
d47d42ee | 663 | |
664 | AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(62084); | |
665 | ||
666 | */ | |
7ce80437 | 667 | |
668 | /* | |
669 | ||
670 | void PlotPressureResol(){ | |
671 | // | |
672 | // Example | |
673 | // | |
674 | dcs->Draw("100000*(press-press2-4.782)/press/sqrt(2.)>>his(100,-50,50)","run>61400","") | |
675 | his->SetXTitle("#sigma_{P/P_{0}}(10^{-5})"); | |
676 | gPad->SaveAs("picDCS/deltaPoverP.eps"); | |
677 | gPad->SaveAs("picDCS/deltaPoverP.gif"); | |
5312f439 | 678 | |
7ce80437 | 679 | } |
680 | void PlotTresol(){ | |
681 | // | |
682 | // T resolution example | |
683 | // plot difference of the temperature from A and C side | |
684 | // Supposing the error is independent - (division by sqrt(2)) | |
685 | dcs->Draw("100000*(temp30.fElements[0]-temp31.fElements[0]+0.00509)/(temp31.fElements[0]+273.15)/sqrt(2.)>>his(100,-5,5)","run>61400",""); | |
686 | his->SetXTitle("#sigma_{T/T_{0}}(10^{-5})"); | |
687 | gPad->SaveAs("picDCS/deltaToverT.eps"); | |
688 | gPad->SaveAs("picDCS/deltaToverT.gif"); | |
689 | } | |
690 | */ |