X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONTrackerDataHistogrammer.cxx;h=a5f74e60f7429d6e86cae646dcd21004b3817604;hb=da448a15ea9ae68f46712e1da954fa06f976756d;hp=0d74f40d680523f37e8054693414fcc5e6391f9f;hpb=10eb3d173dd4f09822d4f0197ebc0b701dcfb429;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONTrackerDataHistogrammer.cxx b/MUON/AliMUONTrackerDataHistogrammer.cxx index 0d74f40d680..a5f74e60f74 100644 --- a/MUON/AliMUONTrackerDataHistogrammer.cxx +++ b/MUON/AliMUONTrackerDataHistogrammer.cxx @@ -17,6 +17,7 @@ #include "AliMUONTrackerDataHistogrammer.h" +#include "AliLog.h" #include "AliMUONPainterGroup.h" #include "AliMUONSparseHisto.h" #include "AliMUONVPainter.h" @@ -27,8 +28,11 @@ #include "AliMpDEIterator.h" #include "AliMpDetElement.h" #include "AliMpManuUID.h" +#include #include #include +#include +#include ///\class AliMUONTrackerDataHistogrammer /// @@ -44,10 +48,12 @@ ClassImp(AliMUONTrackerDataHistogrammer) //_____________________________________________________________________________ AliMUONTrackerDataHistogrammer::AliMUONTrackerDataHistogrammer(const AliMUONVTrackerData& data, - Int_t dim) + Int_t externalDim, + Int_t internalDim) : TObject(), -fData(data), -fDim(dim) +fkData(data), +fExternalDim(externalDim), +fInternalDim(internalDim) { /// ctor } @@ -87,7 +93,7 @@ AliMUONTrackerDataHistogrammer::AddBusPatchHisto(TH1& h, Int_t busPatchId) const { /// Add data from one bus patch to the histogram - if ( fData.HasBusPatch(busPatchId ) ) + if ( fkData.HasBusPatch(busPatchId ) ) { AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(busPatchId); for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) @@ -103,7 +109,7 @@ AliMUONTrackerDataHistogrammer::AddDEHisto(TH1& h, Int_t detElemId) const { /// Add data from one detection element to the histogram - if ( fData.HasDetectionElement(detElemId) ) + if ( fkData.HasDetectionElement(detElemId) ) { AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); for ( Int_t i = 0; i < de->GetNofBusPatches(); ++ i ) @@ -120,89 +126,70 @@ AliMUONTrackerDataHistogrammer::AddManuHisto(TH1& h, Int_t detElemId, Int_t manu { /// Add data from a given manu to histogram - if ( fData.HasManu(detElemId,manuId) ) + if ( fkData.HasManu(detElemId,manuId) ) { - for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) + if ( fkData.IsChannelLevelEnabled() ) { - if ( fData.HasChannel(detElemId,manuId,i) ) + for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) { - AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,i); - - if ( sh ) - { - Add(h,*sh); + if ( fkData.HasChannel(detElemId,manuId,i) ) + { + if ( IsInternalMode() ) + { + h.Fill(fkData.Channel(detElemId,manuId,i,fInternalDim)); + } + else + { + AliMUONSparseHisto* sh = fkData.GetChannelSparseHisto(detElemId,manuId,i,fExternalDim); + + if ( sh ) + { + Add(h,*sh); + } + } } } } - } -} - - -//_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateBusPatchHisto(Int_t busPatchId) const -{ - /// Create histogram of a given bus patch. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... - - TH1* h(0x0); - - if ( fData.HasBusPatch(busPatchId) && fData.IsHistogrammed(fDim)) - { - h = CreateHisto(Form("BP%04d_%d",busPatchId,fDim)); - if ( h ) AddBusPatchHisto(*h,busPatchId); - } - - return h; -} - - -//_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateChamberHisto(Int_t chamberId) const -{ - /// Create histogram of a given chamber. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... - - TH1* h(0x0); - - if ( fData.HasChamber(chamberId) && fData.IsHistogrammed(fDim)) - { - h = CreateHisto(Form("CHAMBER%02d_%d",chamberId,fDim)); - if ( h ) + else { - AliMpDEIterator it; - it.First(chamberId); - while ( !it.IsDone() ) + if ( IsInternalMode() ) + { + h.Fill(fkData.Manu(detElemId,manuId,fInternalDim)); + } + else { - Int_t detElemId = it.CurrentDEId(); - AddDEHisto(*h,detElemId); - it.Next(); + AliMUONSparseHisto* sh = fkData.GetManuSparseHisto(detElemId,manuId,fExternalDim); + if (sh) + { + Add(h,*sh); + } } } } - - return h; } //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId, +AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, + Int_t manuId, Int_t manuChannel) const { /// Create histogram of a given channel. Note that in order /// to keep memory footprint as low as possible, you should delete /// the returned pointer as soon as possible... - if ( fData.HasChannel(detElemId, manuId, manuChannel) && fData.IsHistogrammed(fDim) ) + if ( fkData.HasChannel(detElemId, manuId, manuChannel) && fkData.IsHistogrammed(fExternalDim) ) { - AliMUONSparseHisto* sh = fData.GetChannelSparseHisto(detElemId,manuId,manuChannel); + AliMUONSparseHisto* sh = fkData.GetChannelSparseHisto(detElemId,manuId,manuChannel); if ( sh ) { - TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d_%d",detElemId,manuId,manuChannel,fDim)); + Int_t nbins((1<Nbits())); + Double_t xmin,xmax; + fkData.HistogramRange(xmin,xmax); + + TH1* h = CreateHisto(Form("DE%04dMANU%04dCH%02d",detElemId,manuId,manuChannel), + nbins,xmin,xmax); if (h ) { Add(*h,*sh); @@ -215,26 +202,32 @@ AliMUONTrackerDataHistogrammer::CreateChannelHisto(Int_t detElemId, Int_t manuId //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateDEHisto(Int_t detElemId) const +AliMUONTrackerDataHistogrammer::CreateHisto(const char* name, + Int_t nbins, + Double_t xmin, + Double_t xmax) const { - /// Create histogram of a given detection element. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... + /// Create a single histogram - TH1* h(0x0); + TH1* h(0); - if ( fData.HasDetectionElement(detElemId) && fData.IsHistogrammed(fDim) ) + if ( xmin < xmax ) { - h = CreateHisto(Form("DE%04d-%d",detElemId,fDim)); - if (h) AddDEHisto(*h,detElemId); + h = new TH1F(name,name,nbins,xmin,xmax); + h->SetDirectory(gROOT); } - + else + { + AliError(Form("Cannot create histo for name=%s nbins=%d xmin=%e xmax=%e",name,nbins,xmin,xmax)); + } return h; } //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) +AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter, + Int_t externalDim, + Int_t internalDim) { /// Create an histogram, from given dim of given data, /// for all the channels handled by painter @@ -244,74 +237,152 @@ AliMUONTrackerDataHistogrammer::CreateHisto(const AliMUONVPainter& painter) if ( !group ) return 0x0; // no data to histogram in this painter AliMUONVTrackerData* data = group->Data(); - Int_t dim = data->InternalToExternal(group->DataIndex()); - AliMUONTrackerDataHistogrammer tdh(*data,dim); + if ( externalDim >= data->ExternalDimension() ) + { + AliErrorClass(Form("externalDim %d is out of bounds",externalDim)); + return 0x0; + } + + if ( internalDim >= data->NumberOfDimensions() ) + { + AliErrorClass(Form("internalDim %d is out of bounds",internalDim)); + return 0x0; + } + + if ( internalDim < 0 && externalDim < 0 ) + { + AliErrorClass("Both internal and external dim are < 0 !!!"); + return 0x0; + } + + AliMUONTrackerDataHistogrammer tdh(*data,externalDim,internalDim); TObjArray manuArray; painter.FillManuList(manuArray); - + AliMpManuUID* mid; TIter next(&manuArray); + + TString basename(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName())); + TString ext; + Int_t nbins((1<<12)); + Double_t xmin(0.0); + Double_t xmax(0.0); - TH1* histo = tdh.CreateHisto(Form("%s-%s",painter.PathName().Data(),painter.Attributes().GetName())); + if ( !tdh.IsInternalMode() ) + { + data->HistogramRange(xmin,xmax); + + xmin -= 0.5; + xmax -= 0.5; + + ext = data->ExternalDimensionName(externalDim).Data(); + } + else + { + tdh.GetDataRange(manuArray,xmin,xmax); + ext = data->DimensionName(internalDim).Data(); + nbins = 100; + } - while ( ( mid = static_cast(next()) ) ) + TString name(Form("%s-%s",basename.Data(),ext.Data())); + + TH1* histo = tdh.CreateHisto(name.Data(),nbins,xmin,xmax); + + if ( histo ) { - TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId()); - if ( h ) + while ( ( mid = static_cast(next()) ) ) { - histo->Add(h); + TH1* h = tdh.CreateManuHisto(mid->DetElemId(),mid->ManuId(),nbins,xmin,xmax); + if ( h ) + { + histo->Add(h); + } + delete h; } - delete h; } + else + { + AliErrorClass(Form("Could not create histo for painter %s (%p) data %s (%p) external dim %d internal dim %d", + painter.PathName().Data(),&painter, + data->GetName(),data,externalDim,internalDim)); + } + + if (histo) histo->SetDirectory(gROOT); return histo; } //_____________________________________________________________________________ TH1* -AliMUONTrackerDataHistogrammer::CreateHisto(const char* name) const +AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId, + Int_t nbins, + Double_t xmin, + Double_t xmax) const { - /// Create a single histogram - - Double_t xmin, xmax; - - fData.HistogramRange(xmin,xmax); + /// Create histogram of a given manu. Note that in order + /// to keep memory footprint as low as possible, you should delete + /// the returned pointer as soon as possible... TH1* h(0x0); - if ( xmin != xmax ) + if ( !fkData.HasManu(detElemId,manuId) ) return 0x0; + + if ( ( fExternalDim >= 0 && fkData.IsHistogrammed(fExternalDim) ) || + ( fInternalDim >= 0 && fInternalDim < fkData.NumberOfDimensions() ) ) { - h = new TH1I(name,Form("Data=%s Dim=%s", - fData.GetName(), - fData.ExternalDimensionName(fDim).Data()), - (1<<12), - xmin-0.5, - xmax-0.5); - h->SetDirectory(0); + h = CreateHisto(Form("DE%04dMANU%04d",detElemId,manuId), + nbins,xmin,xmax); + if ( h ) AddManuHisto(*h,detElemId,manuId); } + return h; } - //_____________________________________________________________________________ -TH1* -AliMUONTrackerDataHistogrammer::CreateManuHisto(Int_t detElemId, Int_t manuId) const +void +AliMUONTrackerDataHistogrammer::GetDataRange(const TObjArray& manuArray, + Double_t& xmin, Double_t& xmax) const { - /// Create histogram of a given manu. Note that in order - /// to keep memory footprint as low as possible, you should delete - /// the returned pointer as soon as possible... + /// Get data range (in case of InternalMode() only) spanned by the manus in + /// manuArray - TH1* h(0x0); + xmin = FLT_MAX; + xmax = -FLT_MAX; - if ( fData.HasManu(detElemId, manuId) && fData.IsHistogrammed(fDim) ) + if (!IsInternalMode()) { - h = CreateHisto(Form("DE%04dMANU%04d_%d",detElemId,manuId,fDim)); - if ( h ) AddManuHisto(*h,detElemId,manuId); + AliError("Cannot use this method for external mode !"); } + + AliMpManuUID* mid; + TIter next(&manuArray); - return h; + while ( ( mid = static_cast(next()) ) ) + { + Int_t detElemId = mid->DetElemId(); + Int_t manuId = mid->ManuId(); + + for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) + { + if ( fkData.HasChannel(detElemId,manuId,i) ) + { + Double_t value = fkData.Channel(detElemId,manuId,i,fInternalDim); + + if ( ! TMath::Finite(value) ) + { + AliError(Form("Got a NaN for DE %d manu %d ch %d",detElemId,manuId,i)); + } + else + { + xmin = TMath::Min(xmin,value); + xmax = TMath::Max(xmax,value); + } + } + } + } + }