]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0PreprocessorOffline.cxx
removes OCDB access during merging by splitting out the functionality
[u/mrichter/AliRoot.git] / T0 / AliT0PreprocessorOffline.cxx
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"
25 #include "AliT0RecoParam.h"
26 #include "AliT0CalibTimeEq.h"
27 #include "AliCDBStorage.h"
28 #include "AliCDBMetaData.h"
29 #include "AliCDBManager.h"
30 #include "AliCTPTimeParams.h"
31 #include "AliLHCClockPhase.h"
32 #include "AliT0CalibSeasonTimeShift.h"
33 #include "AliT0CalibLatency.h"
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():
48 TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline"),
49   startRun(0),      
50   endRun(0),  
51   startTime(0),    
52   endTime(0),     
53   ocdbStorage(""),
54   fNewDArun(9999999),
55   fStatusDelay(0),
56   fStatusAdjust(0)
57   
58 {
59   //constructor
60 }
61 //____________________________________________________
62
63 AliT0PreprocessorOffline::~AliT0PreprocessorOffline()
64 {
65   //destructor
66
67 }
68 //____________________________________________________
69 void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
70 {
71   if ( ustartRun < fNewDArun) 
72     CalibOffsetChannels(filePhysName, ustartRun, uendRun, pocdbStorage);
73   CalibT0sPosition(filePhysName, ustartRun, uendRun, pocdbStorage);
74 }
75 //____________________________________________________
76
77 void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
78 {
79
80   Float_t zero_timecdb[24]={0};
81   Float_t *timecdb = zero_timecdb;
82   Float_t *cfdvalue = zero_timecdb;
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;
87   Int_t badpmt=-1;
88   //Processing data from DAQ Physics run
89   AliInfo("Processing Time Offset between channels");
90   if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
91   else
92     ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
93   AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
94   if(!entryCalib) {
95     AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
96   }
97   else
98     {
99       AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
100       timecdb = clb->GetTimeEq();
101       for(Int_t i=0; i<24; i++) 
102         for (Int_t i0=0; i0<5; i0++)  cfd[i][i0] = clb->GetCFDvalue(i, i0);
103       
104     }
105   for(Int_t i=0; i<24; i++)cfdvalue[i]=cfd[i][0];
106   
107   AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
108   Int_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, cfdvalue, badpmt);
109   printf(" AliT0PreprocessorOffline::CalibOffsetChannels :: writeok %i \n", writeok);
110   AliCDBMetaData metaData;
111   metaData.SetBeamPeriod(1);
112   metaData.SetResponsible("Alla Maevskaya");
113   metaData.SetComment("Time equalizing result with slew");
114   fStatusDelay = writeok;
115   if (writeok==0)  {
116     AliCDBId* id1=NULL;
117     id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun );
118     AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
119     gStorage->Put(offline, (*id1), &metaData);
120   }
121   else {
122     
123     AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok));
124       }           
125   
126   delete offline;
127  
128 }
129 //-------------------------------------------------------------------------------------
130 void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
131 {
132   printf(" AliT0PreprocessorOffline::CalibT0sPosition \n");
133   Float_t zero_timecdb[4]={0};
134   Float_t *timecdb = zero_timecdb;
135   if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
136   else
137     ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
138   
139   AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift();
140   Int_t writeok = offline->SetT0Par(filePhysName.Data(), timecdb);
141   printf(" AliT0PreprocessorOffline::CalibT0sPosition :: writeok %i \n", writeok);
142   AliCDBMetaData metaData;
143   metaData.SetBeamPeriod(1);
144   metaData.SetResponsible("Alla Maevskaya");
145   metaData.SetComment("Time equalizing result with slew");
146   fStatusAdjust = writeok;
147   if (writeok == 0)  {
148     AliCDBId* id1=NULL;
149     id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun);
150     AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
151     gStorage->Put(offline, (*id1), &metaData);
152   }
153
154 }
155 //_____________________________________________________________________________
156 Int_t AliT0PreprocessorOffline::GetStatus() const
157 {
158   //
159   // Checks the status
160   // fStatusPos: errors
161   // fStatusNeg: only info
162   //
163   printf("!!!! GetStatus %i delay %i adjust %i \n",fStatusAdjust+ fStatusDelay, fStatusDelay, fStatusAdjust);
164   return   fStatusAdjust+ fStatusDelay;
165 }