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.
22 /// You NEED an access to the Grid to run this macro.
26 /// MUONOfflineShift("path_to_raw_file","basename of output file"); > log
28 /// (the redirection to an output log file is recommended as the output from
29 /// this macro might be quite long...)
31 /// This will read the raw data and process it several times, varying what's done :
32 /// only decoding, decoding + zero-suppression, etc... (TBE)
34 /// Two outputs files will be created :
36 /// - basename.root, containing AliMUONVTrackerData objects that can then
37 /// be displayed using the mchview program (using mchview --use basename.root)
39 /// - basename.log, containing (for the moment) the occupancy numbers of the various detection elements
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...
45 /// \author Laurent Aphecetche
47 #if !defined(__CINT__) || defined(__MAKECINT__)
49 #include "AliCDBEntry.h"
50 #include "AliCDBManager.h"
51 #include "AliCodeTimer.h"
52 #include "AliMUONPainterRegistry.h"
53 #include "AliMUONRecoParam.h"
54 #include "AliMUONTrackerDataMaker.h"
55 #include "AliMUONVTrackerData.h"
57 #include "AliMpConstants.h"
58 #include "AliMpDEIterator.h"
59 #include "AliRawReader.h"
60 #include <Riostream.h>
63 #include <TStopwatch.h>
69 //______________________________________________________________________________
70 Int_t DataMakerReading(const char* input,
72 const char* cdbPath="",
73 const char* calibMode="",
74 Bool_t histogram=kFALSE,
76 Double_t xmax = 4096.0)
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.
84 TString fileName(gSystem->ExpandPathName(input));
86 AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
88 if (!rawReader) return 0;
90 AliMUONVTrackerDataMaker* dm(0x0);
92 AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
93 AliMUONRecoParam* recoParam(0x0);
95 if ( entry ) recoParam = static_cast<AliMUONRecoParam*>(entry->GetObject());
97 if ( strlen(cdbPath) > 0 )
99 dm = new AliMUONTrackerDataMaker(recoParam,rawReader,cdbPath,calibMode,histogram,xmin,xmax);
103 dm = new AliMUONTrackerDataMaker(rawReader,histogram);
106 AliMUONPainterRegistry::Instance()->Register(dm);
111 dm->SetRunning(kTRUE);
113 while (dm->NextEvent())
123 //______________________________________________________________________________
124 void Print(const char* method, TStopwatch& timer, Int_t n)
126 /// Get the timing for a given method
128 cout << Form("%20s %10d events. Total CPU time %7.2f seconds.",
129 method,n,timer.CpuTime());
131 Double_t cpu = timer.CpuTime()/n;
132 Double_t real = timer.RealTime()/n;
134 cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3)
138 //______________________________________________________________________________
139 void Occupancy(ostream& outfile)
141 /// Write occupancy numbers to output text file
143 outfile << "-----------------------------------------------------" << endl;
144 outfile << "Occupancy numbers" << endl;
145 outfile << "-----------------------------------------------------" << endl;
147 const Int_t occIndex = 2;
149 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
151 Int_t nofDataSources = reg->NumberOfDataSources();
153 outfile << Form("%11s|"," ");
155 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
157 AliMUONVTrackerData* data = reg->DataSource(ids);
158 outfile << Form(" %13s |",data->GetName());
163 for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId )
165 Bool_t nonZero(kFALSE);
166 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
168 if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE;
171 if ( !nonZero ) continue;
173 outfile << Form("Chamber %2d |",chamberId);
174 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
176 AliMUONVTrackerData* data = reg->DataSource(ids);
177 outfile << Form(" %7.2f %% |",100.0*data->Chamber(chamberId,occIndex));
185 Int_t detElemId = it.CurrentDEId();
186 Bool_t nonZero(kFALSE);
187 for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
189 AliMUONVTrackerData* data = reg->DataSource(ids);
190 if ( data->DetectionElement(detElemId,occIndex) > 0 )
198 outfile << Form(" DE %04d |",detElemId);
199 for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
201 AliMUONVTrackerData* data = reg->DataSource(ids);
202 outfile << Form(" %7.2f %% |",100.0*data->DetectionElement(detElemId,occIndex));
211 //______________________________________________________________________________
212 void MUONOfflineShift(const char* input="alien:///alice/data/2009/LHC09a/000067495/raw/09000067495031.10.root",
213 const char* outputBase="67495031.10",
214 const char* ocdbPath="alien://folder=/alice/data/2009/OCDB")
216 /// Entry point of the macro.
218 AliCodeTimer::Instance()->Reset();
220 TGrid::Connect("alien://");
222 AliRawReader* rawReader = AliRawReader::Create(input);
224 rawReader->NextEvent();
226 Int_t runNumber = rawReader->GetRunNumber();
230 AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
231 AliCDBManager::Instance()->SetRun(runNumber);
233 AliMpCDB::LoadDDLStore();
234 AliMpCDB::LoadManuStore();
241 Int_t n1 = DataMakerReading(input,timer1,"","",kTRUE,0,0);
243 Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN");
245 Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA");
247 Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN");
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);
269 AliCodeTimer::Instance()->Print();