]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFPreprocessor.cxx
RawData QA update: added expert histograms, changed some histogram ranges, inserted...
[u/mrichter/AliRoot.git] / TOF / AliTOFPreprocessor.cxx
CommitLineData
c9fe8530 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
9edefa04 16/* $Id$ */
9d883ed9 17
3aaf7a5f 18
a174d599 19//#include <Riostream.h>
20//#include <stdio.h>
21//#include <stdlib.h>
c9fe8530 22
9edefa04 23#include <TFile.h>
9edefa04 24#include <TH2S.h>
ea932f75 25#include <TH1F.h>
26#include <TCanvas.h>
9edefa04 27#include <TMath.h>
28#include <TObjArray.h>
29#include <TObjString.h>
30#include <TTimeStamp.h>
c9fe8530 31
32#include "AliCDBMetaData.h"
7fffa85b 33#include "AliCDBEntry.h"
c9fe8530 34#include "AliLog.h"
17149e6b 35#include "AliTOFChannelOnlineArray.h"
36#include "AliTOFChannelOnlineStatusArray.h"
9edefa04 37#include "AliTOFDataDCS.h"
ea932f75 38#include "AliTOFLvHvDataPoints.h"
10056aa6 39#include "AliTOFGeometry.h"
9edefa04 40#include "AliTOFPreprocessor.h"
db83b789 41#include "AliTOFFEEReader.h"
3dda26a0 42#include "AliTOFRawStream.h"
43#include "AliTOFCableLengthMap.h"
b06d5296 44#include "AliTOFcalibHisto.h"
69355034 45#include "AliTOFFEEDump.h"
104ba366 46#include "TChain.h"
47#include "AliTOFDeltaBCOffset.h"
48#include "AliTOFCTPLatency.h"
49#include "AliTOFT0Fill.h"
50#include "AliTOFT0FillOnlineCalib.h"
51#include "AliTOFHitField.h"
52#include "AliTOFChannelOffline.h"
53#include "TF1.h"
54#include "TGeoManager.h"
55#include "AliGeomManager.h"
c9fe8530 56
c9fe8530 57// TOF preprocessor class.
58// It takes data from DCS and passes them to the class AliTOFDataDCS, which
59// processes them. The result is then written to the CDB.
17149e6b 60// Analogously, it takes data form DAQ (both at Run level and inclusive -
c9fe8530 61// of all the runs - level, processes them, and stores both Reference Data
62// and Online Calibration files in the CDB.
17149e6b 63// Processing of Pulser/Noise Run data and of TOF FEE DCS map included also.
7fffa85b 64
65// return codes:
66// return=0 : all ok
67// return=1 : no DCS input data Map
68// return=2 : no DCS input data processing
69// return=3 : no DCS processed data was stored in Ref Data
70// return=4 : no DAQ input for Ref Data
71// return=5 : failed to store DAQ Ref Data
72// return=6 : failed to retrieve DAQ data for calibration
73// return=7 : problems in processing histos in the input DAQ file
74// return=8 : failed to store Online Delays
75// return=9 : failed to store Reference Data for Pulser
76// return=10: failed to retrieve Pulser data
77// return=11: failed to store Pulser map in OCDB
78// return=12: failed to store Reference Data for Noise
79// return=13: failed to retrieve Noise data
80// return=14: failed to store Noise map in OCDB
db83b789 81// return=15: failed to retrieve FEE data from FXS
82// return=16: failed to retrieve FEE data from OCDB
83// return=17: failed to store FEE data in OCDB
84// return=18: failed to store FEE reference data in OCDB
17149e6b 85// return=20: failed in retrieving status variable
c9fe8530 86
87ClassImp(AliTOFPreprocessor)
88
7fffa85b 89const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
90const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel
91const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay
c9fe8530 92
93//_____________________________________________________________________________
94
708db10b 95AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
96 AliPreprocessor("TOF", shuttle),
c9fe8530 97 fData(0),
ea932f75 98 fHVLVmaps(0),
c9fe8530 99 fCal(0),
10056aa6 100 fNChannels(0),
7fffa85b 101 fStoreRefData(kTRUE),
17149e6b 102 fFDRFlag(kFALSE),
013ac2dd 103 fStatus(0),
02ede0c4 104 fMatchingWindow(0),
ea932f75 105 fLatencyWindow(0),
106 fIsStatusMapChanged(0)
c9fe8530 107{
108 // constructor
370aeff7 109 AddRunType("PHYSICS");
110 AddRunType("PULSER");
111 AddRunType("NOISE");
10056aa6 112
c9fe8530 113}
114
115//_____________________________________________________________________________
116
117AliTOFPreprocessor::~AliTOFPreprocessor()
118{
119 // destructor
120}
121
122//______________________________________________________________________________
123void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
124 UInt_t endTime)
125{
126 // Creates AliTOFDataDCS object
127
128 AliPreprocessor::Initialize(run, startTime, endTime);
129
ff326f84 130 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run,
c9fe8530 131 TTimeStamp(startTime).AsString(),
ff326f84 132 TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
c9fe8530 133
ff326f84 134 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
ea932f75 135 fHVLVmaps = new AliTOFLvHvDataPoints(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
10056aa6 136 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
c9fe8530 137}
7fffa85b 138//_____________________________________________________________________________
139Bool_t AliTOFPreprocessor::ProcessDCS(){
140
141 // check whether DCS should be processed or not...
c9fe8530 142
7fffa85b 143 TString runType = GetRunType();
144 Log(Form("RunType %s",runType.Data()));
145
55454922 146 if (runType != "PHYSICS"){
7fffa85b 147 return kFALSE;
148 }
149
150 return kTRUE;
151}
c9fe8530 152//_____________________________________________________________________________
153
104ba366 154UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap)
c9fe8530 155{
156 // Fills data into a AliTOFDataDCS object
157
7fffa85b 158
159 Log("Processing DCS DP");
708db10b 160 TH1::AddDirectory(0);
5936ab02 161
7885c291 162 Bool_t resultDCSMap=kFALSE;
163 Bool_t resultDCSStore=kFALSE;
c9fe8530 164
165 // processing DCS
166
4856f488 167 fData->SetFDRFlag(fFDRFlag);
168
c9fe8530 169 if (!dcsAliasMap){
5936ab02 170 Log("No DCS map found: TOF exiting from Shuttle");
e88f3330 171 if (fData){
172 delete fData;
173 fData = 0;
174 }
5936ab02 175 return 1;// return error Code for DCS input data not found
c9fe8530 176 }
177 else {
4856f488 178
c9fe8530 179 // The processing of the DCS input data is forwarded to AliTOFDataDCS
7885c291 180 resultDCSMap=fData->ProcessData(*dcsAliasMap);
181 if(!resultDCSMap){
182 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
e88f3330 183 if (fData){
184 delete fData;
185 fData = 0;
186 }
5936ab02 187 return 2;// return error Code for processed DCS data not stored
c9fe8530 188 }
7885c291 189 else{
190 AliCDBMetaData metaDataDCS;
191 metaDataDCS.SetBeamPeriod(0);
192 metaDataDCS.SetResponsible("Chiara Zampolli");
193 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
194 AliInfo("Storing DCS Data");
b0d8f3fc 195 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
7885c291 196 if (!resultDCSStore){
b0d8f3fc 197 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
e88f3330 198 if (fData){
199 delete fData;
200 fData = 0;
201 }
7885c291 202 return 3;// return error Code for processed DCS data not stored
b0d8f3fc 203 // in reference data
7885c291 204
205 }
206 }
c9fe8530 207 }
e88f3330 208 if (fData){
209 delete fData;
210 fData = 0;
211 }
212
ee3e792b 213 return 0;
214}
215//_____________________________________________________________________________
216
104ba366 217UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
ea932f75 218{
219 //
220 //Fills data into a AliTOFLvHvDataPoints object
221 // Merges fStatus object with LV and HV status at SOR
222 // Updates fStatus object with LV and HV status
223 // at EOR in case of correct end of run
224 // at last but two value in case of end-of-run caused by TOF detector.
225 //
226
227 Log("Processing HV and LV DCS DPs");
228 TH1::AddDirectory(0);
229
230 Bool_t resultDCSMap=kFALSE;
231
232 // processing DCS
233
234 fHVLVmaps->SetFDRFlag(fFDRFlag);
235
236 if (!dcsAliasMap){
237 Log("No DCS map found: TOF exiting from Shuttle");
238 if (fHVLVmaps){
239 delete fHVLVmaps;
240 fHVLVmaps = 0;
241 }
242 return 1;// return error Code for DCS input data not found
243 }
244 else {
245
246 // The processing of the DCS input data is forwarded to AliTOFDataDCS
247 resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap);
248 if (!resultDCSMap) {
249 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
250 if (fHVLVmaps) {
251 delete fHVLVmaps;
252 fHVLVmaps = 0;
253 }
254 return 2;// return error Code for processed DCS data not stored
255 }
256 else {
257
258 // check with plots. Start...
259 /*
260 TH1F *hROsor = new TH1F("hROsor","RO status map at SOR",91*96*18,-0.5,91*96*18-0.5);
261 for (Int_t ii=1; ii<=91*96*18; ii++) hROsor->SetBinContent(ii,-1);
262 for (Int_t ii=0; ii<91*96*18; ii++) {
263 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
264 hROsor->SetBinContent(ii+1,0);
265 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
266 hROsor->SetBinContent(ii+1,1);
267 }
268
269 TH1F *hROandHVandLVsor = new TH1F("hROandHVandLVsor","RO.and.HV.andLV status map at SOR",91*96*18,-0.5,91*96*18-0.5);
270 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVsor->SetBinContent(ii,-1);
271 TH1F *hROandHVandLVeor = new TH1F("hROandHVandLVeor","RO.and.HV.andLV status map at EOR",91*96*18,-0.5,91*96*18-0.5);
272 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVeor->SetBinContent(ii,-1);
273 */
274
275 AliTOFDCSmaps * lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtSOR(); // Get LV.and.HV status map at SOR
276 for (Int_t index=0; index<fNChannels; index++) {
277 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
278 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
279 ( lvANDhvMap->GetCellValue(index)==1 &&
280 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
281 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
282 fIsStatusMapChanged=kTRUE;
283 }
284 }
104ba366 285
ea932f75 286 // check with plots. Start...
287 /*
288 for (Int_t ii=0; ii<91*96*18; ii++) {
289 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
290 hROandHVandLVsor->SetBinContent(ii+1,0);
291 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
292 hROandHVandLVsor->SetBinContent(ii+1,1);
293 }
294 */
295
296 lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtEOR(); // Get LV.and.HV status map at EOR
297 for (Int_t index=0; index<fNChannels; index++) {
298 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
299 fStatus->GetHWStatus(index)!=AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
300 ( lvANDhvMap->GetCellValue(index)==1 &&
301 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
302 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
303 fIsStatusMapChanged=kTRUE;
304 }
305 }
306
307 // check with plots. Start...
308 /*
309 for (Int_t ii=0; ii<91*96*18; ii++) {
310 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
311 hROandHVandLVeor->SetBinContent(ii+1,0);
312 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
313 hROandHVandLVeor->SetBinContent(ii+1,1);
314 }
315
316 TCanvas *canvas = new TCanvas("canvas","",10,10,1000,1000);
317 canvas->SetFillColor(0);
318 canvas->Divide(2,2);
319 canvas->cd(1);
320 hROsor->SetLineWidth(2);
321 hROsor->Draw();
322 canvas->cd(2);
323 hROandHVandLVsor->SetLineWidth(2);
324 hROandHVandLVsor->Draw();
325 canvas->cd(3);
326 hROandHVandLVeor->SetLineWidth(2);
327 hROandHVandLVeor->Draw();
328 canvas->cd();
329 */
330
331 }
332 }
333
334
335 /* check whether we don't need to update OCDB.
336 * in this case we can return without errors. */
337
338 if (!fIsStatusMapChanged) {
339 AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
340 return 0; // return ok
341 }
342
343 TString runType = GetRunType();
344 if (runType != "PHYSICS") {
345 AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
346 return 0; // return ok
347 }
348
349 // update the OCDB with the current FEE.and.HV.and.LV
350 // since even a little difference has been detected.
351
352 AliCDBMetaData metaData;
353 metaData.SetBeamPeriod(0);
354 metaData.SetResponsible("Roberto Preghenella");
355 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.HV.and.LV data.");
356 AliInfo("Storing Status data from current run. Collected RO.and.HV.and.LV infos @ EOR");
357 // store FEE data
358 if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
359 // failed
360 Log("problems while storing RO.and.HV.and.LV Status data object");
361 if (fStatus){
362 delete fStatus;
363 fStatus = 0;
364 }
365 if (fHVLVmaps) {
366 delete fHVLVmaps;
367 fHVLVmaps = 0;
368 }
369 return 17; // return error code for problems while storing FEE data
370 }
371
372 // everything fine. return
373
374 if (fStatus){
375 delete fStatus;
376 fStatus = 0;
377 }
378
379 if (fHVLVmaps) {
380 delete fHVLVmaps;
381 fHVLVmaps = 0;
382 }
383
384 return 0;
385}
104ba366 386
ea932f75 387//_____________________________________________________________________________
388
ee3e792b 389UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
390{
7fffa85b 391 // Processing data from DAQ for online calibration
392
965fa008 393 Bool_t updateOCDB = kFALSE;
7fffa85b 394 Log("Processing DAQ delays");
ee3e792b 395
17149e6b 396 // reading configuration map
397 TString compDelays = "kFALSE";
398 Int_t deltaStartingRun = fRun;
399 Int_t startingRun = fRun-deltaStartingRun;
400 Int_t binRangeAve = fgkBinRangeAve;
401 Double_t integralThr = fgkIntegralThr;
402 Double_t thrPar = fgkThrPar;
403
404 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config");
405 if (!cdbEntry) {
406 Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
407 }
408 else {
409 TMap *configMap = (TMap*)cdbEntry->GetObject();
410 if (!configMap){
411 Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
412 }
413 else{
414 TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays");
415 if (strDelays) {
416 compDelays = (TString) strDelays->GetString();
417 }
418 else {
419 Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data()));
420 }
421 TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun");
422 if (strRun) {
423 TString tmpstr = strRun->GetString();
424 startingRun = tmpstr.Atoi();
425 deltaStartingRun = fRun - startingRun;
426 }
427 else {
428 Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun));
429 }
430 TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve");
431 if (strBinRangeAve) {
432 TString tmpstr = strBinRangeAve->GetString();
433 binRangeAve = tmpstr.Atoi();
434 }
435 else {
436 Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve));
437 }
438 TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr");
439 if (strIntegralThr) {
440 TString tmpstr = strIntegralThr->GetString();
441 integralThr = tmpstr.Atof();
442 }
443 else {
444 Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
445 }
446 TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
447 if (strThrPar) {
448 TString tmpstr = strThrPar->GetString();
449 thrPar = tmpstr.Atof();
450 }
451 else {
452 Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
453 }
454 }
455 }
456 if (compDelays == "kTRUE") fFDRFlag = kFALSE;
457 else fFDRFlag = kTRUE;
458
e88f3330 459 delete cdbEntry;
460 cdbEntry = 0x0;
461
17149e6b 462 Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
463
965fa008 464 /* init array with current calibration, if any */
465 fCal = new AliTOFChannelOnlineArray(fNChannels);
466 AliTOFChannelOnlineArray *curCal = NULL;
467
468 AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay");
469 if (!cdbEntry2 || !cdbEntry2->GetObject()) {
470 /* no CDB entry found. set update flag */
471 Log(" ************ WARNING ************");
472 Log("No CDB ParOnlineDelay entry found, creating a new one!");
473 Log(" *********************************");
474 updateOCDB = kTRUE;
475 }
476 else {
477 Log("Found previous ParOnlineDelay entry. Using it to init calibration");
478 curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject();
479 for (Int_t i = 0; i < fNChannels; i++)
480 fCal->SetDelay(i, curCal->GetDelay(i));
481 }
482
17149e6b 483
ee3e792b 484 TH1::AddDirectory(0);
485
486 Bool_t resultDAQRef=kFALSE;
7fffa85b 487 Bool_t resultTOFPP=kFALSE;
e88f3330 488 TH2S *h2 = 0x0;
c9fe8530 489 // processing DAQ
7885c291 490
c9fe8530 491 TFile * daqFile=0x0;
7885c291 492
5936ab02 493 if(fStoreRefData){
494 //retrieving data at Run level
17149e6b 495 TList* list = GetFileSources(kDAQ, "RUNLevel");
496 if (list !=0x0 && list->GetEntries()!=0)
497 {
498 AliInfo("The following sources produced files with the id RUNLevel");
499 list->Print();
500 for (Int_t jj=0;jj<list->GetEntries();jj++){
501 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
502 AliInfo(Form("found source %s", str->String().Data()));
503 // file to be stored run per run
504 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
505 if (fileNameRun.Length()>0){
506 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
507 daqFile = new TFile(fileNameRun.Data(),"READ");
e88f3330 508 h2 = (TH2S*) daqFile->Get("htof");
17149e6b 509 AliCDBMetaData metaDataHisto;
510 metaDataHisto.SetBeamPeriod(0);
511 metaDataHisto.SetResponsible("Chiara Zampolli");
512 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
513 AliInfo("Storing Reference Data");
e88f3330 514 resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto);
17149e6b 515 if (!resultDAQRef){
516 Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
e88f3330 517 delete h2;
518 delete list;
519 delete fCal;
520 fCal=0x0;
17149e6b 521 return 5;//return error code for failure in storing Ref Data
522 }
523 daqFile->Close();
524 delete daqFile;
525 }
526
527 else{
528 Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
e88f3330 529 delete list;
530 delete fCal;
531 fCal=0x0;
17149e6b 532 return 4;//return error code for failure in retrieving Ref Data
533 }
534 }
535 delete list;
536 }
5936ab02 537 else{
17149e6b 538 Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
e88f3330 539 delete fCal;
540 fCal=0x0;
17149e6b 541 return 4;//return error code for failure in retrieving Ref Data
542 }
9bc469d1 543 }
544
9bc469d1 545
17149e6b 546 //Total files, with cumulative histos
5936ab02 547
9bc469d1 548 TList* listTot = GetFileSources(kDAQ, "DELAYS");
bf76be9c 549 if (listTot !=0x0 && listTot->GetEntries()!=0)
17149e6b 550 {
551 AliInfo("The following sources produced files with the id DELAYS");
552 listTot->Print();
553 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
554 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
555 AliInfo(Form("found source %s", str->String().Data()));
556
557 // file with summed histos, to extract calib params
558 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
559 if (fileName.Length()>0){
560 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
561
562 daqFile = new TFile(fileName.Data(),"READ");
e88f3330 563 if (h2) delete h2;
564 h2 = (TH2S*) daqFile->Get("htoftot");
565 if (!h2){
17149e6b 566 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
e88f3330 567 delete listTot;
17149e6b 568 delete daqFile;
e88f3330 569 delete fCal;
570 fCal=0x0;
17149e6b 571 return 7; //return error code for histograms not existing/junky
572 }
573 else {
e88f3330 574 static const Int_t kSize=h2->GetNbinsX();
575 static const Int_t kNBins=h2->GetNbinsY();
576 static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
17149e6b 577 if (kSize != fNChannels){
578 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
e88f3330 579 delete listTot;
580 delete h2;
17149e6b 581 delete daqFile;
e88f3330 582 delete fCal;
583 fCal=0x0;
17149e6b 584 return 7; //return error code for histograms not existing/junky
585 }
586 Int_t nNotStatistics = 0; // number of channel with not enough statistics
3dda26a0 587
b06d5296 588 /* FDR flag set. do not compute delays, use nominal cable delays */
3dda26a0 589 if (fFDRFlag) {
590
591 Log(" Not computing delays according to flag set in Config entry in OCDB!");
b06d5296 592 FillWithCosmicCalibration(fCal);
965fa008 593
594 /* check whether the new calibration is different from the previous one */
595 if (curCal) { /* well, check also whether we have a previous calibration */
596 for (Int_t i = 0; i < fNChannels; i++) {
597 if (fCal->GetDelay(i) != curCal->GetDelay(i)) {
598 updateOCDB = kTRUE;
599 break;
600 }
601 }
602 }
603 else /* otherwise update OCDB */
604 updateOCDB = kTRUE;
605
3dda26a0 606 }
17149e6b 607
608 else { // computing delays if not in FDR runs
965fa008 609
610 updateOCDB = kTRUE; /* always update OCDB when computing delays */
611
17149e6b 612 for (Int_t ich=0;ich<kSize;ich++){
613 /* check whether channel has been read out during current run.
614 * if the status is bad it means it has not been read out.
615 * in this case skip channel in order to not affect the mean */
616 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
617 AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
618 continue;
619 }
620 AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
621 TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
622 for (Int_t ibin=0;ibin<kNBins;ibin++){
e88f3330 623 h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
17149e6b 624 }
625 if(h1->Integral()<integralThr) {
626 nNotStatistics++;
627 Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
628 delete h1;
629 h1=0x0;
630 continue;
631 }
632 Bool_t found=kFALSE;
633 Float_t minContent=h1->Integral()*thrPar;
634 Int_t nbinsX = h1->GetNbinsX();
635 Int_t startBin=1;
636 for (Int_t j=1; j<=nbinsX; j++){
637 if ((
638 h1->GetBinContent(j) +
639 h1->GetBinContent(j+1)+
640 h1->GetBinContent(j+2)+
641 h1->GetBinContent(j+3))>minContent){
642 found=kTRUE;
643 startBin=j;
644 break;
645 }
646 }
647 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
648 // Now calculate the mean over the interval.
649 Double_t mean = 0;
650 Double_t sumw2 = 0;
651 Double_t nent = 0;
652 for(Int_t k=0;k<binRangeAve;k++){
653 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
654 nent=nent+h1->GetBinContent(startBin+k);
655 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
656 }
657 mean= mean/nent; //<x>
658 sumw2=sumw2/nent; //<x^2>
659 Double_t rmsmean= 0;
660 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
661 if (ich<fNChannels) {
662 Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
663 fCal->SetDelay(ich,delay); // delay in ns
664 AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
665 }
666 delete h1;
667 h1=0x0;
668 }
669 }
670 if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
671 }
e88f3330 672 delete h2;
17149e6b 673 daqFile->Close();
674 delete daqFile;
675 }
676 else{
677 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
e88f3330 678 delete listTot;
679 delete fCal;
680 fCal=0x0;
17149e6b 681 return 6;//return error code for problems in retrieving DAQ data
682 }
7fffa85b 683 }
17149e6b 684 delete listTot;
c9fe8530 685 }
c9fe8530 686 else{
9d883ed9 687 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
e88f3330 688 delete fCal;
689 fCal=0x0;
7885c291 690 return 6; //return error code for problems in retrieving DAQ data
c9fe8530 691 }
692
965fa008 693 /* check whether we don't need to update OCDB.
694 * in this case we can return without errors and
695 * the current FEE is stored in the fStatus object. */
696 if (!updateOCDB) {
697 AliInfo("update OCDB flag not set. Do not overwrite stored file.");
698 return 0; /* return ok */
699 }
700
c9fe8530 701 daqFile=0;
7fffa85b 702 AliCDBMetaData metaData;
703 metaData.SetBeamPeriod(0);
704 metaData.SetResponsible("Chiara Zampolli");
17149e6b 705 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays.");
7fffa85b 706 AliInfo("Storing Calibration Data");
17149e6b 707 resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE);
7fffa85b 708 if(!resultTOFPP){
709 Log("Some problems occurred while storing online object resulting from DAQ data processing");
e88f3330 710 delete fCal;
711 fCal=0x0;
7fffa85b 712 return 8;//return error code for problems in storing DAQ data
713 }
9d883ed9 714
e88f3330 715 if (fCal){
716 delete fCal;
717 fCal = 0;
718 }
719
5936ab02 720 return 0;
c9fe8530 721}
104ba366 722
723//_____________________________________________________________________________
724
725UInt_t
726AliTOFPreprocessor::ProcessT0Fill()
727{
728 // Processing data from DAQ for T0-fill measurement
729
730 Log("Processing T0-fill");
731
732#if 0
733 /* instance and setup CDB manager */
734 AliCDBManager *cdb = AliCDBManager::Instance();
735 /* load geometry */
736 if (!gGeoManager) AliGeomManager::LoadGeometry();
737#endif
738
739 /* get params from OCDB */
740 AliCDBEntry *cdbe = NULL;
741
742 /* get T0-fill calibration params */
743 cdbe = GetFromOCDB("Calib", "T0FillOnlineCalib");
744 if (!cdbe) {
745 Log("cannot get \"T0FillOnlineCalib\" entry from OCDB");
746 return 21;
747 }
748 AliTOFT0FillOnlineCalib *t0FillOnlineCalibObject = (AliTOFT0FillOnlineCalib *)cdbe->GetObject();
749 if (!t0FillOnlineCalibObject) {
750 Log("cannot get \"T0FillOnlineCalib\" object from CDB entry");
751 return 21;
752 }
753 Float_t t0FillCalibOffset = t0FillOnlineCalibObject->GetOffset();
754 Float_t t0FillCalibCoefficient = t0FillOnlineCalibObject->GetCoefficient();
755 Log(Form("got \"T0FillOnlineCalib\" object: offset=%f coeff=%f", t0FillCalibOffset, t0FillCalibCoefficient));
756
757 /* get online status from OCDB */
758 cdbe = GetFromOCDB("Calib", "Status");
759 if (!cdbe) {
760 Log("cannot get \"Status\" entry from OCDB");
761 return 21;
762 }
763 AliTOFChannelOnlineStatusArray *statusArray = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
764 if (!statusArray) {
765 Log("cannot get \"Status\" object from CDB entry");
766 return 21;
767 }
768 Log("got \"Status\" object");
769
770 /* get offline calibration from OCDB */
771 cdbe = GetFromOCDB("Calib", "ParOffline");
772 if (!cdbe) {
773 Log("cannot get \"ParOffline\" entry from OCDB");
774 return 21;
775 }
776 TObjArray *offlineArray = (TObjArray *)cdbe->GetObject();
777 AliTOFChannelOffline *channelOffline;
778 if (!offlineArray) {
779 Log("cannot get \"ParOffline\" object from CDB entry");
780 return 21;
781 }
782 Log("got \"ParOffline\" object");
783
784 /* get deltaBC offset from OCDB */
785 cdbe = GetFromOCDB("Calib", "DeltaBCOffset");
786 if (!cdbe) {
787 Log("cannot get \"DeltaBCOffset\" entry from OCDB");
788 return 21;
789 }
790 AliTOFDeltaBCOffset *deltaBCOffsetObject = (AliTOFDeltaBCOffset *)cdbe->GetObject();
791 if (!deltaBCOffsetObject) {
792 Log("cannot get \"DeltaBCOffset\" object from CDB entry");
793 return 21;
794 }
795 Int_t deltaBCOffset = deltaBCOffsetObject->GetDeltaBCOffset();
796 Log(Form("got \"DeltaBCOffset\" object: deltaBCOffset=%d (BC bins)", deltaBCOffset));
797
798 /* get CTP latency from OCDB */
799 cdbe = GetFromOCDB("Calib", "CTPLatency");
800 if (!cdbe) {
801 Log("cannot get \"CTPLatency\" entry from OCDB");
802 return 21;
803 }
804 AliTOFCTPLatency *ctpLatencyObject = (AliTOFCTPLatency *)cdbe->GetObject();
805 if (!ctpLatencyObject) {
806 Log("cannot get \"CTPLatency\" object from CDB entry");
807 return 21;
808 }
809 Float_t ctpLatency = ctpLatencyObject->GetCTPLatency();
810 Log(Form("got \"CTPLatency\" object: ctpLatency=%f (ps)", ctpLatency));
811
812 /* get file sources from FXS */
813 TList *fileList = GetFileSources(kDAQ, "HITS");
814 if (!fileList || fileList->GetEntries() == 0) {
815 Log("cannot get DAQ source file list or empty list");
816 return 21;
817 }
818 Log(Form("got DAQ source file list: %d files", fileList->GetEntries()));
819 fileList->Print();
820
821 /* create tree chain using file sources */
822 TChain chain("hitTree");
823 for (Int_t ifile = 0; ifile < fileList->GetEntries(); ifile++) {
824 TObjString *str = (TObjString *)fileList->At(ifile);
825 TString filename = GetFile(kDAQ, "HITS", str->GetName());
826 chain.Add(filename);
827 Log(Form("file added to input chain: source=%s, filename=%s", str->String().Data(), filename.Data()));
828 }
829 Int_t nhits = chain.GetEntries();
830 Log(Form("input chain ready: %d hits", nhits));
831
832 /* setup input chain */
833 AliTOFHitField *hit = new AliTOFHitField();
834 chain.SetBranchAddress("hit", &hit);
835
836 /* create calib histo and geometry */
837 AliTOFcalibHisto calibHisto;
838 calibHisto.LoadCalibHisto();
839 AliTOFGeometry tofGeo;
840
841 /* constants */
842 Float_t c = TMath::C() * 1.e2 / 1.e12; /* cm/ps */
843 Float_t c_1 = 1. / c;
844 /* variables */
845 Int_t index, timebin, totbin, deltaBC, l0l1latency, det[5];
846 Float_t timeps, totns, corrps, length, timeexp, timezero, pos[3], latencyWindow;
847
848 /* histos */
849 TH1F *hT0Fill = new TH1F("hT0Fill", "T0 fill;t - t_{exp}^{(c)} (ps);", 2000, -24400., 24400.);
850
851 /* loop over hits */
852 for (Int_t ihit = 0; ihit < nhits; ihit++) {
853
854 /* get entry */
855 chain.GetEntry(ihit);
856
857 /* get hit info */
858 index = hit->GetIndex();
859 timebin = hit->GetTimeBin();
860 totbin = hit->GetTOTBin();
861 deltaBC = hit->GetDeltaBC();
862 l0l1latency = hit->GetL0L1Latency();
863 latencyWindow = statusArray->GetLatencyWindow(index) * 1.e3;
864
865 /* convert time in ps and tot in ns */
866 timeps = timebin * AliTOFGeometry::TdcBinWidth();
867 totns = totbin * AliTOFGeometry::ToTBinWidth() * 1.e-3;
868 /* get calibration correction in ps */
869 channelOffline = (AliTOFChannelOffline *)offlineArray->At(index);
870 if (totns < AliTOFGeometry::SlewTOTMin()) totns = AliTOFGeometry::SlewTOTMin();
871 if (totns > AliTOFGeometry::SlewTOTMax()) totns = AliTOFGeometry::SlewTOTMax();
872 corrps = 0.;
873 for (Int_t ipar = 0; ipar < 6; ipar++) corrps += channelOffline->GetSlewPar(ipar) * TMath::Power(totns, ipar);
874 corrps *= 1.e3;
875 /* perform time correction */
876 timeps = timeps + (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth() + l0l1latency * AliTOFGeometry::BunchCrossingBinWidth() + ctpLatency - latencyWindow - corrps;
877 /* compute length and expected time */
878 tofGeo.GetVolumeIndices(index, det);
879 tofGeo.GetPosPar(det, pos);
880 length = 0.;
881 for (Int_t i = 0; i < 3; i++) length += pos[i] * pos[i];
882 length = TMath::Sqrt(length);
883 timeexp = length * c_1;
884 /* compute time zero */
885 timezero = timeps - timeexp;
886
887 /* fill histos */
888 hT0Fill->Fill(timezero);
889 }
890
891 /* rebin until maximum bin has required minimum entries */
892 Int_t maxBin = hT0Fill->GetMaximumBin();
17f2cd01 893 Float_t maxBinContent = hT0Fill->GetBinContent(maxBin);
104ba366 894 Float_t binWidth = hT0Fill->GetBinWidth(maxBin);
895 while (maxBinContent < 400 && binWidth < 90.) {
896 hT0Fill->Rebin(2);
897 maxBin = hT0Fill->GetMaximumBin();
898 maxBinContent = hT0Fill->GetBinContent(maxBin);
899 binWidth = hT0Fill->GetBinWidth(maxBin);
900 }
901 Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin);
902
903 /* rough landau fit of the edge */
904 TF1 *landau = (TF1 *)gROOT->GetFunction("landau");
905 landau->SetParameter(1, maxBinCenter);
906 Float_t fitMin = maxBinCenter - 1000.; /* fit from 10 ns before max */
907 Float_t fitMax = maxBinCenter + binWidth; /* fit until a bin width above max */
908 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
909 /* get rough landau mean and sigma to set a better fit range */
910 Float_t mean = landau->GetParameter(1);
911 Float_t sigma = landau->GetParameter(2);
912 /* better landau fit of the edge */
913 fitMin = maxBinCenter - 3. * sigma;
914 fitMax = mean;
915 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
916 /* print params */
917 mean = landau->GetParameter(1);
918 sigma = landau->GetParameter(2);
919 Float_t meane = landau->GetParError(1);
920 Float_t sigmae = landau->GetParError(2);
921 Log(Form("edge fit: mean = %f +- %f ps", mean, meane));
922 Log(Form("edge fit: sigma = %f +- %f ps", sigma, sigmae));
923 Float_t edge = mean - 3. * sigma;
924 Float_t edgee = TMath::Sqrt(meane * meane + 3. * sigmae * 3. * sigmae);
925 Log(Form("edge fit: edge = %f +- %f ps", edge, edgee));
926 /* apply calibration to get T0-fill from egde */
927 Float_t t0Fill = edge * t0FillCalibCoefficient + t0FillCalibOffset;
928 Log(Form("estimated T0-fill: %f ps", t0Fill));
929
930 /* create T0-fill object */
931 AliTOFT0Fill *t0FillObject = new AliTOFT0Fill();
932 t0FillObject->SetT0Fill(t0Fill);
933
934 /* store reference data */
935 if(fStoreRefData){
936 AliCDBMetaData metaDataHisto;
937 metaDataHisto.SetBeamPeriod(0);
938 metaDataHisto.SetResponsible("Roberto Preghenella");
939 metaDataHisto.SetComment("online T0-fill histogram");
940 if (!StoreReferenceData("Calib","T0Fill", hT0Fill, &metaDataHisto)) {
941 Log("error while storing reference data");
942 delete hT0Fill;
943 delete hit;
944 delete t0FillObject;
945 return 21;
946 }
947 Log("reference data successfully stored");
948 }
949
950 AliCDBMetaData metaData;
951 metaData.SetBeamPeriod(0);
952 metaData.SetResponsible("Roberto Preghenella");
953 metaData.SetComment("online T0-fill measurement");
954 if (!Store("Calib", "T0Fill", t0FillObject, &metaData, 0, kFALSE)) {
955 Log("error while storing T0-fill object");
956 delete hT0Fill;
957 delete hit;
958 delete t0FillObject;
959 return 21;
960 }
961 Log("T0-fill object successfully stored");
962
963 delete hT0Fill;
964 delete hit;
965 delete t0FillObject;
966 return 0;
967
968}
969
970
ee3e792b 971//_____________________________________________________________________________
972
973UInt_t AliTOFPreprocessor::ProcessPulserData()
974{
7fffa85b 975 // Processing Pulser Run data for TOF channel status
976
977 Log("Processing Pulser");
ee3e792b 978
17149e6b 979 if (fStatus==0x0){
980 AliError("No valid fStatus found, some errors must have occurred!!");
981 return 20;
982 }
ee3e792b 983
17149e6b 984 TH1::AddDirectory(0);
985
ee3e792b 986 Bool_t resultPulserRef=kFALSE;
7fffa85b 987 Bool_t resultPulser=kFALSE;
17149e6b 988
a174d599 989 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
990 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
991 for (Int_t ibin =1;ibin<=kSize;ibin++){
17149e6b 992 htofPulser->SetBinContent(ibin,-1);
7fffa85b 993 }
17149e6b 994
ee3e792b 995 // processing pulser
996
997 TFile * daqFile=0x0;
998 TH1S *h1=0x0;
999
1000 //retrieving Pulser data
1001 TList* listPulser = GetFileSources(kDAQ, "PULSER");
bf76be9c 1002 if (listPulser !=0x0 && listPulser->GetEntries()!=0)
e88f3330 1003 {
1004 AliInfo("The following sources produced files with the id PULSER");
1005 listPulser->Print();
1006 Int_t nPulser = 0;
1007 for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
1008 Int_t nPulserSource = 0;
1009 TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
1010 AliInfo(Form("found source %s", str->String().Data()));
1011 // file to be stored run per run
1012 TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
1013 if (fileNamePulser.Length()>0){
1014 // storing refernce data
1015 AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
1016 daqFile = new TFile(fileNamePulser.Data(),"READ");
1017 h1 = (TH1S*) daqFile->Get("hTOFpulser");
1018 for (Int_t ibin=0;ibin<kSize;ibin++){
1019 if ((h1->GetBinContent(ibin+1))!=-1){
1020 if ((htofPulser->GetBinContent(ibin+1))==-1){
1021 htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
1022 }
1023 else {
1024 Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
1025 }
1026 }
1027 }
1028
1029 // elaborating infos
1030 Double_t mean =0;
1031 Int_t nread=0;
1032 Int_t nreadNotEmpty=0;
1033 for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
1034
1035 AliDebug(3,Form(" channel %i pulser status before pulser = %i, with global status = %i",ientry,(Int_t)fStatus->GetPulserStatus(ientry),(Int_t)fStatus->GetStatus(ientry)));
1036 /* check whether channel has been read out during current run.
1037 * if the status is bad it means it has not been read out.
1038 * in this case skip channel in order to not affect the mean */
1039 if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1040 continue;
1041 nPulser++;
1042 nPulserSource++;
1043 if (h1->GetBinContent(ientry)==-1) continue;
1044 else {
1045 if (h1->GetBinContent(ientry)>0) {
1046 nreadNotEmpty++;
1047 AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
1048 }
1049 mean+=h1->GetBinContent(ientry);
1050 nread++;
1051 }
1052 }
1053 if (nread!=0) {
1054 mean/=nread;
1055 AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean));
1056 for (Int_t ich =0;ich<fNChannels;ich++){
1057 if (h1->GetBinContent(ich+1)==-1) continue;
1058 AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich)));
1059
1060 /* check whether channel has been read out during current run.
1061 * if the status is bad it means it has not been read out.
1062 * in this case skip channel in order to leave its status
1063 * unchanged */
1064 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1065 continue;
1066
1067 if (h1->GetBinContent(ich+1)<0.05*mean){
1068 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser
1069 AliDebug(2,Form( " channel %i pulser status after pulser = %i (bad, content = %f), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),h1->GetBinContent(ich+1),(Int_t)fStatus->GetStatus(ich)));
1070 }
1071 else {
1072 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser
1073 AliDebug(2,Form( " channel %i pulser status after pulser = %i (good), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),(Int_t)fStatus->GetStatus(ich)));
1074 }
1075 }
1076 }
1077 else {
1078 Log("No channels read!! No action taken, keeping old status");
1079 }
1080
1081 daqFile->Close();
1082 delete daqFile;
1083 delete h1;
17149e6b 1084 }
1a1486e7 1085
e88f3330 1086 else{
1087 Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle ");
1088 delete listPulser;
1089 delete htofPulser;
1090 htofPulser = 0x0;
1091 if (fStatus){
1092 delete fStatus;
1093 fStatus = 0;
1094 }
1095 return 10;//return error code for failure in retrieving Ref Data
1a1486e7 1096 }
e88f3330 1097 AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource));
1a1486e7 1098 }
e88f3330 1099 AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser));
1100 delete listPulser;
ee3e792b 1101 }
7fffa85b 1102
ee3e792b 1103 else{
17149e6b 1104 Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle ");
e88f3330 1105 delete htofPulser;
1106 htofPulser = 0x0;
1107 if (fStatus){
1108 delete fStatus;
1109 fStatus = 0;
1110 }
17149e6b 1111 return 10;//return error code for failure in retrieving Ref Data
ee3e792b 1112 }
17149e6b 1113
7fffa85b 1114 //storing in OCDB
17149e6b 1115
7fffa85b 1116 AliCDBMetaData metaData;
1117 metaData.SetBeamPeriod(0);
1118 metaData.SetResponsible("Chiara Zampolli");
17149e6b 1119 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run.");
7fffa85b 1120 AliInfo("Storing Calibration Data from Pulser Run");
17149e6b 1121 resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
7fffa85b 1122 if(!resultPulser){
1123 Log("Some problems occurred while storing online object resulting from Pulser data processing");
e88f3330 1124 delete htofPulser;
1125 htofPulser = 0x0;
1126 if (fStatus){
1127 delete fStatus;
1128 fStatus = 0;
1129 }
7fffa85b 1130 return 11;//return error code for problems in storing Pulser data
1131 }
1132
ee3e792b 1133 if(fStoreRefData){
1134
1135 AliCDBMetaData metaDataHisto;
1136 metaDataHisto.SetBeamPeriod(0);
1137 metaDataHisto.SetResponsible("Chiara Zampolli");
1138 char comment[200];
17149e6b 1139 sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
ee3e792b 1140 metaDataHisto.SetComment(comment);
1141 AliInfo("Storing Reference Data");
db83b789 1142 resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
ee3e792b 1143 if (!resultPulserRef){
7fffa85b 1144 Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
e88f3330 1145 delete htofPulser;
1146 htofPulser = 0x0;
1147 if (fStatus){
1148 delete fStatus;
1149 fStatus = 0;
1150 }
7fffa85b 1151 return 9;//return error code for failure in storing Ref Data
ee3e792b 1152 }
1153 }
1154
1155 daqFile=0;
1156
e88f3330 1157 delete htofPulser;
1158 htofPulser = 0x0;
1159
1160 if (fStatus){
1161 delete fStatus;
1162 fStatus = 0;
1163 }
1164
ee3e792b 1165 return 0;
1166}
1167//_____________________________________________________________________________
1168
1169UInt_t AliTOFPreprocessor::ProcessNoiseData()
1170{
7fffa85b 1171
1172 // Processing Noise Run data for TOF channel status
1173
1174 Log("Processing Noise");
ee3e792b 1175
17149e6b 1176 if (fStatus==0x0){
1177 AliError("No valid fStatus found, some errors must have occurred!!");
1178 return 20;
1179 }
1180
013ac2dd 1181 Float_t noiseThr = 1; // setting default threshold for noise to 1 Hz
1182 // reading config map
1183 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
1184 if (!cdbEntry) {
1185 Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
1186 }
1187 else {
1188 TMap *configMap = (TMap*)cdbEntry->GetObject();
1189 if (!configMap){
1190 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
1191 }
1192 else{
1193 TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
1194 if (strNoiseThr) {
1195 TString tmpstr = strNoiseThr->GetString();
1196 noiseThr = tmpstr.Atoi();
1197 }
1198 else {
1199 Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
1200 }
1201 }
1202 }
1203
1204 delete cdbEntry;
1205 cdbEntry = 0x0;
1206
ee3e792b 1207 TH1::AddDirectory(0);
1208
1209 Bool_t resultNoiseRef=kFALSE;
7fffa85b 1210 Bool_t resultNoise=kFALSE;
ee3e792b 1211
a174d599 1212 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
17149e6b 1213 TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5);
a174d599 1214 for (Int_t ibin =1;ibin<=kSize;ibin++){
17149e6b 1215 htofNoise->SetBinContent(ibin,-1);
ee3e792b 1216 }
17149e6b 1217
ee3e792b 1218 // processing noise
1219
1220 TFile * daqFile=0x0;
1221 TH1F * h1=0x0;
1222
013ac2dd 1223 // useful counters
1224 Int_t nNoise = 0;
1225 Int_t nNoisyChannels = 0;
1226 Int_t nNotNoisyChannels = 0;
1227 Int_t nChannelsFromDA = 0;
1228 Int_t nMatchingWindowNullNonZero = 0;
1229 Int_t nMatchingWindowNullEqualZero = 0;
1230
1231 // retrieving Noise data
ee3e792b 1232 TList* listNoise = GetFileSources(kDAQ, "NOISE");
bf76be9c 1233 if (listNoise !=0x0 && listNoise->GetEntries()!=0)
e88f3330 1234 {
1235 AliInfo("The following sources produced files with the id NOISE");
1236 listNoise->Print();
e88f3330 1237 for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
1238 Int_t nNoiseSource = 0;
1239 TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
1240 AliInfo(Form("found source %s", str->String().Data()));
1241 // file to be stored run per run
1242 TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
1243 if (fileNameNoise.Length()>0){
1244 // storing reference data
1245 AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
1246 daqFile = new TFile(fileNameNoise.Data(),"READ");
1247 h1 = (TH1F*) daqFile->Get("hTOFnoise");
1248 for (Int_t ibin=0;ibin<kSize;ibin++){
1249 if ((h1->GetBinContent(ibin+1))!=-1){
013ac2dd 1250 nNoiseSource++;
1251 // checking the matching window for current channel
1252 if (fMatchingWindow[ibin] == 0){
fc143ab2 1253 Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin));
013ac2dd 1254 if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;
1255 if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;
1256 continue;
1257 }
e88f3330 1258 if ((htofNoise->GetBinContent(ibin+1))==-1){
013ac2dd 1259 htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9));
1260 if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1)));
e88f3330 1261 }
1262 else {
1263 Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
1264 }
1265 }
1266 }
013ac2dd 1267
1268 Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
e88f3330 1269 daqFile->Close();
1270 delete daqFile;
1271 delete h1;
013ac2dd 1272 daqFile = 0x0;
1273 h1 = 0x0;
1274
e88f3330 1275 }
e88f3330 1276 else{
1277 Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle ");
1278 delete listNoise;
013ac2dd 1279 listNoise = 0x0;
e88f3330 1280 delete htofNoise;
1281 htofNoise = 0x0;
1282 if (fStatus){
1283 delete fStatus;
1284 fStatus = 0;
1285 }
013ac2dd 1286 if (fMatchingWindow){
1287 delete [] fMatchingWindow;
1288 fMatchingWindow = 0;
1289 }
e88f3330 1290 return 13;//return error code for failure in retrieving Ref Data
1291 }
013ac2dd 1292 }
ee3e792b 1293 }
013ac2dd 1294
e88f3330 1295 else{
1296 Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle ");
1297 delete htofNoise;
1298 htofNoise = 0x0;
1299 if (fStatus){
1300 delete fStatus;
1301 fStatus = 0;
ee3e792b 1302 }
013ac2dd 1303 if (fMatchingWindow){
1304 delete [] fMatchingWindow;
1305 fMatchingWindow = 0;
1306 }
7fffa85b 1307 return 13;//return error code for failure in retrieving Ref Data
ee3e792b 1308 }
1309
013ac2dd 1310 // elaborating infos to set NOISE status
1311 for (Int_t ich =0;ich<fNChannels;ich++){
1312 if (htofNoise->GetBinContent(ich+1)== -1) continue;
1313
1314 nChannelsFromDA++;
1315
1316 AliDebug(3,Form(" channel %i noise status before noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
1317 //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
1318
1319 /* check whether channel has been read out during current run.
1320 * if the status is bad it means it has not been read out.
1321 * in this case skip channel in order to leave its status
1322 * unchanged */
1323
1324 if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1325 continue;
1326
1327 nNoise++;
1328 if (htofNoise->GetBinContent(ich+1) >= noiseThr){
1329 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
1330 AliDebug(3,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
1331 nNoisyChannels++;
1332 }
1333 else {
1334 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
1335 AliDebug(3,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
1336 nNotNoisyChannels++;
1337 }
1338 }
1339
1340 Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA));
1341 Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise));
1342 Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels));
1343 Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels));
1344 Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero));
1345 Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero));
1346
1347 delete listNoise;
1348
1349 //daqFile=0;
e88f3330 1350
7fffa85b 1351 //storing in OCDB
e88f3330 1352
7fffa85b 1353 AliCDBMetaData metaData;
1354 metaData.SetBeamPeriod(0);
1355 metaData.SetResponsible("Chiara Zampolli");
17149e6b 1356 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run.");
7fffa85b 1357 AliInfo("Storing Calibration Data from Noise Run");
17149e6b 1358 resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
7fffa85b 1359 if(!resultNoise){
1360 Log("Some problems occurred while storing online object resulting from Noise data processing");
e88f3330 1361 delete htofNoise;
1362 htofNoise = 0x0;
1363 if (fStatus){
1364 delete fStatus;
1365 fStatus = 0;
1366 }
013ac2dd 1367 if (fMatchingWindow){
1368 delete [] fMatchingWindow;
1369 fMatchingWindow = 0;
1370 }
7fffa85b 1371 return 14;//return error code for problems in storing Noise data
1372 }
1373
ee3e792b 1374 if(fStoreRefData){
1375
1376 AliCDBMetaData metaDataHisto;
1377 metaDataHisto.SetBeamPeriod(0);
1378 metaDataHisto.SetResponsible("Chiara Zampolli");
1379 char comment[200];
17149e6b 1380 sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
ee3e792b 1381 metaDataHisto.SetComment(comment);
1382 AliInfo("Storing Reference Data");
db83b789 1383 resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
ee3e792b 1384 if (!resultNoiseRef){
1385 Log("some problems occurred::No Reference Data for noise stored");
e88f3330 1386 delete htofNoise;
1387 htofNoise = 0x0;
1388 if (fStatus){
1389 delete fStatus;
1390 fStatus = 0;
1391 }
013ac2dd 1392 if (fMatchingWindow){
1393 delete [] fMatchingWindow;
1394 fMatchingWindow = 0;
1395 }
7fffa85b 1396 return 12;//return error code for failure in storing Ref Data
ee3e792b 1397 }
1398 }
1399
e88f3330 1400 delete htofNoise;
1401 htofNoise = 0x0;
1402
1403 if (fStatus){
1404 delete fStatus;
1405 fStatus = 0;
1406 }
1407
013ac2dd 1408 if (fMatchingWindow){
1409 delete [] fMatchingWindow;
1410 fMatchingWindow = 0;
1411 }
1412
ee3e792b 1413 return 0;
1414}
1415//_____________________________________________________________________________
1416
db83b789 1417UInt_t AliTOFPreprocessor::ProcessFEEData()
ee3e792b 1418{
7fffa85b 1419 // Processing Pulser Run data for TOF channel status
1420 // dummy for the time being
ee3e792b 1421
db83b789 1422 Log("Processing FEE");
1423
ea932f75 1424 //Bool_t updateOCDB = kFALSE;
db83b789 1425 AliTOFFEEReader feeReader;
17149e6b 1426
db83b789 1427 TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
1428
69355034 1429 /* load current TOF FEE(dump) from DCS FXS,
1430 * setup TOFFEEdump object */
1431
1432 const char * toffeeFileName = GetFile(kDCS,"TofFeeMap","");
1433 AliInfo(Form("toffee file name = %s", toffeeFileName));
1434 if (toffeeFileName == NULL) {
1435 return 15;
1436 }
1437 AliTOFFEEDump feedump;
1438 feedump.ReadFromFile(toffeeFileName);
1439
1440 /* load current TOF FEE(light) config from DCS FXS, parse,
db83b789 1441 * fill current FEE histogram and set FEE status */
1442
fceb731d 1443 const char * nameFile = GetFile(kDCS,"TofFeeLightMap","");
69355034 1444 AliInfo(Form("toffeeLight file name = %s",nameFile));
db83b789 1445 if (nameFile == NULL) {
1446 return 15;
1447 }
fceb731d 1448 feeReader.LoadFEElightConfig(nameFile);
1449 Int_t parseFee = feeReader.ParseFEElightConfig();
1450 AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee));
db83b789 1451 /* load stored TOF FEE from OCDB and compare it with current FEE.
1452 * if stored FEE is different from current FEE set update flag.
1453 * if there is no stored FEE in OCDB set update flag */
1454
013ac2dd 1455 fMatchingWindow = new Int_t[fNChannels];
02ede0c4 1456 fLatencyWindow = new Int_t[fNChannels];
1457
17149e6b 1458 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
1459 if (!cdbEntry) {
1460 /* no CDB entry found. set update flag */
1461 Log(" ************ WARNING ************");
1462 Log("No CDB Status entry found, creating a new one!");
1463 Log(" *********************************");
1464 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
ea932f75 1465 //updateOCDB = kTRUE;
1466 fIsStatusMapChanged = kTRUE;
db83b789 1467 }
db83b789 1468 else {
e88f3330 1469 if (cdbEntry) cdbEntry->SetOwner(kFALSE);
17149e6b 1470 /* CDB entry OK. loop over channels */
1471 fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
e88f3330 1472 delete cdbEntry;
1473 cdbEntry = 0x0;
134e5594 1474 /* cehck whether status object has latency window data */
1475 if (!fStatus->HasLatencyWindow()) {
1476 /* create new status object and update OCDB */
1477 Log(" ************ WARNING ************");
1478 Log("CDB Status entry found but has no latency window data, creating a new one!");
1479 Log(" *********************************");
1480 delete fStatus;
1481 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
ea932f75 1482 //updateOCDB = kTRUE;
1483 fIsStatusMapChanged = kTRUE;
134e5594 1484 }
db83b789 1485 }
17149e6b 1486 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
1487 //AliDebug(2,Form("********** channel %i",iChannel));
1488 /* compare current FEE channel status with stored one
1489 * if different set update flag and break loop */
1490 //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
013ac2dd 1491 fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
02ede0c4 1492 fLatencyWindow[iChannel] = feeReader.GetLatencyWindow(iChannel);
17149e6b 1493 if (feeReader.IsChannelEnabled(iChannel)) {
1494 hCurrentFEE.SetBinContent(iChannel + 1, 1);
1495 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
ea932f75 1496 //updateOCDB = kTRUE;
1497 fIsStatusMapChanged = kTRUE;
17149e6b 1498 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
013ac2dd 1499 AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
17149e6b 1500 }
02ede0c4 1501 if (fStatus->GetLatencyWindow(iChannel)!=fLatencyWindow[iChannel]){
ea932f75 1502 //updateOCDB = kTRUE;
1503 fIsStatusMapChanged = kTRUE;
02ede0c4 1504 fStatus->SetLatencyWindow(iChannel,fLatencyWindow[iChannel]);
1505 AliDebug(3,Form( " changed latency window: channel %i latency window after FEE = %i",iChannel,fStatus->GetLatencyWindow(iChannel)));
1506 }
17149e6b 1507 }
1508 else {
1509 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
ea932f75 1510 //updateOCDB = kTRUE;
1511 fIsStatusMapChanged = kTRUE;
17149e6b 1512 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
013ac2dd 1513 AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
17149e6b 1514 }
1515 }
1516 }
1517
db83b789 1518
1519 /* check whether we don't have to store reference data.
1520 * in this case we return without errors. */
1521 if (fStoreRefData) {
69355034 1522 /* store reference data */
1523 AliCDBMetaData metaDataHisto;
1524 metaDataHisto.SetBeamPeriod(0);
1525 metaDataHisto.SetResponsible("Roberto Preghenella");
1526 metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
1527 AliInfo("Storing FEE reference data");
1528 /* store FEE reference data */
1529 if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
1530 /* failed */
1531 Log("problems while storing FEE reference data");
1532 if (fStatus){
1533 delete fStatus;
1534 fStatus = 0;
1535 }
1536 return 18; /* error return code for problems while storing FEE reference data */
1537 }
1538
1539 /* store TOF FEE dump reference data */
1540 AliCDBMetaData metaDatadump;
1541 metaDatadump.SetBeamPeriod(0);
1542 metaDatadump.SetResponsible("Roberto Preghenella");
1543 metaDatadump.SetComment("This preprocessor stores the TOF FEE dump Ref data of the current run.");
1544 AliInfo("Storing TOF FEE dump reference data");
1545 /* store FEE reference data */
1546 if (!StoreReferenceData("Calib", "FEEDump", &feedump, &metaDatadump)) {
1547 /* failed */
1548 Log("problems while storing TOF FEE dump reference data");
1549 return 18; /* error return code for problems while storing FEE reference data */
1550 }
db83b789 1551 }
1552
7fffa85b 1553 return 0;
1554
1555}
1556
1557//_____________________________________________________________________________
1558
104ba366 1559UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap)
7fffa85b 1560{
a174d599 1561 //
ea932f75 1562 // Main AliTOFPreprocessor method called by SHUTTLE
a174d599 1563 //
7fffa85b 1564
1565 TString runType = GetRunType();
1566 Log(Form("RunType %s",runType.Data()));
bf76be9c 1567
ee3e792b 1568 // processing
1569
db83b789 1570 /* always process FEE data */
1571 Int_t iresultFEE = ProcessFEEData();
1572 if (iresultFEE != 0)
1573 return iresultFEE;
1574
7fffa85b 1575 if (runType == "PULSER") {
1576 Int_t iresultPulser = ProcessPulserData();
1577 return iresultPulser;
1578 }
17149e6b 1579
7fffa85b 1580 if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined
1581 Int_t iresultNoise = ProcessNoiseData();
1582 return iresultNoise;
1583 }
104ba366 1584
7fffa85b 1585 if (runType == "PHYSICS") {
104ba366 1586 // Int_t iresultDAQ = ProcessOnlineDelays();
1587 Int_t iresultDAQ = ProcessT0Fill();
4856f488 1588 if (iresultDAQ != 0) {
7fffa85b 1589 return iresultDAQ;
1590 }
4856f488 1591 else {
1592 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
ea932f75 1593 Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap);
1594 return iresultDCS+iResultHVandLVdps;
4856f488 1595 }
ee3e792b 1596 }
1597
7fffa85b 1598 // storing
ee3e792b 1599 return 0;
1600}
c9fe8530 1601
1602
b06d5296 1603//_____________________________________________________________________________
1604
1605void
1606AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal)
1607{
1608 /*
1609 * fill with cosmic calibration
1610 */
1611
1612 Log(" Using cosmic-ray calibration.");
1613
1614 AliTOFcalibHisto calibHisto;
97a29b32 1615 calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE);
1616 Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName()));
b06d5296 1617 Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName()));
1618 calibHisto.LoadCalibPar();
1619
1620 /* loop over channel index */
1621 for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) {
9155334b 1622 cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex));
b06d5296 1623 }
1624
1625}
1626
b06d5296 1627//_____________________________________________________________________________
1628
1629void
1630AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal)
1631{
1632 /*
1633 * fill with cosmic calibration
1634 */
1635
1636 Log(" Using cable-length map.");
1637 AliTOFRawStream tofrs;
1638 Int_t det[5], dummy, index;
1639 Float_t cableTimeShift;
1640
1641 /* temporarly disable warnings */
1642 AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
1643 AliLog::SetGlobalLogLevel(AliLog::kError);
1644
1645 /* loop over EO indeces */
1646 for (Int_t iddl = 0; iddl < 72; iddl++)
1647 for (Int_t islot = 3; islot <= 12; islot++)
1648 for (Int_t ichain = 0; ichain < 2; ichain++)
1649 for (Int_t itdc = 0; itdc < 15; itdc++)
1650 for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
1651
1652 /* get DO index */
1653 tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
1654
1655 /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
1656 dummy = det[3];
1657 det[3] = det[4];
1658 det[4] = dummy;
1659
1660 /* check DO index */
1661 if (det[0] < 0 || det[0] > 17 ||
1662 det[1] < 0 || det[1] > 4 ||
1663 det[2] < 0 || det[2] > 18 ||
1664 det[3] < 0 || det[3] > 1 ||
1665 det[4] < 0 || det[4] > 47)
1666 continue;
1667
1668 /* get channel index */
1669 index = AliTOFGeometry::GetIndex(det);
1670
1671 /* get cable time shift */
1672 cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
1673
1674 /* set delay */
1675 if (index<fNChannels) {
1676 cal->SetDelay(index,cableTimeShift); // delay in ns
1677 AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
1678 }
1679
1680 } /* loop over EO indeces */
1681
1682 /* re-enable warnings */
1683 AliLog::SetGlobalLogLevel(logLevel);
1684
1685}
1686
1687