]>
Commit | Line | Data |
---|---|---|
10eb3d17 | 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 | /* $Id$ */ | |
17 | ||
18 | /// \ingroup macros | |
19 | /// \file MUONOfflineShift.C | |
20 | /// \brief Macro to be used to check raw data during MUON offline shifts. | |
21 | /// | |
5cb10b53 | 22 | /// You NEED an access to the Grid to run this macro. |
23 | /// | |
10eb3d17 | 24 | /// Basic usage is : |
25 | /// | |
3b6f7dce | 26 | /// MUONOfflineShift("path_to_raw_file","basename of output file"); > log |
27 | /// | |
28 | /// (the redirection to an output log file is recommended as the output from | |
29 | /// this macro might be quite long...) | |
10eb3d17 | 30 | /// |
31 | /// This will read the raw data and process it several times, varying what's done : | |
32 | /// only decoding, decoding + zero-suppression, etc... (TBE) | |
33 | /// | |
34 | /// Two outputs files will be created : | |
35 | /// | |
36 | /// - basename.root, containing AliMUONVTrackerData objects that can then | |
37 | /// be displayed using the mchview program (using mchview --use basename.root) | |
38 | /// | |
39 | /// - basename.log, containing (for the moment) the occupancy numbers of the various detection elements | |
40 | /// | |
5cb10b53 | 41 | /// Unless you really know what you're doing, please use this macro together with |
42 | /// the grid OCDB (i.e. don't set it to a local OCDB). There are now a lot of things | |
43 | /// that are grabbed from the OCDB that are run dependent... | |
44 | /// | |
10eb3d17 | 45 | /// \author Laurent Aphecetche |
46 | ||
47 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
48 | ||
49 | #include "AliCDBManager.h" | |
50 | #include "AliCodeTimer.h" | |
a99c3449 | 51 | #include "AliMUONCDB.h" |
66cdf5b3 | 52 | #include "AliMUONPainterDataRegistry.h" |
5cb10b53 | 53 | #include "AliMUONRecoParam.h" |
b6f591ae | 54 | #include "AliMUONTrackerDataMaker.h" |
10eb3d17 | 55 | #include "AliMUONVTrackerData.h" |
56 | #include "AliMpCDB.h" | |
57 | #include "AliMpConstants.h" | |
58 | #include "AliMpDEIterator.h" | |
59 | #include "AliRawReader.h" | |
10eb3d17 | 60 | #include <Riostream.h> |
61 | #include <TFile.h> | |
62 | #include <TGrid.h> | |
63 | #include <TStopwatch.h> | |
64 | #include <TString.h> | |
65 | #include <TSystem.h> | |
66 | ||
67 | #endif | |
68 | ||
69 | //______________________________________________________________________________ | |
3b6f7dce | 70 | Int_t DataMakerReading(const char* input, |
10eb3d17 | 71 | TStopwatch& timer, |
72 | const char* cdbPath="", | |
73 | const char* calibMode="", | |
74 | Bool_t histogram=kFALSE, | |
75 | Double_t xmin = 0.0, | |
5cb10b53 | 76 | Double_t xmax = 4096.0) |
10eb3d17 | 77 | { |
78 | /// Run over the data and calibrate it if so required (if cdbPath != "") | |
79 | /// calibMode can be : | |
80 | /// - NOGAIN : only zero-suppression will be done | |
81 | /// - GAINCONSTANTCAPA : zero-suppression + gain, but with a single capa value for all channels | |
82 | /// - GAIN : zero-suppression + gain w/ individual capacitance per channel. | |
83 | ||
3b6f7dce | 84 | TString fileName(gSystem->ExpandPathName(input)); |
85 | ||
ce22afdc | 86 | AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); |
3b6f7dce | 87 | |
88 | if (!rawReader) return 0; | |
10eb3d17 | 89 | |
90 | AliMUONVTrackerDataMaker* dm(0x0); | |
91 | ||
a99c3449 | 92 | AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam(); |
93 | if (!recoParam) return 0; | |
5cb10b53 | 94 | |
10eb3d17 | 95 | if ( strlen(cdbPath) > 0 ) |
96 | { | |
5cb10b53 | 97 | dm = new AliMUONTrackerDataMaker(recoParam,rawReader,cdbPath,calibMode,histogram,xmin,xmax); |
10eb3d17 | 98 | } |
99 | else | |
100 | { | |
5cb10b53 | 101 | dm = new AliMUONTrackerDataMaker(rawReader,histogram); |
10eb3d17 | 102 | } |
103 | ||
66cdf5b3 | 104 | AliMUONPainterDataRegistry::Instance()->Register(dm); |
10eb3d17 | 105 | |
106 | timer.Start(kTRUE); | |
107 | Int_t n(0); | |
108 | ||
109 | dm->SetRunning(kTRUE); | |
110 | ||
111 | while (dm->NextEvent()) | |
112 | { | |
113 | ++n; | |
114 | } | |
115 | ||
116 | timer.Stop(); | |
117 | ||
10eb3d17 | 118 | return n; |
119 | } | |
120 | ||
121 | //______________________________________________________________________________ | |
122 | void Print(const char* method, TStopwatch& timer, Int_t n) | |
123 | { | |
124 | /// Get the timing for a given method | |
125 | ||
126 | cout << Form("%20s %10d events. Total CPU time %7.2f seconds.", | |
127 | method,n,timer.CpuTime()); | |
128 | ||
129 | Double_t cpu = timer.CpuTime()/n; | |
130 | Double_t real = timer.RealTime()/n; | |
131 | ||
132 | cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3) | |
133 | << endl; | |
134 | } | |
135 | ||
136 | //______________________________________________________________________________ | |
137 | void Occupancy(ostream& outfile) | |
138 | { | |
139 | /// Write occupancy numbers to output text file | |
140 | ||
141 | outfile << "-----------------------------------------------------" << endl; | |
142 | outfile << "Occupancy numbers" << endl; | |
143 | outfile << "-----------------------------------------------------" << endl; | |
144 | ||
145 | const Int_t occIndex = 2; | |
146 | ||
66cdf5b3 | 147 | AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance(); |
10eb3d17 | 148 | |
149 | Int_t nofDataSources = reg->NumberOfDataSources(); | |
150 | ||
151 | outfile << Form("%11s|"," "); | |
152 | ||
153 | for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) | |
154 | { | |
155 | AliMUONVTrackerData* data = reg->DataSource(ids); | |
156 | outfile << Form(" %13s |",data->GetName()); | |
157 | } | |
158 | ||
159 | outfile << endl; | |
160 | ||
161 | for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId ) | |
162 | { | |
163 | Bool_t nonZero(kFALSE); | |
164 | for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids ) | |
165 | { | |
166 | if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE; | |
167 | } | |
168 | ||
169 | if ( !nonZero ) continue; | |
170 | ||
171 | outfile << Form("Chamber %2d |",chamberId); | |
172 | for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) | |
173 | { | |
174 | AliMUONVTrackerData* data = reg->DataSource(ids); | |
175 | outfile << Form(" %7.2f %% |",100.0*data->Chamber(chamberId,occIndex)); | |
176 | } | |
177 | outfile << endl; | |
178 | ||
179 | AliMpDEIterator it; | |
180 | it.First(chamberId); | |
181 | while (!it.IsDone()) | |
182 | { | |
183 | Int_t detElemId = it.CurrentDEId(); | |
184 | Bool_t nonZero(kFALSE); | |
185 | for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids ) | |
186 | { | |
187 | AliMUONVTrackerData* data = reg->DataSource(ids); | |
188 | if ( data->DetectionElement(detElemId,occIndex) > 0 ) | |
189 | { | |
190 | nonZero = kTRUE; | |
191 | } | |
192 | } | |
193 | ||
194 | if ( nonZero ) | |
195 | { | |
196 | outfile << Form(" DE %04d |",detElemId); | |
197 | for ( Int_t ids = 0; ids < nofDataSources; ++ ids ) | |
198 | { | |
199 | AliMUONVTrackerData* data = reg->DataSource(ids); | |
200 | outfile << Form(" %7.2f %% |",100.0*data->DetectionElement(detElemId,occIndex)); | |
201 | } | |
202 | outfile << endl; | |
203 | } | |
204 | it.Next(); | |
205 | } | |
206 | } | |
207 | } | |
208 | ||
209 | //______________________________________________________________________________ | |
5cb10b53 | 210 | void MUONOfflineShift(const char* input="alien:///alice/data/2009/LHC09a/000067495/raw/09000067495031.10.root", |
211 | const char* outputBase="67495031.10", | |
212 | const char* ocdbPath="alien://folder=/alice/data/2009/OCDB") | |
10eb3d17 | 213 | { |
214 | /// Entry point of the macro. | |
10eb3d17 | 215 | |
5cb10b53 | 216 | AliCodeTimer::Instance()->Reset(); |
217 | ||
10eb3d17 | 218 | TGrid::Connect("alien://"); |
219 | ||
5cb10b53 | 220 | AliRawReader* rawReader = AliRawReader::Create(input); |
221 | ||
222 | rawReader->NextEvent(); | |
223 | ||
224 | Int_t runNumber = rawReader->GetRunNumber(); | |
225 | ||
226 | delete rawReader; | |
10eb3d17 | 227 | |
5cb10b53 | 228 | AliCDBManager::Instance()->SetDefaultStorage(ocdbPath); |
229 | AliCDBManager::Instance()->SetRun(runNumber); | |
230 | ||
a99c3449 | 231 | if (!AliMUONCDB::LoadMapping()) return; |
10eb3d17 | 232 | |
3b6f7dce | 233 | TStopwatch timer1; |
10eb3d17 | 234 | TStopwatch timer2; |
235 | TStopwatch timer3; | |
3b6f7dce | 236 | TStopwatch timer4; |
66cdf5b3 | 237 | TStopwatch timer5; |
10eb3d17 | 238 | |
5cb10b53 | 239 | Int_t n1 = DataMakerReading(input,timer1,"","",kTRUE,0,0); |
ce22afdc | 240 | |
5cb10b53 | 241 | Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN"); |
3b6f7dce | 242 | |
5cb10b53 | 243 | Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA"); |
3b6f7dce | 244 | |
5cb10b53 | 245 | Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN"); |
3b6f7dce | 246 | |
66cdf5b3 | 247 | Int_t n5 = DataMakerReading(input,timer5,ocdbPath,"INJECTIONGAIN"); |
248 | ||
3b6f7dce | 249 | Print("DataMakerReading(HRAW)",timer1,n1); |
250 | Print("DataMakerReading(HCALZ)",timer2,n2); | |
251 | Print("DataMakerReading(HCALG)",timer3,n3); | |
252 | Print("DataMakerReading(HCALC)",timer4,n4); | |
66cdf5b3 | 253 | Print("DataMakerReading(HCALE)",timer5,n5); |
10eb3d17 | 254 | |
66cdf5b3 | 255 | AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance(); |
10eb3d17 | 256 | |
257 | TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE"); | |
258 | ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase))); | |
259 | ||
260 | Occupancy(out); | |
261 | ||
262 | for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i ) | |
263 | { | |
264 | AliMUONVTrackerData* data = reg->DataSource(i); | |
265 | data->Write(); | |
266 | } | |
267 | ||
268 | f.Close(); | |
269 | ||
ce22afdc | 270 | AliCodeTimer::Instance()->Print(); |
271 | ||
10eb3d17 | 272 | } |