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