AliRoot Core  edcc906 (edcc906)
MUONOfflineShift.C
Go to the documentation of this file.
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 
46 
47 #if !defined(__CINT__) || defined(__MAKECINT__)
48 
49 #include "AliCDBManager.h"
50 #include "AliCodeTimer.h"
51 #include "AliMUONCDB.h"
53 #include "AliMUONRecoParam.h"
55 #include "AliMUONVTrackerData.h"
56 #include "AliMpCDB.h"
57 #include "AliMpConstants.h"
58 #include "AliMpDEIterator.h"
59 #include "AliRawReader.h"
60 #include <Riostream.h>
61 #include <TFile.h>
62 #include <TGrid.h>
63 #include <TStopwatch.h>
64 #include <TString.h>
65 #include <TSystem.h>
66 
67 #endif
68 
69 //______________________________________________________________________________
70 Int_t DataMakerReading(const char* input,
71  TStopwatch& timer,
72  const char* cdbPath="",
73  Bool_t histogram=kFALSE,
74  Double_t xmin = 0.0,
75  Double_t xmax = 4096.0)
76 {
78 
79  TString fileName(gSystem->ExpandPathName(input));
80 
81  AliRawReader* rawReader = AliRawReader::Create(fileName.Data());
82 
83  if (!rawReader) return 0;
84 
85  AliMUONVTrackerDataMaker* dm(0x0);
86 
88  if (!recoParam) return 0;
89 
90  if ( strlen(cdbPath) > 0 )
91  {
92  dm = new AliMUONTrackerDataMaker(recoParam,rawReader,cdbPath,histogram,xmin,xmax);
93  }
94  else
95  {
96  dm = new AliMUONTrackerDataMaker(rawReader,histogram);
97  }
98 
100 
101  timer.Start(kTRUE);
102  Int_t n(0);
103 
104  dm->SetRunning(kTRUE);
105 
106  while (dm->NextEvent())
107  {
108  ++n;
109  }
110 
111  timer.Stop();
112 
113  return n;
114 }
115 
116 //______________________________________________________________________________
117 void Print(const char* method, TStopwatch& timer, Int_t n)
118 {
120 
121  cout << Form("%20s %10d events. Total CPU time %7.2f seconds.",
122  method,n,timer.CpuTime());
123 
124  Double_t cpu = timer.CpuTime()/n;
125  Double_t real = timer.RealTime()/n;
126 
127  cout << Form(" ms real/event = %7.2f ms CPU/event = %7.2f",real*1E3,cpu*1E3)
128  << endl;
129 }
130 
131 //______________________________________________________________________________
132 void Occupancy(ostream& outfile)
133 {
135 
136  outfile << "-----------------------------------------------------" << endl;
137  outfile << "Occupancy numbers" << endl;
138  outfile << "-----------------------------------------------------" << endl;
139 
140  const Int_t occIndex = 2;
141 
143 
144  Int_t nofDataSources = reg->NumberOfDataSources();
145 
146  outfile << Form("%11s|"," ");
147 
148  for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
149  {
150  AliMUONVTrackerData* data = reg->DataSource(ids);
151  outfile << Form(" %13s |",data->GetName());
152  }
153 
154  outfile << endl;
155 
156  for ( Int_t chamberId = 0; chamberId < AliMpConstants::NofTrackingChambers(); ++chamberId )
157  {
158  Bool_t nonZero(kFALSE);
159  for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
160  {
161  if ( reg->DataSource(ids)->Chamber(chamberId,occIndex) ) nonZero = kTRUE;
162  }
163 
164  if ( !nonZero ) continue;
165 
166  outfile << Form("Chamber %2d |",chamberId);
167  for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
168  {
169  AliMUONVTrackerData* data = reg->DataSource(ids);
170  outfile << Form(" %7.2f %% |",100.0*data->Chamber(chamberId,occIndex));
171  }
172  outfile << endl;
173 
174  AliMpDEIterator it;
175  it.First(chamberId);
176  while (!it.IsDone())
177  {
178  Int_t detElemId = it.CurrentDEId();
179  Bool_t nonZero(kFALSE);
180  for ( Int_t ids = 0; ids < nofDataSources && nonZero == kFALSE; ++ ids )
181  {
182  AliMUONVTrackerData* data = reg->DataSource(ids);
183  if ( data->DetectionElement(detElemId,occIndex) > 0 )
184  {
185  nonZero = kTRUE;
186  }
187  }
188 
189  if ( nonZero )
190  {
191  outfile << Form(" DE %04d |",detElemId);
192  for ( Int_t ids = 0; ids < nofDataSources; ++ ids )
193  {
194  AliMUONVTrackerData* data = reg->DataSource(ids);
195  outfile << Form(" %7.2f %% |",100.0*data->DetectionElement(detElemId,occIndex));
196  }
197  outfile << endl;
198  }
199  it.Next();
200  }
201  }
202 }
203 
204 //______________________________________________________________________________
205 void MUONOfflineShift(const char* input="alien:///alice/data/2009/LHC09a/000067495/raw/09000067495031.10.root",
206  const char* outputBase="67495031.10",
207  const char* ocdbPath="alien://folder=/alice/data/2009/OCDB")
208 {
210 
212 
213  TGrid::Connect("alien://");
214 
215  AliRawReader* rawReader = AliRawReader::Create(input);
216 
217  rawReader->NextEvent();
218 
219  Int_t runNumber = rawReader->GetRunNumber();
220 
221  delete rawReader;
222 
224  AliCDBManager::Instance()->SetRun(runNumber);
225 
226  if (!AliMUONCDB::LoadMapping()) return;
227 
228  TStopwatch timer1;
229  TStopwatch timer2;
230  TStopwatch timer3;
231  TStopwatch timer4;
232  TStopwatch timer5;
233 
234  Int_t n1 = DataMakerReading(input,timer1,"","",kTRUE,0,0);
235 
236  Int_t n2 = DataMakerReading(input,timer2,ocdbPath,"NOGAIN");
237 
238  Int_t n3 = DataMakerReading(input,timer3,ocdbPath,"GAINCONSTANTCAPA");
239 
240  Int_t n4 = DataMakerReading(input,timer4,ocdbPath,"GAIN");
241 
242  Int_t n5 = DataMakerReading(input,timer5,ocdbPath,"INJECTIONGAIN");
243 
244  Print("DataMakerReading(HRAW)",timer1,n1);
245  Print("DataMakerReading(HCALZ)",timer2,n2);
246  Print("DataMakerReading(HCALG)",timer3,n3);
247  Print("DataMakerReading(HCALC)",timer4,n4);
248  Print("DataMakerReading(HCALE)",timer5,n5);
249 
251 
252  TFile f(gSystem->ExpandPathName(Form("%s.root",outputBase)),"RECREATE");
253  ofstream out(gSystem->ExpandPathName(Form("%s.log",outputBase)));
254 
255  Occupancy(out);
256 
257  for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
258  {
259  AliMUONVTrackerData* data = reg->DataSource(i);
260  data->Write();
261  }
262 
263  f.Close();
264 
266 
267 }
AliMUONVTrackerData * DataSource(Int_t i) const
virtual Double_t DetectionElement(Int_t detElemId, Int_t dim=0) const =0
Get the value for a given DE and given dimension.
The iterator over detection elements.
void Print(Option_t *opt="") const
Print the list of timers we manage.
virtual Double_t Chamber(Int_t chamberId, Int_t dim=0) const =0
Get the value for a given chamber and given dimension.
TStopwatch timer
Definition: kNNSpeed.C:15
Bool_t IsDone() const
Producer of some AliMUONVTrackerData.
Int_t NumberOfDataSources() const
Number of data sources = data makers.
Int_t CurrentDEId() const
Class with MUON reconstruction parameters.
Bool_t LoadMapping(Bool_t segmentationOnly)
Definition: AliMUONCDB.cxx:502
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
void Print(const char *method, TStopwatch &timer, Int_t n)
void Register(AliMUONVTrackerDataMaker *reader)
static AliMUONPainterDataRegistry * Instance()
Registry for painter data sources.
void MUONOfflineShift(const char *input="alien:///alice/data/2009/LHC09a/000067495/raw/09000067495031.10.root", const char *outputBase="67495031.10", const char *ocdbPath="alien://folder=/alice/data/2009/OCDB")
void Occupancy(ostream &outfile)
virtual Bool_t NextEvent()
Advance to next event and process it (no effect if not runnable)
static AliCodeTimer * Instance()
Unique instance of this class, which is a singleton.
void SetRun(Int_t run)
TF1 * f
Definition: interpolTest.C:21
void Reset()
Reset all our timers.
void SetDefaultStorage(const char *dbString)
Implementation of VTrackerDataMaker to read raw data.
virtual void SetRunning(Bool_t flag)=0
Set the running state (no effect if not runnable)
static Int_t runNumber
Definition: pdc06_config.C:126
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
static Int_t NofTrackingChambers()
Return number of tracking chambers.
AliMUONRecoParam * LoadRecoParam()
Definition: AliMUONCDB.cxx:535
Int_t DataMakerReading(const char *input, TStopwatch &timer, const char *cdbPath="", Bool_t histogram=kFALSE, Double_t xmin=0.0, Double_t xmax=4096.0)