]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/TestPMDPreprocessor.C
Moving all Gsatt calls in Init: needed by G4 (Andrei)
[u/mrichter/AliRoot.git] / PMD / TestPMDPreprocessor.C
CommitLineData
ad6005fa 1/* $Id$ */
2
3// This class runs the test preprocessor
4// It uses AliTestShuttle to simulate a full Shuttle process
5
6// The input data is created in the functions
7// CreateDCSAliasMap() creates input that would in the same way come from DCS
8// ReadDCSAliasMap() reads from a file
9// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
10
11void TestPMDPreprocessor()
12{
13 // load library
14 gSystem->Load("libTestShuttle.so");
15
16 // TODO if needed, change location of OCDB and Reference test folders
17 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
18
19 AliTestShuttle::SetOCDBStorage("local://TestCDB");
20 // AliTestShuttle::SetReferenceStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
21
22 printf("Test OCDB storage Uri: %s\n", AliTestShuttle::GetOCDBStorage().Data());
23
24 // create AliTestShuttle instance
25 // The parameters are run, startTime, endTime
26 AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1);
27
28 // TODO(1)
29 //
30 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
31 // some fake data has to be created.
32 //
33 // The "fake" input data can be taken using either (a) or (b):
34 // (a) data from a file: Use ReadDCSAliasMap()
35 // the format of the file is explained in ReadDCSAliasMap()
36 // To use it uncomment the following line:
37 //
38 //TMap* dcsAliasMap = ReadDCSAliasMap();
39 //
40 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
41 // To use it uncomment the following line:
42 //
43 TMap* dcsAliasMap = CreateDCSAliasMap();
44
45 // now give the alias map to the shuttle
46 shuttle->SetDCSInput(dcsAliasMap);
47
48 // TODO(2)
49 //
50 // The shuttle can also process files that originate from DCS, DAQ and HLT.
51 // To test it, we provide some local files and locations where these would be found when
52 // the online machinery would be there.
53 // In real life this functions would be produces by the sub-detectors
54 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
55 //
56 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
57 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
58 // In this example we add a file originating from the GDC with the id PEDESTALS
59 // Three files originating from different LDCs but with the same id are also added
60
61 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "PMD", "PMDGAINS", "LDC1", "xy.root");
62
63
64 // TODO(4)
65 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
66
67 AliPreprocessor* test = new AliPMDPreprocessor("PMD", shuttle);
68
69 printf("Starting SHUTTLE!\n");
70
71 // Test the preprocessor
72 shuttle->Process();
73
74 printf("SHUTTLE done!\n");
75
76 delete shuttle;
77
78 // TODO(5)
79 // In the preprocessor AliShuttleInterface::Store should be called to put the final
80 // data to the CDB.
81 //
82 // Check the file which should have been created
83 AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetOCDBStorage())
84 ->Get("PMD/Calib/Data", 7);
85 if (!entry)
86 {
87 printf("The file is not there. Something went wrong.\n");
88 return;
89 }
90
91 AliPMDCalibData* output = dynamic_cast<AliPMDCalibData*> (entry->GetObject());
92
93 // If everything went fine, print the result
94 if (output)
95 printf("Gain of det=1, smn=2, row=3, col=4: %f\n", output->GetGainFact(1,2,3,4));
96
97 AliCDBManager::Instance()->Destroy();
98
99 printf("DONE!\n");
100}
101
102TMap* CreateDCSAliasMap()
103{
104 // Creates a DCS structure
105 // The structure is the following:
106 // TMap (key --> value)
107 // <DCSAlias> --> <valueList>
108 // <DCSAlias> is a string
109 // <valueList> is a TObjArray of AliDCSValue
110 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
111
112 // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
113 // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
114
115 TMap* aliasMap = new TMap;
116 aliasMap->SetOwner(1);
117
118 TRandom random;
119
120 for(int nAlias=0;nAlias<6;nAlias++)
121 {
122 TObjArray* valueSet = new TObjArray;
123 valueSet->SetOwner(1);
124
125 TString aliasName="DCSAlias";
126 aliasName += nAlias;
127 //printf("\n\n alias: %s\n\n",aliasName.Data());
128
129 for (int timeStamp=0;timeStamp<1000;timeStamp+=10)
130 {
131 AliDCSValue* dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
132 //printf("%s\n",dcsVal->ToString().Data());
133 valueSet->Add(dcsVal);
134 }
135 aliasMap->Add(new TObjString(aliasName), valueSet);
136 }
137
138 return aliasMap;
139}
140