AliESDMuonTrack:
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
CommitLineData
dc7ca31d 1#include "AliT0Preprocessor.h"
2
3#include "AliCDBMetaData.h"
4#include "AliDCSValue.h"
5#include "AliLog.h"
6#include "AliT0Calc.h"
7
8#include <TTimeStamp.h>
9#include <TFile.h>
5221c818 10#include <TObjString.h>
dc7ca31d 11#include <TNamed.h>
12#include "AliT0Dqclass.h"
13
14ClassImp(AliT0Preprocessor)
15
16//____________________________________________________
5221c818 17AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
18 AliPreprocessor("T00", shuttle)
dc7ca31d 19{
20
21}
22
23AliT0Preprocessor::~AliT0Preprocessor()
24{
25
26}
27
28UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
29{
30
38b11747 31 if(!dcsAliasMap) return 1;
dc7ca31d 32
33 TObjArray *aliasArr;
34 // AliDCSValue *aValue;
35 Float_t hv[24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
36
37 for(int j=0; j<24; j++){
38 TString aliasName =Form("T0HV%d",j);
39 // printf("aliasname: %s\n",aliasName.Data());
40 aliasArr = dynamic_cast<TObjArray*> (dcsAliasMap->GetValue(aliasName.Data()));
41 if(!aliasArr){
42 AliError(Form("Alias %s not found!", aliasName.Data()));
43 continue;
44 }
45 AliDCSValue *aValue=dynamic_cast<AliDCSValue*> (aliasArr->At(0));
46 // printf("I'm here! %f %x\n", aValue->GetFloat(), aValue->GetTimeStamp());
47 hv[j]= aValue->GetFloat()*100;
48 //Float_t timestamp= (Float_t) (aValue->GetTimeStamp());
49 // printf("hello! hv = %f timestamp = %f\n" ,hv[j], timestamp);
50
51 }
52 Float_t numbers[24];
53
54 AliT0Calc *calibdata = new AliT0Calc();
55
5221c818 56 TList* list = GetFileSources(kDAQ, "TIME");
57 if (list)
58 {
59 TIter iter(list);
60 TObjString *source;
61 while ((source = dynamic_cast<TObjString *> (iter.Next())))
dc7ca31d 62 {
5221c818 63 const char* TimefileName = GetFile(kDAQ, "TIME", source->GetName());
64
65 if (TimefileName)
66 {
67 Log(Form("File with Id TIME found in source %s!", source->GetName()));
68 TFile *file = TFile::Open(TimefileName);
69 if(!file || !file->IsOpen())
70 {
71 Log(Form("Error opening file with Id TIME from source %s!", source->GetName()));
38b11747 72 return 1;
5221c818 73 }
74 AliT0Dqclass *tempdata = dynamic_cast<AliT0Dqclass*> (file->Get("Time"));
75 if (!tempdata)
76 {
77 Log("Could not find key \"Time\" in DAQ file!");
38b11747 78 return 1;
5221c818 79 }
80 for(Int_t i=0;i<24;i++){
81 numbers[i] = tempdata->GetTime(i);
82 // printf("\nnumbers: %f\n",numbers[i]);
83 }
84 file->Close();
85 delete tempdata;
86 } else {
87 Log(Form("Could not find file with Id TIME in source %s!", source->GetName()));
38b11747 88 return 1;
5221c818 89 }
90 calibdata->SetTime(numbers, hv);
91 calibdata->Print();
dc7ca31d 92 }
5221c818 93 } else {
94 Log("No sources for Id TIME found!");
95 }
dc7ca31d 96
97 AliCDBMetaData metaData;
98 metaData.SetBeamPeriod(0);
99 metaData.SetResponsible("Tomek&Michal");
100 metaData.SetComment("This preprocessor returns time to be used for reconstruction.");
dc7ca31d 101
38b11747 102 Bool_t result = Store("Calib","Data", calibdata, &metaData);
103 delete calibdata;
104 if(result == kTRUE)
105 {return 0;}
106 else {return 1;}
dc7ca31d 107}
108
109