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 <Riostream.h>
43 #include <TObjArray.h>
44 #include <TObjString.h>
46 #include <TTimeStamp.h>
51 /// \class AliMUONTrackerData
53 /// Implementation of AliMUONVTrackerData class
55 /// \author Laurent Aphecetche, Subatech
58 ClassImp(AliMUONTrackerData)
61 const Int_t AliMUONTrackerData::fgkExtraDimension = 2;
62 const Int_t AliMUONTrackerData::fgkVirtualExtraDimension = 1;
64 //_____________________________________________________________________________
65 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
68 : AliMUONVTrackerData(name,title),
69 fIsSingleEvent(issingleevent),
76 fDimension(External2Internal(dimension)+fgkExtraDimension),
78 fDimensionNames(new TObjArray(fDimension+fgkVirtualExtraDimension)),
79 fExternalDimensionNames(new TObjArray(dimension)),
80 fExternalDimension(dimension),
81 fHistogramming(new Int_t[fExternalDimension]),
85 fIsChannelLevelEnabled(kTRUE),
86 fIsManuLevelEnabled(kTRUE),
91 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
92 fExternalDimensionNames->SetOwner(kTRUE);
93 fDimensionNames->SetOwner(kTRUE);
94 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
95 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
96 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
100 //_____________________________________________________________________________
101 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
102 const AliMUONVStore& manuValues)
103 : AliMUONVTrackerData(name,title),
104 fIsSingleEvent(kFALSE),
107 fBusPatchValues(0x0),
113 fDimensionNames(0x0),
114 fExternalDimensionNames(0x0),
115 fExternalDimension(0),
120 fIsChannelLevelEnabled(kFALSE),
121 fIsManuLevelEnabled(kTRUE),
123 fNofEventsPerDDL(0x0)
125 /// ctor with pre-computed values at the manu level
126 /// In this case, we force fIsChannelLevelEnabled = kFALSE
129 if (manuValues.GetSize()==0)
131 AliFatal("Cannot create a tracker data from nothing in that case !");
134 if ( !AliMpDDLStore::Instance(kFALSE) && !AliMpManuStore::Instance(kFALSE) )
136 AliError("Cannot work without (full) mapping");
140 TIter next(manuValues.CreateIterator());
141 AliMUONVCalibParam* m = static_cast<AliMUONVCalibParam*>(next());
143 Int_t dimension = ( m->Dimension() - fgkExtraDimension - fgkVirtualExtraDimension ) / 2;
145 fDimension = External2Internal(dimension)+fgkExtraDimension;
147 fDimensionNames = new TObjArray(fDimension+fgkVirtualExtraDimension);
148 fExternalDimensionNames = new TObjArray(dimension);
149 fExternalDimension = dimension;
150 fHistogramming = new Int_t[fExternalDimension];
151 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
153 fExternalDimensionNames->SetOwner(kTRUE);
154 fDimensionNames->SetOwner(kTRUE);
155 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
156 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
157 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
159 TArrayI nevents(AliDAQ::NumberOfDdls("MUONTRK"));
163 AliMUONVCalibParam* external;
165 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
167 Int_t detElemId, manuId;
169 GetDEManu(*external,detElemId,manuId);
171 AliMUONVCalibParam* chamber(0x0);
172 AliMUONVCalibParam* de(0x0);
173 AliMUONVCalibParam* busPatch(0x0);
174 AliMUONVCalibParam* pcb(0x0);
175 AliMUONVCalibParam* manu(0x0);
176 AliMUONVCalibParam* channel(0x0);
177 AliMpDetElement* mpde(0x0);
179 AliMUONVCalibParam* wec = new AliMUONCalibParamND(external->Dimension()-1,1,detElemId,manuId,0);
180 // as external, but without event count
181 wec->SetValueAsDouble(0,0,external->ValueAsDouble(0,0));
182 wec->SetValueAsDouble(0,1,external->ValueAsDouble(0,1));
183 wec->SetValueAsDouble(0,2,external->ValueAsDouble(0,2));
184 wec->SetValueAsDouble(0,3,external->ValueAsDouble(0,3));
186 Int_t mid = GetParts(wec,chamber,de,busPatch,pcb,manu,channel,mpde);
190 AliError(Form("Something is wrong for DE %5d : manuId = %d vs mid = %d",detElemId,manuId,mid));
196 AliError("Got a < 0 manuId. Should not happen here !");
200 assert(channel==0x0);
202 Int_t n1 = manu->ValueAsInt(0,IndexOfNumberDimension());
203 Int_t n2 = external->ValueAsInt(0,IndexOfNumberDimension());
206 AliError(Form("Incoherent number of manu channels for DE %5d MANU %5d : %d vs %d",
207 detElemId,manuId,n1,n2));
210 Int_t nevt = external->ValueAsInt(0,4);
212 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
214 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus(busPatchId);
216 if ( nevents[ddl] == 0 )
222 if ( nevents.At(ddl) != nevt )
224 AliError(Form("Nevt mismatch for DE %5d MANU %5d DDL %d : %d vs %d",
225 detElemId,manuId,ddl,nevents.At(ddl),nevt));
230 for ( Int_t i = 0; i < wec->Dimension()-1; ++i )
232 manu->SetValueAsDouble(0,i,manu->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
234 busPatch->SetValueAsDouble(0,i,busPatch->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
236 de->SetValueAsDouble(0,i,de->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
238 chamber->SetValueAsDouble(0,i,chamber->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
243 UpdateNumberOfEvents(&nevents);
248 //_____________________________________________________________________________
249 AliMUONTrackerData::~AliMUONTrackerData()
252 delete fChannelValues;
254 delete fBusPatchValues;
256 delete fChamberValues;
258 delete fDimensionNames;
259 delete fExternalDimensionNames;
260 delete[] fHistogramming;
262 delete[] fNofEventsPerDDL;
265 //_____________________________________________________________________________
267 AliMUONTrackerData::Add(const AliMUONVStore& store, TArrayI* nevents)
269 /// Add the given external store to our internal store
270 return InternalAdd(store,nevents,kFALSE);
273 //_____________________________________________________________________________
275 AliMUONTrackerData::Add(const AliMUONTrackerData& data)
277 /// Add data to *this
278 // We do this by looping on all VCalibParam stored in the various containers,
279 // and simply adding the values there.
280 // Same thing for the number of events per DDL.
281 // Same thing for sparsehistograms, if we have some.
283 // First cross check we have compatible objects.
285 if ( fIsChannelLevelEnabled != data.fIsChannelLevelEnabled )
287 AliError("Incompatible IsChannelLevelEnabled status");
291 if ( fIsManuLevelEnabled != data.fIsManuLevelEnabled )
293 AliError("Incompatible IsManuLevelEnabled status");
297 if ( fIsSingleEvent != data.fIsSingleEvent )
299 AliError("Incompatible IsSingleEvent status");
303 if ( fDimension != data.fDimension || fExternalDimension != data.fExternalDimension )
305 AliError("Incompatible dimensions");
309 if ( fNofDDLs != data.fNofDDLs )
311 AliError("Incompatible number of Ddls");
315 if ( ( !fHistogramming && data.fHistogramming ) || ( fHistogramming && !data.fHistogramming )
316 || fXmin != data.fXmin || fXmax != data.fXmax )
318 AliError(Form("Incompatible histogramming (%x vs %x) (xmax = %e vs %e ; xmin = %e vs %e)",
319 fHistogramming,data.fHistogramming,fXmax,data.fXmax,fXmin,data.fXmin));
323 if ( fHistogramming )
325 for ( Int_t i = 0; i < fExternalDimension; ++i )
327 if ( fHistogramming[i] != data.fHistogramming[i] )
329 AliError(Form("Incompatible histogramming for external dimension %d",i));
335 // OK. Seems we have compatible objects, so we can proceed with the actual
338 if ( data.fChannelValues )
340 Add2D(*(data.fChannelValues),*fChannelValues);
343 if ( data.fManuValues )
345 Add2D(*(data.fManuValues),*fManuValues);
348 if ( data.fPCBValues )
350 Add2D(*(data.fPCBValues),*fPCBValues);
353 if ( data.fBusPatchValues )
355 Add1D(*(data.fBusPatchValues),*fBusPatchValues);
358 if ( data.fDEValues )
360 Add1D(*(data.fDEValues),*fDEValues);
363 if ( data.fChamberValues )
365 Add1D(*(data.fChamberValues),*fChamberValues);
368 for ( Int_t i = 0; i < fNofDDLs; ++i )
370 fNofEventsPerDDL[i] += data.fNofEventsPerDDL[i];
375 TIter nexthisto(data.fHistos->CreateIterator());
376 AliMUONVStore* store;
377 while ( ( store = static_cast<AliMUONVStore*>(nexthisto()) ) )
379 TIter ns(store->CreateIterator());
380 AliMUONSparseHisto* h;
381 while ( ( h = static_cast<AliMUONSparseHisto*>(ns()) ) )
383 AliMUONVStore* thisStore = static_cast<AliMUONVStore*>(fHistos->FindObject(store->GetUniqueID()));
387 thisStore = store->Create();
388 thisStore->SetUniqueID(store->GetUniqueID());
389 fHistos->Add(thisStore);
392 AliMUONSparseHisto* mine = static_cast<AliMUONSparseHisto*>(thisStore->FindObject(h->GetUniqueID()));
409 //_____________________________________________________________________________
411 AliMUONTrackerData::Add2D(const AliMUONVStore& src, AliMUONVStore& dest) const
413 /// Add one 2d store to another
415 TIter next(src.CreateIterator());
416 AliMUONVCalibParam* p;
418 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
420 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->ID0(),p->ID1()));
424 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
428 AddCalibParams(*p,*a);
433 //_____________________________________________________________________________
435 AliMUONTrackerData::Add1D(const AliMUONVStore& src, AliMUONVStore& dest) const
437 /// Add one 1d store to another
439 TIter next(src.CreateIterator());
440 AliMUONVCalibParam* p;
442 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
444 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->GetUniqueID()));
448 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
452 AddCalibParams(*p,*a);
457 //_____________________________________________________________________________
459 AliMUONTrackerData::AddCalibParams(const AliMUONVCalibParam& src, AliMUONVCalibParam& dest) const
462 for ( Int_t i = 0; i < src.Size(); ++i )
464 for ( Int_t j = 0; j < src.Dimension(); ++j )
466 dest.SetValueAsFloat(i,j,src.ValueAsFloat(i,j));
471 //_____________________________________________________________________________
473 AliMUONTrackerData::Replace(const AliMUONVStore& store)
475 /// Replace our values by values from the given external store
476 Bool_t rv = InternalAdd(store,0x0,kTRUE);
477 AliMUONVTrackerData::Replace(store);
481 //_____________________________________________________________________________
483 AliMUONTrackerData::UpdateNumberOfEvents(TArrayI* nevents)
485 /// Update the number of events
489 fNofDDLs = AliDAQ::NumberOfDdls("MUONTRK");
490 fNofEventsPerDDL = new Int_t[fNofDDLs];
491 for ( Int_t i = 0; i < fNofDDLs; ++i )
493 fNofEventsPerDDL[i] = 0;
499 if (nevents->GetSize() != fNofDDLs )
501 AliError(Form("nof of ddl per event array size is incorrect : got %d, expecting %d",
502 nevents->GetSize(),fNofDDLs));
506 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
508 fNofEventsPerDDL[i] += nevents->At(i);
509 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
514 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
516 ++fNofEventsPerDDL[i];
517 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
523 //_____________________________________________________________________________
525 AliMUONTrackerData::AssertStores()
527 /// Insure our stores are allocated
531 Int_t numberOfBusPatches(0);
532 Int_t numberOfDEs(0);
534 // get number of bus patches and number of detection element
535 // to initialize fBusPatchValues and fDEValues below
537 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
538 while ( next() ) ++numberOfBusPatches;
539 AliMpDEIterator deIt;
541 while (!deIt.IsDone())
547 if ( fIsChannelLevelEnabled )
549 fChannelValues = new AliMUON2DMap(kTRUE);
551 if ( fIsManuLevelEnabled )
553 fManuValues = new AliMUON2DMap(kTRUE);
555 fPCBValues = new AliMUON2DMap(kFALSE);
556 fBusPatchValues = new AliMUON1DMap(numberOfBusPatches);
557 fDEValues = new AliMUON1DMap(numberOfDEs);
558 fChamberValues = new AliMUON1DArray;
562 //_____________________________________________________________________________
564 AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, TArrayI* nevents, Bool_t replace)
566 /// Add the given external store to our internal store
568 AliCodeTimerAuto(GetName(),0);
572 if ( IsSingleEvent() && NumberOfEvents(-1) == 1 )
574 AliError(Form("%s is supposed to be single event only",GetName()));
579 UpdateNumberOfEvents(nevents);
583 TIter next(store.CreateIterator());
584 AliMUONVCalibParam* external;
588 if ( IsSingleEvent() ) nk = 1;
590 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
592 if ( external->Dimension() != ExternalDimension() )
594 AliError(Form("Incompatible dimensions %d vs %d",
595 external->Dimension(),ExternalDimension()));
599 AliMUONVCalibParam* chamber(0x0);
600 AliMUONVCalibParam* de(0x0);
601 AliMUONVCalibParam* busPatch(0x0);
602 AliMUONVCalibParam* pcb(0x0);
603 AliMUONVCalibParam* manu(0x0);
604 AliMUONVCalibParam* channel(0x0);
605 AliMpDetElement* mpde(0x0);
607 Int_t manuId = GetParts(external,chamber,de,busPatch,pcb,manu,channel,mpde);
609 if ( manuId < 0 ) continue;
611 Int_t detElemId = mpde->GetId();
613 Double_t value[] = { 0.0, 0.0 };
615 Int_t nch = mpde->NofChannelsInManu(manuId);
617 for ( Int_t i = 0; i < external->Size(); ++i )
619 Bool_t existingChannel = ( nch == AliMpConstants::ManuNofChannels() ? kTRUE
620 : mpde->IsConnectedChannel(manuId,i));
621 // note we only use IsConnectedChannel method when really needed, as
622 // it costs (some) CPU time...
624 if ( existingChannel )
626 Bool_t validChannel(kFALSE);
628 for ( Int_t j = 0; j < external->Dimension(); ++j )
630 Double_t vext = external->IsDoublePrecision() ?
631 external->ValueAsDoubleFast(i,j) :
632 external->ValueAsFloatFast(i,j);
634 if ( vext >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
636 validChannel = kTRUE;
638 Int_t ix = External2Internal(j);
641 value[1] = vext*vext;
643 if ( IsHistogrammed(j) )
645 FillHisto(detElemId,manuId,i,j,vext);
648 for ( Int_t k = 0; k < nk; ++k )
650 Double_t e = ( replace && channel ) ? channel->ValueAsDoubleFast(i,ix+k) : 0.0;
654 channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)-e+value[k]);
659 manu->SetValueAsDoubleFast(0,ix+k,manu->ValueAsDoubleFast(0,ix+k)-e+value[k]);
662 busPatch->SetValueAsDoubleFast(0,ix+k,busPatch->ValueAsDoubleFast(0,ix+k)-e+value[k]);
664 de->SetValueAsDoubleFast(0,ix+k,de->ValueAsDoubleFast(0,ix+k)-e+value[k]);
666 chamber->SetValueAsDoubleFast(0,ix+k,chamber->ValueAsDoubleFast(0,ix+k)-e+value[k]);
670 pcb->SetValueAsDoubleFast(0,ix+k,pcb->ValueAsDoubleFast(0,ix+k)-e+value[k]);
675 if ( validChannel && !replace )
679 channel->SetValueAsDoubleFast(i,IndexOfOccupancyDimension(),
680 channel->ValueAsDoubleFast(i,IndexOfOccupancyDimension())+1.0);
685 manu->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
686 manu->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
689 busPatch->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
690 busPatch->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
691 de->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
692 de->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
693 chamber->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
694 chamber->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
697 pcb->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
698 pcb->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
705 NumberOfEventsChanged();
710 //_____________________________________________________________________________
712 AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
714 /// Return the value of a given buspatch for a given dimension
715 /// or 0 if not existing
716 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
717 return param ? Value(*param,0,dim,DdlIdFromBusPatchId(busPatchId)) : 0.0;
720 //_____________________________________________________________________________
722 AliMUONTrackerData::BusPatchParam(Int_t busPatchId, Bool_t create) const
724 /// Return (if it exist), the VCalibParam for a given busPatch
726 AliMUONVCalibParam* busPatch = fBusPatchValues ? static_cast<AliMUONVCalibParam*>
727 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
729 if (!busPatch && create && fBusPatchValues)
731 busPatch = CreateBusPatchParam(busPatchId);
732 fBusPatchValues->Add(busPatch);
738 //_____________________________________________________________________________
740 AliMUONTrackerData::CreateBusPatchParam(Int_t busPatchId) const
742 /// Create storage for one bus patch
744 AliCodeTimerAuto("",0);
746 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
750 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
754 AliMUONVCalibParam* busPatch = new AliMUONCalibParamND(Dimension(),1,busPatchId,0,0.0);
756 // set the number of channels in that buspatch
760 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
762 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
764 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
766 Int_t manuId = bp->GetManuId(i);
767 nchannels += de->NofChannelsInManu(manuId);
770 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
775 //_____________________________________________________________________________
777 AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
779 /// Return the value fo a given chamber for a given dimension,
780 /// or zero if not existing
782 // FIXME: is the Value() correct wrt to number of events in the case of
783 // chamber ? Or should we do something custom at the chamber level
784 // (as it spans several ddls) ?
786 AliMUONVCalibParam* param = ChamberParam(chamberId);
787 return param ? Value(*param,0,dim,DdlIdFromChamberId(chamberId)) : 0.0;
790 //_____________________________________________________________________________
792 AliMUONTrackerData::ChamberParam(Int_t chamberId, Bool_t create) const
794 /// Return (if it exist) the VCalibParam for a given chamber
796 AliMUONVCalibParam* chamber = fChamberValues ? static_cast<AliMUONVCalibParam*>
797 (fChamberValues->FindObject(chamberId)) : 0x0;
799 if (!chamber && create && fChamberValues)
801 chamber = CreateChamberParam(chamberId);
802 fChamberValues->Add(chamber);
808 //_____________________________________________________________________________
810 AliMUONTrackerData::CreateChamberParam(Int_t chamberId) const
812 /// Create storage for one chamber
814 AliCodeTimerAuto("",0);
816 AliMUONVCalibParam* chamber = new AliMUONCalibParamND(Dimension(),1,chamberId,0,0.0);
818 // set the number of channels in that chamber
826 while ( !it.IsDone() )
828 AliMpDetElement* det = it.CurrentDE();
830 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
832 Int_t busPatchId = det->GetBusPatchId(i);
833 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
834 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
836 Int_t manuId = bp->GetManuId(j);
837 nchannels += det->NofChannelsInManu(manuId);
844 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
849 //_____________________________________________________________________________
851 AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
852 Int_t manuChannel, Int_t dim) const
854 /// Return the value for a given channel for a given dimension
856 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
858 return param ? Value(*param,manuChannel,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
861 //_____________________________________________________________________________
863 AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId,
864 AliMUONVCalibParam* external) const
866 /// Return (if it exist) the VCalibParam for a given manu
868 AliMUONVCalibParam* param = fChannelValues ? static_cast<AliMUONVCalibParam*>
869 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
871 if (!param && external && fChannelValues)
873 param = CreateDouble(*external,detElemId,manuId);
874 fChannelValues->Add(param);
880 //_____________________________________________________________________________
882 AliMUONTrackerData::Clear(Option_t*)
884 /// Clear all the values
885 if ( fChannelValues ) fChannelValues->Clear();
886 if ( fManuValues ) fManuValues->Clear();
887 if ( fBusPatchValues) fBusPatchValues->Clear();
888 if ( fPCBValues ) fPCBValues->Clear();
889 if ( fDEValues) fDEValues->Clear();
890 if ( fChamberValues ) fChamberValues->Clear();
891 if ( fHistos ) fHistos->Clear();
892 for ( Int_t i = 0; i < fNofDDLs; ++i )
894 fNofEventsPerDDL[i] = 0;
896 NumberOfEventsChanged();
899 //_____________________________________________________________________________
901 AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
902 Int_t manuChannel) const
904 /// Return the number of times a given channel had data
906 return Channel(detElemId,manuId,manuChannel,IndexOfNumberDimension());
909 //_____________________________________________________________________________
911 AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param,
912 Int_t detElemId, Int_t manuId) const
914 /// Create a double version of VCalibParam, for internal use
916 AliCodeTimerAuto("",0);
918 AliMUONVCalibParam* c = new AliMUONCalibParamND(Dimension(),
924 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId,manuId);
926 for ( Int_t i = 0; i < c->Size(); ++i )
930 if ( de->IsConnectedChannel(manuId,i) ) value = 1.0;
932 c->SetValueAsDouble(i,IndexOfNumberDimension(),value);
938 //_____________________________________________________________________________
940 AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
942 /// Return the value for a given detection element for a given dimension
943 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
944 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
948 //_____________________________________________________________________________
950 AliMUONTrackerData::DetectionElementParam(Int_t detElemId, Bool_t create) const
952 /// Return (if it exist) the VCalibParam for a given detection element
954 AliMUONVCalibParam* de = fDEValues ? static_cast<AliMUONVCalibParam*>
955 (fDEValues->FindObject(detElemId)) : 0x0 ;
957 if (!de && create && fDEValues)
959 de = CreateDetectionElementParam(detElemId);
967 //_____________________________________________________________________________
969 AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
971 /// Create storage for one detection element
973 AliCodeTimerAuto("",0);
975 AliMUONVCalibParam* de = new AliMUONCalibParamND(Dimension(),1,detElemId,0,0.0);
977 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
980 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
982 Int_t busPatchId = det->GetBusPatchId(i);
983 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
984 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
986 Int_t manuId = bp->GetManuId(j);
987 nchannels += det->NofChannelsInManu(manuId);
991 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
996 //_____________________________________________________________________________
998 AliMUONTrackerData::DdlIdFromBusPatchId(Int_t buspatchid) const
1000 /// Get the "local" ddlid (0..19) of a given buspatch
1001 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatchid);
1004 return bp->GetDdlId();
1009 //_____________________________________________________________________________
1011 AliMUONTrackerData::DdlIdFromDetElemId(Int_t detelemid) const
1013 /// Get the "local" ddlid (0..19) of a given detection element
1014 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detelemid);
1017 return de->GetDdlId();
1022 //_____________________________________________________________________________
1024 AliMUONTrackerData::DdlIdFromChamberId(Int_t chamberid) const
1026 /// Get the "local" ddlid (0..19) of a given chamber
1027 /// This has no real meaning (as there are several ddls per chamber),
1028 /// so we take the ddlid where we got the max number of events
1032 it.First(chamberid);
1036 while (!it.IsDone())
1038 Int_t detElemId = it.CurrentDEId();
1039 Int_t ddlId = DdlIdFromDetElemId(detElemId);
1040 if ( NumberOfEvents(ddlId) > n )
1042 n = NumberOfEvents(ddlId);
1051 //_____________________________________________________________________________
1053 AliMUONTrackerData::DimensionName(Int_t dim) const
1055 /// Get the name of a given dimension
1056 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
1059 return value->String();
1063 return TString("Invalid");
1067 //_____________________________________________________________________________
1069 AliMUONTrackerData::DisableChannelLevel()
1071 /// Disable the storing of data at channel level
1073 delete fChannelValues;
1074 fChannelValues = 0x0;
1075 fIsChannelLevelEnabled = kFALSE;
1078 //_____________________________________________________________________________
1080 AliMUONTrackerData::DisableManuLevel()
1082 /// Disable the storing of data at manu level (and below)
1084 DisableChannelLevel();
1087 fIsManuLevelEnabled = kFALSE;
1090 //_____________________________________________________________________________
1092 AliMUONTrackerData::External2Internal(Int_t index) const
1094 /// From external to internal dimension
1095 return IsSingleEvent() ? index : index*2;
1098 //_____________________________________________________________________________
1100 AliMUONTrackerData::ExternalDimensionName(Int_t dim) const
1102 /// Get the name of a given external dimension
1104 TObjString* value = static_cast<TObjString*>(fExternalDimensionNames->At(dim));
1107 return value->String();
1111 return TString("Invalid");
1115 //_____________________________________________________________________________
1117 AliMUONTrackerData::FillHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel,
1118 Int_t dim, Double_t value)
1120 /// Fill histogram of a given channel
1122 AliMUONSparseHisto* h(0x0);
1124 if ( fIsChannelLevelEnabled )
1126 h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
1128 else if ( fIsManuLevelEnabled )
1130 h = GetManuSparseHisto(detElemId,manuId,dim);
1133 AliDebug(1,Form("DE %04d MANU %04d CH %02d dim %d value %e h %p",detElemId,manuId,manuChannel,dim,value,h));
1137 h->Fill(static_cast<Int_t>(TMath::Nint(value)));
1141 //_____________________________________________________________________________
1143 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId,
1146 /// Get histogram of a given manu
1148 if (!fHistos) return 0x0;
1150 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1153 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1158 //_____________________________________________________________________________
1160 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId, Int_t dim)
1162 /// Get histogram of a given manu. Create it if necessary
1164 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1166 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1169 m = new AliMUON1DArray(NumberOfDimensions());
1170 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1174 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1177 h = new AliMUONSparseHisto(fXmin,fXmax);
1179 h->SetUniqueID(dim);
1187 //_____________________________________________________________________________
1189 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1190 Int_t manuChannel, Int_t dim) const
1192 /// Get histogram of a given channel
1194 if (!fHistos) return 0x0;
1196 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1199 UInt_t uid = ( manuChannel << 16 ) | dim;
1201 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1206 //_____________________________________________________________________________
1208 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1209 Int_t manuChannel, Int_t dim)
1211 /// Get histogram of a given channel. Create it if necessary
1213 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1215 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1218 m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
1219 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1223 UInt_t uid = ( manuChannel << 16 ) | dim;
1225 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1228 h = new AliMUONSparseHisto(fXmin,fXmax);
1230 h->SetUniqueID(uid);
1238 //_____________________________________________________________________________
1240 AliMUONTrackerData::GetDEManu(const AliMUONVCalibParam& param,
1241 Int_t& detElemId, Int_t& manuId) const
1243 /// Tries to get (detElemId,manuId) of param
1245 // Load mapping manu store
1246 if ( ! AliMpCDB::LoadManuStore() ) {
1247 AliError("Could not access manu store from OCDB !");
1251 if ( param.ID1() <= 0 )
1253 // we (probably) get a manu serial number
1254 Int_t serial = param.ID0();
1255 MpPair_t pair = AliMpManuStore::Instance()->GetDetElemIdManu(serial);
1256 detElemId = AliMp::PairFirst(pair);
1257 manuId = AliMp::PairSecond(pair);
1260 AliError(Form("DE %d manuId %d from serial %d is not correct !",
1261 detElemId,manuId,serial));
1266 // we get a (de,manu) pair
1267 detElemId = param.ID0();
1268 manuId = param.ID1();
1273 //_____________________________________________________________________________
1275 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
1276 AliMUONVCalibParam*& chamber,
1277 AliMUONVCalibParam*& de,
1278 AliMUONVCalibParam*& busPatch,
1279 AliMUONVCalibParam*& pcb,
1280 AliMUONVCalibParam*& manu,
1281 AliMUONVCalibParam*& channel,
1282 AliMpDetElement*& mpde)
1284 /// Get containers at all levels
1286 chamber = de = busPatch = pcb = manu = channel = 0x0;
1289 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
1294 GetDEManu(*external,detElemId,manuId);
1296 mpde = ddlStore->GetDetElement(detElemId);
1298 if (!mpde) // can happen if reading e.g. capacitances store where we have data for non-connected manus
1303 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1305 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
1307 Int_t pcbIndex = -1;
1309 AliMp::StationType stationType = mpde->GetStationType();
1311 if ( stationType == AliMp::kStation345 )
1313 AliMpDCSNamer namer("TRACKER");
1314 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
1317 if ( fIsChannelLevelEnabled )
1319 channel = ChannelParam(detElemId,manuId,external);
1322 manu = ManuParam(detElemId,manuId,kTRUE);
1324 busPatch = BusPatchParam(busPatchId,kTRUE);
1326 de = DetectionElementParam(detElemId,kTRUE);
1328 chamber = ChamberParam(chamberId,kTRUE);
1332 if ( pcbIndex >= 0 )
1334 pcb = PCBParam(detElemId,pcbIndex,kTRUE);
1340 //_____________________________________________________________________________
1342 AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
1344 /// Whether we have data for a given buspatch
1345 return ( BusPatchParam(busPatchId) != 0 );
1348 //_____________________________________________________________________________
1350 AliMUONTrackerData::HasChamber(Int_t chamberId) const
1352 /// Whether we have data for a given chamber
1353 return ( ChamberParam(chamberId) != 0 );
1356 //_____________________________________________________________________________
1358 AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
1360 /// Whether we have data for a given detection element
1361 return ( DetectionElementParam(detElemId) != 0 );
1364 //_____________________________________________________________________________
1366 AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
1368 /// Whether we have data for a given manu
1369 return ( ManuParam(detElemId,manuId) != 0 );
1372 //_____________________________________________________________________________
1374 AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
1376 /// Whether we have data for a given pcb
1377 return ( PCBParam(detElemId,pcbIndex) != 0 );
1380 //_____________________________________________________________________________
1382 AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
1384 /// Return the value for a given manu and a given dimension
1386 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
1387 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1390 //_____________________________________________________________________________
1392 AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId, Bool_t create) const
1394 /// Get the VCalibParam for a given manu
1396 AliMUONVCalibParam* manu = fManuValues ? static_cast<AliMUONVCalibParam*>
1397 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
1399 if (!manu && create && fManuValues)
1401 manu = CreateManuParam(detElemId,manuId);
1402 fManuValues->Add(manu);
1408 //_____________________________________________________________________________
1410 AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
1412 /// Create storage for one manu
1414 AliCodeTimerAuto("",0);
1416 AliMUONVCalibParam* manu = new AliMUONCalibParamND(Dimension(),1,detElemId,manuId,0.0);
1418 // set the number of channels in that manu
1420 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1422 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
1427 //_____________________________________________________________________________
1429 AliMUONTrackerData::Merge(TCollection* list)
1431 /// Merge this with a list of AliMUONVTrackerData
1433 if (!list) return 0;
1435 if ( list->IsEmpty() ) return NumberOfEvents(-1);
1438 const TObject* o(0x0);
1440 while ( ( o = next() ) )
1442 const AliMUONTrackerData* data = dynamic_cast<const AliMUONTrackerData*>(o);
1445 AliError(Form("Object named %s is not an AliMUONTrackerData ! Skipping it",
1450 Bool_t ok = Add(*data);
1453 AliError("Got incompatible objects");
1458 return NumberOfEvents(-1);
1461 //_____________________________________________________________________________
1463 AliMUONTrackerData::NumberOfDimensions() const
1465 /// Number of dimensions we're dealing with
1467 return fDimension + fgkVirtualExtraDimension;
1470 //_____________________________________________________________________________
1472 AliMUONTrackerData::NumberOfEvents(Int_t ddlNumber) const
1474 /// Get the number of events we've seen for a given DDL, or the max
1475 /// in case ddlNumber<0
1479 if ( fNofEventsPerDDL && ddlNumber >= 0 && ddlNumber < fNofDDLs )
1481 n = fNofEventsPerDDL[ddlNumber];
1485 // get the max number of events
1492 //_____________________________________________________________________________
1494 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
1496 /// Return the value of a given pcb for a given dimension
1498 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
1500 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1503 //_____________________________________________________________________________
1505 AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex, Bool_t create) const
1507 /// Return (if it exist) the VCalibParam for a given pcb
1509 AliMUONVCalibParam* pcb = fPCBValues ? static_cast<AliMUONVCalibParam*>
1510 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
1512 if (create && fPCBValues && !pcb)
1514 pcb = CreatePCBParam(detElemId,pcbIndex);
1515 fPCBValues->Add(pcb);
1521 //_____________________________________________________________________________
1523 AliMUONTrackerData::CreatePCBParam(Int_t detElemId, Int_t pcbIndex) const
1525 /// Create storage for one PCB (station345 only)
1527 AliCodeTimerAuto("",0);
1529 AliMpDCSNamer namer("TRACKER");
1531 AliMUONVCalibParam* pcb = new AliMUONCalibParamND(Dimension(),
1532 namer.NumberOfPCBs(detElemId),
1539 //_____________________________________________________________________________
1541 AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
1547 if ( !fIsSingleEvent )
1549 for ( Int_t i = 0; i < fNofDDLs; ++i )
1551 cout << Form("DDL %04d Nevents=%10d",AliDAQ::DdlID("MUONTRK",i),fNofEventsPerDDL[i]) << endl;
1555 if ( !fIsChannelLevelEnabled )
1557 cout << "Is not storing data at the channel level" << endl;
1560 if ( !fIsManuLevelEnabled )
1562 cout << "Is not storing data at the manu level" << endl;
1565 for ( Int_t i = 0; i <= fExternalDimensionNames->GetLast(); ++i )
1567 TObjString* name = static_cast<TObjString*>(fExternalDimensionNames->At(i));
1568 cout << Form("External Dimension %2d Name %s %s",i,
1569 ( name ? name->String().Data() : "null"),
1570 ( IsHistogrammed(i) ? "(histogrammed)" : "")) << endl;
1573 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
1575 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
1576 cout << Form("Internal Dimension %2d Name %s",i,
1577 ( name ? name->String().Data() : "null")) << endl;
1583 if ( sopt.Contains("CHANNEL") )
1585 if ( fIsChannelLevelEnabled )
1587 if ( fChannelValues ) fChannelValues->Print(wildcard,opt);
1591 AliWarning("You requested channel values, but they were not stored !");
1595 if ( sopt.Contains("MANU") )
1597 if ( fIsManuLevelEnabled )
1599 if ( fManuValues ) fManuValues->Print(wildcard,opt);
1603 AliWarning("You requested manu values, but they were not stored !");
1607 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
1609 fBusPatchValues->Print(wildcard,opt);
1612 if ( sopt.Contains("DE") && fDEValues )
1614 fDEValues->Print(wildcard,opt);
1617 if ( sopt.Contains("CHAMBER") && fChamberValues )
1619 fChamberValues->Print(wildcard,opt);
1624 //_____________________________________________________________________________
1626 AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
1628 /// Set the name of a given dimension
1630 if ( index >= fExternalDimension )
1632 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1636 Int_t ix = External2Internal(index);
1638 if ( !IsSingleEvent() )
1640 const char* prefix[] = { "mean", "sigma" };
1642 for ( Int_t i = 0; i < 2; ++i )
1646 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
1651 SetInternalDimensionName(index,name);
1654 SetExternalDimensionName(index,name);
1657 //_____________________________________________________________________________
1659 AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
1661 /// decide to make histos for a given dimension
1662 if ( index >= ExternalDimension() )
1664 AliError(Form("Index out of bounds : %d / %d",index,ExternalDimension()));
1668 fHistogramming[index] = value;
1673 //_____________________________________________________________________________
1675 AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
1677 /// Set the name of a given internal dimension
1678 if ( index >= fDimension )
1680 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
1684 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
1688 fDimensionNames->Remove(ovalue);
1691 fDimensionNames->AddAt(new TObjString(value),index);
1694 //_____________________________________________________________________________
1696 AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
1698 /// Set the name of a given external dimension
1699 if ( index >= fExternalDimension )
1701 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1705 TObjString* ovalue = static_cast<TObjString*>(fExternalDimensionNames->At(index));
1709 fExternalDimensionNames->Remove(ovalue);
1712 fExternalDimensionNames->AddAt(new TObjString(value),index);
1715 //_____________________________________________________________________________
1717 AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i,
1718 Int_t dim, Int_t ddlId) const
1720 /// Compute the value for a given dim, using the internal information we have
1721 /// Basically we're converting sum of weights and sum of squares of weights
1722 /// into means and sigmas, and number of events into occupancy number.
1724 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
1726 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
1728 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
1730 if ( dim >= fDimension )
1735 if ( dim == IndexOfOccupancyDimension() )
1737 if ( ddlId < 0 ) AliError("Got a negative ddl id !");
1738 return occ/n/NumberOfEvents(ddlId);
1741 Double_t value = param.ValueAsDouble(i,dim);
1743 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
1745 if ( TMath::Even(dim) || IsSingleEvent() )
1747 Double_t x = value/occ;
1749 return ( TMath::Finite(x) ? x : 0.0 ) ;
1757 Double_t mean = param.ValueAsDouble(i,dim-1)/nn;
1759 return TMath::Sqrt(TMath::Abs((value-nn*mean*mean)/(nn-1.0)));
1767 AliError("Why am I here ?");
1771 //_____________________________________________________________________________
1773 AliMUONTrackerData::Streamer(TBuffer &R__b)
1775 /// Customized streamer
1777 if (R__b.IsReading()) {
1778 AliMUONTrackerData::Class()->ReadBuffer(R__b, this);
1781 // backward compatible mode : we set number of events
1782 // per DDL to the total number of events (the only information
1783 // we had before version 7 of that class)
1784 delete[] fNofEventsPerDDL;
1786 fNofEventsPerDDL = new Int_t[fNofDDLs];
1787 for ( Int_t i = 0; i < fNofDDLs; ++i )
1789 fNofEventsPerDDL[i] = fNevents;
1794 AliMUONTrackerData::Class()->WriteBuffer(R__b, this);
1798 //_____________________________________________________________________________
1800 AliMUONTrackerData::ExportAsASCIIOccupancyFile(const char* filename, Int_t runNumber) const
1802 /// Export only the occupancy part, in a format compatible with what
1803 /// the online occupancy DA is writing
1805 if ( ! AliMpDDLStore::Instance(kFALSE) )
1807 AliError("Mapping not loaded. Cannot work");
1813 AliError("No manu values. Cannot work");
1817 ofstream out(filename);
1821 AliError(Form("Cannot create file %s",filename));
1825 out << "//===========================================================================" << endl;
1826 out << "// Hit counter exported from $Id$" << endl;
1827 out << "//===========================================================================" << endl;
1828 out << "//" << endl;
1829 out << "// * Run Number : " << runNumber << endl;
1830 out << "// * File Creation Date : " << TTimeStamp().AsString("l") << endl;
1831 out << "//---------------------------------------------------------------------------" << endl;
1832 out << "// BP MANU SUM_N NEVENTS" << endl;
1833 out << "//---------------------------------------------------------------------------" << endl;
1835 TIter next(fManuValues->CreateIterator());
1836 AliMUONVCalibParam* manu;
1838 while ( ( manu = static_cast<AliMUONVCalibParam*>(next()) ) )
1840 Int_t detElemId = manu->ID0();
1841 Int_t manuId = manu->ID1();
1842 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1843 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus( busPatchId);
1844 if ( busPatchId < 0 || ddl < 0 )
1846 AliError(Form("Got invalid (DE,manu,bp,ddl)=(%d,%d,%d,%d). Skipping it",detElemId,manuId,busPatchId,ddl));
1850 Int_t nevents = fNofEventsPerDDL[ddl];
1852 out << Form("%5d %5d %10d %10d",busPatchId,manuId,manu->ValueAsInt(0,IndexOfOccupancyDimension()),nevents) << endl;