1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliMUONTrackerData.h"
20 #include "AliCodeTimer.h"
22 #include "AliMUON1DArray.h"
23 #include "AliMUON1DMap.h"
24 #include "AliMUON2DMap.h"
25 #include "AliMUONCalibParamND.h"
26 #include "AliMUONSparseHisto.h"
27 #include "AliMUONVStore.h"
28 #include "AliMpBusPatch.h"
29 #include "AliMpConstants.h"
30 #include "AliMpDDLStore.h"
31 #include "AliMpDEIterator.h"
32 #include "AliMpDEManager.h"
33 #include "AliMpDetElement.h"
34 #include "AliMpHVNamer.h"
35 #include "AliMpManuIterator.h"
36 #include <Riostream.h>
38 #include <TObjArray.h>
39 #include <TObjString.h>
44 /// \class AliMUONTrackerData
46 /// Implementation of AliMUONVTrackerData class
48 /// \author Laurent Aphecetche, Subatech
51 ClassImp(AliMUONTrackerData)
54 const Int_t AliMUONTrackerData::fgkExtraDimension = 2;
55 const Int_t AliMUONTrackerData::fgkVirtualExtraDimension = 1;
57 //_____________________________________________________________________________
58 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
61 : AliMUONVTrackerData(name,title),
62 fIsSingleEvent(issingleevent),
69 fDimension(External2Internal(dimension)+fgkExtraDimension),
71 fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)),
72 fExternalDimensionNames(new TObjArray(dimension)),
73 fExternalDimension(dimension),
74 fHistogramming(new Int_t[fExternalDimension]),
80 memset(fHistogramming,0,sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
81 fExternalDimensionNames->SetOwner(kTRUE);
82 fDimensionNames->SetOwner(kTRUE);
83 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
84 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
85 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
89 //_____________________________________________________________________________
90 AliMUONTrackerData::~AliMUONTrackerData()
93 delete fChannelValues;
95 delete fBusPatchValues;
97 delete fChamberValues;
99 delete fDimensionNames;
100 delete fExternalDimensionNames;
101 delete[] fHistogramming;
102 delete fChannelHistos;
105 //_____________________________________________________________________________
107 AliMUONTrackerData::Add(const AliMUONVStore& store)
109 /// Add the given external store to our internal store
110 return InternalAdd(store,kFALSE);
113 //_____________________________________________________________________________
115 AliMUONTrackerData::Replace(const AliMUONVStore& store)
117 /// Replace our values by values from the given external store
118 Bool_t rv = InternalAdd(store,kTRUE);
119 AliMUONVTrackerData::Replace(store);
123 //_____________________________________________________________________________
125 AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, Bool_t replace)
127 /// Add the given external store to our internal store
129 AliCodeTimerAuto(GetName());
133 if ( IsSingleEvent() && fNevents == 1 )
135 AliError(Form("%s is supposed to be single event only",GetName()));
139 NumberOfEventsChanged();
144 Int_t numberOfBusPatches(0);
145 Int_t numberOfDEs(0);
147 // get number of bus patches and number of detection element
148 // to initialize fBusPatchValues and fDEValues below
150 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
151 while ( next() ) ++numberOfBusPatches;
152 AliMpDEIterator deIt;
154 while (!deIt.IsDone())
160 fChannelValues = new AliMUON2DMap(kTRUE);
161 fManuValues = new AliMUON2DMap(kTRUE);
162 fPCBValues = new AliMUON2DMap(kFALSE);
163 fBusPatchValues = new AliMUON1DMap(numberOfBusPatches);
164 fDEValues = new AliMUON1DMap(numberOfDEs);
165 fChamberValues = new AliMUON1DArray;
168 TIter next(store.CreateIterator());
169 AliMUONVCalibParam* external;
173 if ( IsSingleEvent() ) nk = 1;
175 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
177 if ( external->Dimension() != ExternalDimension() )
179 AliError(Form("Incompatible dimensions %d vs %d",
180 external->Dimension(),ExternalDimension()));
185 AliMUONVCalibParam* chamber, *de, *busPatch, *pcb, *manu, *channel;
186 AliMpDetElement* mpde;
188 Int_t manuId = GetParts(external,chamber,de,busPatch,pcb,manu,channel,mpde);
190 if ( manuId < 0 ) continue;
192 Int_t detElemId = mpde->GetId();
194 Double_t value[] = { 0.0, 0.0 };
196 Int_t nch = mpde->NofChannelsInManu(manuId);
198 for ( Int_t i = 0; i < external->Size(); ++i )
200 Bool_t existingChannel = ( nch == AliMpConstants::ManuNofChannels() ? kTRUE
201 : mpde->IsConnectedChannel(manuId,i));
202 // note we only use IsConnectedChannel method when really needed, as
203 // it costs (some) CPU time...
205 if ( existingChannel )
207 Bool_t validChannel(kFALSE);
209 for ( Int_t j = 0; j < external->Dimension(); ++j )
211 Double_t vext = external->IsDoublePrecision() ?
212 external->ValueAsDoubleFast(i,j) :
213 external->ValueAsFloatFast(i,j);
215 if ( vext >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
217 validChannel = kTRUE;
219 Int_t ix = External2Internal(j);
222 value[1] = vext*vext;
224 if ( IsHistogrammed(j) )
226 FillChannel(detElemId,manuId,i,j,vext);
229 for ( Int_t k = 0; k < nk; ++k )
231 Double_t e = replace ? channel->ValueAsDoubleFast(i,ix+k) : 0.0;
233 channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)-e+value[k]);
235 manu->SetValueAsDoubleFast(0,ix+k,manu->ValueAsDoubleFast(0,ix+k)-e+value[k]);
237 busPatch->SetValueAsDoubleFast(0,ix+k,busPatch->ValueAsDoubleFast(0,ix+k)-e+value[k]);
239 de->SetValueAsDoubleFast(0,ix+k,de->ValueAsDoubleFast(0,ix+k)-e+value[k]);
241 chamber->SetValueAsDoubleFast(0,ix+k,chamber->ValueAsDoubleFast(0,ix+k)-e+value[k]);
245 pcb->SetValueAsDoubleFast(0,ix+k,pcb->ValueAsDoubleFast(0,ix+k)-e+value[k]);
250 if ( validChannel && !replace )
252 channel->SetValueAsDoubleFast(i,IndexOfOccupancyDimension(),
253 channel->ValueAsDoubleFast(i,IndexOfOccupancyDimension())+1.0);
254 manu->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
255 manu->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
256 busPatch->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
257 busPatch->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
258 de->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
259 de->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
260 chamber->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
261 chamber->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
264 pcb->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
265 pcb->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
275 //_____________________________________________________________________________
277 AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
279 /// Return the value of a given buspatch for a given dimension
280 /// or 0 if not existing
281 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
282 return param ? Value(*param,0,dim) : 0.0;
285 //_____________________________________________________________________________
287 AliMUONTrackerData::BusPatchParam(Int_t busPatchId, Bool_t create) const
289 /// Return (if it exist), the VCalibParam for a given busPatch
291 AliMUONVCalibParam* busPatch = fBusPatchValues ? static_cast<AliMUONVCalibParam*>
292 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
294 if (!busPatch && create && fBusPatchValues)
296 busPatch = CreateBusPatchParam(busPatchId);
297 fBusPatchValues->Add(busPatch);
303 //_____________________________________________________________________________
305 AliMUONTrackerData::CreateBusPatchParam(Int_t busPatchId) const
307 /// Create storage for one bus patch
309 AliCodeTimerAuto("");
311 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
315 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
319 AliMUONVCalibParam* busPatch = new AliMUONCalibParamND(Dimension(),1,busPatchId,0,0.0);
321 // set the number of channels in that buspatch
325 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
327 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
329 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
331 Int_t manuId = bp->GetManuId(i);
332 nchannels += de->NofChannelsInManu(manuId);
335 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
340 //_____________________________________________________________________________
342 AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
344 /// Return the value fo a given chamber for a given dimension,
345 /// or zero if not existing
346 AliMUONVCalibParam* param = ChamberParam(chamberId);
347 return param ? Value(*param,0,dim) : 0.0;
350 //_____________________________________________________________________________
352 AliMUONTrackerData::ChamberParam(Int_t chamberId, Bool_t create) const
354 /// Return (if it exist) the VCalibParam for a given chamber
356 AliMUONVCalibParam* chamber = fChamberValues ? static_cast<AliMUONVCalibParam*>
357 (fChamberValues->FindObject(chamberId)) : 0x0;
359 if (!chamber && create && fChamberValues)
361 chamber = CreateChamberParam(chamberId);
362 fChamberValues->Add(chamber);
368 //_____________________________________________________________________________
370 AliMUONTrackerData::CreateChamberParam(Int_t chamberId) const
372 /// Create storage for one chamber
374 AliCodeTimerAuto("");
376 AliMUONVCalibParam* chamber = new AliMUONCalibParamND(Dimension(),1,chamberId,0,0.0);
378 // set the number of channels in that chamber
386 while ( !it.IsDone() )
388 AliMpDetElement* det = it.CurrentDE();
390 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
392 Int_t busPatchId = det->GetBusPatchId(i);
393 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
394 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
396 Int_t manuId = bp->GetManuId(j);
397 nchannels += det->NofChannelsInManu(manuId);
404 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
409 //_____________________________________________________________________________
411 AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
412 Int_t manuChannel, Int_t dim) const
414 /// Return the value for a given channel for a given dimension
416 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
418 return param ? Value(*param,manuChannel,dim) : 0.0;
421 //_____________________________________________________________________________
423 AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId,
424 AliMUONVCalibParam* external) const
426 /// Return (if it exist) the VCalibParam for a given manu
428 AliMUONVCalibParam* param = fChannelValues ? static_cast<AliMUONVCalibParam*>
429 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
431 if (!param && external && fChannelValues)
433 param = CreateDouble(*external,detElemId,manuId);
434 fChannelValues->Add(param);
440 //_____________________________________________________________________________
442 AliMUONTrackerData::Clear(Option_t*)
444 /// Clear all the values
445 if ( fChannelValues ) fChannelValues->Clear();
446 if ( fManuValues ) fManuValues->Clear();
447 if ( fBusPatchValues) fBusPatchValues->Clear();
448 if ( fPCBValues ) fPCBValues->Clear();
449 if ( fDEValues) fDEValues->Clear();
450 if ( fChamberValues ) fChamberValues->Clear();
451 if ( fChannelHistos ) fChannelHistos->Clear();
453 NumberOfEventsChanged();
456 //_____________________________________________________________________________
458 AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
459 Int_t manuChannel) const
461 /// Return the number of times a given channel had data
463 return Channel(detElemId,manuId,manuChannel,IndexOfNumberDimension());
466 //_____________________________________________________________________________
468 AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param,
469 Int_t detElemId, Int_t manuId) const
471 /// Create a double version of VCalibParam, for internal use
473 AliCodeTimerAuto("");
475 AliMUONVCalibParam* c = new AliMUONCalibParamND(Dimension(),
481 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId,manuId);
483 for ( Int_t i = 0; i < c->Size(); ++i )
487 if ( de->IsConnectedChannel(manuId,i) ) value = 1.0;
489 c->SetValueAsDouble(i,IndexOfNumberDimension(),value);
495 //_____________________________________________________________________________
497 AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
499 /// Return the value for a given detection element for a given dimension
500 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
501 return param ? Value(*param,0,dim) : 0.0;
505 //_____________________________________________________________________________
507 AliMUONTrackerData::DetectionElementParam(Int_t detElemId, Bool_t create) const
509 /// Return (if it exist) the VCalibParam for a given detection element
511 AliMUONVCalibParam* de = fDEValues ? static_cast<AliMUONVCalibParam*>
512 (fDEValues->FindObject(detElemId)) : 0x0 ;
514 if (!de && create && fDEValues)
516 de = CreateDetectionElementParam(detElemId);
524 //_____________________________________________________________________________
526 AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
528 /// Create storage for one detection element
530 AliCodeTimerAuto("");
532 AliMUONVCalibParam* de = new AliMUONCalibParamND(Dimension(),1,detElemId,0,0.0);
534 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
537 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
539 Int_t busPatchId = det->GetBusPatchId(i);
540 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
541 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
543 Int_t manuId = bp->GetManuId(j);
544 nchannels += det->NofChannelsInManu(manuId);
548 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
553 //_____________________________________________________________________________
555 AliMUONTrackerData::DimensionName(Int_t dim) const
557 /// Get the name of a given dimension
558 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
561 return value->String();
565 return TString("Invalid");
569 //_____________________________________________________________________________
571 AliMUONTrackerData::External2Internal(Int_t index) const
573 /// From external to internal dimension
574 return IsSingleEvent() ? index : index*2;
577 //_____________________________________________________________________________
579 AliMUONTrackerData::ExternalDimensionName(Int_t dim) const
581 /// Get the name of a given external dimension
583 TObjString* value = static_cast<TObjString*>(fExternalDimensionNames->At(dim));
586 return value->String();
590 return TString("Invalid");
594 //_____________________________________________________________________________
596 AliMUONTrackerData::FillChannel(Int_t detElemId, Int_t manuId, Int_t manuChannel,
597 Int_t dim, Double_t value)
599 /// Fill histogram of a given channel
601 AliMUONSparseHisto* h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
603 h->Fill(static_cast<Int_t>(TMath::Nint(value)));
606 //_____________________________________________________________________________
608 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
609 Int_t manuChannel, Int_t dim) const
611 /// Get histogram of a given channel
613 if (!fChannelHistos) return 0x0;
615 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fChannelHistos->FindObject(detElemId,manuId));
618 UInt_t uid = ( manuChannel << 16 ) | dim;
620 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
625 //_____________________________________________________________________________
627 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
628 Int_t manuChannel, Int_t dim)
630 /// Get histogram of a given channel. Create it if necessary
632 if (!fChannelHistos) fChannelHistos = new AliMUON2DMap(kTRUE);
634 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fChannelHistos->FindObject(detElemId,manuId));
637 m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
638 m->SetUniqueID( ( manuId << 16 ) | detElemId );
639 fChannelHistos->Add(m);
642 UInt_t uid = ( manuChannel << 16 ) | dim;
644 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
647 h = new AliMUONSparseHisto(fXmin,fXmax);
657 //_____________________________________________________________________________
659 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
660 AliMUONVCalibParam*& chamber,
661 AliMUONVCalibParam*& de,
662 AliMUONVCalibParam*& busPatch,
663 AliMUONVCalibParam*& pcb,
664 AliMUONVCalibParam*& manu,
665 AliMUONVCalibParam*& channel,
666 AliMpDetElement*& mpde)
668 /// Get containers at all levels
670 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
675 if ( external->ID1() <= 0 )
677 // we get a manu serial number
678 Int_t serial = external->ID0();
679 AliMpIntPair pair = ddlStore->GetDetElemIdManu(serial);
680 detElemId = pair.GetFirst();
681 manuId = pair.GetSecond();
684 AliError(Form("DE %d manuId %d from serial %d is not correct !",
685 detElemId,manuId,serial));
691 // we get a (de,manu) pair
692 detElemId = external->ID0();
693 manuId = external->ID1();
696 mpde = ddlStore->GetDetElement(detElemId);
698 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
700 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
704 AliMp::StationType stationType = mpde->GetStationType();
706 if ( stationType == AliMp::kStation345 )
709 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
712 channel = ChannelParam(detElemId,manuId,external);
714 manu = ManuParam(detElemId,manuId,kTRUE);
716 busPatch = BusPatchParam(busPatchId,kTRUE);
718 de = DetectionElementParam(detElemId,kTRUE);
720 chamber = ChamberParam(chamberId,kTRUE);
726 pcb = PCBParam(detElemId,pcbIndex,kTRUE);
732 //_____________________________________________________________________________
734 AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
736 /// Whether we have data for a given buspatch
737 return ( BusPatchParam(busPatchId) != 0 );
740 //_____________________________________________________________________________
742 AliMUONTrackerData::HasChamber(Int_t chamberId) const
744 /// Whether we have data for a given chamber
745 return ( ChamberParam(chamberId) != 0 );
748 //_____________________________________________________________________________
750 AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
752 /// Whether we have data for a given detection element
753 return ( DetectionElementParam(detElemId) != 0 );
756 //_____________________________________________________________________________
758 AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
760 /// Whether we have data for a given manu
761 return ( ManuParam(detElemId,manuId) != 0 );
764 //_____________________________________________________________________________
766 AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
768 /// Whether we have data for a given pcb
769 return ( PCBParam(detElemId,pcbIndex) != 0 );
772 //_____________________________________________________________________________
774 AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
776 /// Return the value for a given manu and a given dimension
778 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
779 return param ? Value(*param,0,dim) : 0.0;
782 //_____________________________________________________________________________
784 AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId, Bool_t create) const
786 /// Get the VCalibParam for a given manu
788 AliMUONVCalibParam* manu = fManuValues ? static_cast<AliMUONVCalibParam*>
789 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
791 if (!manu && create && fManuValues)
793 manu = CreateManuParam(detElemId,manuId);
794 fManuValues->Add(manu);
800 //_____________________________________________________________________________
802 AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
804 /// Create storage for one manu
806 AliCodeTimerAuto("");
808 AliMUONVCalibParam* manu = new AliMUONCalibParamND(Dimension(),1,detElemId,manuId,0.0);
810 // set the number of channels in that manu
812 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
814 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
819 //_____________________________________________________________________________
821 AliMUONTrackerData::Merge(TCollection*)
823 /// Merge all tracker data objects from li into a single one.
825 AliError("Not implemented yet");
830 //_____________________________________________________________________________
832 AliMUONTrackerData::NumberOfDimensions() const
834 /// Number of dimensions we're dealing with
836 return fDimension + fgkVirtualExtraDimension;
839 //_____________________________________________________________________________
841 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
843 /// Return the value of a given pcb for a given dimension
845 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
847 return param ? Value(*param,0,dim) : 0.0;
850 //_____________________________________________________________________________
852 AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex, Bool_t create) const
854 /// Return (if it exist) the VCalibParam for a given pcb
856 AliMUONVCalibParam* pcb = fPCBValues ? static_cast<AliMUONVCalibParam*>
857 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
859 if (create && fPCBValues && !pcb)
861 pcb = CreatePCBParam(detElemId,pcbIndex);
862 fPCBValues->Add(pcb);
868 //_____________________________________________________________________________
870 AliMUONTrackerData::CreatePCBParam(Int_t detElemId, Int_t pcbIndex) const
872 /// Create storage for one PCB (station345 only)
874 AliCodeTimerAuto("");
878 AliMUONVCalibParam* pcb = new AliMUONCalibParamND(Dimension(),
879 namer.NumberOfPCBs(detElemId),
886 //_____________________________________________________________________________
888 AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
894 if ( !fIsSingleEvent )
896 cout << " Nevents=" << fNevents << endl;
899 for ( Int_t i = 0; i <= fExternalDimensionNames->GetLast(); ++i )
901 TObjString* name = static_cast<TObjString*>(fExternalDimensionNames->At(i));
902 cout << Form("External Dimension %2d Name %s %s",i,
903 ( name ? name->String().Data() : "null"),
904 ( IsHistogrammed(i) ? "(histogrammed)" : "")) << endl;
907 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
909 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
910 cout << Form("Internal Dimension %2d Name %s",i,
911 ( name ? name->String().Data() : "null")) << endl;
917 if ( sopt.Contains("CHANNEL") && fChannelValues )
919 fChannelValues->Print(wildcard,opt);
922 if ( sopt.Contains("MANU") && fManuValues )
924 fManuValues->Print(wildcard,opt);
927 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
929 fBusPatchValues->Print(wildcard,opt);
932 if ( sopt.Contains("DE") && fDEValues )
934 fDEValues->Print(wildcard,opt);
937 if ( sopt.Contains("CHAMBER") && fChamberValues )
939 fChamberValues->Print(wildcard,opt);
944 //_____________________________________________________________________________
946 AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
948 /// Set the name of a given dimension
950 if ( index >= fExternalDimension )
952 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
956 Int_t ix = External2Internal(index);
958 if ( !IsSingleEvent() )
960 const char* prefix[] = { "mean", "sigma" };
962 for ( Int_t i = 0; i < 2; ++i )
966 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
971 SetInternalDimensionName(index,name);
974 SetExternalDimensionName(index,name);
977 //_____________________________________________________________________________
979 AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
981 /// decide to make histos for a given dimension
982 if ( index >= ExternalDimension() )
984 AliError(Form("Index out of bounds : %d / %d",index,ExternalDimension()));
988 fHistogramming[index] = value;
993 //_____________________________________________________________________________
995 AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
997 /// Set the name of a given internal dimension
998 if ( index >= fDimension )
1000 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
1004 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
1008 fDimensionNames->Remove(ovalue);
1011 fDimensionNames->AddAt(new TObjString(value),index);
1014 //_____________________________________________________________________________
1016 AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
1018 /// Set the name of a given external dimension
1019 if ( index >= fExternalDimension )
1021 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1025 TObjString* ovalue = static_cast<TObjString*>(fExternalDimensionNames->At(index));
1029 fExternalDimensionNames->Remove(ovalue);
1032 fExternalDimensionNames->AddAt(new TObjString(value),index);
1035 //_____________________________________________________________________________
1037 AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) const
1039 /// Compute the value for a given dim, using the internal information we have
1040 /// Basically we're converting sum of weights and sum of squares of weights
1041 /// into means and sigmas, and number of events into occupancy number.
1043 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
1045 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
1047 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
1049 if ( dim >= fDimension )
1054 if ( dim == IndexOfOccupancyDimension() ) return occ/n/NumberOfEvents();
1056 Double_t value = param.ValueAsDouble(i,dim);
1058 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
1060 if ( TMath::Even(dim) || IsSingleEvent() )
1070 Double_t mean = param.ValueAsDouble(i,dim-1)/nn;
1072 return TMath::Sqrt(TMath::Abs((value-nn*mean*mean)/(nn-1.0)));
1080 AliError("Why am I here ?");