correct calibration of short runs
[u/mrichter/AliRoot.git] / T0 / AliT0PreprocessorOffline.cxx
CommitLineData
dd162229 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
16/*
17
18*/
19// T0 preprocessor:
20// 2) takes data after pass0 ,
21// processes it, and stores either to OCDB .
22
23
24#include "AliT0PreprocessorOffline.h"
65521adf 25#include "AliT0RecoParam.h"
dd162229 26#include "AliT0CalibTimeEq.h"
27#include "AliCDBStorage.h"
28#include "AliCDBMetaData.h"
29#include "AliCDBManager.h"
612737bb 30#include "AliCTPTimeParams.h"
31#include "AliLHCClockPhase.h"
65521adf 32#include "AliT0CalibSeasonTimeShift.h"
612737bb 33#include "AliT0CalibLatency.h"
dd162229 34#include "AliCDBEntry.h"
35#include "AliLog.h"
36
37#include <TTimeStamp.h>
38#include <TFile.h>
39#include <TObjString.h>
40#include <TNamed.h>
41#include "TClass.h"
42
43
44ClassImp(AliT0PreprocessorOffline)
45
46//____________________________________________________
47AliT0PreprocessorOffline::AliT0PreprocessorOffline():
65521adf 48TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline"),
bb54f817 49 startRun(0),
50 endRun(0),
51 startTime(0),
52 endTime(0),
53 ocdbStorage("")
dd162229 54{
55 //constructor
56}
57//____________________________________________________
58
59AliT0PreprocessorOffline::~AliT0PreprocessorOffline()
60{
61 //destructor
62
63}
64//____________________________________________________
65521adf 65void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
66{
e24f582d 67 CalibOffsetChannels(filePhysName, ustartRun, uendRun, pocdbStorage);
65521adf 68 CalibT0sPosition(filePhysName, ustartRun, uendRun, pocdbStorage);
69}
dd162229 70//____________________________________________________
71
65521adf 72void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
dd162229 73{
74
b0ab3f59 75 Float_t zero_timecdb[24]={0};
76 Float_t *timecdb = zero_timecdb;
77 Float_t *cfdvalue = zero_timecdb;
b9dd81a7 78 Int_t badpmt=-1;
dd162229 79 //Processing data from DAQ Physics run
80 AliInfo("Processing Time Offset between channels");
b0ab3f59 81 if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
82 else
83 ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
13366e78 84
b0ab3f59 85 AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
86 Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, cfdvalue, badpmt);
87 AliCDBMetaData metaData;
88 metaData.SetBeamPeriod(1);
89 metaData.SetResponsible("Alla Maevskaya");
90 metaData.SetComment("Time equalizing result with slew");
dd162229 91
b0ab3f59 92 if (writeok) {
93 AliCDBId* id1=NULL;
94 id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun );
95 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
96 gStorage->Put(offline, (*id1), &metaData);
97 }
98 else {
99
100 AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok));
dd162229 101 }
b0ab3f59 102
103 delete offline;
104
dd162229 105}
65521adf 106//-------------------------------------------------------------------------------------
107void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
108{
b0ab3f59 109 Float_t zero_timecdb[4]={0};
110 Float_t *timecdb = zero_timecdb;
111 if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
112 else
113 ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
b0ab3f59 114
115 AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift();
116 Bool_t writeok = offline->SetT0Par(filePhysName.Data(), timecdb);
117 AliCDBMetaData metaData;
118 metaData.SetBeamPeriod(1);
119 metaData.SetResponsible("Alla Maevskaya");
120 metaData.SetComment("Time equalizing result with slew");
121
122 if (writeok) {
123 AliCDBId* id1=NULL;
bb54f817 124 id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun);
125 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
126 gStorage->Put(offline, (*id1), &metaData);
b0ab3f59 127 }
128
65521adf 129}