Fixed coding conventions in MUONQADataMaker classes.
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerData.cxx
CommitLineData
0145e89a 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
18#include "AliMUONTrackerData.h"
19
20#include "AliMUONCalibParamND.h"
21#include "AliMUONVStore.h"
22#include "AliMpBusPatch.h"
23#include "AliMpDDLStore.h"
24#include "AliMpDEManager.h"
25#include "AliMpDEIterator.h"
26#include "AliMpDetElement.h"
27#include "AliMpHVNamer.h"
28#include "AliCodeTimer.h"
29#include "AliLog.h"
30#include <Riostream.h>
31#include <TMath.h>
32#include <TObjArray.h>
33#include <TObjString.h>
34#include <TString.h>
35#include <TVector2.h>
36#include <float.h>
37
38/// \class AliMUONTrackerData
39///
40/// Implementation of AliMUONVTrackerData class
41///
42/// \author Laurent Aphecetche, Subatech
43
44///\cond CLASSIMP
45ClassImp(AliMUONTrackerData)
46///\endcond
47
48const Int_t AliMUONTrackerData::fgkExtraDimension = 2;
49const Int_t AliMUONTrackerData::fgkVirtualExtraDimension = 1;
50
51//_____________________________________________________________________________
52AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
53 Int_t dimension,
54 Bool_t runnable)
55: AliMUONVTrackerData(name,title),
56fChannelValues(0x0),
57fManuValues(0x0),
58fBusPatchValues(0x0),
59fDEValues(0x0),
60fChamberValues(0x0),
61fPCBValues(0x0),
62fDimension(dimension*2+fgkExtraDimension),
63fNevents(0x0),
64fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)),
65fExternalDimension(dimension),
66fIsRunnable(runnable)
67{
68 /// ctor
69 fDimensionNames->SetOwner(kTRUE);
70 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
71 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
72 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
73 Clear();
74}
75
76//_____________________________________________________________________________
77AliMUONTrackerData::~AliMUONTrackerData()
78{
79 /// dtor
80 delete fChannelValues;
81 delete fManuValues;
82 delete fBusPatchValues;
83 delete fDEValues;
84 delete fChamberValues;
85 delete fPCBValues;
86 delete fDimensionNames;
87}
88
89//_____________________________________________________________________________
90Bool_t
91AliMUONTrackerData::Add(const AliMUONVStore& store)
92{
93 /// We first convert the external store to a temporary internal store
94 /// with more dimension (2*store's dimension)
95
96 AliCodeTimerAuto(GetName())
97
98 Int_t ndim(NumberOfDimensions()-fgkExtraDimension-fgkVirtualExtraDimension);
99
100 AliMUONVStore* istore = store.Create();
101
102 TIter next(store.CreateIterator());
103 AliMUONVCalibParam* external;
104
105 AliCodeTimerStart("from external to internal store");
106
107 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
108 {
109 Int_t detElemId = external->ID0();
110 Int_t manuId = external->ID1();
111
112 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
113
114 AliMUONVCalibParam* internal = static_cast<AliMUONVCalibParam*>
115 (istore->FindObject(detElemId,manuId));
116
117 if (!internal)
118 {
119 internal = new AliMUONCalibParamND(ndim,external->Size(),
120 detElemId, manuId,
121 0.0);
122 istore->Add(internal);
123 }
124
125 for ( Int_t i = 0; i < external->Size(); ++i )
126 {
127 Bool_t connectPad = de->IsConnectedChannel(manuId,i);
128
129 if (!connectPad) continue;
130
131 for ( Int_t j = 0; j < external->Dimension(); ++j )
132 {
133 Int_t ix = External2Internal(j);
134
135 Double_t vext = external->IsDoublePrecision() ?
136 external->ValueAsDouble(i,j) :
137 external->ValueAsFloat(i,j);
138
139 Double_t sumw = internal->ValueAsDouble(i,ix) + vext;
140 Double_t sumw2 = internal->ValueAsDouble(i,ix+1) + vext*vext;
141
142 internal->SetValueAsFloat(i,ix,sumw);
143 internal->SetValueAsFloat(i,ix+1,sumw2);
144 }
145 }
146 }
147
148 AliCodeTimerStop("from external to internal store");
149
150 /// and we add this internal store to what we already have
151
152 InternalAdd(*istore);
153
154 /// delete the temporary internal store.
155 AliCodeTimerStart("delete");
156 delete istore;
157 AliCodeTimerStop("delete");
158
159 return kTRUE;
160}
161
162//_____________________________________________________________________________
163Double_t
164AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
165{
166 /// Return the value of a given buspatch for a given dimension
167 /// or 0 if not existing
168 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
169 return param ? Value(*param,0,dim) : 0.0;
170}
171
172//_____________________________________________________________________________
173AliMUONVCalibParam*
174AliMUONTrackerData::BusPatchParam(Int_t busPatchId) const
175{
176 /// Return (if it exist), the VCalibParam for a given busPatch
177 return fBusPatchValues ? static_cast<AliMUONVCalibParam*>
178 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
179}
180
181//_____________________________________________________________________________
182Double_t
183AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
184{
185 /// Return the value fo a given chamber for a given dimension,
186 /// or zero if not existing
187 AliMUONVCalibParam* param = ChamberParam(chamberId);
188 return param ? Value(*param,0,dim) : 0.0;
189}
190
191//_____________________________________________________________________________
192AliMUONVCalibParam*
193AliMUONTrackerData::ChamberParam(Int_t chamberId) const
194{
195 /// Return (if it exist) the VCalibParam for a given chamber
196 return fChamberValues ? static_cast<AliMUONVCalibParam*>
197 (fChamberValues->FindObject(chamberId)) : 0x0;
198}
199
200//_____________________________________________________________________________
201Double_t
202AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
203 Int_t manuChannel, Int_t dim) const
204{
205 /// Return the value for a given channel for a given dimension
206
207 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
208
209 return param ? Value(*param,manuChannel,dim) : 0.0;
210}
211
212//_____________________________________________________________________________
213AliMUONVCalibParam*
214AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId) const
215{
216 /// Return (if it exist) the VCalibParam for a given manu
217 return fChannelValues ? static_cast<AliMUONVCalibParam*>
218 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
219}
220
221
222//_____________________________________________________________________________
223void
224AliMUONTrackerData::Clear(Option_t*)
225{
226 /// Clear all the values
227 if ( fChannelValues ) fChannelValues->Clear();
228 if ( fManuValues ) fManuValues->Clear();
229 if ( fBusPatchValues) fBusPatchValues->Clear();
230 if ( fPCBValues ) fPCBValues->Clear();
231 if ( fDEValues) fDEValues->Clear();
232 if ( fChamberValues) fChamberValues->Clear();
233 fNevents = 0;
234 NumberOfEventsChanged();
235}
236
237//_____________________________________________________________________________
238Double_t
239AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
240 Int_t manuChannel) const
241{
242 /// Return the number of times a given channel had data
243 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>
244 (fChannelValues->FindObject(detElemId,manuId));
245
246 if ( !param ) return 0.0;
247
248 return param->ValueAsDouble(manuChannel,IndexOfOccupancyDimension());
249}
250
251//_____________________________________________________________________________
252AliMUONVCalibParam*
253AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param) const
254{
255 /// Create a double version of VCalibParam, for internal use
256 AliMUONVCalibParam* c = new AliMUONCalibParamND(param.Dimension()+fgkExtraDimension,
257 param.Size(),
258 param.ID0(),
259 param.ID1(),
260 0.0);
261
262 for ( Int_t i = 0; i < c->Size(); ++i )
263 {
264 c->SetValueAsDouble(i,IndexOfNumberDimension(),1.0);
265 }
266
267 return c;
268}
269
270//_____________________________________________________________________________
271Double_t
272AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
273{
274 /// Return the value for a given detection element for a given dimension
275 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
276 return param ? Value(*param,0,dim) : 0.0;
277
278}
279
280//_____________________________________________________________________________
281AliMUONVCalibParam*
282AliMUONTrackerData::DetectionElementParam(Int_t detElemId) const
283{
284 /// Return (if it exist) the VCalibParam for a given detection element
285 return fDEValues ? static_cast<AliMUONVCalibParam*>
286 (fDEValues->FindObject(detElemId)) : 0x0 ;
287}
288
289//_____________________________________________________________________________
290TString
291AliMUONTrackerData::DimensionName(Int_t dim) const
292{
293 /// Get the name of a given dimension
294 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
295 if ( value )
296 {
297 return value->String();
298 }
299 else
300 {
301 return TString("Invalid");
302 }
303}
304
305//_____________________________________________________________________________
306Bool_t
307AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
308{
309 /// Whether we have data for a given buspatch
310 return ( BusPatchParam(busPatchId) != 0 );
311}
312
313//_____________________________________________________________________________
314Bool_t
315AliMUONTrackerData::HasChamber(Int_t chamberId) const
316{
317 /// Whether we have data for a given chamber
318 return ( ChamberParam(chamberId) != 0 );
319}
320
321//_____________________________________________________________________________
322Bool_t
323AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
324{
325 /// Whether we have data for a given detection element
326 return ( DetectionElementParam(detElemId) != 0 );
327}
328
329//_____________________________________________________________________________
330Bool_t
331AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
332{
333 /// Whether we have data for a given manu
334 return ( ManuParam(detElemId,manuId) != 0 );
335}
336
337//_____________________________________________________________________________
338Bool_t
339AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
340{
341 /// Whether we have data for a given pcb
342 return ( PCBParam(detElemId,pcbIndex) != 0 );
343}
344
345//_____________________________________________________________________________
346Bool_t
347AliMUONTrackerData::InternalAdd(const AliMUONVStore& store)
348{
349 /// Add the given store to our internal store
350 /// Store must be of dimension = fDimension-1
351
352 AliCodeTimerAuto(GetName());
353
354 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
355
356 ++fNevents;
357 NumberOfEventsChanged();
358
359 if (!fChannelValues)
360 {
361 fChannelValues = store.Create();
362 fManuValues = store.Create();
363 fBusPatchValues = store.Create();
364 fDEValues = store.Create();
365 fChamberValues = store.Create();
366 fPCBValues = store.Create();
367 }
368
369 TIter next(store.CreateIterator());
370 AliMUONVCalibParam* external;
371
372 AliMpHVNamer namer;
373
374 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
375 {
376 if ( external->Dimension() != fDimension-fgkExtraDimension )
377 {
378 AliError(Form("Incompatible dimensions %d vs %d",
379 external->Dimension(),fDimension-fgkExtraDimension));
380 return kFALSE;
381 }
382
383 Int_t detElemId = external->ID0();
384
385 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
386
387 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
388
389 Int_t manuId = external->ID1();
390
391 AliMpDetElement* mpde = ddlStore->GetDetElement(detElemId);
392
393 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
394
395 Int_t pcbIndex = -1;
396
397 if ( stationType == AliMp::kStation345 )
398 {
399 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
400 }
401
402 AliMUONVCalibParam* channel = ChannelParam(detElemId,manuId);
403 if (!channel)
404 {
405 channel = CreateDouble(*external);
406 fChannelValues->Add(channel);
407 }
408
409 AliMUONVCalibParam* manu = ManuParam(detElemId,manuId);
410 if (!manu)
411 {
412 manu = new AliMUONCalibParamND(external->Dimension()+fgkExtraDimension,
413 1,
414 detElemId,
415 manuId,
416 0.0);
417
418 // set the number of channels in that manu
419
420 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
421
422 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
423
424 fManuValues->Add(manu);
425 }
426
427 AliMUONVCalibParam* busPatch = BusPatchParam(busPatchId);
428 if (!busPatch)
429 {
430 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
431
432 if (!bp)
433 {
434 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
435 continue;
436 }
437
438 busPatch = new AliMUONCalibParamND(external->Dimension()+fgkExtraDimension,
439 1,
440 busPatchId,
441 0,
442 0.0);
443
444 // set the number of channels in that buspatch
445
446 Int_t nchannels(0);
447
448 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
449
450 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
451 {
452 Int_t manuId = bp->GetManuId(i);
453 nchannels += de->NofChannelsInManu(manuId);
454 }
455
456 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
457
458 fBusPatchValues->Add(busPatch);
459 }
460
461 AliMUONVCalibParam* de = DetectionElementParam(detElemId);
462 if (!de)
463 {
464 de = new AliMUONCalibParamND(external->Dimension()+fgkExtraDimension,
465 1,
466 detElemId,
467 0,
468 0.0);
469
470 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
471 Int_t nchannels(0);
472
473 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
474 {
475 Int_t busPatchId = det->GetBusPatchId(i);
476 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
477 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
478 {
479 Int_t manuId = bp->GetManuId(j);
480 nchannels += det->NofChannelsInManu(manuId);
481 }
482 }
483
484 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
485
486 fDEValues->Add(de);
487 }
488
489 AliMUONVCalibParam* chamber = ChamberParam(chamberId);
490 if (!chamber)
491 {
492 chamber = new AliMUONCalibParamND(external->Dimension()+fgkExtraDimension,
493 1,
494 chamberId,
495 0,
496 0.0);
497
498 // set the number of channels in that chamber
499
500 Int_t nchannels(0);
501
502 AliMpDEIterator it;
503
504 it.First(chamberId);
505
506 while ( !it.IsDone() )
507 {
508 AliMpDetElement* det = it.CurrentDE();
509
510 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
511 {
512 Int_t busPatchId = det->GetBusPatchId(i);
513 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
514 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
515 {
516 Int_t manuId = bp->GetManuId(j);
517 nchannels += det->NofChannelsInManu(manuId);
518 }
519 }
520
521 it.Next();
522 }
523
524 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
525
526 fChamberValues->Add(chamber);
527 }
528
529 AliMUONVCalibParam* pcb = 0x0;
530
531 if ( pcbIndex >= 0 )
532 {
533 pcb = PCBParam(detElemId,pcbIndex);
534 if (!pcb)
535 {
536 pcb = new AliMUONCalibParamND(external->Dimension()+fgkExtraDimension,
537 namer.NumberOfPCBs(detElemId),
538 detElemId,
539 pcbIndex,
540 0.0);
541 fPCBValues->Add(pcb);
542 }
543 }
544
545 for ( Int_t i = 0; i < external->Size(); ++i )
546 {
547 Bool_t existingChannel = mpde->IsConnectedChannel(manuId,i);
548
549 if ( existingChannel )
550 {
551 Bool_t validChannel(kFALSE);
552
553 for ( Int_t j = 0; j < external->Dimension(); ++j )
554 {
555 if ( external->ValueAsFloat(i,j) >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
556
557 validChannel = kTRUE;
558
559 Double_t vext = external->IsDoublePrecision() ?
560 external->ValueAsDouble(i,j) :
561 external->ValueAsFloat(i,j);
562
563 Double_t value = channel->ValueAsDouble(i,j) + vext;
564
565 channel->SetValueAsDouble(i,j,value);
566
567 manu->SetValueAsDouble(0,j,manu->ValueAsDouble(0,j)+vext);
568
569 busPatch->SetValueAsDouble(0,j,busPatch->ValueAsDouble(0,j)+vext);
570
571 de->SetValueAsDouble(0,j,de->ValueAsDouble(0,j)+vext);
572
573 chamber->SetValueAsDouble(0,j,chamber->ValueAsDouble(0,j)+vext);
574
575 if ( pcb )
576 {
577 pcb->SetValueAsDouble(pcbIndex,j,pcb->ValueAsDouble(pcbIndex,j)+vext);
578 }
579 }
580
581 if ( validChannel )
582 {
583 channel->SetValueAsDouble(i,IndexOfOccupancyDimension(),
584 channel->ValueAsDouble(i,IndexOfOccupancyDimension())+1.0);
585 manu->SetValueAsDouble(0,IndexOfOccupancyDimension(),
586 manu->ValueAsDouble(0,IndexOfOccupancyDimension())+1.0);
587 busPatch->SetValueAsDouble(0,IndexOfOccupancyDimension(),
588 busPatch->ValueAsDouble(0,IndexOfOccupancyDimension())+1.0);
589 de->SetValueAsDouble(0,IndexOfOccupancyDimension(),
590 de->ValueAsDouble(0,IndexOfOccupancyDimension())+1.0);
591 chamber->SetValueAsDouble(0,IndexOfOccupancyDimension(),
592 chamber->ValueAsDouble(0,IndexOfOccupancyDimension())+1.0);
593 if ( pcb )
594 {
595 pcb->SetValueAsDouble(pcbIndex,IndexOfOccupancyDimension(),
596 pcb->ValueAsDouble(pcbIndex,IndexOfOccupancyDimension())+1.0);
597 }
598 }
599 }
600 }
601 }
602
603 return kTRUE;
604}
605
606//_____________________________________________________________________________
607Double_t
608AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
609{
610 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
611 return param ? Value(*param,0,dim) : 0.0;
612}
613
614//_____________________________________________________________________________
615AliMUONVCalibParam*
616AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId) const
617{
618 return fManuValues ? static_cast<AliMUONVCalibParam*>
619 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
620}
621
622//_____________________________________________________________________________
623Int_t
624AliMUONTrackerData::NumberOfDimensions() const
625{
626 /// Number of dimensions we're dealing with
627
628 return fDimension + fgkVirtualExtraDimension;
629}
630
631//_____________________________________________________________________________
632Double_t
633AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
634{
635 /// Return the value of a given pcb for a given dimension
636
637 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
638
639 return param ? Value(*param,pcbIndex,dim) : 0.0;
640}
641
642//_____________________________________________________________________________
643AliMUONVCalibParam*
644AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex) const
645{
646 /// Return (if it exist) the VCalibParam for a given pcb
647 return fPCBValues ? static_cast<AliMUONVCalibParam*>
648 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
649}
650
651//_____________________________________________________________________________
652void
653AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
654{
655 /// Printout
656
657 TNamed::Print(opt);
658
659 if ( fIsRunnable )
660 {
661 cout << " Nevents=" << fNevents << endl;
662 }
663
664 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
665 {
666 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
667 cout << Form("Dimension %2d Name %s",i,
668 ( name ? name->String().Data() : "null")) << endl;
669 }
670
671 cout << Form("External Dimensions = %d",fExternalDimension) << endl;
672
673 TString sopt(opt);
674 sopt.ToUpper();
675
676 if ( sopt.Contains("CHANNEL") && fChannelValues )
677 {
678 fChannelValues->Print(wildcard,opt);
679 }
680
681 if ( sopt.Contains("MANU") && fManuValues )
682 {
683 fManuValues->Print(wildcard,opt);
684 }
685
686 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
687 {
688 fBusPatchValues->Print(wildcard,opt);
689 }
690
691 if ( sopt.Contains("DE") && fDEValues )
692 {
693 fDEValues->Print(wildcard,opt);
694 }
695
696 if ( sopt.Contains("CHAMBER") && fChamberValues )
697 {
698 fChamberValues->Print(wildcard,opt);
699 }
700
701}
702
703//_____________________________________________________________________________
704void
705AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
706{
707 /// Set the name of a given dimension
708
709 if ( index >= fExternalDimension )
710 {
711 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
712 return;
713 }
714
715 Int_t ix = External2Internal(index);
716
717 const char* prefix[] = { "mean", "sigma" };
718
719 for ( Int_t i = 0; i < 2; ++i )
720 {
721 Int_t j = ix+i;
722
723 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
724 }
725}
726
727//_____________________________________________________________________________
728void
729AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
730{
731 /// Set the name of a given internal dimension
732 if ( index >= fDimension )
733 {
734 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
735 return;
736 }
737
738 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
739
740 if ( ovalue )
741 {
742 fDimensionNames->Remove(ovalue);
743 delete ovalue;
744 }
745 fDimensionNames->AddAt(new TObjString(value),index);
746}
747
748//_____________________________________________________________________________
749Double_t
750AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) const
751{
752 /// Compute the value for a given dim, using the internal information we have
753 /// Basically we're converting sum of weights and sum of squares of weights
754 /// into means and sigmas, and number of events into occupancy number.
755
756 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
757
758 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
759
760 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
761
762 if ( dim >= fDimension )
763 {
764 return occ;
765 }
766
767 if ( dim == IndexOfOccupancyDimension() ) return occ/n/NumberOfEvents();
768
769 Double_t value = param.ValueAsDouble(i,dim);
770
771 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
772
773 if ( TMath::Even(dim) )
774 {
775 return value/occ;
776 }
777 else
778 {
779 Double_t sumw = param.ValueAsDouble(i,dim-1);
780 Double_t mean = sumw/n;
781
782 return TMath::Sqrt(TMath::Abs(value/occ - mean*mean));
783 }
784
785 AliError("Why am I here ?");
786 return 0.0;
787}
788