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"
23 #include "AliMUON1DArray.h"
24 #include "AliMUON1DMap.h"
25 #include "AliMUON2DMap.h"
26 #include "AliMUONCalibParamND.h"
27 #include "AliMUONSparseHisto.h"
28 #include "AliMUONVStore.h"
29 #include "AliMpBusPatch.h"
30 #include "AliMpConstants.h"
32 #include "AliMpDDLStore.h"
33 #include "AliMpManuStore.h"
34 #include "AliMpDEIterator.h"
35 #include "AliMpDEManager.h"
36 #include "AliMpDetElement.h"
37 #include "AliMpDCSNamer.h"
38 #include "AliMpManuIterator.h"
39 #include "AliMpEncodePair.h"
40 #include "AliMpSegmentation.h"
41 #include <Riostream.h>
44 #include <TObjArray.h>
45 #include <TObjString.h>
47 #include <TTimeStamp.h>
52 /// \class AliMUONTrackerData
54 /// Implementation of AliMUONVTrackerData class
56 /// \author Laurent Aphecetche, Subatech
59 ClassImp(AliMUONTrackerData)
62 const Int_t AliMUONTrackerData::fgkExtraDimension = 2;
63 const Int_t AliMUONTrackerData::fgkVirtualExtraDimension = 1;
65 //_____________________________________________________________________________
66 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
69 : AliMUONVTrackerData(name,title),
70 fIsSingleEvent(issingleevent),
77 fDimension(External2Internal(dimension)+fgkExtraDimension),
79 fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)),
80 fExternalDimensionNames(new TObjArray(dimension)),
81 fExternalDimension(dimension),
82 fHistogramming(new Int_t[fExternalDimension]),
86 fIsChannelLevelEnabled(kTRUE),
87 fIsManuLevelEnabled(kTRUE),
88 fIsBustPatchLevelEnabled(kTRUE),
89 fIsPCBLevelEnabled(kTRUE),
94 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
95 fExternalDimensionNames->SetOwner(kTRUE);
96 fDimensionNames->SetOwner(kTRUE);
97 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
98 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
99 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
103 //_____________________________________________________________________________
104 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
105 const AliMUONVStore& manuValues)
106 : AliMUONVTrackerData(name,title),
107 fIsSingleEvent(kFALSE),
110 fBusPatchValues(0x0),
116 fDimensionNames(0x0),
117 fExternalDimensionNames(0x0),
118 fExternalDimension(0),
123 fIsChannelLevelEnabled(kFALSE),
124 fIsManuLevelEnabled(kTRUE),
125 fIsBustPatchLevelEnabled(kTRUE),
126 fIsPCBLevelEnabled(kTRUE),
128 fNofEventsPerDDL(0x0)
130 /// ctor with pre-computed values at the manu level
131 /// In this case, we force fIsChannelLevelEnabled = kFALSE
134 if (manuValues.GetSize()==0)
136 AliFatal("Cannot create a tracker data from nothing in that case !");
139 if ( !AliMpDDLStore::Instance(kFALSE) && !AliMpManuStore::Instance(kFALSE) )
141 AliError("Cannot work without (full) mapping");
145 TIter next(manuValues.CreateIterator());
146 AliMUONVCalibParam* m = static_cast<AliMUONVCalibParam*>(next());
148 Int_t dimension = ( m->Dimension() - fgkExtraDimension - fgkVirtualExtraDimension ) / 2;
150 fDimension = External2Internal(dimension)+fgkExtraDimension;
152 fDimensionNames = new TObjArray(fDimension+fgkVirtualExtraDimension);
153 fExternalDimensionNames = new TObjArray(dimension);
154 fExternalDimension = dimension;
155 fHistogramming = new Int_t[fExternalDimension];
156 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
158 fExternalDimensionNames->SetOwner(kTRUE);
159 fDimensionNames->SetOwner(kTRUE);
160 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
161 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
162 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
164 TArrayI nevents(AliDAQ::NumberOfDdls("MUONTRK"));
168 AliMUONVCalibParam* external;
170 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
172 Int_t detElemId, manuId;
174 GetDEManu(*external,detElemId,manuId);
176 AliMUONVCalibParam* chamber(0x0);
177 AliMUONVCalibParam* de(0x0);
178 AliMUONVCalibParam* busPatch(0x0);
179 AliMUONVCalibParam* pcb(0x0);
180 AliMUONVCalibParam* manu(0x0);
181 AliMUONVCalibParam* channel(0x0);
182 AliMpDetElement* mpde(0x0);
184 AliMUONVCalibParam* wec = new AliMUONCalibParamND(external->Dimension()-1,1,detElemId,manuId,0);
185 // as external, but without event count
186 wec->SetValueAsDouble(0,0,external->ValueAsDouble(0,0));
187 wec->SetValueAsDouble(0,1,external->ValueAsDouble(0,1));
188 wec->SetValueAsDouble(0,2,external->ValueAsDouble(0,2));
189 wec->SetValueAsDouble(0,3,external->ValueAsDouble(0,3));
191 Int_t mid = GetParts(wec,chamber,de,busPatch,pcb,manu,channel,mpde);
195 AliError(Form("Something is wrong for DE %5d : manuId = %d vs mid = %d",detElemId,manuId,mid));
201 AliError("Got a < 0 manuId. Should not happen here !");
205 assert(channel==0x0);
207 Int_t n1 = manu->ValueAsInt(0,IndexOfNumberDimension());
208 Int_t n2 = external->ValueAsInt(0,IndexOfNumberDimension());
211 AliError(Form("Incoherent number of manu channels for DE %5d MANU %5d : %d vs %d",
212 detElemId,manuId,n1,n2));
215 Int_t nevt = external->ValueAsInt(0,4);
217 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
219 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus(busPatchId);
221 if ( nevents[ddl] == 0 )
227 if ( nevents.At(ddl) != nevt )
229 AliError(Form("Nevt mismatch for DE %5d MANU %5d DDL %d : %d vs %d",
230 detElemId,manuId,ddl,nevents.At(ddl),nevt));
235 for ( Int_t i = 0; i < wec->Dimension()-1; ++i )
237 manu->SetValueAsDouble(0,i,manu->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
239 busPatch->SetValueAsDouble(0,i,busPatch->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
241 de->SetValueAsDouble(0,i,de->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
243 chamber->SetValueAsDouble(0,i,chamber->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
248 UpdateNumberOfEvents(&nevents);
252 //_____________________________________________________________________________
253 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
254 const AliMUONVStore& deValues, Int_t val)
255 : AliMUONVTrackerData(name,title),
256 fIsSingleEvent(kFALSE),
259 fBusPatchValues(0x0),
265 fDimensionNames(0x0),
266 fExternalDimensionNames(0x0),
267 fExternalDimension(0),
272 fIsChannelLevelEnabled(kFALSE),
273 fIsManuLevelEnabled(kFALSE),
274 fIsBustPatchLevelEnabled(kFALSE),
275 fIsPCBLevelEnabled(kFALSE),
277 fNofEventsPerDDL(0x0)
279 /// ctor with values at the detection element level
280 /// In this case, we force fIsChannelLevelEnabled = fIsManuLevelEnabled = kFALSE
283 if (deValues.GetSize()==0)
285 AliFatal("Cannot create a tracker data from nothing in that case !");
290 AliFatal("Wrong parameter. For DE, must be 1");
293 if ( !AliMpDDLStore::Instance(kFALSE) && !AliMpManuStore::Instance(kFALSE) )
295 AliError("Cannot work without (full) mapping");
299 TIter next(deValues.CreateIterator());
300 AliMUONVCalibParam* m = static_cast<AliMUONVCalibParam*>(next());
302 Int_t dimension = ( m->Dimension() - fgkExtraDimension - fgkVirtualExtraDimension ) / 2;
304 fDimension = External2Internal(dimension)+fgkExtraDimension;
306 fDimensionNames = new TObjArray(fDimension+fgkVirtualExtraDimension);
307 fExternalDimensionNames = new TObjArray(dimension);
308 fExternalDimension = dimension;
309 fHistogramming = new Int_t[fExternalDimension];
310 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
312 fExternalDimensionNames->SetOwner(kTRUE);
313 fDimensionNames->SetOwner(kTRUE);
314 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
315 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
316 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
318 TArrayI nevents(AliDAQ::NumberOfDdls("MUONTRK"));
322 AliMUONVCalibParam* external;
324 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
326 Int_t detElemId = external->ID0();
328 AliMpDetElement* mpde = AliMpDDLStore::Instance()->GetDetElement(detElemId,kFALSE);
332 AliError(Form("Got an invalid DE (%d) from external store",detElemId));
336 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
337 AliMUONVCalibParam* chamber = ChamberParam(chamberId,kTRUE);
338 AliMUONVCalibParam* de = DetectionElementParam(detElemId,kTRUE);
340 AliMUONVCalibParam* wec = new AliMUONCalibParamND(external->Dimension()-1,1,detElemId,0,0);
341 // as external, but without event count
342 wec->SetValueAsDouble(0,0,external->ValueAsDouble(0,0));
343 wec->SetValueAsDouble(0,1,external->ValueAsDouble(0,1));
344 wec->SetValueAsDouble(0,2,external->ValueAsDouble(0,2));
345 wec->SetValueAsDouble(0,3,external->ValueAsDouble(0,3));
347 Int_t n1 = de->ValueAsInt(0,IndexOfNumberDimension());
348 Int_t n2 = external->ValueAsInt(0,IndexOfNumberDimension());
351 AliError(Form("Incoherent number of dimensions for DE%d : %d vs %d",
356 Int_t nevt = external->ValueAsInt(0,4);
358 Int_t ddl = mpde->GetDdlId();
360 if ( nevents[ddl] == 0 )
366 if ( nevents.At(ddl) != nevt )
368 AliError(Form("Nevt mismatch for DE %5d DDL %d : %d vs %d",
369 detElemId,ddl,nevents.At(ddl),nevt));
374 for ( Int_t i = 0; i < wec->Dimension()-1; ++i )
376 de->SetValueAsDouble(0,i,de->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
378 chamber->SetValueAsDouble(0,i,chamber->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
383 UpdateNumberOfEvents(&nevents);
387 //_____________________________________________________________________________
388 AliMUONTrackerData::~AliMUONTrackerData()
391 delete fChannelValues;
393 delete fBusPatchValues;
395 delete fChamberValues;
397 delete fDimensionNames;
398 delete fExternalDimensionNames;
399 delete[] fHistogramming;
401 delete[] fNofEventsPerDDL;
404 //_____________________________________________________________________________
406 AliMUONTrackerData::Add(const AliMUONVStore& store, TArrayI* nevents)
408 /// Add the given external store to our internal store
409 return InternalAdd(store,nevents,kFALSE);
412 //_____________________________________________________________________________
414 AliMUONTrackerData::Add(const AliMUONTrackerData& data)
416 /// Add data to *this
417 // We do this by looping on all VCalibParam stored in the various containers,
418 // and simply adding the values there.
419 // Same thing for the number of events per DDL.
420 // Same thing for sparsehistograms, if we have some.
422 // First cross check we have compatible objects.
424 if ( fIsChannelLevelEnabled != data.fIsChannelLevelEnabled )
426 AliError("Incompatible IsChannelLevelEnabled status");
430 if ( fIsManuLevelEnabled != data.fIsManuLevelEnabled )
432 AliError("Incompatible IsManuLevelEnabled status");
436 if ( fIsSingleEvent != data.fIsSingleEvent )
438 AliError("Incompatible IsSingleEvent status");
442 if ( fDimension != data.fDimension || fExternalDimension != data.fExternalDimension )
444 AliError("Incompatible dimensions");
448 if ( fNofDDLs != data.fNofDDLs )
450 AliError("Incompatible number of Ddls");
454 if ( ( !fHistogramming && data.fHistogramming ) || ( fHistogramming && !data.fHistogramming )
455 || fXmin != data.fXmin || fXmax != data.fXmax )
457 AliError(Form("Incompatible histogramming (%p vs %p) (xmax = %e vs %e ; xmin = %e vs %e)",
458 fHistogramming,data.fHistogramming,fXmax,data.fXmax,fXmin,data.fXmin));
462 if ( fHistogramming )
464 for ( Int_t i = 0; i < fExternalDimension; ++i )
466 if ( fHistogramming[i] != data.fHistogramming[i] )
468 AliError(Form("Incompatible histogramming for external dimension %d",i));
474 // OK. Seems we have compatible objects, so we can proceed with the actual
477 if ( data.fChannelValues )
479 Add2D(*(data.fChannelValues),*fChannelValues);
482 if ( data.fManuValues )
484 Add2D(*(data.fManuValues),*fManuValues);
487 if ( data.fPCBValues )
489 Add2D(*(data.fPCBValues),*fPCBValues);
492 if ( data.fBusPatchValues )
494 Add1D(*(data.fBusPatchValues),*fBusPatchValues);
497 if ( data.fDEValues )
499 Add1D(*(data.fDEValues),*fDEValues);
502 if ( data.fChamberValues )
504 Add1D(*(data.fChamberValues),*fChamberValues);
507 for ( Int_t i = 0; i < fNofDDLs; ++i )
509 fNofEventsPerDDL[i] += data.fNofEventsPerDDL[i];
514 TIter nexthisto(data.fHistos->CreateIterator());
515 AliMUONVStore* store;
516 while ( ( store = static_cast<AliMUONVStore*>(nexthisto()) ) )
518 TIter ns(store->CreateIterator());
519 AliMUONSparseHisto* h;
520 while ( ( h = static_cast<AliMUONSparseHisto*>(ns()) ) )
522 AliMUONVStore* thisStore = static_cast<AliMUONVStore*>(fHistos->FindObject(store->GetUniqueID()));
526 thisStore = store->Create();
527 thisStore->SetUniqueID(store->GetUniqueID());
528 fHistos->Add(thisStore);
531 AliMUONSparseHisto* mine = static_cast<AliMUONSparseHisto*>(thisStore->FindObject(h->GetUniqueID()));
545 fNevents = TMath::Max(fNevents,data.fNevents);
550 //_____________________________________________________________________________
552 AliMUONTrackerData::Add2D(const AliMUONVStore& src, AliMUONVStore& dest) const
554 /// Add one 2d store to another
556 TIter next(src.CreateIterator());
557 AliMUONVCalibParam* p;
559 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
561 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->ID0(),p->ID1()));
565 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
569 AddCalibParams(*p,*a);
574 //_____________________________________________________________________________
576 AliMUONTrackerData::Add1D(const AliMUONVStore& src, AliMUONVStore& dest) const
578 /// Add one 1d store to another
580 TIter next(src.CreateIterator());
581 AliMUONVCalibParam* p;
583 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
585 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->GetUniqueID()));
589 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
593 AddCalibParams(*p,*a);
598 //_____________________________________________________________________________
600 AliMUONTrackerData::AddCalibParams(const AliMUONVCalibParam& src, AliMUONVCalibParam& dest) const
603 for ( Int_t i = 0; i < src.Size(); ++i )
605 for ( Int_t j = 0; j < src.Dimension(); ++j )
607 dest.SetValueAsFloat(i,j,src.ValueAsFloat(i,j));
612 //_____________________________________________________________________________
614 AliMUONTrackerData::Replace(const AliMUONVStore& store)
616 /// Replace our values by values from the given external store
617 Bool_t rv = InternalAdd(store,0x0,kTRUE);
618 AliMUONVTrackerData::Replace(store);
622 //_____________________________________________________________________________
624 AliMUONTrackerData::UpdateNumberOfEvents(TArrayI* nevents)
626 /// Update the number of events
630 fNofDDLs = AliDAQ::NumberOfDdls("MUONTRK");
631 fNofEventsPerDDL = new Int_t[fNofDDLs];
632 for ( Int_t i = 0; i < fNofDDLs; ++i )
634 fNofEventsPerDDL[i] = 0;
640 if (nevents->GetSize() != fNofDDLs )
642 AliError(Form("nof of ddl per event array size is incorrect : got %d, expecting %d",
643 nevents->GetSize(),fNofDDLs));
647 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
649 fNofEventsPerDDL[i] += nevents->At(i);
650 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
655 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
657 ++fNofEventsPerDDL[i];
658 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
664 //_____________________________________________________________________________
666 AliMUONTrackerData::AssertStores()
668 /// Insure our stores are allocated
672 Int_t numberOfBusPatches(0);
673 Int_t numberOfDEs(0);
675 // get number of bus patches and number of detection element
676 // to initialize fBusPatchValues and fDEValues below
678 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
679 while ( next() ) ++numberOfBusPatches;
680 AliMpDEIterator deIt;
682 while (!deIt.IsDone())
688 if ( fIsChannelLevelEnabled )
690 fChannelValues = new AliMUON2DMap(kTRUE);
692 if ( fIsManuLevelEnabled )
694 fManuValues = new AliMUON2DMap(kTRUE);
696 if ( fIsPCBLevelEnabled )
698 fPCBValues = new AliMUON2DMap(kFALSE);
700 if ( fIsBustPatchLevelEnabled )
702 fBusPatchValues = new AliMUON1DMap(numberOfBusPatches);
704 fDEValues = new AliMUON1DMap(numberOfDEs);
705 fChamberValues = new AliMUON1DArray;
709 //_____________________________________________________________________________
711 AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, TArrayI* nevents, Bool_t replace)
713 /// Add the given external store to our internal store
715 AliCodeTimerAuto(GetName(),0);
719 if ( IsSingleEvent() && NumberOfEvents(-1) == 1 )
721 AliError(Form("%s is supposed to be single event only",GetName()));
726 UpdateNumberOfEvents(nevents);
730 TIter next(store.CreateIterator());
731 AliMUONVCalibParam* external;
735 if ( IsSingleEvent() ) nk = 1;
737 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
739 if ( external->Dimension() != ExternalDimension() )
741 AliError(Form("Incompatible dimensions %d vs %d",
742 external->Dimension(),ExternalDimension()));
746 AliMUONVCalibParam* chamber(0x0);
747 AliMUONVCalibParam* de(0x0);
748 AliMUONVCalibParam* busPatch(0x0);
749 AliMUONVCalibParam* pcb(0x0);
750 AliMUONVCalibParam* manu(0x0);
751 AliMUONVCalibParam* channel(0x0);
752 AliMpDetElement* mpde(0x0);
754 Int_t manuId = GetParts(external,chamber,de,busPatch,pcb,manu,channel,mpde);
756 if ( manuId < 0 ) continue;
758 Int_t detElemId = mpde->GetId();
760 Double_t value[] = { 0.0, 0.0 };
762 Int_t nch = mpde->NofChannelsInManu(manuId);
764 for ( Int_t i = 0; i < external->Size(); ++i )
766 Bool_t existingChannel = ( nch == AliMpConstants::ManuNofChannels() ? kTRUE
767 : mpde->IsConnectedChannel(manuId,i));
768 // note we only use IsConnectedChannel method when really needed, as
769 // it costs (some) CPU time...
771 if ( existingChannel )
773 Bool_t validChannel(kFALSE);
775 for ( Int_t j = 0; j < external->Dimension(); ++j )
777 Double_t vext = external->IsDoublePrecision() ?
778 external->ValueAsDoubleFast(i,j) :
779 external->ValueAsFloatFast(i,j);
781 if ( vext >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
783 validChannel = kTRUE;
785 Int_t ix = External2Internal(j);
788 value[1] = vext*vext;
790 if ( IsHistogrammed(j) )
792 FillHisto(detElemId,manuId,i,j,vext);
795 for ( Int_t k = 0; k < nk; ++k )
797 Double_t e = ( replace && channel ) ? channel->ValueAsDoubleFast(i,ix+k) : 0.0;
801 channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)-e+value[k]);
806 manu->SetValueAsDoubleFast(0,ix+k,manu->ValueAsDoubleFast(0,ix+k)-e+value[k]);
809 busPatch->SetValueAsDoubleFast(0,ix+k,busPatch->ValueAsDoubleFast(0,ix+k)-e+value[k]);
811 de->SetValueAsDoubleFast(0,ix+k,de->ValueAsDoubleFast(0,ix+k)-e+value[k]);
813 chamber->SetValueAsDoubleFast(0,ix+k,chamber->ValueAsDoubleFast(0,ix+k)-e+value[k]);
817 pcb->SetValueAsDoubleFast(0,ix+k,pcb->ValueAsDoubleFast(0,ix+k)-e+value[k]);
822 if ( validChannel && !replace )
826 channel->SetValueAsDoubleFast(i,IndexOfOccupancyDimension(),
827 channel->ValueAsDoubleFast(i,IndexOfOccupancyDimension())+1.0);
832 manu->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
833 manu->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
836 busPatch->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
837 busPatch->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
838 de->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
839 de->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
840 chamber->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
841 chamber->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
844 pcb->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
845 pcb->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
852 NumberOfEventsChanged();
857 //_____________________________________________________________________________
859 AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
861 /// Return the value of a given buspatch for a given dimension
862 /// or 0 if not existing
863 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
864 return param ? Value(*param,0,dim,DdlIdFromBusPatchId(busPatchId)) : 0.0;
867 //_____________________________________________________________________________
869 AliMUONTrackerData::BusPatchParam(Int_t busPatchId, Bool_t create) const
871 /// Return (if it exist), the VCalibParam for a given busPatch
873 AliMUONVCalibParam* busPatch = fBusPatchValues ? static_cast<AliMUONVCalibParam*>
874 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
876 if (!busPatch && create && fBusPatchValues)
878 busPatch = CreateBusPatchParam(busPatchId);
879 fBusPatchValues->Add(busPatch);
885 //_____________________________________________________________________________
887 AliMUONTrackerData::CreateBusPatchParam(Int_t busPatchId) const
889 /// Create storage for one bus patch
891 AliCodeTimerAuto("",0);
893 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
897 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
901 AliMUONVCalibParam* busPatch = new AliMUONCalibParamND(Dimension(),1,busPatchId,0,0.0);
903 // set the number of channels in that buspatch
907 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
909 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
911 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
913 Int_t manuId = bp->GetManuId(i);
914 nchannels += de->NofChannelsInManu(manuId);
917 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
922 //_____________________________________________________________________________
924 AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
926 /// Return the value fo a given chamber for a given dimension,
927 /// or zero if not existing
929 // FIXME: is the Value() correct wrt to number of events in the case of
930 // chamber ? Or should we do something custom at the chamber level
931 // (as it spans several ddls) ?
933 AliMUONVCalibParam* param = ChamberParam(chamberId);
934 return param ? Value(*param,0,dim,DdlIdFromChamberId(chamberId)) : 0.0;
937 //_____________________________________________________________________________
939 AliMUONTrackerData::ChamberParam(Int_t chamberId, Bool_t create) const
941 /// Return (if it exist) the VCalibParam for a given chamber
943 AliMUONVCalibParam* chamber = fChamberValues ? static_cast<AliMUONVCalibParam*>
944 (fChamberValues->FindObject(chamberId)) : 0x0;
946 if (!chamber && create && fChamberValues)
948 chamber = CreateChamberParam(chamberId);
949 fChamberValues->Add(chamber);
955 //_____________________________________________________________________________
957 AliMUONTrackerData::CreateChamberParam(Int_t chamberId) const
959 /// Create storage for one chamber
961 AliCodeTimerAuto("",0);
963 AliMUONVCalibParam* chamber = new AliMUONCalibParamND(Dimension(),1,chamberId,0,0.0);
965 // set the number of channels in that chamber
973 while ( !it.IsDone() )
975 AliMpDetElement* det = it.CurrentDE();
977 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
979 Int_t busPatchId = det->GetBusPatchId(i);
980 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
981 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
983 Int_t manuId = bp->GetManuId(j);
984 nchannels += det->NofChannelsInManu(manuId);
991 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
996 //_____________________________________________________________________________
998 AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
999 Int_t manuChannel, Int_t dim) const
1001 /// Return the value for a given channel for a given dimension
1003 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
1005 return param ? Value(*param,manuChannel,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1008 //_____________________________________________________________________________
1010 AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId,
1011 const AliMUONVCalibParam* external) const
1013 /// Return (if it exist) the VCalibParam for a given manu
1015 AliMUONVCalibParam* param = fChannelValues ? static_cast<AliMUONVCalibParam*>
1016 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
1018 if (!param && external && fChannelValues)
1020 param = CreateDouble(*external,detElemId,manuId);
1021 fChannelValues->Add(param);
1027 //_____________________________________________________________________________
1029 AliMUONTrackerData::Clear(Option_t*)
1031 /// Clear all the values
1032 if ( fChannelValues ) fChannelValues->Clear();
1033 if ( fManuValues ) fManuValues->Clear();
1034 if ( fBusPatchValues) fBusPatchValues->Clear();
1035 if ( fPCBValues ) fPCBValues->Clear();
1036 if ( fDEValues) fDEValues->Clear();
1037 if ( fChamberValues ) fChamberValues->Clear();
1038 if ( fHistos ) fHistos->Clear();
1039 for ( Int_t i = 0; i < fNofDDLs; ++i )
1041 fNofEventsPerDDL[i] = 0;
1044 NumberOfEventsChanged();
1047 //_____________________________________________________________________________
1049 AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
1050 Int_t manuChannel) const
1052 /// Return the number of times a given channel had data
1054 return Channel(detElemId,manuId,manuChannel,IndexOfNumberDimension());
1057 //_____________________________________________________________________________
1059 AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param,
1060 Int_t detElemId, Int_t manuId) const
1062 /// Create a double version of VCalibParam, for internal use
1064 AliCodeTimerAuto("",0);
1066 AliMUONVCalibParam* c = new AliMUONCalibParamND(Dimension(),
1072 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId,manuId);
1074 for ( Int_t i = 0; i < c->Size(); ++i )
1076 Double_t value(0.0);
1078 if ( de->IsConnectedChannel(manuId,i) ) value = 1.0;
1080 c->SetValueAsDouble(i,IndexOfNumberDimension(),value);
1086 //_____________________________________________________________________________
1088 AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
1090 /// Return the value for a given detection element for a given dimension
1091 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
1092 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1096 //_____________________________________________________________________________
1098 AliMUONTrackerData::DetectionElementParam(Int_t detElemId, Bool_t create) const
1100 /// Return (if it exist) the VCalibParam for a given detection element
1102 AliMUONVCalibParam* de = fDEValues ? static_cast<AliMUONVCalibParam*>
1103 (fDEValues->FindObject(detElemId)) : 0x0 ;
1105 if (!de && create && fDEValues)
1107 de = CreateDetectionElementParam(detElemId);
1115 //_____________________________________________________________________________
1117 AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
1119 /// Create storage for one detection element
1121 AliCodeTimerAuto("",0);
1123 AliMUONVCalibParam* de = new AliMUONCalibParamND(Dimension(),1,detElemId,0,0.0);
1125 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1128 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
1130 Int_t busPatchId = det->GetBusPatchId(i);
1131 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
1132 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
1134 Int_t manuId = bp->GetManuId(j);
1135 nchannels += det->NofChannelsInManu(manuId);
1139 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
1144 //_____________________________________________________________________________
1146 AliMUONTrackerData::DdlIdFromBusPatchId(Int_t buspatchid) const
1148 /// Get the "local" ddlid (0..19) of a given buspatch
1149 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatchid);
1152 return bp->GetDdlId();
1157 //_____________________________________________________________________________
1159 AliMUONTrackerData::DdlIdFromDetElemId(Int_t detelemid) const
1161 /// Get the "local" ddlid (0..19) of a given detection element
1162 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detelemid);
1165 return de->GetDdlId();
1170 //_____________________________________________________________________________
1172 AliMUONTrackerData::DdlIdFromChamberId(Int_t chamberid) const
1174 /// Get the "local" ddlid (0..19) of a given chamber
1175 /// This has no real meaning (as there are several ddls per chamber),
1176 /// so we take the ddlid where we got the max number of events
1180 it.First(chamberid);
1184 while (!it.IsDone())
1186 Int_t detElemId = it.CurrentDEId();
1187 Int_t ddlId = DdlIdFromDetElemId(detElemId);
1188 if ( NumberOfEvents(ddlId) > n )
1190 n = NumberOfEvents(ddlId);
1199 //_____________________________________________________________________________
1201 AliMUONTrackerData::DimensionName(Int_t dim) const
1203 /// Get the name of a given dimension
1204 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
1207 return value->String();
1211 return TString("Invalid");
1215 //_____________________________________________________________________________
1217 AliMUONTrackerData::DisableChannelLevel()
1219 /// Disable the storing of data at channel level
1221 delete fChannelValues;
1222 fChannelValues = 0x0;
1223 fIsChannelLevelEnabled = kFALSE;
1226 //_____________________________________________________________________________
1228 AliMUONTrackerData::DisableManuLevel()
1230 /// Disable the storing of data at manu level (and below)
1232 DisableChannelLevel();
1235 fIsManuLevelEnabled = kFALSE;
1238 //_____________________________________________________________________________
1240 AliMUONTrackerData::External2Internal(Int_t index) const
1242 /// From external to internal dimension
1243 return IsSingleEvent() ? index : index*2;
1246 //_____________________________________________________________________________
1248 AliMUONTrackerData::ExternalDimensionName(Int_t dim) const
1250 /// Get the name of a given external dimension
1252 TObjString* value = static_cast<TObjString*>(fExternalDimensionNames->At(dim));
1255 return value->String();
1259 return TString("Invalid");
1263 //_____________________________________________________________________________
1265 AliMUONTrackerData::FillHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel,
1266 Int_t dim, Double_t value)
1268 /// Fill histogram of a given channel
1270 AliMUONSparseHisto* h(0x0);
1272 if ( fIsChannelLevelEnabled )
1274 h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
1276 else if ( fIsManuLevelEnabled )
1278 h = GetManuSparseHisto(detElemId,manuId,dim);
1281 AliDebug(1,Form("DE %04d MANU %04d CH %02d dim %d value %e h %p",detElemId,manuId,manuChannel,dim,value,h));
1285 h->Fill(static_cast<Int_t>(TMath::Nint(value)));
1289 //_____________________________________________________________________________
1291 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId,
1294 /// Get histogram of a given manu
1296 if (!fHistos) return 0x0;
1298 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1301 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1306 //_____________________________________________________________________________
1308 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId, Int_t dim)
1310 /// Get histogram of a given manu. Create it if necessary
1312 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1314 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1317 m = new AliMUON1DArray(NumberOfDimensions());
1318 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1322 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1325 h = new AliMUONSparseHisto(fXmin,fXmax);
1327 h->SetUniqueID(dim);
1335 //_____________________________________________________________________________
1337 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1338 Int_t manuChannel, Int_t dim) const
1340 /// Get histogram of a given channel
1342 if (!fHistos) return 0x0;
1344 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1347 UInt_t uid = ( manuChannel << 16 ) | dim;
1349 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1354 //_____________________________________________________________________________
1356 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1357 Int_t manuChannel, Int_t dim)
1359 /// Get histogram of a given channel. Create it if necessary
1361 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1363 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1366 m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
1367 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1371 UInt_t uid = ( manuChannel << 16 ) | dim;
1373 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1376 h = new AliMUONSparseHisto(fXmin,fXmax);
1378 h->SetUniqueID(uid);
1386 //_____________________________________________________________________________
1388 AliMUONTrackerData::GetDEManu(const AliMUONVCalibParam& param,
1389 Int_t& detElemId, Int_t& manuId) const
1391 /// Tries to get (detElemId,manuId) of param
1393 // Load mapping manu store
1394 if ( ! AliMpCDB::LoadManuStore() ) {
1395 AliError("Could not access manu store from OCDB !");
1399 if ( param.ID1() <= 0 )
1401 // we (probably) get a manu serial number
1402 Int_t serial = param.ID0();
1403 MpPair_t pair = AliMpManuStore::Instance()->GetDetElemIdManu(serial);
1404 detElemId = AliMp::PairFirst(pair);
1405 manuId = AliMp::PairSecond(pair);
1408 AliDebug(1,Form("DE %d manuId %d from serial %d is not correct !",
1409 detElemId,manuId,serial));
1414 // we get a (de,manu) pair
1415 detElemId = param.ID0();
1416 manuId = param.ID1();
1421 //_____________________________________________________________________________
1423 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
1424 AliMUONVCalibParam*& chamber,
1425 AliMUONVCalibParam*& de,
1426 AliMUONVCalibParam*& busPatch,
1427 AliMUONVCalibParam*& pcb,
1428 AliMUONVCalibParam*& manu,
1429 AliMUONVCalibParam*& channel,
1430 AliMpDetElement*& mpde)
1432 /// Get containers at all levels
1434 chamber = de = busPatch = pcb = manu = channel = 0x0;
1437 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
1442 GetDEManu(*external,detElemId,manuId);
1444 mpde = ddlStore->GetDetElement(detElemId,kFALSE);
1446 if (!mpde) // can happen if reading e.g. capacitances store where we have data for non-connected manus
1451 // explicitely check that de,manu is correct
1452 const AliMpVSegmentation* mpseg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, manuId,kFALSE);
1459 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1461 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
1463 if ( busPatchId <= 0 )
1468 Int_t pcbIndex = -1;
1470 AliMp::StationType stationType = mpde->GetStationType();
1472 if ( stationType == AliMp::kStation345 )
1474 AliMpDCSNamer namer("TRACKER");
1475 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
1478 if ( fIsChannelLevelEnabled )
1480 channel = ChannelParam(detElemId,manuId,external);
1483 manu = ManuParam(detElemId,manuId,kTRUE);
1485 busPatch = BusPatchParam(busPatchId,kTRUE);
1487 de = DetectionElementParam(detElemId,kTRUE);
1489 chamber = ChamberParam(chamberId,kTRUE);
1493 if ( pcbIndex >= 0 )
1495 pcb = PCBParam(detElemId,pcbIndex,kTRUE);
1501 //_____________________________________________________________________________
1503 AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
1505 /// Whether we have data for a given buspatch
1506 return ( BusPatchParam(busPatchId) != 0 );
1509 //_____________________________________________________________________________
1511 AliMUONTrackerData::HasChamber(Int_t chamberId) const
1513 /// Whether we have data for a given chamber
1514 return ( ChamberParam(chamberId) != 0 );
1517 //_____________________________________________________________________________
1519 AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
1521 /// Whether we have data for a given detection element
1522 return ( DetectionElementParam(detElemId) != 0 );
1525 //_____________________________________________________________________________
1527 AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
1529 /// Whether we have data for a given manu
1530 return ( ManuParam(detElemId,manuId) != 0 );
1533 //_____________________________________________________________________________
1535 AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
1537 /// Whether we have data for a given pcb
1538 return ( PCBParam(detElemId,pcbIndex) != 0 );
1541 //_____________________________________________________________________________
1543 AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
1545 /// Return the value for a given manu and a given dimension
1547 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
1548 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1551 //_____________________________________________________________________________
1553 AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId, Bool_t create) const
1555 /// Get the VCalibParam for a given manu
1557 AliMUONVCalibParam* manu = fManuValues ? static_cast<AliMUONVCalibParam*>
1558 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
1560 if (!manu && create && fManuValues)
1562 manu = CreateManuParam(detElemId,manuId);
1563 fManuValues->Add(manu);
1569 //_____________________________________________________________________________
1571 AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
1573 /// Create storage for one manu
1575 AliCodeTimerAuto("",0);
1577 AliMUONVCalibParam* manu = new AliMUONCalibParamND(Dimension(),1,detElemId,manuId,0.0);
1579 // set the number of channels in that manu
1581 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1583 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
1588 //_____________________________________________________________________________
1590 AliMUONTrackerData::Merge(TCollection* list)
1592 /// Merge this with a list of AliMUONVTrackerData
1594 if (!list) return 0;
1596 if ( list->IsEmpty() ) return NumberOfEvents(-1);
1599 const TObject* o(0x0);
1601 while ( ( o = next() ) )
1603 const AliMUONTrackerData* data = dynamic_cast<const AliMUONTrackerData*>(o);
1606 AliError(Form("Object named %s is not an AliMUONTrackerData ! Skipping it",
1611 Bool_t ok = Add(*data);
1614 AliError("Got incompatible objects");
1619 return NumberOfEvents(-1);
1622 //_____________________________________________________________________________
1624 AliMUONTrackerData::NumberOfDimensions() const
1626 /// Number of dimensions we're dealing with
1628 return fDimension + fgkVirtualExtraDimension;
1631 //_____________________________________________________________________________
1633 AliMUONTrackerData::NumberOfEvents(Int_t ddlNumber) const
1635 /// Get the number of events we've seen for a given DDL, or the max
1636 /// in case ddlNumber<0
1640 if ( fNofEventsPerDDL && ddlNumber >= 0 && ddlNumber < fNofDDLs )
1642 n = fNofEventsPerDDL[ddlNumber];
1646 // get the max number of events
1653 //_____________________________________________________________________________
1655 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
1657 /// Return the value of a given pcb for a given dimension
1659 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
1661 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1664 //_____________________________________________________________________________
1666 AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex, Bool_t create) const
1668 /// Return (if it exist) the VCalibParam for a given pcb
1670 AliMUONVCalibParam* pcb = fPCBValues ? static_cast<AliMUONVCalibParam*>
1671 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
1673 if (create && fPCBValues && !pcb)
1675 pcb = CreatePCBParam(detElemId,pcbIndex);
1676 fPCBValues->Add(pcb);
1682 //_____________________________________________________________________________
1684 AliMUONTrackerData::CreatePCBParam(Int_t detElemId, Int_t pcbIndex) const
1686 /// Create storage for one PCB (station345 only)
1688 AliCodeTimerAuto("",0);
1690 AliMpDCSNamer namer("TRACKER");
1692 AliMUONVCalibParam* pcb = new AliMUONCalibParamND(Dimension(),
1693 namer.NumberOfPCBs(detElemId),
1700 //_____________________________________________________________________________
1702 AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
1708 if ( !fIsSingleEvent )
1710 for ( Int_t i = 0; i < fNofDDLs; ++i )
1712 cout << Form("DDL %04d Nevents=%10d",AliDAQ::DdlID("MUONTRK",i),fNofEventsPerDDL[i]) << endl;
1716 if ( !fIsChannelLevelEnabled )
1718 cout << "Is not storing data at the channel level" << endl;
1721 if ( !fIsManuLevelEnabled )
1723 cout << "Is not storing data at the manu level" << endl;
1726 for ( Int_t i = 0; i <= fExternalDimensionNames->GetLast(); ++i )
1728 TObjString* name = static_cast<TObjString*>(fExternalDimensionNames->At(i));
1729 cout << Form("External Dimension %2d Name %s %s",i,
1730 ( name ? name->String().Data() : "null"),
1731 ( IsHistogrammed(i) ? "(histogrammed)" : "")) << endl;
1734 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
1736 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
1737 cout << Form("Internal Dimension %2d Name %s",i,
1738 ( name ? name->String().Data() : "null")) << endl;
1744 if ( sopt.Contains("CHANNEL") )
1746 if ( fIsChannelLevelEnabled )
1748 if ( fChannelValues ) fChannelValues->Print(wildcard,opt);
1752 AliWarning("You requested channel values, but they were not stored !");
1756 if ( sopt.Contains("MANU") )
1758 if ( fIsManuLevelEnabled )
1760 if ( fManuValues ) fManuValues->Print(wildcard,opt);
1764 AliWarning("You requested manu values, but they were not stored !");
1768 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
1770 fBusPatchValues->Print(wildcard,opt);
1773 if ( sopt.Contains("DE") && fDEValues )
1775 fDEValues->Print(wildcard,opt);
1778 if ( sopt.Contains("CHAMBER") && fChamberValues )
1780 fChamberValues->Print(wildcard,opt);
1785 //_____________________________________________________________________________
1787 AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
1789 /// Set the name of a given dimension
1791 if ( index >= fExternalDimension )
1793 AliError(Form("%s : dimension %s : Index out of bounds : %d / %d",
1795 name,index,fExternalDimension));
1799 Int_t ix = External2Internal(index);
1801 if ( !IsSingleEvent() )
1803 const char* prefix[] = { "mean", "sigma" };
1805 for ( Int_t i = 0; i < 2; ++i )
1809 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
1814 SetInternalDimensionName(index,name);
1817 SetExternalDimensionName(index,name);
1820 //_____________________________________________________________________________
1822 AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
1824 /// decide to make histos for a given dimension
1825 if ( index >= ExternalDimension() )
1827 AliError(Form("Index out of bounds : %d / %d",index,ExternalDimension()));
1831 AliWarning(Form("Will %s make histogram for data %s index %d : that might ressemble a memory leak depending on the input data",
1832 value ? "":"not", GetName(),index));
1833 fHistogramming[index] = value;
1838 //_____________________________________________________________________________
1840 AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
1842 /// Set the name of a given internal dimension
1843 if ( index >= fDimension )
1845 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
1849 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
1853 fDimensionNames->Remove(ovalue);
1856 fDimensionNames->AddAt(new TObjString(value),index);
1859 //_____________________________________________________________________________
1861 AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
1863 /// Set the name of a given external dimension
1864 if ( index >= fExternalDimension )
1866 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1870 TObjString* ovalue = static_cast<TObjString*>(fExternalDimensionNames->At(index));
1874 fExternalDimensionNames->Remove(ovalue);
1877 fExternalDimensionNames->AddAt(new TObjString(value),index);
1880 //_____________________________________________________________________________
1882 AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i,
1883 Int_t dim, Int_t ddlId) const
1885 /// Compute the value for a given dim, using the internal information we have
1886 /// Basically we're converting sum of weights and sum of squares of weights
1887 /// into means and sigmas, and number of events into occupancy number.
1889 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
1891 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
1893 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
1895 if ( dim >= fDimension )
1900 if ( dim == IndexOfOccupancyDimension() )
1902 if ( ddlId < 0 ) AliError("Got a negative ddl id !");
1903 return occ/n/NumberOfEvents(ddlId);
1906 Double_t value = param.ValueAsDouble(i,dim);
1908 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
1910 if ( TMath::Even(dim) || IsSingleEvent() )
1912 Double_t x = value/occ;
1914 return ( TMath::Finite(x) ? x : 0.0 ) ;
1922 Double_t mean = param.ValueAsDouble(i,dim-1)/nn;
1924 return TMath::Sqrt(TMath::Abs((value-nn*mean*mean)/(nn-1.0)));
1932 AliError("Why am I here ?");
1936 //_____________________________________________________________________________
1938 AliMUONTrackerData::Streamer(TBuffer &R__b)
1940 /// Customized streamer
1942 if (R__b.IsReading()) {
1943 AliMUONTrackerData::Class()->ReadBuffer(R__b, this);
1946 // backward compatible mode : we set number of events
1947 // per DDL to the total number of events (the only information
1948 // we had before version 7 of that class)
1949 delete[] fNofEventsPerDDL;
1951 fNofEventsPerDDL = new Int_t[fNofDDLs];
1952 for ( Int_t i = 0; i < fNofDDLs; ++i )
1954 fNofEventsPerDDL[i] = fNevents;
1959 AliMUONTrackerData::Class()->WriteBuffer(R__b, this);
1963 //_____________________________________________________________________________
1965 AliMUONTrackerData::ExportAsASCIIOccupancyFile(const char* filename, Int_t runNumber) const
1967 /// Export only the occupancy part, in a format compatible with what
1968 /// the online occupancy DA is writing
1970 if ( ! AliMpDDLStore::Instance(kFALSE) )
1972 AliError("Mapping not loaded. Cannot work");
1978 AliError("No manu values. Cannot work");
1982 ofstream out(filename);
1986 AliError(Form("Cannot create file %s",filename));
1990 out << "//===========================================================================" << endl;
1991 out << "// Hit counter exported from $Id$" << endl;
1992 out << "//===========================================================================" << endl;
1993 out << "//" << endl;
1994 out << "// * Run Number : " << runNumber << endl;
1995 out << "// * File Creation Date : " << TTimeStamp().AsString("l") << endl;
1996 out << "//---------------------------------------------------------------------------" << endl;
1997 out << "// BP MANU SUM_N NEVENTS" << endl;
1998 out << "//---------------------------------------------------------------------------" << endl;
2000 TIter next(fManuValues->CreateIterator());
2001 AliMUONVCalibParam* manu;
2003 while ( ( manu = static_cast<AliMUONVCalibParam*>(next()) ) )
2005 Int_t detElemId = manu->ID0();
2006 Int_t manuId = manu->ID1();
2007 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
2008 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus( busPatchId);
2009 if ( busPatchId < 0 || ddl < 0 )
2011 AliError(Form("Got invalid (DE,manu,bp,ddl)=(%d,%d,%d,%d). Skipping it",detElemId,manuId,busPatchId,ddl));
2015 Int_t nevents = fNofEventsPerDDL[ddl];
2017 out << Form("%5d %5d %10d %10d",busPatchId,manuId,manu->ValueAsInt(0,IndexOfOccupancyDimension()),nevents) << endl;