Flexible pt range for the efficiency histogramming
[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),
a9f9c69b 53 ocdbStorage(0),
cdd58213 54 fNewDArun(9999999),
55 fStatusDelay(0),
56 fStatusAdjust(0)
16beeccf 57
dd162229 58{
59 //constructor
60}
61//____________________________________________________
62
63AliT0PreprocessorOffline::~AliT0PreprocessorOffline()
64{
65 //destructor
66
67}
68//____________________________________________________
a9f9c69b 69void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, Int_t uendRun, AliCDBStorage* pocdbStorage)
65521adf 70{
cdd58213 71 if ( ustartRun < fNewDArun)
16beeccf 72 CalibOffsetChannels(filePhysName, ustartRun, uendRun, pocdbStorage);
65521adf 73 CalibT0sPosition(filePhysName, ustartRun, uendRun, pocdbStorage);
74}
dd162229 75//____________________________________________________
76
a9f9c69b 77void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, AliCDBStorage* pocdbStorage)
dd162229 78{
79
b0ab3f59 80 Float_t zero_timecdb[24]={0};
81 Float_t *timecdb = zero_timecdb;
82 Float_t *cfdvalue = zero_timecdb;
11c0962a 83 Float_t cfd[24][5];
84 for(Int_t i=0; i<24; i++)
85 for (Int_t i0=0; i0<5; i0++)
86 cfd[i][i0] = 0;
b9dd81a7 87 Int_t badpmt=-1;
dd162229 88 //Processing data from DAQ Physics run
89 AliInfo("Processing Time Offset between channels");
a9f9c69b 90 if (pocdbStorage) ocdbStorage=pocdbStorage;
91 else {
92 TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
93 ocdbStorage= AliCDBManager::Instance()->GetStorage(localStorage.Data());
94 }
11c0962a 95 AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
96 if(!entryCalib) {
97 AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
98 }
99 else
100 {
101 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
102 timecdb = clb->GetTimeEq();
103 for(Int_t i=0; i<24; i++)
104 for (Int_t i0=0; i0<5; i0++) cfd[i][i0] = clb->GetCFDvalue(i, i0);
105
106 }
107 for(Int_t i=0; i<24; i++)cfdvalue[i]=cfd[i][0];
108
b0ab3f59 109 AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
32d3e409 110 Int_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, cfdvalue, badpmt);
111 printf(" AliT0PreprocessorOffline::CalibOffsetChannels :: writeok %i \n", writeok);
b0ab3f59 112 AliCDBMetaData metaData;
113 metaData.SetBeamPeriod(1);
114 metaData.SetResponsible("Alla Maevskaya");
115 metaData.SetComment("Time equalizing result with slew");
cdd58213 116 fStatusDelay = writeok;
11c0962a 117 if (writeok==0) {
b0ab3f59 118 AliCDBId* id1=NULL;
119 id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun );
a9f9c69b 120 ocdbStorage->Put(offline, (*id1), &metaData);
b0ab3f59 121 }
122 else {
123
124 AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok));
dd162229 125 }
b0ab3f59 126
127 delete offline;
128
dd162229 129}
65521adf 130//-------------------------------------------------------------------------------------
a9f9c69b 131void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, AliCDBStorage* pocdbStorage)
65521adf 132{
16beeccf 133 printf(" AliT0PreprocessorOffline::CalibT0sPosition \n");
b0ab3f59 134 Float_t zero_timecdb[4]={0};
135 Float_t *timecdb = zero_timecdb;
a9f9c69b 136 if (pocdbStorage) ocdbStorage=pocdbStorage;
137 else {
138 TString localStorage = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
139 ocdbStorage=AliCDBManager::Instance()->GetStorage(localStorage.Data());
140 }
b0ab3f59 141
142 AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift();
32d3e409 143 Int_t writeok = offline->SetT0Par(filePhysName.Data(), timecdb);
144 printf(" AliT0PreprocessorOffline::CalibT0sPosition :: writeok %i \n", writeok);
b0ab3f59 145 AliCDBMetaData metaData;
146 metaData.SetBeamPeriod(1);
147 metaData.SetResponsible("Alla Maevskaya");
148 metaData.SetComment("Time equalizing result with slew");
cdd58213 149 fStatusAdjust = writeok;
11c0962a 150 if (writeok == 0) {
b0ab3f59 151 AliCDBId* id1=NULL;
bb54f817 152 id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun);
a9f9c69b 153 ocdbStorage->Put(offline, (*id1), &metaData);
b0ab3f59 154 }
155
65521adf 156}
cdd58213 157//_____________________________________________________________________________
158Int_t AliT0PreprocessorOffline::GetStatus() const
159{
160 //
161 // Checks the status
162 // fStatusPos: errors
163 // fStatusNeg: only info
164 //
11c0962a 165 printf("!!!! GetStatus %i delay %i adjust %i \n",fStatusAdjust+ fStatusDelay, fStatusDelay, fStatusAdjust);
166 return fStatusAdjust+ fStatusDelay;
cdd58213 167}