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),
92 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
93 fExternalDimensionNames->SetOwner(kTRUE);
94 fDimensionNames->SetOwner(kTRUE);
95 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
96 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
97 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
101 //_____________________________________________________________________________
102 AliMUONTrackerData::AliMUONTrackerData(const char* name, const char* title,
103 const AliMUONVStore& manuValues)
104 : AliMUONVTrackerData(name,title),
105 fIsSingleEvent(kFALSE),
108 fBusPatchValues(0x0),
114 fDimensionNames(0x0),
115 fExternalDimensionNames(0x0),
116 fExternalDimension(0),
121 fIsChannelLevelEnabled(kFALSE),
122 fIsManuLevelEnabled(kTRUE),
124 fNofEventsPerDDL(0x0)
126 /// ctor with pre-computed values at the manu level
127 /// In this case, we force fIsChannelLevelEnabled = kFALSE
130 if (manuValues.GetSize()==0)
132 AliFatal("Cannot create a tracker data from nothing in that case !");
135 if ( !AliMpDDLStore::Instance(kFALSE) && !AliMpManuStore::Instance(kFALSE) )
137 AliError("Cannot work without (full) mapping");
141 TIter next(manuValues.CreateIterator());
142 AliMUONVCalibParam* m = static_cast<AliMUONVCalibParam*>(next());
144 Int_t dimension = ( m->Dimension() - fgkExtraDimension - fgkVirtualExtraDimension ) / 2;
146 fDimension = External2Internal(dimension)+fgkExtraDimension;
148 fDimensionNames = new TObjArray(fDimension+fgkVirtualExtraDimension);
149 fExternalDimensionNames = new TObjArray(dimension);
150 fExternalDimension = dimension;
151 fHistogramming = new Int_t[fExternalDimension];
152 memset(fHistogramming,0,fExternalDimension*sizeof(Int_t)); // histogramming is off by default. Use MakeHistogramForDimension to turn it on.
154 fExternalDimensionNames->SetOwner(kTRUE);
155 fDimensionNames->SetOwner(kTRUE);
156 fDimensionNames->AddAt(new TObjString("occ"),IndexOfOccupancyDimension());
157 fDimensionNames->AddAt(new TObjString("N"),IndexOfNumberDimension());
158 fDimensionNames->AddAt(new TObjString("n"),NumberOfDimensions()-fgkVirtualExtraDimension);
160 TArrayI nevents(AliDAQ::NumberOfDdls("MUONTRK"));
164 AliMUONVCalibParam* external;
166 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
168 Int_t detElemId, manuId;
170 GetDEManu(*external,detElemId,manuId);
172 AliMUONVCalibParam* chamber(0x0);
173 AliMUONVCalibParam* de(0x0);
174 AliMUONVCalibParam* busPatch(0x0);
175 AliMUONVCalibParam* pcb(0x0);
176 AliMUONVCalibParam* manu(0x0);
177 AliMUONVCalibParam* channel(0x0);
178 AliMpDetElement* mpde(0x0);
180 AliMUONVCalibParam* wec = new AliMUONCalibParamND(external->Dimension()-1,1,detElemId,manuId,0);
181 // as external, but without event count
182 wec->SetValueAsDouble(0,0,external->ValueAsDouble(0,0));
183 wec->SetValueAsDouble(0,1,external->ValueAsDouble(0,1));
184 wec->SetValueAsDouble(0,2,external->ValueAsDouble(0,2));
185 wec->SetValueAsDouble(0,3,external->ValueAsDouble(0,3));
187 Int_t mid = GetParts(wec,chamber,de,busPatch,pcb,manu,channel,mpde);
191 AliError(Form("Something is wrong for DE %5d : manuId = %d vs mid = %d",detElemId,manuId,mid));
197 AliError("Got a < 0 manuId. Should not happen here !");
201 assert(channel==0x0);
203 Int_t n1 = manu->ValueAsInt(0,IndexOfNumberDimension());
204 Int_t n2 = external->ValueAsInt(0,IndexOfNumberDimension());
207 AliError(Form("Incoherent number of manu channels for DE %5d MANU %5d : %d vs %d",
208 detElemId,manuId,n1,n2));
211 Int_t nevt = external->ValueAsInt(0,4);
213 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
215 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus(busPatchId);
217 if ( nevents[ddl] == 0 )
223 if ( nevents.At(ddl) != nevt )
225 AliError(Form("Nevt mismatch for DE %5d MANU %5d DDL %d : %d vs %d",
226 detElemId,manuId,ddl,nevents.At(ddl),nevt));
231 for ( Int_t i = 0; i < wec->Dimension()-1; ++i )
233 manu->SetValueAsDouble(0,i,manu->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
235 busPatch->SetValueAsDouble(0,i,busPatch->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
237 de->SetValueAsDouble(0,i,de->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
239 chamber->SetValueAsDouble(0,i,chamber->ValueAsDouble(0,i) + wec->ValueAsDouble(0,i));
244 UpdateNumberOfEvents(&nevents);
249 //_____________________________________________________________________________
250 AliMUONTrackerData::~AliMUONTrackerData()
253 delete fChannelValues;
255 delete fBusPatchValues;
257 delete fChamberValues;
259 delete fDimensionNames;
260 delete fExternalDimensionNames;
261 delete[] fHistogramming;
263 delete[] fNofEventsPerDDL;
266 //_____________________________________________________________________________
268 AliMUONTrackerData::Add(const AliMUONVStore& store, TArrayI* nevents)
270 /// Add the given external store to our internal store
271 return InternalAdd(store,nevents,kFALSE);
274 //_____________________________________________________________________________
276 AliMUONTrackerData::Add(const AliMUONTrackerData& data)
278 /// Add data to *this
279 // We do this by looping on all VCalibParam stored in the various containers,
280 // and simply adding the values there.
281 // Same thing for the number of events per DDL.
282 // Same thing for sparsehistograms, if we have some.
284 // First cross check we have compatible objects.
286 if ( fIsChannelLevelEnabled != data.fIsChannelLevelEnabled )
288 AliError("Incompatible IsChannelLevelEnabled status");
292 if ( fIsManuLevelEnabled != data.fIsManuLevelEnabled )
294 AliError("Incompatible IsManuLevelEnabled status");
298 if ( fIsSingleEvent != data.fIsSingleEvent )
300 AliError("Incompatible IsSingleEvent status");
304 if ( fDimension != data.fDimension || fExternalDimension != data.fExternalDimension )
306 AliError("Incompatible dimensions");
310 if ( fNofDDLs != data.fNofDDLs )
312 AliError("Incompatible number of Ddls");
316 if ( ( !fHistogramming && data.fHistogramming ) || ( fHistogramming && !data.fHistogramming )
317 || fXmin != data.fXmin || fXmax != data.fXmax )
319 AliError(Form("Incompatible histogramming (%p vs %p) (xmax = %e vs %e ; xmin = %e vs %e)",
320 fHistogramming,data.fHistogramming,fXmax,data.fXmax,fXmin,data.fXmin));
324 if ( fHistogramming )
326 for ( Int_t i = 0; i < fExternalDimension; ++i )
328 if ( fHistogramming[i] != data.fHistogramming[i] )
330 AliError(Form("Incompatible histogramming for external dimension %d",i));
336 // OK. Seems we have compatible objects, so we can proceed with the actual
339 if ( data.fChannelValues )
341 Add2D(*(data.fChannelValues),*fChannelValues);
344 if ( data.fManuValues )
346 Add2D(*(data.fManuValues),*fManuValues);
349 if ( data.fPCBValues )
351 Add2D(*(data.fPCBValues),*fPCBValues);
354 if ( data.fBusPatchValues )
356 Add1D(*(data.fBusPatchValues),*fBusPatchValues);
359 if ( data.fDEValues )
361 Add1D(*(data.fDEValues),*fDEValues);
364 if ( data.fChamberValues )
366 Add1D(*(data.fChamberValues),*fChamberValues);
369 for ( Int_t i = 0; i < fNofDDLs; ++i )
371 fNofEventsPerDDL[i] += data.fNofEventsPerDDL[i];
376 TIter nexthisto(data.fHistos->CreateIterator());
377 AliMUONVStore* store;
378 while ( ( store = static_cast<AliMUONVStore*>(nexthisto()) ) )
380 TIter ns(store->CreateIterator());
381 AliMUONSparseHisto* h;
382 while ( ( h = static_cast<AliMUONSparseHisto*>(ns()) ) )
384 AliMUONVStore* thisStore = static_cast<AliMUONVStore*>(fHistos->FindObject(store->GetUniqueID()));
388 thisStore = store->Create();
389 thisStore->SetUniqueID(store->GetUniqueID());
390 fHistos->Add(thisStore);
393 AliMUONSparseHisto* mine = static_cast<AliMUONSparseHisto*>(thisStore->FindObject(h->GetUniqueID()));
407 fNevents = TMath::Max(fNevents,data.fNevents);
412 //_____________________________________________________________________________
414 AliMUONTrackerData::Add2D(const AliMUONVStore& src, AliMUONVStore& dest) const
416 /// Add one 2d store to another
418 TIter next(src.CreateIterator());
419 AliMUONVCalibParam* p;
421 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
423 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->ID0(),p->ID1()));
427 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
431 AddCalibParams(*p,*a);
436 //_____________________________________________________________________________
438 AliMUONTrackerData::Add1D(const AliMUONVStore& src, AliMUONVStore& dest) const
440 /// Add one 1d store to another
442 TIter next(src.CreateIterator());
443 AliMUONVCalibParam* p;
445 while ( ( p = static_cast<AliMUONVCalibParam*>(next()) ) )
447 AliMUONVCalibParam* a = static_cast<AliMUONVCalibParam*>(dest.FindObject(p->GetUniqueID()));
451 dest.Add(static_cast<AliMUONVCalibParam*>(p->Clone()));
455 AddCalibParams(*p,*a);
460 //_____________________________________________________________________________
462 AliMUONTrackerData::AddCalibParams(const AliMUONVCalibParam& src, AliMUONVCalibParam& dest) const
465 for ( Int_t i = 0; i < src.Size(); ++i )
467 for ( Int_t j = 0; j < src.Dimension(); ++j )
469 dest.SetValueAsFloat(i,j,src.ValueAsFloat(i,j));
474 //_____________________________________________________________________________
476 AliMUONTrackerData::Replace(const AliMUONVStore& store)
478 /// Replace our values by values from the given external store
479 Bool_t rv = InternalAdd(store,0x0,kTRUE);
480 AliMUONVTrackerData::Replace(store);
484 //_____________________________________________________________________________
486 AliMUONTrackerData::UpdateNumberOfEvents(TArrayI* nevents)
488 /// Update the number of events
492 fNofDDLs = AliDAQ::NumberOfDdls("MUONTRK");
493 fNofEventsPerDDL = new Int_t[fNofDDLs];
494 for ( Int_t i = 0; i < fNofDDLs; ++i )
496 fNofEventsPerDDL[i] = 0;
502 if (nevents->GetSize() != fNofDDLs )
504 AliError(Form("nof of ddl per event array size is incorrect : got %d, expecting %d",
505 nevents->GetSize(),fNofDDLs));
509 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
511 fNofEventsPerDDL[i] += nevents->At(i);
512 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
517 for ( Int_t i = 0 ; i < fNofDDLs; ++i )
519 ++fNofEventsPerDDL[i];
520 fNevents = TMath::Max(fNevents,fNofEventsPerDDL[i]);
526 //_____________________________________________________________________________
528 AliMUONTrackerData::AssertStores()
530 /// Insure our stores are allocated
534 Int_t numberOfBusPatches(0);
535 Int_t numberOfDEs(0);
537 // get number of bus patches and number of detection element
538 // to initialize fBusPatchValues and fDEValues below
540 TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
541 while ( next() ) ++numberOfBusPatches;
542 AliMpDEIterator deIt;
544 while (!deIt.IsDone())
550 if ( fIsChannelLevelEnabled )
552 fChannelValues = new AliMUON2DMap(kTRUE);
554 if ( fIsManuLevelEnabled )
556 fManuValues = new AliMUON2DMap(kTRUE);
558 fPCBValues = new AliMUON2DMap(kFALSE);
559 fBusPatchValues = new AliMUON1DMap(numberOfBusPatches);
560 fDEValues = new AliMUON1DMap(numberOfDEs);
561 fChamberValues = new AliMUON1DArray;
565 //_____________________________________________________________________________
567 AliMUONTrackerData::InternalAdd(const AliMUONVStore& store, TArrayI* nevents, Bool_t replace)
569 /// Add the given external store to our internal store
571 AliCodeTimerAuto(GetName(),0);
575 if ( IsSingleEvent() && NumberOfEvents(-1) == 1 )
577 AliError(Form("%s is supposed to be single event only",GetName()));
582 UpdateNumberOfEvents(nevents);
586 TIter next(store.CreateIterator());
587 AliMUONVCalibParam* external;
591 if ( IsSingleEvent() ) nk = 1;
593 while ( ( external = static_cast<AliMUONVCalibParam*>(next()) ) )
595 if ( external->Dimension() != ExternalDimension() )
597 AliError(Form("Incompatible dimensions %d vs %d",
598 external->Dimension(),ExternalDimension()));
602 AliMUONVCalibParam* chamber(0x0);
603 AliMUONVCalibParam* de(0x0);
604 AliMUONVCalibParam* busPatch(0x0);
605 AliMUONVCalibParam* pcb(0x0);
606 AliMUONVCalibParam* manu(0x0);
607 AliMUONVCalibParam* channel(0x0);
608 AliMpDetElement* mpde(0x0);
610 Int_t manuId = GetParts(external,chamber,de,busPatch,pcb,manu,channel,mpde);
612 if ( manuId < 0 ) continue;
614 Int_t detElemId = mpde->GetId();
616 Double_t value[] = { 0.0, 0.0 };
618 Int_t nch = mpde->NofChannelsInManu(manuId);
620 for ( Int_t i = 0; i < external->Size(); ++i )
622 Bool_t existingChannel = ( nch == AliMpConstants::ManuNofChannels() ? kTRUE
623 : mpde->IsConnectedChannel(manuId,i));
624 // note we only use IsConnectedChannel method when really needed, as
625 // it costs (some) CPU time...
627 if ( existingChannel )
629 Bool_t validChannel(kFALSE);
631 for ( Int_t j = 0; j < external->Dimension(); ++j )
633 Double_t vext = external->IsDoublePrecision() ?
634 external->ValueAsDoubleFast(i,j) :
635 external->ValueAsFloatFast(i,j);
637 if ( vext >= AliMUONVCalibParam::InvalidFloatValue() ) continue;
639 validChannel = kTRUE;
641 Int_t ix = External2Internal(j);
644 value[1] = vext*vext;
646 if ( IsHistogrammed(j) )
648 FillHisto(detElemId,manuId,i,j,vext);
651 for ( Int_t k = 0; k < nk; ++k )
653 Double_t e = ( replace && channel ) ? channel->ValueAsDoubleFast(i,ix+k) : 0.0;
657 channel->SetValueAsDoubleFast(i,ix+k,channel->ValueAsDoubleFast(i,ix+k)-e+value[k]);
662 manu->SetValueAsDoubleFast(0,ix+k,manu->ValueAsDoubleFast(0,ix+k)-e+value[k]);
665 busPatch->SetValueAsDoubleFast(0,ix+k,busPatch->ValueAsDoubleFast(0,ix+k)-e+value[k]);
667 de->SetValueAsDoubleFast(0,ix+k,de->ValueAsDoubleFast(0,ix+k)-e+value[k]);
669 chamber->SetValueAsDoubleFast(0,ix+k,chamber->ValueAsDoubleFast(0,ix+k)-e+value[k]);
673 pcb->SetValueAsDoubleFast(0,ix+k,pcb->ValueAsDoubleFast(0,ix+k)-e+value[k]);
678 if ( validChannel && !replace )
682 channel->SetValueAsDoubleFast(i,IndexOfOccupancyDimension(),
683 channel->ValueAsDoubleFast(i,IndexOfOccupancyDimension())+1.0);
688 manu->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
689 manu->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
692 busPatch->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
693 busPatch->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
694 de->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
695 de->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
696 chamber->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
697 chamber->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
700 pcb->SetValueAsDoubleFast(0,IndexOfOccupancyDimension(),
701 pcb->ValueAsDoubleFast(0,IndexOfOccupancyDimension())+1.0);
708 NumberOfEventsChanged();
713 //_____________________________________________________________________________
715 AliMUONTrackerData::BusPatch(Int_t busPatchId, Int_t dim) const
717 /// Return the value of a given buspatch for a given dimension
718 /// or 0 if not existing
719 AliMUONVCalibParam* param = BusPatchParam(busPatchId);
720 return param ? Value(*param,0,dim,DdlIdFromBusPatchId(busPatchId)) : 0.0;
723 //_____________________________________________________________________________
725 AliMUONTrackerData::BusPatchParam(Int_t busPatchId, Bool_t create) const
727 /// Return (if it exist), the VCalibParam for a given busPatch
729 AliMUONVCalibParam* busPatch = fBusPatchValues ? static_cast<AliMUONVCalibParam*>
730 (fBusPatchValues->FindObject(busPatchId)) : 0x0;
732 if (!busPatch && create && fBusPatchValues)
734 busPatch = CreateBusPatchParam(busPatchId);
735 fBusPatchValues->Add(busPatch);
741 //_____________________________________________________________________________
743 AliMUONTrackerData::CreateBusPatchParam(Int_t busPatchId) const
745 /// Create storage for one bus patch
747 AliCodeTimerAuto("",0);
749 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
753 AliError(Form("Got an invalid buspatchId = %d",busPatchId));
757 AliMUONVCalibParam* busPatch = new AliMUONCalibParamND(Dimension(),1,busPatchId,0,0.0);
759 // set the number of channels in that buspatch
763 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
765 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
767 for ( Int_t i = 0; i < bp->GetNofManus(); ++i )
769 Int_t manuId = bp->GetManuId(i);
770 nchannels += de->NofChannelsInManu(manuId);
773 busPatch->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
778 //_____________________________________________________________________________
780 AliMUONTrackerData::Chamber(Int_t chamberId, Int_t dim) const
782 /// Return the value fo a given chamber for a given dimension,
783 /// or zero if not existing
785 // FIXME: is the Value() correct wrt to number of events in the case of
786 // chamber ? Or should we do something custom at the chamber level
787 // (as it spans several ddls) ?
789 AliMUONVCalibParam* param = ChamberParam(chamberId);
790 return param ? Value(*param,0,dim,DdlIdFromChamberId(chamberId)) : 0.0;
793 //_____________________________________________________________________________
795 AliMUONTrackerData::ChamberParam(Int_t chamberId, Bool_t create) const
797 /// Return (if it exist) the VCalibParam for a given chamber
799 AliMUONVCalibParam* chamber = fChamberValues ? static_cast<AliMUONVCalibParam*>
800 (fChamberValues->FindObject(chamberId)) : 0x0;
802 if (!chamber && create && fChamberValues)
804 chamber = CreateChamberParam(chamberId);
805 fChamberValues->Add(chamber);
811 //_____________________________________________________________________________
813 AliMUONTrackerData::CreateChamberParam(Int_t chamberId) const
815 /// Create storage for one chamber
817 AliCodeTimerAuto("",0);
819 AliMUONVCalibParam* chamber = new AliMUONCalibParamND(Dimension(),1,chamberId,0,0.0);
821 // set the number of channels in that chamber
829 while ( !it.IsDone() )
831 AliMpDetElement* det = it.CurrentDE();
833 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
835 Int_t busPatchId = det->GetBusPatchId(i);
836 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
837 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
839 Int_t manuId = bp->GetManuId(j);
840 nchannels += det->NofChannelsInManu(manuId);
847 chamber->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
852 //_____________________________________________________________________________
854 AliMUONTrackerData::Channel(Int_t detElemId, Int_t manuId,
855 Int_t manuChannel, Int_t dim) const
857 /// Return the value for a given channel for a given dimension
859 AliMUONVCalibParam* param = ChannelParam(detElemId,manuId);
861 return param ? Value(*param,manuChannel,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
864 //_____________________________________________________________________________
866 AliMUONTrackerData::ChannelParam(Int_t detElemId, Int_t manuId,
867 const AliMUONVCalibParam* external) const
869 /// Return (if it exist) the VCalibParam for a given manu
871 AliMUONVCalibParam* param = fChannelValues ? static_cast<AliMUONVCalibParam*>
872 (fChannelValues->FindObject(detElemId,manuId)) : 0x0 ;
874 if (!param && external && fChannelValues)
876 param = CreateDouble(*external,detElemId,manuId);
877 fChannelValues->Add(param);
883 //_____________________________________________________________________________
885 AliMUONTrackerData::Clear(Option_t*)
887 /// Clear all the values
888 if ( fChannelValues ) fChannelValues->Clear();
889 if ( fManuValues ) fManuValues->Clear();
890 if ( fBusPatchValues) fBusPatchValues->Clear();
891 if ( fPCBValues ) fPCBValues->Clear();
892 if ( fDEValues) fDEValues->Clear();
893 if ( fChamberValues ) fChamberValues->Clear();
894 if ( fHistos ) fHistos->Clear();
895 for ( Int_t i = 0; i < fNofDDLs; ++i )
897 fNofEventsPerDDL[i] = 0;
900 NumberOfEventsChanged();
903 //_____________________________________________________________________________
905 AliMUONTrackerData::Count(Int_t detElemId, Int_t manuId,
906 Int_t manuChannel) const
908 /// Return the number of times a given channel had data
910 return Channel(detElemId,manuId,manuChannel,IndexOfNumberDimension());
913 //_____________________________________________________________________________
915 AliMUONTrackerData::CreateDouble(const AliMUONVCalibParam& param,
916 Int_t detElemId, Int_t manuId) const
918 /// Create a double version of VCalibParam, for internal use
920 AliCodeTimerAuto("",0);
922 AliMUONVCalibParam* c = new AliMUONCalibParamND(Dimension(),
928 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId,manuId);
930 for ( Int_t i = 0; i < c->Size(); ++i )
934 if ( de->IsConnectedChannel(manuId,i) ) value = 1.0;
936 c->SetValueAsDouble(i,IndexOfNumberDimension(),value);
942 //_____________________________________________________________________________
944 AliMUONTrackerData::DetectionElement(Int_t detElemId, Int_t dim) const
946 /// Return the value for a given detection element for a given dimension
947 AliMUONVCalibParam* param = DetectionElementParam(detElemId);
948 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
952 //_____________________________________________________________________________
954 AliMUONTrackerData::DetectionElementParam(Int_t detElemId, Bool_t create) const
956 /// Return (if it exist) the VCalibParam for a given detection element
958 AliMUONVCalibParam* de = fDEValues ? static_cast<AliMUONVCalibParam*>
959 (fDEValues->FindObject(detElemId)) : 0x0 ;
961 if (!de && create && fDEValues)
963 de = CreateDetectionElementParam(detElemId);
971 //_____________________________________________________________________________
973 AliMUONTrackerData::CreateDetectionElementParam(Int_t detElemId) const
975 /// Create storage for one detection element
977 AliCodeTimerAuto("",0);
979 AliMUONVCalibParam* de = new AliMUONCalibParamND(Dimension(),1,detElemId,0,0.0);
981 AliMpDetElement* det = AliMpDDLStore::Instance()->GetDetElement(detElemId);
984 for ( Int_t i = 0; i < det->GetNofBusPatches(); ++i )
986 Int_t busPatchId = det->GetBusPatchId(i);
987 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
988 for ( Int_t j = 0; j < bp->GetNofManus(); ++j )
990 Int_t manuId = bp->GetManuId(j);
991 nchannels += det->NofChannelsInManu(manuId);
995 de->SetValueAsDouble(0,IndexOfNumberDimension(),nchannels);
1000 //_____________________________________________________________________________
1002 AliMUONTrackerData::DdlIdFromBusPatchId(Int_t buspatchid) const
1004 /// Get the "local" ddlid (0..19) of a given buspatch
1005 AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatchid);
1008 return bp->GetDdlId();
1013 //_____________________________________________________________________________
1015 AliMUONTrackerData::DdlIdFromDetElemId(Int_t detelemid) const
1017 /// Get the "local" ddlid (0..19) of a given detection element
1018 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detelemid);
1021 return de->GetDdlId();
1026 //_____________________________________________________________________________
1028 AliMUONTrackerData::DdlIdFromChamberId(Int_t chamberid) const
1030 /// Get the "local" ddlid (0..19) of a given chamber
1031 /// This has no real meaning (as there are several ddls per chamber),
1032 /// so we take the ddlid where we got the max number of events
1036 it.First(chamberid);
1040 while (!it.IsDone())
1042 Int_t detElemId = it.CurrentDEId();
1043 Int_t ddlId = DdlIdFromDetElemId(detElemId);
1044 if ( NumberOfEvents(ddlId) > n )
1046 n = NumberOfEvents(ddlId);
1055 //_____________________________________________________________________________
1057 AliMUONTrackerData::DimensionName(Int_t dim) const
1059 /// Get the name of a given dimension
1060 TObjString* value = static_cast<TObjString*>(fDimensionNames->At(dim));
1063 return value->String();
1067 return TString("Invalid");
1071 //_____________________________________________________________________________
1073 AliMUONTrackerData::DisableChannelLevel()
1075 /// Disable the storing of data at channel level
1077 delete fChannelValues;
1078 fChannelValues = 0x0;
1079 fIsChannelLevelEnabled = kFALSE;
1082 //_____________________________________________________________________________
1084 AliMUONTrackerData::DisableManuLevel()
1086 /// Disable the storing of data at manu level (and below)
1088 DisableChannelLevel();
1091 fIsManuLevelEnabled = kFALSE;
1094 //_____________________________________________________________________________
1096 AliMUONTrackerData::External2Internal(Int_t index) const
1098 /// From external to internal dimension
1099 return IsSingleEvent() ? index : index*2;
1102 //_____________________________________________________________________________
1104 AliMUONTrackerData::ExternalDimensionName(Int_t dim) const
1106 /// Get the name of a given external dimension
1108 TObjString* value = static_cast<TObjString*>(fExternalDimensionNames->At(dim));
1111 return value->String();
1115 return TString("Invalid");
1119 //_____________________________________________________________________________
1121 AliMUONTrackerData::FillHisto(Int_t detElemId, Int_t manuId, Int_t manuChannel,
1122 Int_t dim, Double_t value)
1124 /// Fill histogram of a given channel
1126 AliMUONSparseHisto* h(0x0);
1128 if ( fIsChannelLevelEnabled )
1130 h = GetChannelSparseHisto(detElemId, manuId, manuChannel,dim);
1132 else if ( fIsManuLevelEnabled )
1134 h = GetManuSparseHisto(detElemId,manuId,dim);
1137 AliDebug(1,Form("DE %04d MANU %04d CH %02d dim %d value %e h %p",detElemId,manuId,manuChannel,dim,value,h));
1141 h->Fill(static_cast<Int_t>(TMath::Nint(value)));
1145 //_____________________________________________________________________________
1147 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId,
1150 /// Get histogram of a given manu
1152 if (!fHistos) return 0x0;
1154 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1157 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1162 //_____________________________________________________________________________
1164 AliMUONTrackerData::GetManuSparseHisto(Int_t detElemId, Int_t manuId, Int_t dim)
1166 /// Get histogram of a given manu. Create it if necessary
1168 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1170 AliMUON1DArray* m = static_cast<AliMUON1DArray*>(fHistos->FindObject(detElemId,manuId));
1173 m = new AliMUON1DArray(NumberOfDimensions());
1174 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1178 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(dim));
1181 h = new AliMUONSparseHisto(fXmin,fXmax);
1183 h->SetUniqueID(dim);
1191 //_____________________________________________________________________________
1193 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1194 Int_t manuChannel, Int_t dim) const
1196 /// Get histogram of a given channel
1198 if (!fHistos) return 0x0;
1200 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1203 UInt_t uid = ( manuChannel << 16 ) | dim;
1205 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1210 //_____________________________________________________________________________
1212 AliMUONTrackerData::GetChannelSparseHisto(Int_t detElemId, Int_t manuId,
1213 Int_t manuChannel, Int_t dim)
1215 /// Get histogram of a given channel. Create it if necessary
1217 if (!fHistos) fHistos = new AliMUON2DMap(kTRUE);
1219 AliMUON1DMap* m = static_cast<AliMUON1DMap*>(fHistos->FindObject(detElemId,manuId));
1222 m = new AliMUON1DMap(AliMpConstants::ManuNofChannels()); // start with only 1 dim
1223 m->SetUniqueID( ( manuId << 16 ) | detElemId );
1227 UInt_t uid = ( manuChannel << 16 ) | dim;
1229 AliMUONSparseHisto* h = static_cast<AliMUONSparseHisto*>(m->FindObject(uid));
1232 h = new AliMUONSparseHisto(fXmin,fXmax);
1234 h->SetUniqueID(uid);
1242 //_____________________________________________________________________________
1244 AliMUONTrackerData::GetDEManu(const AliMUONVCalibParam& param,
1245 Int_t& detElemId, Int_t& manuId) const
1247 /// Tries to get (detElemId,manuId) of param
1249 // Load mapping manu store
1250 if ( ! AliMpCDB::LoadManuStore() ) {
1251 AliError("Could not access manu store from OCDB !");
1255 if ( param.ID1() <= 0 )
1257 // we (probably) get a manu serial number
1258 Int_t serial = param.ID0();
1259 MpPair_t pair = AliMpManuStore::Instance()->GetDetElemIdManu(serial);
1260 detElemId = AliMp::PairFirst(pair);
1261 manuId = AliMp::PairSecond(pair);
1264 AliDebug(1,Form("DE %d manuId %d from serial %d is not correct !",
1265 detElemId,manuId,serial));
1270 // we get a (de,manu) pair
1271 detElemId = param.ID0();
1272 manuId = param.ID1();
1277 //_____________________________________________________________________________
1279 AliMUONTrackerData::GetParts(AliMUONVCalibParam* external,
1280 AliMUONVCalibParam*& chamber,
1281 AliMUONVCalibParam*& de,
1282 AliMUONVCalibParam*& busPatch,
1283 AliMUONVCalibParam*& pcb,
1284 AliMUONVCalibParam*& manu,
1285 AliMUONVCalibParam*& channel,
1286 AliMpDetElement*& mpde)
1288 /// Get containers at all levels
1290 chamber = de = busPatch = pcb = manu = channel = 0x0;
1293 AliMpDDLStore* ddlStore = AliMpDDLStore::Instance();
1298 GetDEManu(*external,detElemId,manuId);
1300 mpde = ddlStore->GetDetElement(detElemId,kFALSE);
1302 if (!mpde) // can happen if reading e.g. capacitances store where we have data for non-connected manus
1307 // explicitely check that de,manu is correct
1308 const AliMpVSegmentation* mpseg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId, manuId,kFALSE);
1315 Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
1317 Int_t busPatchId = ddlStore->GetBusPatchId(detElemId,manuId);
1319 if ( busPatchId <= 0 )
1324 Int_t pcbIndex = -1;
1326 AliMp::StationType stationType = mpde->GetStationType();
1328 if ( stationType == AliMp::kStation345 )
1330 AliMpDCSNamer namer("TRACKER");
1331 pcbIndex = namer.ManuId2PCBIndex(detElemId,manuId);
1334 if ( fIsChannelLevelEnabled )
1336 channel = ChannelParam(detElemId,manuId,external);
1339 manu = ManuParam(detElemId,manuId,kTRUE);
1341 busPatch = BusPatchParam(busPatchId,kTRUE);
1343 de = DetectionElementParam(detElemId,kTRUE);
1345 chamber = ChamberParam(chamberId,kTRUE);
1349 if ( pcbIndex >= 0 )
1351 pcb = PCBParam(detElemId,pcbIndex,kTRUE);
1357 //_____________________________________________________________________________
1359 AliMUONTrackerData::HasBusPatch(Int_t busPatchId) const
1361 /// Whether we have data for a given buspatch
1362 return ( BusPatchParam(busPatchId) != 0 );
1365 //_____________________________________________________________________________
1367 AliMUONTrackerData::HasChamber(Int_t chamberId) const
1369 /// Whether we have data for a given chamber
1370 return ( ChamberParam(chamberId) != 0 );
1373 //_____________________________________________________________________________
1375 AliMUONTrackerData::HasDetectionElement(Int_t detElemId) const
1377 /// Whether we have data for a given detection element
1378 return ( DetectionElementParam(detElemId) != 0 );
1381 //_____________________________________________________________________________
1383 AliMUONTrackerData::HasManu(Int_t detElemId, Int_t manuId) const
1385 /// Whether we have data for a given manu
1386 return ( ManuParam(detElemId,manuId) != 0 );
1389 //_____________________________________________________________________________
1391 AliMUONTrackerData::HasPCB(Int_t detElemId, Int_t pcbIndex) const
1393 /// Whether we have data for a given pcb
1394 return ( PCBParam(detElemId,pcbIndex) != 0 );
1397 //_____________________________________________________________________________
1399 AliMUONTrackerData::Manu(Int_t detElemId, Int_t manuId, Int_t dim) const
1401 /// Return the value for a given manu and a given dimension
1403 AliMUONVCalibParam* param = ManuParam(detElemId,manuId);
1404 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1407 //_____________________________________________________________________________
1409 AliMUONTrackerData::ManuParam(Int_t detElemId, Int_t manuId, Bool_t create) const
1411 /// Get the VCalibParam for a given manu
1413 AliMUONVCalibParam* manu = fManuValues ? static_cast<AliMUONVCalibParam*>
1414 (fManuValues->FindObject(detElemId,manuId)) : 0x0 ;
1416 if (!manu && create && fManuValues)
1418 manu = CreateManuParam(detElemId,manuId);
1419 fManuValues->Add(manu);
1425 //_____________________________________________________________________________
1427 AliMUONTrackerData::CreateManuParam(Int_t detElemId, Int_t manuId) const
1429 /// Create storage for one manu
1431 AliCodeTimerAuto("",0);
1433 AliMUONVCalibParam* manu = new AliMUONCalibParamND(Dimension(),1,detElemId,manuId,0.0);
1435 // set the number of channels in that manu
1437 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
1439 manu->SetValueAsDouble(0,IndexOfNumberDimension(),de->NofChannelsInManu(manuId));
1444 //_____________________________________________________________________________
1446 AliMUONTrackerData::Merge(TCollection* list)
1448 /// Merge this with a list of AliMUONVTrackerData
1450 if (!list) return 0;
1452 if ( list->IsEmpty() ) return NumberOfEvents(-1);
1455 const TObject* o(0x0);
1457 while ( ( o = next() ) )
1459 const AliMUONTrackerData* data = dynamic_cast<const AliMUONTrackerData*>(o);
1462 AliError(Form("Object named %s is not an AliMUONTrackerData ! Skipping it",
1467 Bool_t ok = Add(*data);
1470 AliError("Got incompatible objects");
1475 return NumberOfEvents(-1);
1478 //_____________________________________________________________________________
1480 AliMUONTrackerData::NumberOfDimensions() const
1482 /// Number of dimensions we're dealing with
1484 return fDimension + fgkVirtualExtraDimension;
1487 //_____________________________________________________________________________
1489 AliMUONTrackerData::NumberOfEvents(Int_t ddlNumber) const
1491 /// Get the number of events we've seen for a given DDL, or the max
1492 /// in case ddlNumber<0
1496 if ( fNofEventsPerDDL && ddlNumber >= 0 && ddlNumber < fNofDDLs )
1498 n = fNofEventsPerDDL[ddlNumber];
1502 // get the max number of events
1509 //_____________________________________________________________________________
1511 AliMUONTrackerData::PCB(Int_t detElemId, Int_t pcbIndex, Int_t dim) const
1513 /// Return the value of a given pcb for a given dimension
1515 AliMUONVCalibParam* param = PCBParam(detElemId,pcbIndex);
1517 return param ? Value(*param,0,dim,DdlIdFromDetElemId(detElemId)) : 0.0;
1520 //_____________________________________________________________________________
1522 AliMUONTrackerData::PCBParam(Int_t detElemId, Int_t pcbIndex, Bool_t create) const
1524 /// Return (if it exist) the VCalibParam for a given pcb
1526 AliMUONVCalibParam* pcb = fPCBValues ? static_cast<AliMUONVCalibParam*>
1527 (fPCBValues->FindObject(detElemId,pcbIndex)) : 0x0 ;
1529 if (create && fPCBValues && !pcb)
1531 pcb = CreatePCBParam(detElemId,pcbIndex);
1532 fPCBValues->Add(pcb);
1538 //_____________________________________________________________________________
1540 AliMUONTrackerData::CreatePCBParam(Int_t detElemId, Int_t pcbIndex) const
1542 /// Create storage for one PCB (station345 only)
1544 AliCodeTimerAuto("",0);
1546 AliMpDCSNamer namer("TRACKER");
1548 AliMUONVCalibParam* pcb = new AliMUONCalibParamND(Dimension(),
1549 namer.NumberOfPCBs(detElemId),
1556 //_____________________________________________________________________________
1558 AliMUONTrackerData::Print(Option_t* wildcard, Option_t* opt) const
1564 if ( !fIsSingleEvent )
1566 for ( Int_t i = 0; i < fNofDDLs; ++i )
1568 cout << Form("DDL %04d Nevents=%10d",AliDAQ::DdlID("MUONTRK",i),fNofEventsPerDDL[i]) << endl;
1572 if ( !fIsChannelLevelEnabled )
1574 cout << "Is not storing data at the channel level" << endl;
1577 if ( !fIsManuLevelEnabled )
1579 cout << "Is not storing data at the manu level" << endl;
1582 for ( Int_t i = 0; i <= fExternalDimensionNames->GetLast(); ++i )
1584 TObjString* name = static_cast<TObjString*>(fExternalDimensionNames->At(i));
1585 cout << Form("External Dimension %2d Name %s %s",i,
1586 ( name ? name->String().Data() : "null"),
1587 ( IsHistogrammed(i) ? "(histogrammed)" : "")) << endl;
1590 for ( Int_t i = 0; i <= fDimensionNames->GetLast(); ++i )
1592 TObjString* name = static_cast<TObjString*>(fDimensionNames->At(i));
1593 cout << Form("Internal Dimension %2d Name %s",i,
1594 ( name ? name->String().Data() : "null")) << endl;
1600 if ( sopt.Contains("CHANNEL") )
1602 if ( fIsChannelLevelEnabled )
1604 if ( fChannelValues ) fChannelValues->Print(wildcard,opt);
1608 AliWarning("You requested channel values, but they were not stored !");
1612 if ( sopt.Contains("MANU") )
1614 if ( fIsManuLevelEnabled )
1616 if ( fManuValues ) fManuValues->Print(wildcard,opt);
1620 AliWarning("You requested manu values, but they were not stored !");
1624 if ( sopt.Contains("BUSPATCH") && fBusPatchValues )
1626 fBusPatchValues->Print(wildcard,opt);
1629 if ( sopt.Contains("DE") && fDEValues )
1631 fDEValues->Print(wildcard,opt);
1634 if ( sopt.Contains("CHAMBER") && fChamberValues )
1636 fChamberValues->Print(wildcard,opt);
1641 //_____________________________________________________________________________
1643 AliMUONTrackerData::SetDimensionName(Int_t index, const char* name)
1645 /// Set the name of a given dimension
1647 if ( index >= fExternalDimension )
1649 AliError(Form("%s : dimension %s : Index out of bounds : %d / %d",
1651 name,index,fExternalDimension));
1655 Int_t ix = External2Internal(index);
1657 if ( !IsSingleEvent() )
1659 const char* prefix[] = { "mean", "sigma" };
1661 for ( Int_t i = 0; i < 2; ++i )
1665 SetInternalDimensionName(j,Form("%s of %s",prefix[i],name));
1670 SetInternalDimensionName(index,name);
1673 SetExternalDimensionName(index,name);
1676 //_____________________________________________________________________________
1678 AliMUONTrackerData::MakeHistogramForDimension(Int_t index, Bool_t value, Double_t xmin, Double_t xmax)
1680 /// decide to make histos for a given dimension
1681 if ( index >= ExternalDimension() )
1683 AliError(Form("Index out of bounds : %d / %d",index,ExternalDimension()));
1687 AliWarning(Form("Will %s make histogram for data %s index %d : that might ressemble a memory leak depending on the input data",
1688 value ? "":"not", GetName(),index));
1689 fHistogramming[index] = value;
1694 //_____________________________________________________________________________
1696 AliMUONTrackerData::SetInternalDimensionName(Int_t index, const char* value)
1698 /// Set the name of a given internal dimension
1699 if ( index >= fDimension )
1701 AliError(Form("Index out of bounds : %d / %d",index,fDimension));
1705 TObjString* ovalue = static_cast<TObjString*>(fDimensionNames->At(index));
1709 fDimensionNames->Remove(ovalue);
1712 fDimensionNames->AddAt(new TObjString(value),index);
1715 //_____________________________________________________________________________
1717 AliMUONTrackerData::SetExternalDimensionName(Int_t index, const char* value)
1719 /// Set the name of a given external dimension
1720 if ( index >= fExternalDimension )
1722 AliError(Form("Index out of bounds : %d / %d",index,fExternalDimension));
1726 TObjString* ovalue = static_cast<TObjString*>(fExternalDimensionNames->At(index));
1730 fExternalDimensionNames->Remove(ovalue);
1733 fExternalDimensionNames->AddAt(new TObjString(value),index);
1736 //_____________________________________________________________________________
1738 AliMUONTrackerData::Value(const AliMUONVCalibParam& param, Int_t i,
1739 Int_t dim, Int_t ddlId) const
1741 /// Compute the value for a given dim, using the internal information we have
1742 /// Basically we're converting sum of weights and sum of squares of weights
1743 /// into means and sigmas, and number of events into occupancy number.
1745 Double_t n = param.ValueAsDouble(i,IndexOfNumberDimension());
1747 if ( dim == IndexOfNumberDimension() ) return n; // the number of channels in any given element does not depend on the number of events
1749 Double_t occ = param.ValueAsDouble(i,IndexOfOccupancyDimension());
1751 if ( dim >= fDimension )
1756 if ( dim == IndexOfOccupancyDimension() )
1758 if ( ddlId < 0 ) AliError("Got a negative ddl id !");
1759 return occ/n/NumberOfEvents(ddlId);
1762 Double_t value = param.ValueAsDouble(i,dim);
1764 if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return AliMUONVCalibParam::InvalidFloatValue();
1766 if ( TMath::Even(dim) || IsSingleEvent() )
1768 Double_t x = value/occ;
1770 return ( TMath::Finite(x) ? x : 0.0 ) ;
1778 Double_t mean = param.ValueAsDouble(i,dim-1)/nn;
1780 return TMath::Sqrt(TMath::Abs((value-nn*mean*mean)/(nn-1.0)));
1788 AliError("Why am I here ?");
1792 //_____________________________________________________________________________
1794 AliMUONTrackerData::Streamer(TBuffer &R__b)
1796 /// Customized streamer
1798 if (R__b.IsReading()) {
1799 AliMUONTrackerData::Class()->ReadBuffer(R__b, this);
1802 // backward compatible mode : we set number of events
1803 // per DDL to the total number of events (the only information
1804 // we had before version 7 of that class)
1805 delete[] fNofEventsPerDDL;
1807 fNofEventsPerDDL = new Int_t[fNofDDLs];
1808 for ( Int_t i = 0; i < fNofDDLs; ++i )
1810 fNofEventsPerDDL[i] = fNevents;
1815 AliMUONTrackerData::Class()->WriteBuffer(R__b, this);
1819 //_____________________________________________________________________________
1821 AliMUONTrackerData::ExportAsASCIIOccupancyFile(const char* filename, Int_t runNumber) const
1823 /// Export only the occupancy part, in a format compatible with what
1824 /// the online occupancy DA is writing
1826 if ( ! AliMpDDLStore::Instance(kFALSE) )
1828 AliError("Mapping not loaded. Cannot work");
1834 AliError("No manu values. Cannot work");
1838 ofstream out(filename);
1842 AliError(Form("Cannot create file %s",filename));
1846 out << "//===========================================================================" << endl;
1847 out << "// Hit counter exported from $Id$" << endl;
1848 out << "//===========================================================================" << endl;
1849 out << "//" << endl;
1850 out << "// * Run Number : " << runNumber << endl;
1851 out << "// * File Creation Date : " << TTimeStamp().AsString("l") << endl;
1852 out << "//---------------------------------------------------------------------------" << endl;
1853 out << "// BP MANU SUM_N NEVENTS" << endl;
1854 out << "//---------------------------------------------------------------------------" << endl;
1856 TIter next(fManuValues->CreateIterator());
1857 AliMUONVCalibParam* manu;
1859 while ( ( manu = static_cast<AliMUONVCalibParam*>(next()) ) )
1861 Int_t detElemId = manu->ID0();
1862 Int_t manuId = manu->ID1();
1863 Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1864 Int_t ddl = AliMpDDLStore::Instance()->GetDDLfromBus( busPatchId);
1865 if ( busPatchId < 0 || ddl < 0 )
1867 AliError(Form("Got invalid (DE,manu,bp,ddl)=(%d,%d,%d,%d). Skipping it",detElemId,manuId,busPatchId,ddl));
1871 Int_t nevents = fNofEventsPerDDL[ddl];
1873 out << Form("%5d %5d %10d %10d",busPatchId,manuId,manu->ValueAsInt(0,IndexOfOccupancyDimension()),nevents) << endl;