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