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 "AliRawReaderDate.h"
54 #include "AliRawReaderRoot.h"
55 #include <Riostream.h>
58 #include <TStopwatch.h>
64 //______________________________________________________________________________
65 Int_t DataMakerReading(const char* input,
67 const char* cdbPath="",
68 const char* calibMode="",
69 Bool_t histogram=kFALSE,
71 Double_t xmax = 4096.0)
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.
79 TString fileName(gSystem->ExpandPathName(input));
81 AliRawReader* rawReader(0x0);
83 // check extention to choose the rawdata file format
84 if (fileName.EndsWith(".root"))
86 rawReader = new AliRawReaderRoot(fileName);
88 else if (!fileName.IsNull())
90 rawReader = new AliRawReaderDate(fileName); // DATE file
93 if (!rawReader) return 0;
95 AliMUONVTrackerDataMaker* dm(0x0);
97 if ( strlen(cdbPath) > 0 )
99 dm = new AliMUONTrackerCalibratedDataMaker(rawReader,cdbPath,calibMode,histogram,xmin,xmax);
103 dm = new AliMUONTrackerRawDataMaker(rawReader,kTRUE);
106 AliMUONPainterRegistry::Instance()->Register(dm);
111 dm->SetRunning(kTRUE);
113 while (dm->NextEvent())
125 //______________________________________________________________________________
126 void Print(const char* method, TStopwatch& timer, Int_t n)
128 /// Get the timing for a given method
130 cout << Form("%20s %10d events. Total CPU time %7.2f seconds.",
131 method,n,timer.CpuTime());
133 Double_t cpu = timer.CpuTime()/n;
134 Double_t real = timer.RealTime()/n;
136 cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3)
140 //______________________________________________________________________________
141 void Occupancy(ostream& outfile)
143 /// Write occupancy numbers to output text file
145 outfile << "-----------------------------------------------------" << endl;
146 outfile << "Occupancy numbers" << endl;
147 outfile << "-----------------------------------------------------" << endl;
149 const Int_t occIndex = 2;
151 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
153 Int_t nofDataSources = reg->NumberOfDataSources();
155 outfile << Form("%11s|"," ");
157 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
159 AliMUONVTrackerData* data = reg->DataSource(ids);
160 outfile << Form(" %13s |",data->GetName());
165 for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId )
167 Bool_t nonZero(kFALSE);
168 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
170 if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE;
173 if ( !nonZero ) continue;
175 outfile << Form("Chamber %2d |",chamberId);
176 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
178 AliMUONVTrackerData* data = reg->DataSource(ids);
179 outfile << Form(" %7.2f %% |",100.0*data->Chamber(chamberId,occIndex));
187 Int_t detElemId = it.CurrentDEId();
188 Bool_t nonZero(kFALSE);
189 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
191 AliMUONVTrackerData* data = reg->DataSource(ids);
192 if ( data->DetectionElement(detElemId,occIndex) > 0 )
200 outfile << Form(" DE %04d |",detElemId);
201 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
203 AliMUONVTrackerData* data = reg->DataSource(ids);
204 outfile << Form(" %7.2f %% |",100.0*data->DetectionElement(detElemId,occIndex));
213 //______________________________________________________________________________
214 void MUONOfflineShift(const char* input="alien:///alice/data/2008/LHC08a/000021931/raw/08000021931001.50.root",
215 const char* outputBase="21931.001.50",
216 const char* ocdbPath="alien://folder=/alice/data/2008/LHC08a/OCDB")
218 /// Entry point of the macro.
219 /// Example of syntax for an input file (from alien)
221 /// alien::///alice/data/2007/LHC07w/000014493/raw/07000014493001.10.root
223 /// and for an OCDB path :
225 /// alien://folder=/alice/data/2007/LHC07w/OCDB
228 TGrid::Connect("alien://");
230 AliCodeTimer::Instance()->Reset();
232 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
233 AliCDBManager::Instance()->SetRun(0);
234 AliMpCDB::LoadDDLStore();
241 Int_t n1 = DataMakerReading(input,timer1);
243 Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN",kTRUE);
245 Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA",kTRUE);
247 Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN",kTRUE);
249 Print("DataMakerReading(HRAW)",timer1,n1);
250 Print("DataMakerReading(HCALZ)",timer2,n2);
251 Print("DataMakerReading(HCALG)",timer3,n3);
252 Print("DataMakerReading(HCALC)",timer4,n4);
254 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
256 TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE");
257 ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase)));
261 for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
263 AliMUONVTrackerData* data = reg->DataSource(i);