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