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]),
78 fIsChannelLevelEnabled(kTRUE),
79 fIsManuLevelEnabled(kTRUE)
82 memset(fHistogramming,0,sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
83 fExternalDimensionNames->SetOwner(kTRUE);
84 fDimensionNames->SetOwner(kTRUE);
85 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
86 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
87 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
91 //_____________________________________________________________________________
92 AliMUONTrackerData::~AliMUONTrackerData()
95 delete fChannelValues;
97 delete fBusPatchValues;
99 delete fChamberValues;
101 delete fDimensionNames;
102 delete fExternalDimensionNames;
103 delete[] fHistogramming;
107 //_____________________________________________________________________________
109 AliMUONTrackerData::Add(const AliMUONVStore& store)
111 /// Add the given external store to our internal store
112 return InternalAdd(store,kFALSE);
115 //_____________________________________________________________________________
117 AliMUONTrackerData::Replace(const AliMUONVStore& store)
119 /// Replace our values by values from the given external store
120 Bool_t rv = InternalAdd(store,kTRUE);
121 AliMUONVTrackerData::Replace(store);
125 //_____________________________________________________________________________
127 AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, Bool_t replace)
129 /// Add the given external store to our internal store
131 AliCodeTimerAuto(GetName());
135 if ( IsSingleEvent() && fNevents == 1 )
137 AliError(Form("%s is supposed to be single event only",GetName()));
141 NumberOfEventsChanged();
146 Int_t numberOfBusPatches(0);
147 Int_t numberOfDEs(0);
149 // get number of bus patches and number of detection element
150 // to initialize fBusPatchValues and fDEValues below
152 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
153 while ( next() ) ++numberOfBusPatches;
154 AliMpDEIterator deIt;
156 while (!deIt.IsDone())
162 if ( fIsChannelLevelEnabled )
164 fChannelValues = new AliMUON2DMap(kTRUE);
166 if ( fIsManuLevelEnabled )
168 fManuValues = new AliMUON2DMap(kTRUE);
170 fPCBValues = new AliMUON2DMap(kFALSE);
171 fBusPatchValues = new AliMUON1DMap(numberOfBusPatches);
172 fDEValues = new AliMUON1DMap(numberOfDEs);
173 fChamberValues = new AliMUON1DArray;
176 TIter next(store.CreateIterator());
177 AliMUONVCalibParam* external;
181 if ( IsSingleEvent() ) nk = 1;
183 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
185 if ( external->Dimension() != ExternalDimension() )
187 AliError(Form("Incompatible dimensions %d vs %d",
188 external->Dimension(),ExternalDimension()));
193 AliMUONVCalibParam* chamber, *de, *busPatch, *pcb, *manu, *channel;
194 AliMpDetElement* mpde;
196 Int_t manuId = GetParts(external,chamber,de,busPatch,pcb,manu,channel,mpde);
198 if ( manuId < 0 ) continue;
200 Int_t detElemId = mpde->GetId();
202 Double_t value[] = { 0.0, 0.0 };
204 Int_t nch = mpde->NofChannelsInManu(manuId);
206 for ( Int_t i = 0; i < external->Size(); ++i )
208 Bool_t existingChannel = ( nch == AliMpConstants::ManuNofChannels() ? kTRUE
209 : mpde->IsConnectedChannel(manuId,i));
210 // note we only use IsConnectedChannel method when really needed, as
211 // it costs (some) CPU time...
213 if ( existingChannel )
215 Bool_t validChannel(kFALSE);
217 for ( Int_t j = 0; j < external->Dimension(); ++j )
219 Double_t vext = external->IsDoublePrecision() ?
220 external->ValueAsDoubleFast(i,j) :
221 external->ValueAsFloatFast(i,j);
223 if ( vext >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
225 validChannel = kTRUE;
227 Int_t ix = External2Internal(j);
230 value[1] = vext*vext;
232 if ( IsHistogrammed(j) )
234 FillHisto(detElemId,manuId,i,j,vext);
237 for ( Int_t k = 0; k < nk; ++k )
239 Double_t e = ( replace && channel ) ? channel->ValueAsDoubleFast(i,ix+k) : 0.0;
243 channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)-e+value[k]);
248 manu->SetValueAsDoubleFast(0,ix+k,manu->ValueAsDoubleFast(0,ix+k)-e+value[k]);
251 busPatch->SetValueAsDoubleFast(0,ix+k,busPatch->ValueAsDoubleFast(0,ix+k)-e+value[k]);
253 de->SetValueAsDoubleFast(0,ix+k,de->ValueAsDoubleFast(0,ix+k)-e+value[k]);
255 chamber->SetValueAsDoubleFast(0,ix+k,chamber->ValueAsDoubleFast(0,ix+k)-e+value[k]);
259 pcb->SetValueAsDoubleFast(0,ix+k,pcb->ValueAsDoubleFast(0,ix+k)-e+value[k]);
264 if ( validChannel && !replace )
268 channel->SetValueAsDoubleFast(i,IndexOfOccupancyDimension(),
269 channel->ValueAsDoubleFast(i,IndexOfOccupancyDimension())+1.0);
274 manu->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
275 manu->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
278 busPatch->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
279 busPatch->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
280 de->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
281 de->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
282 chamber->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
283 chamber->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
286 pcb->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
287 pcb->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
297 //_____________________________________________________________________________
299 AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
301 /// Return the value of a given buspatch for a given dimension
302 /// or 0 if not existing
303 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
304 return param ? Value(*param,0,dim) : 0.0;
307 //_____________________________________________________________________________
309 AliMUONTrackerData::BusPatchParam(Int_t busPatchId, Bool_t create) const
311 /// Return (if it exist), the VCalibParam for a given busPatch
313 AliMUONVCalibParam* busPatch = fBusPatchValues ? static_cast<AliMUONVCalibParam*>
314 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
316 if (!busPatch && create && fBusPatchValues)
318 busPatch = CreateBusPatchParam(busPatchId);
319 fBusPatchValues->Add(busPatch);
325 //_____________________________________________________________________________
327 AliMUONTrackerData::CreateBusPatchParam(Int_t busPatchId) const
329 /// Create storage for one bus patch
331 AliCodeTimerAuto("");
333 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
337 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
341 AliMUONVCalibParam* busPatch = new AliMUONCalibParamND(Dimension(),1,busPatchId,0,0.0);
343 // set the number of channels in that buspatch
347 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
349 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
351 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
353 Int_t manuId = bp->GetManuId(i);
354 nchannels += de->NofChannelsInManu(manuId);
357 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
362 //_____________________________________________________________________________
364 AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
366 /// Return the value fo a given chamber for a given dimension,
367 /// or zero if not existing
368 AliMUONVCalibParam* param = ChamberParam(chamberId);
369 return param ? Value(*param,0,dim) : 0.0;
372 //_____________________________________________________________________________
374 AliMUONTrackerData::ChamberParam(Int_t chamberId, Bool_t create) const
376 /// Return (if it exist) the VCalibParam for a given chamber
378 AliMUONVCalibParam* chamber = fChamberValues ? static_cast<AliMUONVCalibParam*>
379 (fChamberValues->FindObject(chamberId)) : 0x0;
381 if (!chamber && create && fChamberValues)
383 chamber = CreateChamberParam(chamberId);
384 fChamberValues->Add(chamber);
390 //_____________________________________________________________________________
392 AliMUONTrackerData::CreateChamberParam(Int_t chamberId) const
394 /// Create storage for one chamber
396 AliCodeTimerAuto("");
398 AliMUONVCalibParam* chamber = new AliMUONCalibParamND(Dimension(),1,chamberId,0,0.0);
400 // set the number of channels in that chamber
408 while ( !it.IsDone() )
410 AliMpDetElement* det = it.CurrentDE();
412 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
414 Int_t busPatchId = det->GetBusPatchId(i);
415 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
416 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
418 Int_t manuId = bp->GetManuId(j);
419 nchannels += det->NofChannelsInManu(manuId);
426 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
431 //_____________________________________________________________________________
433 AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
434 Int_t manuChannel, Int_t dim) const
436 /// Return the value for a given channel for a given dimension
438 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
440 return param ? Value(*param,manuChannel,dim) : 0.0;
443 //_____________________________________________________________________________
445 AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId,
446 AliMUONVCalibParam* external) const
448 /// Return (if it exist) the VCalibParam for a given manu
450 AliMUONVCalibParam* param = fChannelValues ? static_cast<AliMUONVCalibParam*>
451 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
453 if (!param && external && fChannelValues)
455 param = CreateDouble(*external,detElemId,manuId);
456 fChannelValues->Add(param);
462 //_____________________________________________________________________________
464 AliMUONTrackerData::Clear(Option_t*)
466 /// Clear all the values
467 if ( fChannelValues ) fChannelValues->Clear();
468 if ( fManuValues ) fManuValues->Clear();
469 if ( fBusPatchValues) fBusPatchValues->Clear();
470 if ( fPCBValues ) fPCBValues->Clear();
471 if ( fDEValues) fDEValues->Clear();
472 if ( fChamberValues ) fChamberValues->Clear();
473 if ( fHistos ) fHistos->Clear();
475 NumberOfEventsChanged();
478 //_____________________________________________________________________________
480 AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
481 Int_t manuChannel) const
483 /// Return the number of times a given channel had data
485 return Channel(detElemId,manuId,manuChannel,IndexOfNumberDimension());
488 //_____________________________________________________________________________
490 AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param,
491 Int_t detElemId, Int_t manuId) const
493 /// Create a double version of VCalibParam, for internal use
495 AliCodeTimerAuto("");
497 AliMUONVCalibParam* c = new AliMUONCalibParamND(Dimension(),
503 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId,manuId);
505 for ( Int_t i = 0; i < c->Size(); ++i )
509 if ( de->IsConnectedChannel(manuId,i) ) value = 1.0;
511 c->SetValueAsDouble(i,IndexOfNumberDimension(),value);
517 //_____________________________________________________________________________
519 AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
521 /// Return the value for a given detection element for a given dimension
522 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
523 return param ? Value(*param,0,dim) : 0.0;
527 //_____________________________________________________________________________
529 AliMUONTrackerData::DetectionElementParam(Int_t detElemId, Bool_t create) const
531 /// Return (if it exist) the VCalibParam for a given detection element
533 AliMUONVCalibParam* de = fDEValues ? static_cast<AliMUONVCalibParam*>
534 (fDEValues->FindObject(detElemId)) : 0x0 ;
536 if (!de && create && fDEValues)
538 de = CreateDetectionElementParam(detElemId);
546 //_____________________________________________________________________________
548 AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
550 /// Create storage for one detection element
552 AliCodeTimerAuto("");
554 AliMUONVCalibParam* de = new AliMUONCalibParamND(Dimension(),1,detElemId,0,0.0);
556 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
559 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
561 Int_t busPatchId = det->GetBusPatchId(i);
562 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
563 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
565 Int_t manuId = bp->GetManuId(j);
566 nchannels += det->NofChannelsInManu(manuId);
570 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
575 //_____________________________________________________________________________
577 AliMUONTrackerData::DimensionName(Int_t dim) const
579 /// Get the name of a given dimension
580 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
583 return value->String();
587 return TString("Invalid");
591 //_____________________________________________________________________________
593 AliMUONTrackerData::DisableChannelLevel()
595 /// Disable the storing of data at channel level
597 delete fChannelValues;
598 fChannelValues = 0x0;
599 fIsChannelLevelEnabled = kFALSE;
602 //_____________________________________________________________________________
604 AliMUONTrackerData::DisableManuLevel()
606 /// Disable the storing of data at manu level (and below)
608 DisableChannelLevel();
611 fIsManuLevelEnabled = kFALSE;
614 //_____________________________________________________________________________
616 AliMUONTrackerData::External2Internal(Int_t index) const
618 /// From external to internal dimension
619 return IsSingleEvent() ? index : index*2;
622 //_____________________________________________________________________________
624 AliMUONTrackerData::ExternalDimensionName(Int_t dim) const
626 /// Get the name of a given external dimension
628 TObjString* value = static_cast<TObjString*>(fExternalDimensionNames->At(dim));
631 return value->String();
635 return TString("Invalid");
639 //_____________________________________________________________________________
641 AliMUONTrackerData::FillHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel,
642 Int_t dim, Double_t value)
644 /// Fill histogram of a given channel
646 AliMUONSparseHisto* h(0x0);
648 if ( fIsChannelLevelEnabled )
650 h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
652 else if ( fIsManuLevelEnabled )
654 h = GetManuSparseHisto(detElemId,manuId,dim);
657 AliDebug(1,Form("DE %04d MANU %04d CH %02d dim %d value %e h %p",detElemId,manuId,manuChannel,dim,value,h));
661 h->Fill(static_cast<Int_t>(TMath::Nint(value)));
665 //_____________________________________________________________________________
667 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId,
670 /// Get histogram of a given manu
672 if (!fHistos) return 0x0;
674 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
677 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
682 //_____________________________________________________________________________
684 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId, Int_t dim)
686 /// Get histogram of a given manu. Create it if necessary
688 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
690 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
693 m = new AliMUON1DArray(NumberOfDimensions());
694 m->SetUniqueID( ( manuId << 16 ) | detElemId );
698 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
701 h = new AliMUONSparseHisto(fXmin,fXmax);
711 //_____________________________________________________________________________
713 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
714 Int_t manuChannel, Int_t dim) const
716 /// Get histogram of a given channel
718 if (!fHistos) return 0x0;
720 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
723 UInt_t uid = ( manuChannel << 16 ) | dim;
725 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
730 //_____________________________________________________________________________
732 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
733 Int_t manuChannel, Int_t dim)
735 /// Get histogram of a given channel. Create it if necessary
737 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
739 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
742 m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
743 m->SetUniqueID( ( manuId << 16 ) | detElemId );
747 UInt_t uid = ( manuChannel << 16 ) | dim;
749 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
752 h = new AliMUONSparseHisto(fXmin,fXmax);
762 //_____________________________________________________________________________
764 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
765 AliMUONVCalibParam*& chamber,
766 AliMUONVCalibParam*& de,
767 AliMUONVCalibParam*& busPatch,
768 AliMUONVCalibParam*& pcb,
769 AliMUONVCalibParam*& manu,
770 AliMUONVCalibParam*& channel,
771 AliMpDetElement*& mpde)
773 /// Get containers at all levels
775 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
780 if ( external->ID1() <= 0 )
782 // we get a manu serial number
783 Int_t serial = external->ID0();
784 AliMpIntPair pair = ddlStore->GetDetElemIdManu(serial);
785 detElemId = pair.GetFirst();
786 manuId = pair.GetSecond();
789 AliError(Form("DE %d manuId %d from serial %d is not correct !",
790 detElemId,manuId,serial));
796 // we get a (de,manu) pair
797 detElemId = external->ID0();
798 manuId = external->ID1();
801 mpde = ddlStore->GetDetElement(detElemId);
803 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
805 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
809 AliMp::StationType stationType = mpde->GetStationType();
811 if ( stationType == AliMp::kStation345 )
814 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
817 channel = ChannelParam(detElemId,manuId,external);
819 manu = ManuParam(detElemId,manuId,kTRUE);
821 busPatch = BusPatchParam(busPatchId,kTRUE);
823 de = DetectionElementParam(detElemId,kTRUE);
825 chamber = ChamberParam(chamberId,kTRUE);
831 pcb = PCBParam(detElemId,pcbIndex,kTRUE);
837 //_____________________________________________________________________________
839 AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
841 /// Whether we have data for a given buspatch
842 return ( BusPatchParam(busPatchId) != 0 );
845 //_____________________________________________________________________________
847 AliMUONTrackerData::HasChamber(Int_t chamberId) const
849 /// Whether we have data for a given chamber
850 return ( ChamberParam(chamberId) != 0 );
853 //_____________________________________________________________________________
855 AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
857 /// Whether we have data for a given detection element
858 return ( DetectionElementParam(detElemId) != 0 );
861 //_____________________________________________________________________________
863 AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
865 /// Whether we have data for a given manu
866 return ( ManuParam(detElemId,manuId) != 0 );
869 //_____________________________________________________________________________
871 AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
873 /// Whether we have data for a given pcb
874 return ( PCBParam(detElemId,pcbIndex) != 0 );
877 //_____________________________________________________________________________
879 AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
881 /// Return the value for a given manu and a given dimension
883 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
884 return param ? Value(*param,0,dim) : 0.0;
887 //_____________________________________________________________________________
889 AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId, Bool_t create) const
891 /// Get the VCalibParam for a given manu
893 AliMUONVCalibParam* manu = fManuValues ? static_cast<AliMUONVCalibParam*>
894 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
896 if (!manu && create && fManuValues)
898 manu = CreateManuParam(detElemId,manuId);
899 fManuValues->Add(manu);
905 //_____________________________________________________________________________
907 AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
909 /// Create storage for one manu
911 AliCodeTimerAuto("");
913 AliMUONVCalibParam* manu = new AliMUONCalibParamND(Dimension(),1,detElemId,manuId,0.0);
915 // set the number of channels in that manu
917 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
919 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
924 //_____________________________________________________________________________
926 AliMUONTrackerData::Merge(TCollection*)
928 /// Merge all tracker data objects from li into a single one.
930 AliError("Not implemented yet");
935 //_____________________________________________________________________________
937 AliMUONTrackerData::NumberOfDimensions() const
939 /// Number of dimensions we're dealing with
941 return fDimension + fgkVirtualExtraDimension;
944 //_____________________________________________________________________________
946 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
948 /// Return the value of a given pcb for a given dimension
950 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
952 return param ? Value(*param,0,dim) : 0.0;
955 //_____________________________________________________________________________
957 AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex, Bool_t create) const
959 /// Return (if it exist) the VCalibParam for a given pcb
961 AliMUONVCalibParam* pcb = fPCBValues ? static_cast<AliMUONVCalibParam*>
962 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
964 if (create && fPCBValues && !pcb)
966 pcb = CreatePCBParam(detElemId,pcbIndex);
967 fPCBValues->Add(pcb);
973 //_____________________________________________________________________________
975 AliMUONTrackerData::CreatePCBParam(Int_t detElemId, Int_t pcbIndex) const
977 /// Create storage for one PCB (station345 only)
979 AliCodeTimerAuto("");
983 AliMUONVCalibParam* pcb = new AliMUONCalibParamND(Dimension(),
984 namer.NumberOfPCBs(detElemId),
991 //_____________________________________________________________________________
993 AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
999 if ( !fIsSingleEvent )
1001 cout << " Nevents=" << fNevents << endl;
1004 if ( !fIsChannelLevelEnabled )
1006 cout << "Is not storing data at the channel level" << endl;
1009 if ( !fIsManuLevelEnabled )
1011 cout << "Is not storing data at the manu level" << endl;
1014 for ( Int_t i = 0; i <= fExternalDimensionNames->GetLast(); ++i )
1016 TObjString* name = static_cast<TObjString*>(fExternalDimensionNames->At(i));
1017 cout << Form("External Dimension %2d Name %s %s",i,
1018 ( name ? name->String().Data() : "null"),
1019 ( IsHistogrammed(i) ? "(histogrammed)" : "")) << endl;
1022 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
1024 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
1025 cout << Form("Internal Dimension %2d Name %s",i,
1026 ( name ? name->String().Data() : "null")) << endl;
1032 if ( sopt.Contains("CHANNEL") )
1034 if ( fIsChannelLevelEnabled )
1036 if ( fChannelValues ) fChannelValues->Print(wildcard,opt);
1040 AliWarning("You requested channel values, but they were not stored !");
1044 if ( sopt.Contains("MANU") )
1046 if ( fIsManuLevelEnabled )
1048 if ( fManuValues ) fManuValues->Print(wildcard,opt);
1052 AliWarning("You requested manu values, but they were not stored !");
1056 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
1058 fBusPatchValues->Print(wildcard,opt);
1061 if ( sopt.Contains("DE") && fDEValues )
1063 fDEValues->Print(wildcard,opt);
1066 if ( sopt.Contains("CHAMBER") && fChamberValues )
1068 fChamberValues->Print(wildcard,opt);
1073 //_____________________________________________________________________________
1075 AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
1077 /// Set the name of a given dimension
1079 if ( index >= fExternalDimension )
1081 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1085 Int_t ix = External2Internal(index);
1087 if ( !IsSingleEvent() )
1089 const char* prefix[] = { "mean", "sigma" };
1091 for ( Int_t i = 0; i < 2; ++i )
1095 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
1100 SetInternalDimensionName(index,name);
1103 SetExternalDimensionName(index,name);
1106 //_____________________________________________________________________________
1108 AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
1110 /// decide to make histos for a given dimension
1111 if ( index >= ExternalDimension() )
1113 AliError(Form("Index out of bounds : %d / %d",index,ExternalDimension()));
1117 fHistogramming[index] = value;
1122 //_____________________________________________________________________________
1124 AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
1126 /// Set the name of a given internal dimension
1127 if ( index >= fDimension )
1129 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
1133 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
1137 fDimensionNames->Remove(ovalue);
1140 fDimensionNames->AddAt(new TObjString(value),index);
1143 //_____________________________________________________________________________
1145 AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
1147 /// Set the name of a given external dimension
1148 if ( index >= fExternalDimension )
1150 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1154 TObjString* ovalue = static_cast<TObjString*>(fExternalDimensionNames->At(index));
1158 fExternalDimensionNames->Remove(ovalue);
1161 fExternalDimensionNames->AddAt(new TObjString(value),index);
1164 //_____________________________________________________________________________
1166 AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i, Int_t dim) const
1168 /// Compute the value for a given dim, using the internal information we have
1169 /// Basically we're converting sum of weights and sum of squares of weights
1170 /// into means and sigmas, and number of events into occupancy number.
1172 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
1174 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
1176 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
1178 if ( dim >= fDimension )
1183 if ( dim == IndexOfOccupancyDimension() ) return occ/n/NumberOfEvents();
1185 Double_t value = param.ValueAsDouble(i,dim);
1187 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
1189 if ( TMath::Even(dim) || IsSingleEvent() )
1191 Double_t x = value/occ;
1193 return ( TMath::Finite(x) ? x : 0.0 ) ;
1201 Double_t mean = param.ValueAsDouble(i,dim-1)/nn;
1203 return TMath::Sqrt(TMath::Abs((value-nn*mean*mean)/(nn-1.0)));
1211 AliError("Why am I here ?");