]>
Commit | Line | Data |
---|---|---|
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 | ||
44 | ClassImp(AliT0PreprocessorOffline) | |
45 | ||
46 | //____________________________________________________ | |
47 | AliT0PreprocessorOffline::AliT0PreprocessorOffline(): | |
65521adf | 48 | TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline"), |
bb54f817 | 49 | startRun(0), |
50 | endRun(0), | |
51 | startTime(0), | |
52 | endTime(0), | |
53 | ocdbStorage("") | |
dd162229 | 54 | { |
55 | //constructor | |
56 | } | |
57 | //____________________________________________________ | |
58 | ||
59 | AliT0PreprocessorOffline::~AliT0PreprocessorOffline() | |
60 | { | |
61 | //destructor | |
62 | ||
63 | } | |
64 | //____________________________________________________ | |
65521adf | 65 | void 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 | 72 | void 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; | |
65521adf | 78 | Int_t badpmt=0; |
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"; | |
84 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); | |
85 | if (!entry) AliFatal("CTP timing parameters are not found in OCDB !"); | |
86 | AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); | |
87 | Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; | |
88 | ||
89 | AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); | |
90 | if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !"); | |
91 | AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); | |
92 | l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); | |
93 | ||
94 | AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase"); | |
95 | if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !"); | |
96 | AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject(); | |
97 | Float_t fGRPdelays = l1Delay - phase->GetMeanPhase(); | |
593a6aab | 98 | |
b0ab3f59 | 99 | AliCDBEntry *entryL = AliCDBManager::Instance()->Get("T0/Calib/Latency"); |
593a6aab | 100 | if (!entryL) AliFatal(" T0 Latency is not found in OCDB !"); |
b0ab3f59 | 101 | AliT0CalibLatency *lat = (AliT0CalibLatency*)entryL->GetObject(); |
102 | Float_t fLatencyHPTDC = lat->GetLatencyHPTDC(); | |
103 | Float_t fLatencyL1 = lat->GetLatencyL1(); | |
593a6aab | 104 | |
b0ab3f59 | 105 | AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay"); |
106 | if(!entryCalib) { | |
107 | AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!")); | |
108 | } | |
109 | else | |
dd162229 | 110 | { |
b0ab3f59 | 111 | AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject(); |
612737bb | 112 | timecdb = clb->GetTimeEq(); |
113 | cfdvalue = clb->GetCFDvalue(); | |
114 | for (Int_t i=0; i<24; i++) { | |
bb54f817 | 115 | if( cfdvalue[i] < 500 || cfdvalue[i] > 30000) cfdvalue[i] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4; |
612737bb | 116 | printf("Calc mean CFD time %i %f \n",i,cfdvalue[i]); |
117 | } | |
b0ab3f59 | 118 | } |
bb54f817 | 119 | //AliCDBEntry *entryCalibreco = AliCDBManager::Instance()->Get("T0/Calib/RecoParam"); |
120 | // if(entryCalibreco) { | |
121 | // AliT0RecoParam *rpr = (AliT0RecoParam*) entryCalibreco->GetObject(); | |
122 | // badpmt = rpr->GetRefPoint(); | |
123 | badpmt = -1; | |
124 | // } | |
b0ab3f59 | 125 | AliT0CalibTimeEq *offline = new AliT0CalibTimeEq(); |
126 | Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, cfdvalue, badpmt); | |
127 | AliCDBMetaData metaData; | |
128 | metaData.SetBeamPeriod(1); | |
129 | metaData.SetResponsible("Alla Maevskaya"); | |
130 | metaData.SetComment("Time equalizing result with slew"); | |
dd162229 | 131 | |
b0ab3f59 | 132 | if (writeok) { |
133 | AliCDBId* id1=NULL; | |
134 | id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun ); | |
135 | AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage); | |
136 | gStorage->Put(offline, (*id1), &metaData); | |
137 | } | |
138 | else { | |
139 | ||
140 | AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok)); | |
dd162229 | 141 | } |
b0ab3f59 | 142 | |
143 | delete offline; | |
144 | ||
dd162229 | 145 | } |
65521adf | 146 | //------------------------------------------------------------------------------------- |
147 | void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage) | |
148 | { | |
b0ab3f59 | 149 | Float_t zero_timecdb[4]={0}; |
150 | Float_t *timecdb = zero_timecdb; | |
151 | if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage; | |
152 | else | |
153 | ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; | |
154 | AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeAdjust"); | |
155 | if(!entryCalib) { | |
156 | AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeAdjust]!")); | |
157 | } | |
158 | else | |
65521adf | 159 | { |
b0ab3f59 | 160 | AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*)entryCalib->GetObject(); |
161 | timecdb = clb->GetT0Means(); | |
162 | } | |
163 | ||
164 | AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift(); | |
165 | Bool_t writeok = offline->SetT0Par(filePhysName.Data(), timecdb); | |
166 | AliCDBMetaData metaData; | |
167 | metaData.SetBeamPeriod(1); | |
168 | metaData.SetResponsible("Alla Maevskaya"); | |
169 | metaData.SetComment("Time equalizing result with slew"); | |
170 | ||
171 | if (writeok) { | |
172 | AliCDBId* id1=NULL; | |
bb54f817 | 173 | id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun); |
174 | AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage); | |
175 | gStorage->Put(offline, (*id1), &metaData); | |
b0ab3f59 | 176 | } |
177 | ||
65521adf | 178 | } |