Shows the DCS aliasname in case source is HV
[u/mrichter/AliRoot.git] / MUON / AliMUONCDB.cxx
CommitLineData
de01cdf0 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
3d1463c8 18//-----------------------------------------------------------------------------
a99c3449 19/// \namespace AliMUONCDB
de01cdf0 20///
a99c3449 21/// Helper functions to experience the OCDB
22///
23/// They allow to read magnetic field, mapping and recoParam from OCDB
24///
25/// And also to generate dummy (but complete) containers for all the
de01cdf0 26/// calibration data types we have for tracker and trigger, and to write
27/// them into OCDB.
28///
a99c3449 29/// For more information, please see READMEcalib
de01cdf0 30///
baf1a7a0 31/// \author Laurent Aphecetche
3d1463c8 32//-----------------------------------------------------------------------------
de01cdf0 33
34#include "AliMUONCDB.h"
35
de01cdf0 36#include "AliMUON1DArray.h"
37#include "AliMUON1DMap.h"
38#include "AliMUON2DMap.h"
39#include "AliMUON2DStoreValidator.h"
7eafe398 40#include "AliMUONCalibParamND.h"
de01cdf0 41#include "AliMUONCalibParamNF.h"
42#include "AliMUONCalibParamNI.h"
207947f7 43#include "AliMUONCalibrationData.h"
de01cdf0 44#include "AliMUONConstants.h"
207947f7 45#include "AliMUONGlobalCrateConfig.h"
46#include "AliMUONPadStatusMaker.h"
47#include "AliMUONPadStatusMapMaker.h"
48#include "AliMUONRecoParam.h"
49#include "AliMUONRegionalTriggerConfig.h"
0045b488 50#include "AliMUONRejectList.h"
9e7c4517 51#include "AliMUONTrackerData.h"
49419555 52#include "AliMUONTrackerIO.h"
de01cdf0 53#include "AliMUONTriggerEfficiencyCells.h"
54#include "AliMUONTriggerLut.h"
de01cdf0 55#include "AliMUONVCalibParam.h"
56#include "AliMUONVCalibParam.h"
207947f7 57#include "AliMUONVStore.h"
58
25e1df3e 59#include "AliMpCDB.h"
a0eca509 60#include "AliMpConstants.h"
a99c3449 61#include "AliMpDEStore.h"
de01cdf0 62#include "AliMpDDLStore.h"
ab167304 63#include "AliMpManuStore.h"
de01cdf0 64#include "AliMpDEManager.h"
65#include "AliMpDetElement.h"
92c23b09 66#include "AliMpFiles.h"
49e110ec 67#include "AliMpDCSNamer.h"
409de10f 68#include "AliMpManuIterator.h"
de01cdf0 69#include "AliMpSegmentation.h"
70#include "AliMpStationType.h"
71#include "AliMpVSegmentation.h"
92e36663 72
73#include "AliCodeTimer.h"
74#include "AliCDBEntry.h"
75#include "AliCDBManager.h"
a99c3449 76#include "AliGRPManager.h"
92e36663 77#include "AliDCSValue.h"
78#include "AliLog.h"
a31df857 79#include "AliMpBusPatch.h"
92e36663 80
de01cdf0 81#include <Riostream.h>
82#include <TArrayI.h>
83#include <TClass.h>
9e7c4517 84#include <TFile.h>
de01cdf0 85#include <TH1F.h>
86#include <TList.h>
87#include <TMap.h>
88#include <TObjString.h>
89#include <TROOT.h>
90#include <TRandom.h>
91#include <TStopwatch.h>
92#include <TSystem.h>
cf27231a 93#include <TMath.h>
a99c3449 94#include <TGeoGlobalMagField.h>
73d3aca5 95#include <TClonesArray.h>
a31df857 96#include <sstream>
9e7c4517 97#include <set>
c05673c9 98
de01cdf0 99namespace
100{
409de10f 101 //_____________________________________________________________________________
102AliMUONVStore* Create2DMap()
103{
104 return new AliMUON2DMap(true);
105}
106
107 //_____________________________________________________________________________
046e5fd4 108void getBoundaries(const AliMUONVStore& store, Int_t dim,
109 Float_t* xmin, Float_t* xmax)
de01cdf0 110{
046e5fd4 111 /// Assuming the store contains AliMUONVCalibParam objects, compute the
112 /// limits of the value contained in the VCalibParam, for each of its dimensions
113 /// xmin and xmax must be of dimension dim
114
115 for ( Int_t i = 0; i < dim; ++i )
116 {
117 xmin[i]=1E30;
118 xmax[i]=-1E30;
119 }
de01cdf0 120
a0eca509 121 TIter next(store.CreateIterator());
122 AliMUONVCalibParam* value;
de01cdf0 123
a0eca509 124 while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
de01cdf0 125 {
a0eca509 126 Int_t detElemId = value->ID0();
127 Int_t manuId = value->ID1();
de01cdf0 128
129 const AliMpVSegmentation* seg =
130 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
131
132 for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
133 {
168e9c4d 134 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
de01cdf0 135 if (!pad.IsValid()) continue;
136
046e5fd4 137 for ( Int_t i = 0; i < dim; ++i )
de01cdf0 138 {
046e5fd4 139 Float_t x0 = value->ValueAsFloat(manuChannel,i);
140
141 xmin[i] = TMath::Min(xmin[i],x0);
142 xmax[i] = TMath::Max(xmax[i],x0);
de01cdf0 143 }
144 }
046e5fd4 145 }
146
147 for ( Int_t i = 0; i < dim; ++i )
148 {
149 if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 )
150 {
151 xmin[i] -= 1;
152 xmax[i] += 1;
153 }
154 }
de01cdf0 155}
156
cf27231a 157//_____________________________________________________________________________
158Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
159{
160 Double_t x(-1);
161 if ( mustBePositive )
162 {
163 while ( x < 0 )
164 {
165 x = gRandom->Gaus(mean,sigma);
166 }
167 }
168 else
169 {
170 x = gRandom->Gaus(mean,sigma);
171 }
172 return x;
173}
174
de01cdf0 175}
176
177//_____________________________________________________________________________
a99c3449 178Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
de01cdf0 179{
a99c3449 180 /// Check that OCDB path and run number are properly set
181
182 AliCDBManager* man = AliCDBManager::Instance();
183
184 // first OCDB path
185 if (!man->IsDefaultStorageSet()) {
186 AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set");
187 return kFALSE;
188 }
189
190 // then run number if required
191 if (pathOnly) return kTRUE;
192 if (man->GetRun() < 0) {
193 AliErrorGeneral("AliMUONCDB", "Run number must be properly set");
194 return kFALSE;
195 }
196
197 return kTRUE;
198
199}
200
201//_____________________________________________________________________________
202Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
203{
204 /// Check that the mapping has been loaded
205
206 // first the segmentation
207 if (!AliMpSegmentation::Instance(false)) {
208 AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first");
209 return kFALSE;
210 }
211
212 // then the others if required
213 if (segmentationOnly) return kTRUE;
214 if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) {
215 AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first");
216 return kFALSE;
217 }
218
219 return kTRUE;
220
221}
222
223//_____________________________________________________________________________
224Bool_t AliMUONCDB::LoadField()
225{
226 /// Load magnetic field (existing field will be deleted).
227 /// OCDB path and run number are supposed to be set.
228
229 AliInfoGeneral("AliMUONCDB","Loading field map from GRP...");
230
231 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
232
233 AliGRPManager grpMan;
234
235 // make sure the old field is deleted even if it is locked
236 if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance();
237
238 if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) {
239 AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB");
240 return kFALSE;
241 }
242
243 return kTRUE;
244
245}
ab167304 246
a99c3449 247//_____________________________________________________________________________
248Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly)
249{
250 /// Load mapping (existing mapping will be unloaded).
251 /// OCDB path and run number are supposed to be set.
252
253 AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB...");
254
255 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
256
257 // in case it has already been set
258 AliMpCDB::UnloadAll();
259
260 if (segmentationOnly) {
261
262 if (!AliMpCDB::LoadMpSegmentation(kTRUE)){
263 AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB");
264 return kFALSE;
265 }
266
267 } else {
268
269 if (!AliMpCDB::LoadAll(kTRUE)) {
270 AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB");
271 return kFALSE;
ab167304 272 }
a99c3449 273
274 }
275
276 return kTRUE;
277
de01cdf0 278}
279
280//_____________________________________________________________________________
a99c3449 281AliMUONRecoParam* AliMUONCDB::LoadRecoParam()
de01cdf0 282{
a99c3449 283 /// Load and return reconstruction parameters.
284 /// OCDB path is supposed to be set.
285
286 AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
287
288 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
289
290 AliMUONRecoParam* recoParam = 0x0;
291 AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
292
293 if(entry) {
294
295 // load recoParam according OCDB content (single or array)
296 if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
297
298 TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
299
300 for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
301 recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
302 if (recoParam->IsDefault()) break;
303 recoParam = 0x0;
304 }
305
306 }
307
308 }
309
310 if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
311
312 return recoParam;
313
a0eca509 314}
315
316//_____________________________________________________________________________
73d3aca5 317TClonesArray* AliMUONCDB::LoadAlignmentData()
318{
319 /// Load and return the array of alignment objects.
320
321 AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB...");
322
323 if (!AliMUONCDB::CheckOCDB()) return kFALSE;
324
325 TClonesArray* alignmentArray = 0x0;
326 AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data");
327
328 if (entry) {
329 // load alignement array
330 alignmentArray = dynamic_cast<TClonesArray*>(entry->GetObject());
331 }
332
333 if (!alignmentArray) {
334 AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB");
335 }
336
337 return alignmentArray;
338}
339
340//_____________________________________________________________________________
a0eca509 341AliMUONVStore*
342AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2,
de01cdf0 343 const char* opt)
344{
345 /// creates a store which contains store1-store2
346 /// if opt="abs" the difference is absolute one,
347 /// if opt="rel" then what is stored is (store1-store2)/store1
046e5fd4 348 /// if opt="percent" then what is stored is rel*100
349 ///
de01cdf0 350 /// WARNING Works only for stores which holds AliMUONVCalibParam objects
351
352 TString sopt(opt);
353 sopt.ToUpper();
354
046e5fd4 355 if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
de01cdf0 356 {
a99c3449 357 AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
de01cdf0 358 return 0x0;
359 }
360
a0eca509 361 AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone());
de01cdf0 362
a0eca509 363 TIter next(d->CreateIterator());
de01cdf0 364
a0eca509 365 AliMUONVCalibParam* param;
de01cdf0 366
a0eca509 367 while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
de01cdf0 368 {
a0eca509 369 Int_t detElemId = param->ID0();
370 Int_t manuId = param->ID1();
de01cdf0 371
a0eca509 372 AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
de01cdf0 373 //FIXME: this might happen. Handle it.
374 if (!param2)
375 {
376 cerr << "param2 is null : FIXME : this might happen !" << endl;
377 delete d;
378 return 0;
379 }
380
381 for ( Int_t i = 0; i < param->Size(); ++i )
382 {
383 for ( Int_t j = 0; j < param->Dimension(); ++j )
384 {
385 Float_t value(0);
386 if ( sopt.Contains("ABS") )
387 {
388 value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j);
389 }
046e5fd4 390 else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") )
de01cdf0 391 {
392 if ( param->ValueAsFloat(i,j) )
393 {
394 value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j);
395 }
396 else
397 {
398 continue;
399 }
046e5fd4 400 if ( sopt.Contains("PERCENT") ) value *= 100.0;
de01cdf0 401 }
402 param->SetValueAsFloat(i,j,value);
403 }
404 }
de01cdf0 405 }
406 return d;
407}
408
409//_____________________________________________________________________________
410void
a0eca509 411AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
de01cdf0 412{
046e5fd4 413 /// Make histograms of each dimension of the AliMUONVCalibParam
de01cdf0 414 /// contained inside store.
415 /// It produces histograms named name_0, name_1, etc...
416
a99c3449 417 if (!AliMUONCDB::CheckMapping(kTRUE)) return;
418
046e5fd4 419 TIter next(store.CreateIterator());
420 AliMUONVCalibParam* param;
de01cdf0 421 Int_t n(0);
046e5fd4 422 const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2;
423 Int_t* nPerStation = new Int_t[kNStations];
424 TH1** h(0x0);
de01cdf0 425
046e5fd4 426 for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0;
de01cdf0 427
046e5fd4 428 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
de01cdf0 429 {
046e5fd4 430 if (!h)
431 {
432 Int_t dim = param->Dimension();
433 h = new TH1*[dim];
434 Float_t* xmin = new Float_t[dim];
435 Float_t* xmax = new Float_t[dim];
436 getBoundaries(store,dim,xmin,xmax);
437
438 for ( Int_t i = 0; i < dim; ++i )
439 {
440 h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
441 nbins,xmin[i],xmax[i]);
a99c3449 442 AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
046e5fd4 443 }
f1bf7efd 444 delete [] xmin;
445 delete [] xmax;
046e5fd4 446 }
447
448 Int_t detElemId = param->ID0();
449 Int_t manuId = param->ID1();
450 Int_t station = AliMpDEManager::GetChamberId(detElemId)/2;
de01cdf0 451
452 const AliMpVSegmentation* seg =
453 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
454
046e5fd4 455 for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
de01cdf0 456 {
168e9c4d 457 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
046e5fd4 458 if (!pad.IsValid()) continue;
de01cdf0 459
046e5fd4 460 ++n;
461 ++nPerStation[station];
462
463 for ( Int_t dim = 0; dim < param->Dimension(); ++dim )
464 {
465 h[dim]->Fill(param->ValueAsFloat(manuChannel,dim));
de01cdf0 466 }
467 }
046e5fd4 468 }
de01cdf0 469
046e5fd4 470 for ( Int_t i = 0; i < kNStations; ++i )
de01cdf0 471 {
a99c3449 472 AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i]));
de01cdf0 473 }
046e5fd4 474
a99c3449 475 AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
046e5fd4 476
477 delete[] nPerStation;
de01cdf0 478}
479
480//_____________________________________________________________________________
481Int_t
482AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
483{
484 /// Create a HV store
485
a99c3449 486 if (!AliMUONCDB::CheckMapping()) return 0;
487
49e110ec 488 AliMpDCSNamer hvNamer("TRACKER");
de01cdf0 489
490 TObjArray* aliases = hvNamer.GenerateAliases();
491
492 Int_t nSwitch(0);
493 Int_t nChannels(0);
494
495 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
496 {
497 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
498 TString& aliasName = alias->String();
499 if ( aliasName.Contains("sw") )
500 {
501 // HV Switch (St345 only)
502 TObjArray* valueSet = new TObjArray;
503 valueSet->SetOwner(kTRUE);
504
505 Bool_t value = kTRUE;
506
507 if (!defaultValues)
508 {
a0eca509 509 Float_t r = gRandom->Uniform();
de01cdf0 510 if ( r < 0.007 ) value = kFALSE;
511 }
512
513 for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
514 {
515 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
516 valueSet->Add(dcsValue);
517 }
518 aliasMap.Add(new TObjString(*alias),valueSet);
519 ++nSwitch;
520 }
521 else
522 {
523 TObjArray* valueSet = new TObjArray;
524 valueSet->SetOwner(kTRUE);
525 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
526 {
527 Float_t value = 1500;
cf27231a 528 if (!defaultValues) value = GetRandom(1750,62.5,true);
de01cdf0 529 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
530 valueSet->Add(dcsValue);
531 }
532 aliasMap.Add(new TObjString(*alias),valueSet);
533 ++nChannels;
534 }
535 }
536
537 delete aliases;
538
a99c3449 539 AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch));
de01cdf0 540
541 return nChannels+nSwitch;
542}
543
544//_____________________________________________________________________________
545Int_t
49e110ec 546AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues)
547{
548 /// Create a Trigger HV and Currents store
549
a99c3449 550 if (!AliMUONCDB::CheckMapping()) return 0;
551
49e110ec 552 AliMpDCSNamer triggerDCSNamer("TRIGGER");
553
554 TObjArray* aliases = triggerDCSNamer.GenerateAliases();
555
556 Int_t nChannels[2] = {0, 0};
557
558 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
559 {
560 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
561 TString& aliasName = alias->String();
562
563 TObjArray* valueSet = new TObjArray;
564 valueSet->SetOwner(kTRUE);
ad30b53f 565
49e110ec 566 Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data());
ad30b53f 567 if ( measureType < 0 ) {
568 AliErrorGeneralStream("AliMUONCDB")
569 << "Failed to get DCS variable from an alias (trigger): "
570 << aliasName.Data() << endl;
571 return 0;
572 }
573
49e110ec 574 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
575 {
576 Float_t value =
9b1e069f 577 (measureType == AliMpDCSNamer::kDCSI) ? 2. : 8000.;
49e110ec 578 if (!defaultValues) {
579 switch (measureType){
580 case AliMpDCSNamer::kDCSI:
9b1e069f 581 value = GetRandom(2.,0.4,true);
49e110ec 582 break;
583 case AliMpDCSNamer::kDCSHV:
9b1e069f 584 value = GetRandom(8000.,16.,true);
49e110ec 585 break;
586 }
587 }
588 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
589 valueSet->Add(dcsValue);
590 }
591 aliasMap.Add(new TObjString(*alias),valueSet);
592 ++nChannels[measureType];
593 }
594
595 delete aliases;
596
a99c3449 597 AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
49e110ec 598
599 return nChannels[0] + nChannels[1];
600}
601
602//_____________________________________________________________________________
603Int_t
a0eca509 604AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues)
de01cdf0 605{
606 /// Create a pedestal store. if defaultValues=true, ped.mean=ped.sigma=1,
607 /// otherwise mean and sigma are from a gaussian (with parameters
608 /// defined below by the kPedestal* constants)
409de10f 609
a99c3449 610 AliCodeTimerAutoGeneral("",0);
611
612 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 613
614 Int_t nchannels(0);
615 Int_t nmanus(0);
616
a0eca509 617 const Int_t kChannels(AliMpConstants::ManuNofChannels());
e7ee8d13 618
619 // bending
620 const Float_t kPedestalMeanMeanB(200.);
621 const Float_t kPedestalMeanSigmaB(10.);
622 const Float_t kPedestalSigmaMeanB(1.);
623 const Float_t kPedestalSigmaSigmaB(0.2);
624
625 // non bending
626 const Float_t kPedestalMeanMeanNB(200.);
627 const Float_t kPedestalMeanSigmaNB(10.);
628 const Float_t kPedestalSigmaMeanNB(1.);
629 const Float_t kPedestalSigmaSigmaNB(0.2);
630
631 const Float_t kFractionOfDeadManu(0.); // within [0.,1.]
409de10f 632
633 Int_t detElemId;
634 Int_t manuId;
635
636 AliMpManuIterator it;
de01cdf0 637
409de10f 638 while ( it.Next(detElemId,manuId) )
de01cdf0 639 {
e7ee8d13 640 // skip a given fraction of manus
641 if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue;
642
de01cdf0 643 ++nmanus;
a0eca509 644
046e5fd4 645 AliMUONVCalibParam* ped =
646 new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
409de10f 647
648 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
de01cdf0 649
650 for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel )
651 {
409de10f 652 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 653
654 ++nchannels;
655
656 Float_t meanPedestal;
657 Float_t sigmaPedestal;
658
659 if ( defaultValues )
660 {
661 meanPedestal = 0.0;
662 sigmaPedestal = 1.0;
663 }
664 else
665 {
cf27231a 666 Bool_t positive(kTRUE);
046e5fd4 667 meanPedestal = 0.0;
e7ee8d13 668
669 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane
670
671 while ( meanPedestal == 0.0 ) // avoid strict zero
672 {
673 meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive);
674 }
675 sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive);
676
677 } else { // manu in bending plane
678
679 while ( meanPedestal == 0.0 ) // avoid strict zero
680 {
681 meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive);
682 }
683 sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive);
684
685 }
686
de01cdf0 687 }
e7ee8d13 688
de01cdf0 689 ped->SetValueAsFloat(manuChannel,0,meanPedestal);
690 ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
691
692 }
a0eca509 693 Bool_t ok = pedestalStore.Add(ped);
de01cdf0 694 if (!ok)
695 {
a99c3449 696 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 697 }
698 }
699
a99c3449 700 AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
de01cdf0 701 return nchannels;
de01cdf0 702}
703
704//_____________________________________________________________________________
0045b488 705AliMUONRejectList*
706AliMUONCDB::MakeRejectListStore(Bool_t defaultValues)
707{
708 /// Create a reject list
709
a99c3449 710 AliCodeTimerAutoGeneral("",0);
0045b488 711
712 AliMUONRejectList* rl = new AliMUONRejectList;
713
714 if (!defaultValues)
715 {
716 rl->SetDetectionElementProbability(510);
717 rl->SetDetectionElementProbability(508);
718 return rl;
719 }
720
721 return rl;
722}
723
724//_____________________________________________________________________________
2b8a1212 725Int_t
7eafe398 726AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues)
2b8a1212 727{
7eafe398 728 /// Create an occupancy map.
2b8a1212 729
a99c3449 730 AliCodeTimerAutoGeneral("",0);
731
732 if (!AliMUONCDB::CheckMapping()) return 0;
2b8a1212 733
2b8a1212 734 Int_t nmanus(0);
735
2b8a1212 736 Int_t detElemId;
737 Int_t manuId;
738
739 AliMpManuIterator it;
740
7eafe398 741 Int_t nevents(1000);
742
2b8a1212 743 while ( it.Next(detElemId,manuId) )
744 {
2b8a1212 745 ++nmanus;
746
7eafe398 747 AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0);
2b8a1212 748
7eafe398 749 Double_t occ = 0.0;
750
2b8a1212 751 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
752
7eafe398 753 Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
754
a99c3449 755 if (!defaultValues) occ = gRandom->Rndm(1);
7eafe398 756
757 Double_t sumn = occ*nevents;
758
759 occupancy->SetValueAsFloat(0,0,sumn);
760 occupancy->SetValueAsFloat(0,1,sumn);
761 occupancy->SetValueAsFloat(0,2,sumn);
762 occupancy->SetValueAsInt(0,3,numberOfChannelsInManu);
763 occupancy->SetValueAsInt(0,4,nevents);
764
765 Bool_t ok = occupancyMapStore.Add(occupancy);
2b8a1212 766 if (!ok)
767 {
a99c3449 768 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
2b8a1212 769 }
2b8a1212 770 }
771
7eafe398 772 return nmanus;
2b8a1212 773}
774
775//_____________________________________________________________________________
25e1df3e 776Int_t
777AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
778{
6687de6d 779 /// Read the capacitance values from file and append them to the capaStore
780
a99c3449 781 if (!AliMUONCDB::CheckMapping()) return 0;
782
49419555 783 return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
25e1df3e 784}
785
786//_____________________________________________________________________________
de01cdf0 787Int_t
a0eca509 788AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
de01cdf0 789{
790 /// Create a capacitance store. if defaultValues=true, all capa are 1.0,
791 /// otherwise they are from a gaussian with parameters defined in the
792 /// kCapa* constants below.
409de10f 793
a99c3449 794 AliCodeTimerAutoGeneral("",0);
795
796 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 797
798 Int_t nchannels(0);
799 Int_t nmanus(0);
800 Int_t nmanusOK(0); // manus for which we got the serial number
a0eca509 801
25e1df3e 802 const Float_t kCapaMean(0.3);
803 const Float_t kCapaSigma(0.1);
804 const Float_t kInjectionGainMean(3);
805 const Float_t kInjectionGainSigma(1);
409de10f 806
807 Int_t detElemId;
808 Int_t manuId;
809
810 AliMpManuIterator it;
de01cdf0 811
409de10f 812 while ( it.Next(detElemId,manuId) )
de01cdf0 813 {
814 ++nmanus;
815
de01cdf0 816 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
ab167304 817 Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
de01cdf0 818
a0eca509 819 if ( serialNumber <= 0 ) continue;
820
821 ++nmanusOK;
de01cdf0 822
a0eca509 823 AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
de01cdf0 824
825 if (!capa)
826 {
25e1df3e 827 capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
a0eca509 828 Bool_t ok = capaStore.Add(capa);
de01cdf0 829 if (!ok)
830 {
a99c3449 831 AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
de01cdf0 832 }
833 }
834
835 for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel )
836 {
409de10f 837 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 838
839 ++nchannels;
840
841 Float_t capaValue;
25e1df3e 842 Float_t injectionGain;
de01cdf0 843
844 if ( defaultValues )
845 {
846 capaValue = 1.0;
25e1df3e 847 injectionGain = 1.0;
de01cdf0 848 }
849 else
850 {
cf27231a 851 capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE);
25e1df3e 852 injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE);
de01cdf0 853 }
854 capa->SetValueAsFloat(manuChannel,0,capaValue);
25e1df3e 855 capa->SetValueAsFloat(manuChannel,1,injectionGain);
de01cdf0 856 }
857 }
858
859 Float_t percent = 0;
860 if ( nmanus ) percent = 100*nmanusOK/nmanus;
a99c3449 861 AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
de01cdf0 862 nmanusOK,nmanus,percent));
a99c3449 863 AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels));
de01cdf0 864 if ( percent < 100 )
865 {
a99c3449 866 AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!");
de01cdf0 867 }
868 return nchannels;
869
870}
871
872//_____________________________________________________________________________
873Int_t
a0eca509 874AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
de01cdf0 875{
cf27231a 876 /// Create a gain store. if defaultValues=true, all gains set so that
877 /// charge = (adc-ped)
878 ///
879 /// otherwise parameters are taken from gaussians with parameters
880 /// defined in the k* constants below.
de01cdf0 881
a99c3449 882 AliCodeTimerAutoGeneral("",0);
883
884 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 885
886 Int_t nchannels(0);
887 Int_t nmanus(0);
a0eca509 888
cf27231a 889 const Int_t kSaturation(3000);
890 const Double_t kA0Mean(1.2);
409de10f 891 const Double_t kA0Sigma(0.1);
892 const Double_t kA1Mean(1E-5);
893 const Double_t kA1Sigma(1E-6);
cf27231a 894 const Double_t kQualMean(0xFF);
895 const Double_t kQualSigma(0x10);
896 const Int_t kThresMean(1600);
409de10f 897 const Int_t kThresSigma(100);
898
899 Int_t detElemId;
900 Int_t manuId;
de01cdf0 901
409de10f 902 AliMpManuIterator it;
903
904 while ( it.Next(detElemId,manuId) )
de01cdf0 905 {
906 ++nmanus;
de01cdf0 907
a0eca509 908 AliMUONVCalibParam* gain =
cf27231a 909 new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(),
a0eca509 910 detElemId,
911 manuId,
912 AliMUONVCalibParam::InvalidFloatValue());
913
409de10f 914 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
de01cdf0 915
916 for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel )
917 {
409de10f 918 if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
de01cdf0 919
920 ++nchannels;
921
de01cdf0 922 if ( defaultValues )
923 {
cf27231a 924 gain->SetValueAsFloat(manuChannel,0,1.0);
925 gain->SetValueAsFloat(manuChannel,1,0.0);
926 gain->SetValueAsInt(manuChannel,2,4095);
927 gain->SetValueAsInt(manuChannel,3,1);
928 gain->SetValueAsInt(manuChannel,4,kSaturation);
de01cdf0 929 }
930 else
931 {
cf27231a 932 Bool_t positive(kTRUE);
933 gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive));
934 gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive));
935 gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive)));
936 gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive)));
937 gain->SetValueAsInt(manuChannel,4,kSaturation);
de01cdf0 938 }
de01cdf0 939
940 }
a0eca509 941 Bool_t ok = gainStore.Add(gain);
de01cdf0 942 if (!ok)
943 {
a99c3449 944 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 945 }
946 }
947
a99c3449 948 AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
de01cdf0 949 return nchannels;
950}
951
952//_____________________________________________________________________________
953Int_t
a99c3449 954AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks)
de01cdf0 955{
956 /// Generate local trigger masks store. All masks are set to FFFF
957
a99c3449 958 AliCodeTimerAutoGeneral("",0);
409de10f 959
de01cdf0 960 Int_t ngenerated(0);
630711ed 961 // Generate fake mask values for all localboards and put that into
de01cdf0 962 // one single container (localBoardMasks)
0145e89a 963 for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i )
de01cdf0 964 {
a0eca509 965 AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
de01cdf0 966 for ( Int_t x = 0; x < 2; ++x )
967 {
968 for ( Int_t y = 0; y < 4; ++y )
969 {
970 Int_t index = x*4+y;
971 localBoard->SetValueAsInt(index,0,0xFFFF);
972 ++ngenerated;
973 }
974 }
a0eca509 975 localBoardMasks.Add(localBoard);
de01cdf0 976 }
977 return ngenerated;
978}
979
980//_____________________________________________________________________________
981Int_t
a99c3449 982AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm)
de01cdf0 983{
92c23b09 984 /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.)
de01cdf0 985
a99c3449 986 AliCodeTimerAutoGeneral("",0);
409de10f 987
5cc125b2 988 if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) {
a99c3449 989 AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
5cc125b2 990 return 0;
991 }
992
993 return rtm.GetNofTriggerCrates();
de01cdf0 994}
995
92c23b09 996
de01cdf0 997//_____________________________________________________________________________
998Int_t
a99c3449 999AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm)
de01cdf0 1000{
92c23b09 1001 /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.)
de01cdf0 1002
a99c3449 1003 AliCodeTimerAutoGeneral("",0);
913f1b43 1004
1005 return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping());
de01cdf0 1006}
1007
92c23b09 1008
de01cdf0 1009//_____________________________________________________________________________
1010AliMUONTriggerLut*
a99c3449 1011AliMUONCDB::MakeTriggerLUT(const char* file)
de01cdf0 1012{
1013 /// Make a triggerlut object, from a file.
1014
a99c3449 1015 AliCodeTimerAutoGeneral("",0);
409de10f 1016
de01cdf0 1017 AliMUONTriggerLut* lut = new AliMUONTriggerLut;
1018 lut->ReadFromFile(file);
1019 return lut;
1020}
1021
1022//_____________________________________________________________________________
1023AliMUONTriggerEfficiencyCells*
a99c3449 1024AliMUONCDB::MakeTriggerEfficiency(const char* file)
de01cdf0 1025{
1026 /// Make a trigger efficiency object from a file.
1027
a99c3449 1028 AliCodeTimerAutoGeneral("",0);
409de10f 1029
de01cdf0 1030 return new AliMUONTriggerEfficiencyCells(file);
1031}
1032
1033//_____________________________________________________________________________
1034void
1035AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
25e1df3e 1036 Int_t startRun, Int_t endRun,
1037 const char* filename)
1038{
1039 /// Write a given object to OCDB
1040
913f1b43 1041 TString comment(gSystem->ExpandPathName(filename));
1042
1043 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
25e1df3e 1044}
1045
1046//_____________________________________________________________________________
1047void
1048AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
de01cdf0 1049 Int_t startRun, Int_t endRun, Bool_t defaultValues)
1050{
1051 /// Write a given object to OCDB
1052
913f1b43 1053 TString comment;
1054 if ( defaultValues ) comment += "Test with default values";
1055 else comment += "Test with random values";
1056
1057 WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1058}
1059
1060//_____________________________________________________________________________
1061void
1062AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun,
1063 const char* comment, const char* responsible)
1064{
1065 /// Write a given object to OCDB
1066
a99c3449 1067 if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
1068
de01cdf0 1069 AliCDBId id(calibpath,startRun,endRun);
1070 AliCDBMetaData md;
1071 md.SetAliRootVersion(gROOT->GetVersion());
913f1b43 1072 md.SetComment(comment);
1073 md.SetResponsible(responsible);
a99c3449 1074 AliCDBManager::Instance()->Put(object,id,&md);
de01cdf0 1075}
1076
1077//_____________________________________________________________________________
1078Int_t
a0eca509 1079AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore)
de01cdf0 1080{
1081 /// Fill the neighbours store with, for each channel, a TObjArray of its
1082 /// neighbouring pads (including itself)
1083
a99c3449 1084 AliCodeTimerAutoGeneral("",0);
1085
1086 if (!AliMUONCDB::CheckMapping()) return 0;
de01cdf0 1087
a99c3449 1088 AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient.");
de01cdf0 1089
1090 Int_t nchannels(0);
1091
1092 TObjArray tmp;
409de10f 1093
1094 Int_t detElemId;
1095 Int_t manuId;
de01cdf0 1096
409de10f 1097 AliMpManuIterator it;
1098
1099 while ( it.Next(detElemId,manuId) )
de01cdf0 1100 {
de01cdf0 1101 const AliMpVSegmentation* seg =
1102 AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId);
1103
a0eca509 1104 AliMUONVCalibParam* calibParam = static_cast<AliMUONVCalibParam*>(neighbourStore.FindObject(detElemId,manuId));
de01cdf0 1105 if (!calibParam)
1106 {
1107 Int_t dimension(11);
a0eca509 1108 Int_t size(AliMpConstants::ManuNofChannels());
de01cdf0 1109 Int_t defaultValue(-1);
a0eca509 1110 Int_t packingFactor(size);
de01cdf0 1111
a0eca509 1112 calibParam = new AliMUONCalibParamNI(dimension,size,detElemId,manuId,defaultValue,packingFactor);
1113 Bool_t ok = neighbourStore.Add(calibParam);
de01cdf0 1114 if (!ok)
1115 {
a99c3449 1116 AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
de01cdf0 1117 return -1;
1118 }
1119 }
1120
a0eca509 1121 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel )
de01cdf0 1122 {
168e9c4d 1123 AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
de01cdf0 1124
1125 if (pad.IsValid())
1126 {
1127 ++nchannels;
1128
1129 seg->GetNeighbours(pad,tmp,true,true);
1130 Int_t nofPadNeighbours = tmp.GetEntriesFast();
1131
1132 for ( Int_t i = 0; i < nofPadNeighbours; ++i )
1133 {
bf0d3528 1134 AliMpPad* p = static_cast<AliMpPad*>(tmp.UncheckedAt(i));
de01cdf0 1135 Int_t x;
409de10f 1136// Bool_t ok =
6e97fbb8 1137 calibParam->PackValues(p->GetManuId(),p->GetManuChannel(),x);
409de10f 1138// if (!ok)
1139// {
1140// AliError("Could not pack value. Something is seriously wrong. Please check");
1141// StdoutToAliError(pad->Print(););
1142// return -1;
1143// }
de01cdf0 1144 calibParam->SetValueAsInt(manuChannel,i,x);
1145 }
1146 }
1147 }
1148 }
1149
de01cdf0 1150 return nchannels;
1151}
1152
1153//_____________________________________________________________________________
1154void
1155AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
1156{
1157 /// Write local trigger masks to OCDB
1158
630711ed 1159 AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1);
de01cdf0 1160 Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
a99c3449 1161 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1162 if (ngenerated>0)
1163 {
1164 WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
1165 }
1166 delete ltm;
1167}
1168
1169//_____________________________________________________________________________
1170void
92c23b09 1171AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
de01cdf0 1172{
1173 /// Write regional trigger masks to OCDB
1174
92c23b09 1175 AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig();
1176 Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
a99c3449 1177 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1178 if (ngenerated>0)
1179 {
92c23b09 1180 WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
de01cdf0 1181 }
1182 delete rtm;
1183}
1184
92c23b09 1185
de01cdf0 1186//_____________________________________________________________________________
1187void
92c23b09 1188AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
de01cdf0 1189{
1190 /// Write global trigger masks to OCDB
1191
92c23b09 1192 AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig();
de01cdf0 1193
92c23b09 1194 Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
a99c3449 1195 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1196 if (ngenerated>0)
1197 {
92c23b09 1198 WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
de01cdf0 1199 }
1200 delete gtm;
1201}
1202
92c23b09 1203
de01cdf0 1204//_____________________________________________________________________________
1205void
1206AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun)
1207{
1208 /// Write trigger LUT to OCDB
1209
1210 AliMUONTriggerLut* lut = MakeTriggerLUT();
1211 if (lut)
1212 {
1213 WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true);
1214 }
1215 delete lut;
1216}
1217
1218//_____________________________________________________________________________
1219void
1220AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun)
1221{
1222 /// Write trigger efficiency to OCDB
1223
1224 AliMUONTriggerEfficiencyCells* eff = MakeTriggerEfficiency();
1225 if (eff)
1226 {
1227 WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true);
1228 }
1229 delete eff;
1230}
1231
1232//_____________________________________________________________________________
1233void
1234AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun)
1235{
1236 /// Write neighbours to OCDB
1237
409de10f 1238 AliMUONVStore* neighbours = Create2DMap();
de01cdf0 1239 Int_t ngenerated = MakeNeighbourStore(*neighbours);
a99c3449 1240 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1241 if (ngenerated>0)
1242 {
1243 WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true);
1244 }
1245 delete neighbours;
1246}
1247
1248//_____________________________________________________________________________
1249void
1250AliMUONCDB::WriteHV(Bool_t defaultValues,
1251 Int_t startRun, Int_t endRun)
1252{
1253 /// generate HV values (either cste = 1500 V) if defaultValues=true or random
1254 /// if defaultValues=false, see makeHVStore) and
1255 /// store them into CDB located at cdbpath, with a validity period
1256 /// ranging from startRun to endRun
1257
1258 TMap* hvStore = new TMap;
1259 Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
a99c3449 1260 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1261 if (ngenerated>0)
1262 {
1263 WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
1264 }
1265 delete hvStore;
1266}
1267
1268//_____________________________________________________________________________
1269void
49e110ec 1270AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues,
1271 Int_t startRun, Int_t endRun)
1272{
1273 /// generate Trigger HV and current values (either const if defaultValues=true or random
1274 /// if defaultValues=false, see makeTriggerDCSStore) and
1275 /// store them into CDB located at cdbpath, with a validity period
1276 /// ranging from startRun to endRun
1277
1278 TMap* triggerDCSStore = new TMap;
1279 Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues);
a99c3449 1280 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
49e110ec 1281 if (ngenerated>0)
1282 {
1283 WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues);
1284 }
1285 delete triggerDCSStore;
1286}
1287
1288//_____________________________________________________________________________
1289void
de01cdf0 1290AliMUONCDB::WritePedestals(Bool_t defaultValues,
1291 Int_t startRun, Int_t endRun)
1292{
1293 /// generate pedestal values (either 0 if defaultValues=true or random
1294 /// if defaultValues=false, see makePedestalStore) and
1295 /// store them into CDB located at cdbpath, with a validity period
1296 /// ranging from startRun to endRun
1297
409de10f 1298 AliMUONVStore* pedestalStore = Create2DMap();
de01cdf0 1299 Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
a99c3449 1300 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1301 WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
1302 delete pedestalStore;
1303}
1304
2b8a1212 1305//_____________________________________________________________________________
1306void
7eafe398 1307AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues,
1308 Int_t startRun, Int_t endRun)
2b8a1212 1309{
7eafe398 1310 /// generate occupancy map values (either empty one if defaultValues=true, or
1311 /// random one, see MakeOccupancyMapStore) and
2b8a1212 1312 /// store them into CDB located at cdbpath, with a validity period
1313 /// ranging from startRun to endRun
1314
7eafe398 1315 AliMUONVStore* occupancyMapStore = Create2DMap();
1316 Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
a99c3449 1317 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
7eafe398 1318 WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
1319 delete occupancyMapStore;
2b8a1212 1320}
1321
0045b488 1322//_____________________________________________________________________________
1323void
1324AliMUONCDB::WriteRejectList(Bool_t defaultValues,
1325 Int_t startRun, Int_t endRun)
1326{
1327 /// generate reject list values (either empty one if defaultValues=true, or
1328 /// random one, see MakeRejectListStore) and
1329 /// store them into CDB located at cdbpath, with a validity period
1330 /// ranging from startRun to endRun
1331
1332 AliMUONRejectList* rl = MakeRejectListStore(defaultValues);
1333 WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues);
1334 delete rl;
1335}
1336
de01cdf0 1337
1338//_____________________________________________________________________________
1339void
1340AliMUONCDB::WriteGains(Bool_t defaultValues,
1341 Int_t startRun, Int_t endRun)
1342{
1343 /// generate gain values (either 1 if defaultValues=true or random
1344 /// if defaultValues=false, see makeGainStore) and
1345 /// store them into CDB located at cdbpath, with a validity period
1346 /// ranging from startRun to endRun
1347
409de10f 1348 AliMUONVStore* gainStore = Create2DMap();
de01cdf0 1349 Int_t ngenerated = MakeGainStore(*gainStore,defaultValues);
a99c3449 1350 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1351 WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
1352 delete gainStore;
1353}
1354
1355//_____________________________________________________________________________
1356void
25e1df3e 1357AliMUONCDB::WriteCapacitances(const char* filename,
1358 Int_t startRun, Int_t endRun)
1359{
1360 /// read manu capacitance and injection gain values from file
1361 /// and store them into CDB located at cdbpath, with a validity period
1362 /// ranging from startRun to endRun
1363
1364 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1365 Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
a99c3449 1366 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
25e1df3e 1367 if ( ngenerated > 0 )
1368 {
1369 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
1370 }
1371 delete capaStore;
1372}
1373
1374//_____________________________________________________________________________
1375void
de01cdf0 1376AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
1377 Int_t startRun, Int_t endRun)
1378{
1379 /// generate manu capacitance values (either 1 if defaultValues=true or random
1380 /// if defaultValues=false, see makeCapacitanceStore) and
1381 /// store them into CDB located at cdbpath, with a validity period
1382 /// ranging from startRun to endRun
1383
a0eca509 1384 AliMUONVStore* capaStore = new AliMUON1DMap(16828);
de01cdf0 1385 Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues);
a99c3449 1386 AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
de01cdf0 1387 WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues);
1388 delete capaStore;
1389}
1390
1391//_____________________________________________________________________________
1392void
49e110ec 1393AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
de01cdf0 1394{
1395 /// Writes all Trigger related calibration to CDB
49e110ec 1396 WriteTriggerDCS(defaultValues,startRun,endRun);
de01cdf0 1397 WriteLocalTriggerMasks(startRun,endRun);
92c23b09 1398 WriteRegionalTriggerConfig(startRun,endRun);
1399 WriteGlobalTriggerConfig(startRun,endRun);
de01cdf0 1400 WriteTriggerLut(startRun,endRun);
1401 WriteTriggerEfficiency(startRun,endRun);
1402}
1403
1404//_____________________________________________________________________________
1405void
a31df857 1406AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun)
1407{
1408 /// Write complete tracker configuration to OCDB
1409 ostringstream lines;
1410 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1411 AliMpBusPatch* bp;
1412 while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
1413 {
1414 for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu)
1415 {
1416 lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl;
1417 }
1418 }
1419
1420 AliMUON2DMap config(kTRUE);
a31df857 1421
042cd64e 1422 AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config);
a31df857 1423
1424 WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE);
1425}
1426
1427//_____________________________________________________________________________
1428void
de01cdf0 1429AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1430{
1431 /// Writes all Tracker related calibration to CDB
1432 WriteHV(defaultValues,startRun,endRun);
1433 WritePedestals(defaultValues,startRun,endRun);
1434 WriteGains(defaultValues,startRun,endRun);
1435 WriteCapacitances(defaultValues,startRun,endRun);
1436 WriteNeighbours(startRun,endRun);
c21c5694 1437 WriteOccupancyMap(defaultValues,startRun,endRun);
1438 WriteRejectList(defaultValues,startRun,endRun);
a31df857 1439 WriteConfig(startRun,endRun);
de01cdf0 1440}
913f1b43 1441
5148da98 1442//_____________________________________________________________________________
1443void
c241bfaa 1444AliMUONCDB::ShowCapacitances()
1445{
1446 /// Show briefly the number of capa values we have in the OCDB,
1447 /// and the list of manu that are actually in the config and for which
1448 /// we miss the capa (if any).
1449
1450 if (!AliMUONCDB::CheckOCDB()) return;
1451
1452 AliMUONCDB::LoadMapping();
1453
1454 if (!AliMUONCDB::CheckMapping()) return;
1455
1456 AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
1457
1458 if (!e) return ;
1459
1460 AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
1461
1462 e = AliCDBManager::Instance()->Get("MUON/Calib/Capacitances");
1463
1464 if (!e) return;
1465
1466 AliMUONVStore* capacitances = static_cast<AliMUONVStore*>(e->GetObject());
1467
1468 AliInfoGeneral("ShowCapacitances",Form("%d capacitances are in OCDB",capacitances->GetSize()));
1469
1470 TIter nextManu(config->CreateIterator());
1471 AliMUONVCalibParam* param;
1472
1473 while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
1474 {
1475 Int_t detElemId = param->ID0();
1476 Int_t manuId = param->ID1();
1477
1478 Int_t serialNumber
1479 = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
1480
1481 if (serialNumber<0)
1482 {
1483 AliErrorGeneral("ShowCapacitances",Form("Did not find serial for DE %04d MANUID %04d",detElemId,manuId));
1484 }
1485 else
1486 {
1487 AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capacitances->FindObject(serialNumber));
1488 if (!capa)
1489 {
1490 AliErrorGeneral("ShowCapacitances",Form("Did not find capacitance for DE %04d MANUID %04d SERIAL %d",detElemId,manuId,serialNumber));
1491 }
1492 }
1493 }
1494
1495}
1496
1497//_____________________________________________________________________________
1498void
207947f7 1499AliMUONCDB::ShowConfig(Bool_t withStatusMap)
5148da98 1500{
1501 /// Dumps the current tracker configuration, i.e. number and identity of missing buspatches
207947f7 1502 /// If statusMap is true, will also take into account the status map to report the number
1503 /// of good channels
1504
5148da98 1505 if (!AliMUONCDB::CheckOCDB()) return;
1506
1507 AliMUONCDB::LoadMapping();
1508
1509 if (!AliMUONCDB::CheckMapping()) return;
1510
1511 AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
1512
1513 if (!e) return ;
1514
1515 AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
1516
207947f7 1517 AliMUONPadStatusMapMaker* statusMapMaker(0x0);
1518 AliMUONCalibrationData* cd(0x0);
1519 AliMUONPadStatusMaker* statusMaker(0x0);
1520
1521 if ( withStatusMap )
1522 {
1523 cd = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
1524
1525 statusMaker = new AliMUONPadStatusMaker(*cd);
1526
1527 AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
1528
1529 statusMaker->SetLimits(*recoParam);
1530
207947f7 1531 UInt_t mask = recoParam->PadGoodnessMask();
9b780418 1532
1533 delete recoParam;
1534
207947f7 1535 const Bool_t deferredInitialization = kFALSE;
1536
1537 statusMapMaker = new AliMUONPadStatusMapMaker(*cd,mask,deferredInitialization);
1538 }
1539
5148da98 1540 TIter nextManu(config->CreateIterator());
1541 AliMUONVCalibParam* param;
1542
1543 AliMpExMap buspatches;
1544
1545 while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
1546 {
1547 Int_t detElemId = param->ID0();
1548 Int_t manuId = param->ID1();
1549 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1550 if ( buspatches.GetValue(busPatchId) == 0x0 )
1551 {
1552 buspatches.Add(busPatchId,new TObjString(Form("BP%04d",busPatchId)));
1553 }
1554 }
1555
1556 TArrayI removed(buspatches.GetSize());
1557
1558 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1559 AliMpBusPatch* bp;
1560 Int_t n(0);
1561 Int_t nok(0);
1562 Int_t nremoved(0);
1563
207947f7 1564 // accounting of bus patches first
1565
5148da98 1566 while ( ( bp = static_cast<AliMpBusPatch*>(next())))
1567 {
1568 if ( buspatches.GetValue(bp->GetId()) )
1569 {
1570 ++nok;
1571 }
1572 else
1573 {
1574 removed.SetAt(bp->GetId(),nremoved++);
1575 }
5148da98 1576 }
1577
207947f7 1578 // accounting of channels
1579
1580 AliMpManuIterator it;
1581
1582 Int_t totalNumberOfChannels(0);
1583 Int_t removedChannels(0);
1584 Int_t badChannels(0);
1585 Int_t badAndRemovedChannels(0);
1586 Int_t badOrRemovedChannels(0);
1587
1588 Int_t detElemId, manuId;
1589
1590 while ( it.Next(detElemId,manuId) )
1591 {
1592 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1593 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
1594 {
1595 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1596
1597 if ( de->IsConnectedChannel(manuId,i) )
1598 {
1599 ++totalNumberOfChannels;
1600 Bool_t badBusPatch = ( buspatches.GetValue(busPatchId) == 0x0 );
1601
1602 if ( withStatusMap )
1603 {
47274b13 1604 Bool_t badChannel = ( ( statusMapMaker->StatusMap(detElemId,manuId,i) & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0);
207947f7 1605 if ( badChannel ) ++badChannels;
1606 if ( badBusPatch && badChannel ) ++badAndRemovedChannels;
1607 if ( badBusPatch || badChannel ) ++badOrRemovedChannels;
1608 }
1609
1610 if ( badBusPatch) ++removedChannels;
1611 }
1612 }
1613 }
1614
5148da98 1615
1616 Int_t* indices = new Int_t[nremoved];
1617
1618 TMath::Sort(nremoved,removed.GetArray(),indices,kFALSE);
1619
1620 for ( Int_t i = 0; i < nremoved; ++i )
1621 {
1622 Int_t busPatchId = removed[indices[i]];
1623 bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
1624 bp->Print();
1625 }
1626
1627 delete[] indices;
207947f7 1628
1629 cout << endl;
1630 cout << Form("Bus patches n=%3d nok=%3d nremoved=%3d",n,nok,nremoved) << endl;
1631
1632 cout << Form("Channels n=%6d nremoved=%6d bad=%6d bad and removed=%6d bad or removed=%6d",
1633 totalNumberOfChannels,removedChannels,badChannels,badAndRemovedChannels,badOrRemovedChannels) << endl;
1634
1635 if (totalNumberOfChannels>0)
1636 {
1637 cout << Form("Percentage of readout channels %5.1f %%",removedChannels*100.0/totalNumberOfChannels) << endl;
1638 if ( withStatusMap )
1639 {
1640 cout << Form("Percentage of non useable channels (bad or removed) %5.1f %%",
1641 badOrRemovedChannels*100.0/totalNumberOfChannels) << endl;
1642 }
1643 }
1644
1645
1646 delete statusMapMaker;
1647 delete cd;
1648 delete statusMaker;
5148da98 1649}
9e7c4517 1650
1651//______________________________________________________________________________
1652void AliMUONCDB::ReadIntegers(const char* filename, std::vector<int>& integers)
1653{
1654 /// Read integers from filename, where integers are either
1655 /// separated by "," or by return carriage
1656 ifstream in(gSystem->ExpandPathName(filename));
1657 int i;
1658
1659 std::set<int> runset;
1660
1661 char line[10000];
1662
1663 in.getline(line,10000,'\n');
1664
1665 TString sline(line);
1666
1667 if (sline.Contains(","))
1668 {
1669 TObjArray* a = sline.Tokenize(",");
1670 TIter next(a);
1671 TObjString* s;
1672 while ( ( s = static_cast<TObjString*>(next()) ) )
1673 {
1674 runset.insert(s->String().Atoi());
1675 }
1676 delete a;
1677 }
1678 else
1679 {
1680 runset.insert(sline.Atoi());
1681
1682 while ( in >> i )
1683 {
1684 runset.insert(i);
1685 }
1686 }
1687
1688 for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it )
1689 {
1690 integers.push_back((*it));
1691 }
1692
1693 std::sort(integers.begin(),integers.end());
1694}
1695
1696//______________________________________________________________________________
1697void AliMUONCDB::ShowFaultyBusPatches(const char* runlist, double occLimit,
1698 const char* outputBaseName,
1699 const char* ocdbPath)
1700{
1701 /// Shows the list of bus patches above a given occupancy limit,
1702 /// for each run in the runlist
1703
1704 AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError);
1705
1706 // AliLog::SetPrintType(AliLog::kInfo,kFALSE);
1707 // AliLog::SetPrintType(AliLog::kWarning,kFALSE);
1708 // gErrorIgnoreLevel=kError; // to avoid all the TAlienFile::Open messages...
1709
1710 AliCDBManager* man = AliCDBManager::Instance();
1711
1712 man->SetDefaultStorage(ocdbPath);
1713
1714 Bool_t first(kTRUE);
1715
1716 std::vector<int> runnumbers;
1717
1718 ReadIntegers(runlist,runnumbers);
1719
1720 AliMUON2DMap bpValues(kFALSE);
1721
1722 std::ofstream outfile(Form("%s.txt",outputBaseName));
1723
1724 for ( unsigned int i = 0 ; i < runnumbers.size(); ++i )
1725 {
1726 int runNumber = runnumbers[i];
1727
1728 man->SetRun(runNumber);
1729
1730 if ( first )
1731 {
1732 AliMpCDB::LoadAll();
1733 first = kFALSE;
1734 }
1735
1736 AliCDBEntry* e = man->Get("MUON/Calib/OccupancyMap",runNumber);
1737
1738 AliMUONVStore* occmap = static_cast<AliMUONVStore*>(e->GetObject());
1739
1740 AliMUONTrackerData td("occ","occ",*occmap);
1741
1742 TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1743 AliMpBusPatch* bp;
1744 std::set<int> buspatches;
1745 Double_t sumn = 1000.0;
1746
1747 while ( ( bp = static_cast<AliMpBusPatch*>(nextBP()) ) )
1748 {
1749 Double_t occ = td.BusPatch(bp->GetId(),2);
1750
1751 if (occ>occLimit)
1752 {
1753 buspatches.insert(bp->GetId());
1754
1755 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(bpValues.FindObject(bp->GetId()));
1756
1757 if (!param)
1758 {
1759 param = new AliMUONCalibParamND(5, 1, bp->GetId(), 0);
1760 bpValues.Add(param);
1761
1762 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId());
1763 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1764
1765 Int_t nchannels(0);
1766
1767 for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
1768 {
1769 Int_t manuId = bp->GetManuId(imanu);
1770 nchannels += de->NofChannelsInManu(manuId);
1771 }
1772
1773 param->SetValueAsDouble(0,2,sumn);
1774 param->SetValueAsDouble(0,3,nchannels);
1775 param->SetValueAsDouble(0,4,1);
1776 }
1777
1778 Double_t sumw = sumn*(param->ValueAsDouble(0)/sumn+1.0/runnumbers.size());
1779 Double_t sumw2 = 0.0; //(sumn-1)*ey*ey+sumw*sumw/sumn;
1780
1781 param->SetValueAsDouble(0,0,sumw);
1782 param->SetValueAsDouble(0,1,sumw2);
1783
1784 }
1785 }
1786
1787 outfile << Form("RUN %09d",runNumber);
1788
1789 for ( std::set<int>::const_iterator bit = buspatches.begin(); bit != buspatches.end(); ++bit )
1790 {
1791 outfile << Form(" %4d",*bit);
1792 }
1793 outfile << endl;
1794 }
1795
1796 outfile.close();
1797
1798 const char* name = "BPfailureRate";
1799
1800 AliMUONTrackerData* mpData = new AliMUONTrackerData(name,name,bpValues,2);
1801 mpData->SetDimensionName(0,name);
1802
1803 TFile f(Form("%s.root",outputBaseName),"recreate");
1804 mpData->Write();
1805 f.Close();
1806
1807 cout << Form("Results are in %s.txt and %s.root",outputBaseName,outputBaseName) << endl;
1808
1809 gSystem->Exec(Form("cat %s.txt",outputBaseName));
1810
1811}
1812