1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /// \file MUONOfflineShift.C
20 /// \brief Macro to be used to check raw data during MUON offline shifts.
24 /// MUONOfflineShift("path_to_raw_file","basename of output file"); > log
26 /// (the redirection to an output log file is recommended as the output from
27 /// this macro might be quite long...)
29 /// This will read the raw data and process it several times, varying what's done :
30 /// only decoding, decoding + zero-suppression, etc... (TBE)
32 /// Two outputs files will be created :
34 /// - basename.root, containing AliMUONVTrackerData objects that can then
35 /// be displayed using the mchview program (using mchview --use basename.root)
37 /// - basename.log, containing (for the moment) the occupancy numbers of the various detection elements
39 /// \author Laurent Aphecetche
41 #if !defined(__CINT__) || defined(__MAKECINT__)
43 #include "AliCDBManager.h"
44 #include "AliCodeTimer.h"
45 #include "AliMUONPainterRegistry.h"
46 #include "AliMUONTrackerCalibratedDataMaker.h"
47 #include "AliMUONTrackerRawDataMaker.h"
48 #include "AliMUONVTrackerData.h"
50 #include "AliMpConstants.h"
51 #include "AliMpDEIterator.h"
52 #include "AliRawReader.h"
53 #include <Riostream.h>
56 #include <TStopwatch.h>
62 //______________________________________________________________________________
63 Int_t DataMakerReading(const char* input,
65 const char* cdbPath="",
66 const char* calibMode="",
67 Bool_t histogram=kFALSE,
69 Double_t xmax = 4096.0,
70 Bool_t fastDecoder=kFALSE)
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.
78 TString fileName(gSystem->ExpandPathName(input));
80 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
82 if (!rawReader) return 0;
84 AliMUONVTrackerDataMaker* dm(0x0);
86 if ( strlen(cdbPath) > 0 )
88 dm = new AliMUONTrackerCalibratedDataMaker(rawReader,cdbPath,calibMode,histogram,xmin,xmax);
92 dm = new AliMUONTrackerRawDataMaker(rawReader,histogram,fastDecoder);
95 AliMUONPainterRegistry::Instance()->Register(dm);
100 dm->SetRunning(kTRUE);
102 while (dm->NextEvent())
112 //______________________________________________________________________________
113 void Print(const char* method, TStopwatch& timer, Int_t n)
115 /// Get the timing for a given method
117 cout << Form("%20s %10d events. Total CPU time %7.2f seconds.",
118 method,n,timer.CpuTime());
120 Double_t cpu = timer.CpuTime()/n;
121 Double_t real = timer.RealTime()/n;
123 cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3)
127 //______________________________________________________________________________
128 void Occupancy(ostream& outfile)
130 /// Write occupancy numbers to output text file
132 outfile << "-----------------------------------------------------" << endl;
133 outfile << "Occupancy numbers" << endl;
134 outfile << "-----------------------------------------------------" << endl;
136 const Int_t occIndex = 2;
138 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
140 Int_t nofDataSources = reg->NumberOfDataSources();
142 outfile << Form("%11s|"," ");
144 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
146 AliMUONVTrackerData* data = reg->DataSource(ids);
147 outfile << Form(" %13s |",data->GetName());
152 for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId )
154 Bool_t nonZero(kFALSE);
155 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
157 if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE;
160 if ( !nonZero ) continue;
162 outfile << Form("Chamber %2d |",chamberId);
163 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
165 AliMUONVTrackerData* data = reg->DataSource(ids);
166 outfile << Form(" %7.2f %% |",100.0*data->Chamber(chamberId,occIndex));
174 Int_t detElemId = it.CurrentDEId();
175 Bool_t nonZero(kFALSE);
176 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
178 AliMUONVTrackerData* data = reg->DataSource(ids);
179 if ( data->DetectionElement(detElemId,occIndex) > 0 )
187 outfile << Form(" DE %04d |",detElemId);
188 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
190 AliMUONVTrackerData* data = reg->DataSource(ids);
191 outfile << Form(" %7.2f %% |",100.0*data->DetectionElement(detElemId,occIndex));
200 //______________________________________________________________________________
201 void MUONOfflineShift(const char* input="alien:///alice/data/2008/LHC08a/000021931/raw/08000021931001.50.root",
202 const char* outputBase="21931.001.50",
203 const char* ocdbPath="alien://folder=/alice/data/2008/LHC08a/OCDB")
205 /// Entry point of the macro.
206 /// Example of syntax for an input file (from alien)
208 /// alien::///alice/data/2007/LHC07w/000014493/raw/07000014493001.10.root
210 /// and for an OCDB path :
212 /// alien://folder=/alice/data/2007/LHC07w/OCDB
215 TGrid::Connect("alien://");
217 AliCodeTimer::Instance()->Reset();
219 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
220 AliCDBManager::Instance()->SetRun(0);
221 AliMpCDB::LoadDDLStore();
229 Int_t n0 = DataMakerReading(input,timer0,"","",kTRUE,0,0,kFALSE); // using old decoder
231 Int_t n1 = DataMakerReading(input,timer1,"","",kTRUE,0,0,kTRUE); // using new decoder
233 Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN",kTRUE);
235 Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA",kTRUE);
237 Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN",kTRUE);
239 Print("DataMakerReading(HRAW)",timer0,n0);
240 Print("DataMakerReading(HRAW)",timer1,n1);
241 Print("DataMakerReading(HCALZ)",timer2,n2);
242 Print("DataMakerReading(HCALG)",timer3,n3);
243 Print("DataMakerReading(HCALC)",timer4,n4);
245 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
247 TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE");
248 ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase)));
252 for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
254 AliMUONVTrackerData* data = reg->DataSource(i);
260 AliCodeTimer::Instance()->Print();