sorry fixed now
[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"
65521adf 30#include "AliT0CalibSeasonTimeShift.h"
dd162229 31
32#include "AliCDBEntry.h"
33#include "AliLog.h"
34
35#include <TTimeStamp.h>
36#include <TFile.h>
37#include <TObjString.h>
38#include <TNamed.h>
39#include "TClass.h"
40
41
42ClassImp(AliT0PreprocessorOffline)
43
44//____________________________________________________
45AliT0PreprocessorOffline::AliT0PreprocessorOffline():
65521adf 46TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline"),
47 startRun(0), // start Run - used to make fast selection in THnSparse
48 endRun(0), // end Run - used to make fast selection in THnSparse
49 startTime(0), // startTime - used to make fast selection in THnSparse
50 endTime(0), // endTime - used to make fast selection in THnSparse
51 ocdbStorage("") // path to the OCDB storage
52
dd162229 53{
54 //constructor
55}
56//____________________________________________________
57
58AliT0PreprocessorOffline::~AliT0PreprocessorOffline()
59{
60 //destructor
61
62}
63//____________________________________________________
65521adf 64void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
65{
66 CalibOffsetChannels(filePhysName, ustartRun, uendRun, pocdbStorage);
67 CalibT0sPosition(filePhysName, ustartRun, uendRun, pocdbStorage);
68}
dd162229 69//____________________________________________________
70
65521adf 71void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
dd162229 72{
73
65521adf 74 Float_t *timecdb = 0;
75 Int_t badpmt=0;
dd162229 76 //Processing data from DAQ Physics run
77 AliInfo("Processing Time Offset between channels");
65521adf 78
dd162229 79 if (filePhysName)
80 {
65521adf 81 if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
82 else
83 ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
84 // AliCDBManager* man = AliCDBManager::Instance();
85 // man->SetDefaultStorage("raw://");
86 // man->SetDefaultStorage("ocdbStorage");
87 // man->SetRun(ustartRun);
88 AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
89 if(!entryCalib) {
90 AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
91 for (Int_t i=0; i<24; i++) timecdb[i]=999;
92 }
93 else
94 {
95 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
96 timecdb = clb->GetTimeEq();
97 }
98 AliCDBEntry *entryCalibreco = AliCDBManager::Instance()->Get("T0/Calib/RecoParam");
99 if(entryCalibreco) {
100 AliT0RecoParam *rpr = (AliT0RecoParam*) entryCalibreco->GetObject();
101 badpmt = rpr->GetRefPoint();
102 printf(" bad PMT %i \n", badpmt);
103 }
dd162229 104 AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
105 offline->Reset();
65521adf 106 Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, badpmt);
dd162229 107 AliCDBMetaData metaData;
108 metaData.SetBeamPeriod(1);
109 metaData.SetResponsible("Alla Maevskaya");
110 metaData.SetComment("Time equalizing result with slew");
111
112 if (writeok) {
113 AliCDBId* id1=NULL;
65521adf 114 id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun );
dd162229 115 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
116 gStorage->Put(offline, (*id1), &metaData);
117 }
118 else {
119
65521adf 120 AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok));
dd162229 121 }
122
123 delete offline;
124 }
125
126
127}
65521adf 128//-------------------------------------------------------------------------------------
129void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
130{
131 if (filePhysName)
132 {
133 if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
134 else
135 ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
136
137 AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift();
138 Bool_t writeok = offline->SetT0Par(filePhysName.Data());
139 AliCDBMetaData metaData;
140 metaData.SetBeamPeriod(1);
141 metaData.SetResponsible("Alla Maevskaya");
142 metaData.SetComment("Time equalizing result with slew");
143
144 if (writeok) {
145 AliCDBId* id1=NULL;
146 id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun);
147 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
148 gStorage->Put(offline, (*id1), &metaData);
149 }
150 }
151}