]>
Commit | Line | Data |
---|---|---|
4b9e7694 | 1 | /* |
2 | $Id$ | |
3 | */ | |
4 | ||
5 | // This class runs the test TOF preprocessor | |
6 | // It uses AliTestShuttle to simulate a full Shuttle process | |
7 | ||
8 | // The input data is created in the functions | |
9 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
10 | // ReadDCSAliasMap() reads from a file | |
11 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
12 | ||
13 | extern TBenchmark *gBenchmark; | |
14 | void TOFPreprocessorFDR() | |
15 | { | |
16 | gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so"); | |
17 | ||
18 | AliLog::SetClassDebugLevel("AliTOFPreprocessorFDR",1); | |
19 | // initialize location of CDB | |
162637e4 | 20 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); |
21 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); | |
4b9e7694 | 22 | |
23 | // create AliTestShuttle instance | |
24 | AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000); | |
25 | ||
26 | // Generation of "fake" input DCS data | |
27 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
28 | ||
29 | // now give the alias map to the shuttle | |
30 | shuttle->SetDCSInput(dcsAliasMap); | |
31 | ||
32 | // instantiation of the preprocessor | |
33 | AliPreprocessor* pp = new AliTOFPreprocessorFDR(shuttle); | |
34 | ||
35 | // preprocessing | |
36 | gBenchmark->Start("process"); | |
37 | shuttle->Process(); | |
38 | gBenchmark->Stop("process"); | |
39 | gBenchmark->Print("process"); | |
40 | ||
41 | // checking the file which should have been created | |
42 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/DCSData", 0); | |
43 | if (!chkEntry) | |
44 | { | |
45 | printf("The file is not there. Something went wrong.\n"); | |
46 | return; | |
47 | } | |
48 | ||
49 | AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject()); | |
50 | // If everything went fine, draw the result | |
51 | if (output) | |
52 | printf("Output found.\n"); | |
53 | // output->Draw(); | |
54 | ||
55 | } | |
56 | ||
57 | TMap* CreateDCSAliasMap() | |
58 | { | |
59 | // Creates a DCS structure | |
60 | // The structure is the following: | |
61 | // TMap (key --> value) | |
62 | // <DCSAlias> --> <valueList> | |
63 | // <DCSAlias> is a string | |
64 | // <valueList> is a TObjArray of AliDCSValue | |
65 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
66 | ||
67 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 | |
68 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
69 | ||
70 | TMap* aliasMap = new TMap; | |
71 | aliasMap->SetOwner(1); | |
72 | ||
73 | TRandom random; | |
74 | TDatime *datime = new TDatime(); | |
75 | Int_t time = datime->GetTime(); | |
76 | Int_t date = datime->GetDate(); | |
77 | Int_t pid = gSystem->GetPid(); | |
78 | delete datime; | |
79 | Int_t iseed = TMath::Abs(10000 * pid + time - date); | |
80 | ||
81 | Float_t tentLVv33=3.3, tentLVv48=48, tentLVi33=100, tentLVi48=10; | |
82 | Float_t sigmaLVv33=0.1, sigmaLVv48=1, sigmaLVi33=10, sigmaLVi48=2; | |
83 | ||
84 | Float_t tent=0, sigma=0, thr=0; | |
85 | Int_t NAliases=4; | |
86 | ||
87 | for(int nAlias=0;nAlias<NAliases;nAlias++) { | |
88 | ||
89 | TObjArray* valueSet = new TObjArray; | |
90 | valueSet->SetOwner(1); | |
91 | ||
92 | TString sindex; | |
93 | TString aliasName; | |
94 | if (nAlias==0){ | |
95 | aliasName = "tof_lv_i48_02"; | |
96 | tent=tentLVi48; | |
97 | sigma=sigmaLVi48; | |
98 | } | |
99 | else if (nAlias==1){ | |
100 | aliasName = "tof_lv_v48_02"; | |
101 | tent=tentLVv48; | |
102 | sigma=sigmaLVv48; | |
103 | } | |
104 | else if (nAlias==2){ | |
105 | aliasName = "tof_lv_i33_02"; | |
106 | tent=tentLVi33; | |
107 | sigma=sigmaLVi33; | |
108 | } | |
109 | else if (nAlias==3){ | |
110 | aliasName = "tof_lv_v33_02"; | |
111 | tent=tentLVv33; | |
112 | sigma=sigmaLVv33; | |
113 | } | |
114 | ||
115 | // gauss generation of values | |
116 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10){ | |
117 | Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma)); | |
118 | if (TMath::Abs(gaussvalue-tent)>sigma){ | |
119 | AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); | |
120 | valueSet->Add(dcsVal); | |
121 | } | |
122 | } | |
123 | ||
124 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
125 | } | |
126 | return aliasMap; | |
127 | ||
128 | } | |
129 | ||
130 | TMap* ReadDCSAliasMap() | |
131 | { | |
132 | // Open a file that contains DCS input data | |
133 | // The CDB framework is used to open the file, this means the file is located | |
134 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
135 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
136 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
137 | ||
138 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); | |
139 | return dynamic_cast<TMap*> (entry->GetObject()); | |
140 | } | |
141 | ||
142 | void WriteDCSAliasMap() | |
143 | { | |
144 | // This writes the output from CreateDCSAliasMap to a CDB file | |
145 | ||
146 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
147 | ||
148 | AliCDBMetaData metaData; | |
149 | metaData.SetBeamPeriod(0); | |
150 | metaData.SetResponsible("Chiara"); | |
151 | metaData.SetComment("Test object for TOFPreprocessorDCS.C"); | |
152 | ||
153 | AliCDBId id("TOF/DCS/Data", 0, 0); | |
154 | ||
155 | // initialize location of CDB | |
162637e4 | 156 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); |
4b9e7694 | 157 | |
158 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
159 | } |