TObject(),
fPedestalLowGain(),
fPedestalHighGain(),
- fPedestalRMSLowGain(),
- fPedestalRMSHighGain(),
+ fPedestalLEDRefLowGain(),
+ fPedestalLEDRefHighGain(),
fPeakMinusPedLowGain(),
fPeakMinusPedHighGain(),
fPeakMinusPedHighGainHisto(),
fPedestalLowGainDiff(),
fPedestalHighGainDiff(),
+ fPedestalLEDRefLowGainDiff(),
+ fPedestalLEDRefHighGainDiff(),
fPeakMinusPedLowGainDiff(),
fPeakMinusPedHighGainDiff(),
fPedestalLowGainRatio(),
fPedestalHighGainRatio(),
+ fPedestalLEDRefLowGainRatio(),
+ fPedestalLEDRefHighGainRatio(),
fPeakMinusPedLowGainRatio(),
fPeakMinusPedHighGainRatio(),
fDeadMap(),
fDetType(kNone),
fColumns(0),
fRows(0),
+ fLEDRefs(0),
fModules(0),
fRowMin(0),
fRowMax(0),
if (detectorType == kPhos) {
fColumns = fgkPhosCols;
fRows = fgkPhosRows;
+ fLEDRefs = fgkPhosLEDRefs;
fModules = fgkPhosModules;
fCaloString = "PHOS";
fRowMin = -1*fRows;
//case, if someone intentionally gives another number
fColumns = AliEMCALGeoParams::fgkEMCALCols;
fRows = AliEMCALGeoParams::fgkEMCALRows;
+ fLEDRefs = AliEMCALGeoParams::fgkEMCALLEDRefs;
fModules = AliEMCALGeoParams::fgkEMCALModules;
fCaloString = "EMCAL";
fRowMin = 0;
fPedestalHighGain.Add(new TProfile2D(name, title,
fColumns, 0.0, fColumns,
fRows, fRowMin, fRowMax,"s"));
- //All Samples, low gain
- name = "hPedestalRMSlowgain";
+
+ //LED Ref/Mon pedestals, low gain
+ name = "hPedestalLEDReflowgain";
name += i;
- title = "Pedestal RMS, low gain, module ";
+ title = "Pedestal LEDRef, low gain, module ";
title += i;
- fPedestalRMSLowGain.Add(new TProfile2D(name, title,
- fColumns, 0.0, fColumns,
- fRows, fRowMin, fRowMax,"s"));
-
- //All Samples, high gain
- name = "hPedestalRMShighgain";
+ fPedestalLEDRefLowGain.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
+
+ //LED Ref/Mon pedestals, high gain
+ name = "hPedestalLEDRefhighgain";
name += i;
- title = "Pedestal RMS, high gain, module ";
+ title = "Pedestal LEDRef, high gain, module ";
title += i;
- fPedestalRMSHighGain.Add(new TProfile2D(name, title,
- fColumns, 0.0, fColumns,
- fRows, fRowMin, fRowMax,"s"));
+ fPedestalLEDRefHighGain.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
//Peak-Pedestals, low gain
name = "hPeakMinusPedlowgain";
//Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
fPedestalLowGain.Compress();
fPedestalHighGain.Compress();
- fPedestalRMSLowGain.Compress();
- fPedestalRMSHighGain.Compress();
+ fPedestalLEDRefLowGain.Compress();
+ fPedestalLEDRefHighGain.Compress();
fPeakMinusPedLowGain.Compress();
fPeakMinusPedHighGain.Compress();
fPeakMinusPedHighGainHisto.Compress();
fDeadMap.Compress();
- //Make them the owners of the profiles, so we don't need to care about deleting them
- //fPedestalLowGain.SetOwner();
- //fPedestalHighGain.SetOwner();
- //fPeakMinusPedLowGain.SetOwner();
- //fPeakMinusPedHighGain.SetOwner();
-
+
}
// dtor
TObject(ped),
fPedestalLowGain(),
fPedestalHighGain(),
- fPedestalRMSLowGain(),
- fPedestalRMSHighGain(),
+ fPedestalLEDRefLowGain(),
+ fPedestalLEDRefHighGain(),
fPeakMinusPedLowGain(),
fPeakMinusPedHighGain(),
fPeakMinusPedHighGainHisto(),
fPedestalLowGainDiff(),
fPedestalHighGainDiff(),
+ fPedestalLEDRefLowGainDiff(),
+ fPedestalLEDRefHighGainDiff(),
fPeakMinusPedLowGainDiff(),
fPeakMinusPedHighGainDiff(),
fPedestalLowGainRatio(),
fPedestalHighGainRatio(),
+ fPedestalLEDRefLowGainRatio(),
+ fPedestalLEDRefHighGainRatio(),
fPeakMinusPedLowGainRatio(),
fPeakMinusPedHighGainRatio(),
fDeadMap(),
fDetType(ped.GetDetectorType()),
fColumns(ped.GetColumns()),
fRows(ped.GetRows()),
+ fLEDRefs(ped.GetLEDRefs()),
fModules(ped.GetModules()),
fRowMin(ped.GetRowMin()),
fRowMax(ped.GetRowMax()),
for (int i = 0; i < fModules; i++) {
fPedestalLowGain.Add( ped.GetPedProfileLowGain(i) );
fPedestalHighGain.Add( ped.GetPedProfileHighGain(i) );
- fPedestalRMSLowGain.Add( ped.GetPedRMSProfileLowGain(i) );
- fPedestalRMSHighGain.Add( ped.GetPedRMSProfileHighGain(i) );
+ fPedestalLEDRefLowGain.Add( ped.GetPedLEDRefProfileLowGain(i) );
+ fPedestalLEDRefHighGain.Add( ped.GetPedLEDRefProfileHighGain(i) );
fPeakMinusPedLowGain.Add( ped.GetPeakProfileLowGain(i) );
fPeakMinusPedHighGain.Add( ped.GetPeakProfileHighGain(i) );
fPeakMinusPedHighGainHisto.Add( ped.GetPeakHighGainHisto(i) );
//Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
fPedestalLowGain.Compress();
fPedestalHighGain.Compress();
- fPedestalRMSLowGain.Compress();
- fPedestalRMSHighGain.Compress();
+ fPedestalLEDRefLowGain.Compress();
+ fPedestalLEDRefHighGain.Compress();
fPeakMinusPedLowGain.Compress();
fPeakMinusPedHighGain.Compress();
fPeakMinusPedHighGainHisto.Compress();
for (int i = 0; i < fModules; i++) {
GetPedProfileLowGain(i)->Reset();
GetPedProfileHighGain(i)->Reset();
+ GetPedLEDRefProfileLowGain(i)->Reset();
+ GetPedLEDRefProfileHighGain(i)->Reset();
GetPeakProfileLowGain(i)->Reset();
GetPeakProfileHighGain(i)->Reset();
GetPeakHighGainHisto(i)->Reset();
GetPedProfileLowGainDiff(i)->Reset();
GetPedProfileHighGainDiff(i)->Reset();
+ GetPedLEDRefProfileLowGainDiff(i)->Reset();
+ GetPedLEDRefProfileHighGainDiff(i)->Reset();
GetPeakProfileLowGainDiff(i)->Reset();
GetPeakProfileHighGainDiff(i)->Reset();
GetPedProfileLowGainRatio(i)->Reset();
GetPedProfileHighGainRatio(i)->Reset();
+ GetPedLEDRefProfileLowGainRatio(i)->Reset();
+ GetPedLEDRefProfileHighGainRatio(i)->Reset();
GetPeakProfileLowGainRatio(i)->Reset();
GetPeakProfileHighGainRatio(i)->Reset();
}
// indices for the reading
int sample = 0;
- int gain = 0;
int time = 0;
int i = 0; // sample counter
int startBin = 0;
int max = AliEMCALGeoParams::fgkSampleMin, min = AliEMCALGeoParams::fgkSampleMax; // min and max sample values
int nsamples = 0;
- // for the pedestal calculation
- int sampleSum = 0; // sum of samples
- int squaredSampleSum = 0; // sum of samples squared
- int nSum = 0; // number of samples in sum
- // calc. quantities
- double mean = 0, squaredMean = 0, rms = 0;
-
+ // pedestal samples
+ int nPed = 0;
+ vector<int> pedSamples;
+
while (in->NextBunch()) {
const UShort_t *sig = in->GetSignals();
startBin = in->GetStartTimeBin();
// should we add it for the pedestal calculation?
if ( (fFirstPedestalSample<=time && time<=fLastPedestalSample) || // sample time in range
!fSelectPedestalSamples ) { // or we don't restrict the sample range.. - then we'll take all
- sampleSum += sample;
- squaredSampleSum += sample*sample;
- nSum++;
+ pedSamples.push_back( sig[i] );
+ nPed++;
}
} // loop over samples in bunch
if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
- // calculate pedesstal estimate: mean of possibly selected samples
- if (nSum > 0) {
- mean = sampleSum / (1.0 * nSum);
- squaredMean = squaredSampleSum / (1.0 * nSum);
- // The variance (rms squared) is equal to the mean of the squares minus the square of the mean..
- rms = sqrt(squaredMean - mean*mean);
- }
- else {
- mean = 0;
- squaredMean = 0;
- rms = 0;
- }
-
- // we're done with the calc. for this channel; let's prepare to fill histo
- gain = -1; // init to not valid value
- if ( in->IsLowGain() ) {
- gain = 0;
- }
- else if ( in->IsHighGain() ) {
- gain = 1;
- }
-
// it should be enough to check the SuperModule info for each DDL really, but let's keep it here for now
int arrayPos = in->GetModule(); //The modules are numbered starting from 0
if (arrayPos >= fModules) {
fNChanFills++; // one more channel found, and profile to be filled
//NOTE: coordinates are (column, row) for the profiles
- if (gain == 0) {
+ if ( in->IsLowGain() ) {
//fill the low gain histograms
((TProfile2D*)fPeakMinusPedLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
- if (nSum>0) { // only fill pedestal info in case it could be calculated
- ((TProfile2D*)fPedestalLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), mean);
- ((TProfile2D*)fPedestalRMSLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), rms);
+ if (nPed>0) { // only fill pedestal info in case it could be calculated
+ for ( i=0; i<nPed; i++) {
+ ((TProfile2D*)fPedestalLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), pedSamples[i]);
+ }
}
}
- else if (gain == 1) {
+ else if ( in->IsHighGain() ) {
//fill the high gain ones
((TProfile2D*)fPeakMinusPedHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
- if (nSum>0) { // only fill pedestal info in case it could be calculated
- ((TProfile2D*)fPedestalHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), mean);
- ((TProfile2D*)fPedestalRMSHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), rms);
+ if (nPed>0) { // only fill pedestal info in case it could be calculated
+ for ( i=0; i<nPed; i++) {
+ ((TProfile2D*)fPedestalHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), pedSamples[i]);
+ }
}
// for warning checks
int idx = in->GetRow() + fRows * in->GetColumn();
((TH2F*)fPeakMinusPedHighGainHisto[arrayPos])->Fill(idx, max - min);
- }//end if valid gain
+ }
+ else if ( in->IsLEDMonData() ) {
+ // for LED Mon data, the mapping class holds the gain info in the Row variable
+ // and the Strip number in the Column..
+ int gain = in->GetRow();
+ int stripId = in->GetColumn();
+ if (nPed>0 && stripId<fLEDRefs) {
+ if (gain == 0) {
+ for ( i=0; i<nPed; i++) {
+ ((TProfile*)fPedestalLEDRefLowGain[arrayPos])->Fill(stripId, pedSamples[i]);
+ }
+ }
+ else {
+ for ( i=0; i<nPed; i++) {
+ ((TProfile*)fPedestalLEDRefHighGain[arrayPos])->Fill(stripId, pedSamples[i]);
+ }
+ }
+ }
+ }
} // nsamples>0 check, some data found for this channel; not only trailer/header
}// end while over channel
if( ((TProfile2D *)fPedestalHighGain[i])->GetEntries() || saveEmptyHistos) {
fPedestalHighGain[i]->Write();
}
- if( ((TProfile2D *)fPedestalRMSLowGain[i])->GetEntries() || saveEmptyHistos) {
- fPedestalRMSLowGain[i]->Write();
+ if( ((TProfile *)fPedestalLEDRefLowGain[i])->GetEntries() || saveEmptyHistos) {
+ fPedestalLEDRefLowGain[i]->Write();
}
- if( ((TProfile2D *)fPedestalRMSHighGain[i])->GetEntries() || saveEmptyHistos) {
- fPedestalRMSHighGain[i]->Write();
+ if( ((TProfile *)fPedestalLEDRefHighGain[i])->GetEntries() || saveEmptyHistos) {
+ fPedestalLEDRefHighGain[i]->Write();
}
if( ((TH2F *)fPeakMinusPedHighGainHisto[i])->GetEntries() || saveEmptyHistos) {
fPeakMinusPedHighGainHisto[i]->Write();
}
delete sourceFile;
-
+
//Reset the histogram ownership behaviour. NOTE: a better workaround would be good, since this may accidentally set AddDirectory to true, even
//if we are called by someone who has set it to false...
TH1::AddDirectory(kTRUE);
fColumns, 0.0, fColumns,
fRows, fRowMin, fRowMax,"s"));
+ //LED Ref/Mon pedestals, low gain
+ name = "hPedestalLEDReflowgainDiff";
+ name += i;
+ title = "Pedestal difference LEDRef, low gain, module ";
+ title += i;
+ fPedestalLEDRefLowGainDiff.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
+
+ //LED Ref/Mon pedestals, high gain
+ name = "hPedestalLEDRefhighgainDiff";
+ name += i;
+ title = "Pedestal difference LEDRef, high gain, module ";
+ title += i;
+ fPedestalLEDRefHighGainDiff.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
+
//Peak-Pedestals, high gain
name = "hPeakMinusPedhighgainDiff";
name += i;
fPeakMinusPedHighGainDiff.Add(new TProfile2D(name, title,
fColumns, 0.0, fColumns,
fRows, fRowMin, fRowMax,"s"));
+
+ //Peak-Pedestals, low gain
+ name = "hPeakMinusPedlowgainDiff";
+ name += i;
+ title = "Peak-Pedestal difference, low gain, module ";
+ title += i;
+ fPeakMinusPedLowGainDiff.Add(new TProfile2D(name, title,
+ fColumns, 0.0, fColumns,
+ fRows, fRowMin, fRowMax,"s"));
//Pedestals, low gain
name = "hPedlowgainRatio";
fPedestalHighGainRatio.Add(new TProfile2D(name, title,
fColumns, 0.0, fColumns,
fRows, fRowMin, fRowMax,"s"));
+
+ //LED Ref/Mon pedestals, low gain
+ name = "hPedestalLEDReflowgain";
+ name += i;
+ title = "Pedestal ratio LEDRef, low gain, module ";
+ title += i;
+ fPedestalLEDRefLowGainRatio.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
+
+ //LED Ref/Mon pedestals, high gain
+ name = "hPedestalLEDRefhighgainRatio";
+ name += i;
+ title = "Pedestal ratio LEDRef, high gain, module ";
+ title += i;
+ fPedestalLEDRefHighGainRatio.Add(new TProfile(name, title,
+ fLEDRefs, 0.0, fLEDRefs, "s"));
//Peak-Pedestals, low gain
name = "hPeakMinusPedlowgainRatio";
return;//Return if the reference object isn't loaded
}
+ int bin = 0;
+ double diff = 0;
+ double ratio = 1;
for (int i = 0; i < fModules; i++) {
- //Compute the ratio of the histograms
-
- ((TProfile2D*)fPedestalLowGainRatio[i])->Divide(GetPedProfileLowGain(i), fReference->GetPedProfileLowGain(i), 1.0, 1.0);
- ((TProfile2D*)fPedestalHighGainRatio[i])->Divide(GetPedProfileHighGain(i), fReference->GetPedProfileHighGain(i), 1.0, 1.0);
- ((TProfile2D*)fPeakMinusPedLowGainRatio[i])->Divide(GetPeakProfileLowGain(i), fReference->GetPeakProfileLowGain(i), 1.0, 1.0);
- ((TProfile2D*)fPeakMinusPedHighGainRatio[i])->Divide(GetPeakProfileHighGain(i), fReference->GetPeakProfileHighGain(i), 1.0, 1.0);
-
//For computing the difference, we cannot simply do TProfile2D->Add(), because that subtracts the sum of all entries,
//which means that the mean of the new profile will not be the difference of the means. So do it by hand:
- for (int j = 0; j <= fColumns; j++) {
- for (int k = 0; k <= fRows; k++) {
- int bin = ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->GetBin(j+1, k+1);//Note that we assume here that all histos have the same structure...
- double diff = fReference->GetPeakProfileHighGain(i)->GetBinContent(bin) - GetPeakProfileHighGain(i)->GetBinContent(bin);
- ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinContent(j+1, k+1, diff);
- ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinEntries(bin, 1);
-
- diff = fReference->GetPeakProfileLowGain(i)->GetBinContent(bin) - GetPeakProfileLowGain(i)->GetBinContent(bin);
- ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinContent(j+1, k+1, diff);
- ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinEntries(bin, 1);
-
- diff = fReference->GetPedProfileHighGain(i)->GetBinContent(bin) - GetPedProfileHighGain(i)->GetBinContent(bin);
- ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinContent(j+1, k+1, diff);
- ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinEntries(bin, 1);
-
- diff = fReference->GetPedProfileLowGain(i)->GetBinContent(bin) - GetPedProfileLowGain(i)->GetBinContent(bin);
- ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinContent(j+1, k+1, diff);
- ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinEntries(bin, 1);
-
+ for (int j = 0; j < fColumns; j++) {
+ for (int k = 0; k < fRows; k++) {
+ bin = ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->GetBin(j+1, k+1);//Note that we assume here that all histos have the same structure...
+
+ if (fReference->GetPeakProfileHighGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPeakProfileHighGain(i)->GetBinContent(bin) - fReference->GetPeakProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPeakProfileHighGain(i)->GetBinContent(bin) / fReference->GetPeakProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPeakMinusPedHighGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile2D*)fPeakMinusPedHighGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
+ if (fReference->GetPeakProfileLowGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPeakProfileLowGain(i)->GetBinContent(bin) - fReference->GetPeakProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPeakProfileLowGain(i)->GetBinContent(bin) / fReference->GetPeakProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPeakMinusPedLowGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile2D*)fPeakMinusPedLowGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
+ if (fReference->GetPedProfileHighGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPedProfileHighGain(i)->GetBinContent(bin) - fReference->GetPedProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPedProfileHighGain(i)->GetBinContent(bin) / fReference->GetPedProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPedestalHighGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile2D*)fPedestalHighGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
+ if (fReference->GetPedProfileLowGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPedProfileLowGain(i)->GetBinContent(bin) - fReference->GetPedProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPedProfileLowGain(i)->GetBinContent(bin) / fReference->GetPedProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile2D*)fPedestalLowGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile2D*)fPedestalLowGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
} // rows
} // columns
-
+
+ // same for LED Ref/Mon channels
+ for (int j = 0; j <= fLEDRefs; j++) {
+ bin = j+1;//Note that we assume here that all histos have the same structure...
+
+ if (fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) - fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile*)fPedestalLEDRefHighGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile*)fPedestalLEDRefHighGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) / fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin);
+ ((TProfile*)fPedestalLEDRefHighGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile*)fPedestalLEDRefHighGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
+ if (fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) > 0) {
+ diff = GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) - fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile*)fPedestalLEDRefLowGainDiff[i])->SetBinContent(bin, diff);
+ ((TProfile*)fPedestalLEDRefLowGainDiff[i])->SetBinEntries(bin, 1);
+ ratio = GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) / fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin);
+ ((TProfile*)fPedestalLEDRefLowGainRatio[i])->SetBinContent(bin, ratio);
+ ((TProfile*)fPedestalLEDRefLowGainRatio[i])->SetBinEntries(bin, 1);
+ }
+
+ }
+
} // modules
}
// \version $Revision$
// \date $Date$
+#include "TProfile.h"
#include "TProfile2D.h"
#include "TH2.h"
#include "TObjArray.h"
// Main profiles:
TProfile2D * GetPedProfileLowGain(int i) const {return (TProfile2D*)fPedestalLowGain[i];}; // Return a pointer to the low-gain pedestal profile
TProfile2D * GetPedProfileHighGain(int i) const {return (TProfile2D*)fPedestalHighGain[i];}; // Return a pointer to the high-gain pedestal profile
- TProfile2D * GetPedRMSProfileLowGain(int i) const {return (TProfile2D*)fPedestalRMSLowGain[i];}; // Return a pointer to the low-gain rms profile
- TProfile2D * GetPedRMSProfileHighGain(int i) const {return (TProfile2D*)fPedestalRMSHighGain[i];}; // Return a pointer to the high-gain rms profile
+ TProfile * GetPedLEDRefProfileLowGain(int i) const {return (TProfile*)fPedestalLEDRefLowGain[i];}; // Return a pointer to the low-gain LEDRef profile
+ TProfile * GetPedLEDRefProfileHighGain(int i) const {return (TProfile*)fPedestalLEDRefHighGain[i];}; // Return a pointer to the high-gain LEDRef profile
TProfile2D * GetPeakProfileLowGain(int i) const {return (TProfile2D*)fPeakMinusPedLowGain[i];}; // Return a pointer to the low-gain peak-pedestal profile
TProfile2D * GetPeakProfileHighGain(int i) const {return (TProfile2D*)fPeakMinusPedHighGain[i];}; // Return a pointer to the high-gain peak-pedestal profile
// Differences to references:
TProfile2D * GetPedProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainDiff[i];}; // Return a pointer to the low-gain pedestal profile difference
TProfile2D * GetPedProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainDiff[i];}; // Return a pointer to the high-gain pedestal profile difference
+ TProfile * GetPedLEDRefProfileLowGainDiff(int i) {ValidateComparisonProfiles(); return (TProfile*)fPedestalLEDRefLowGainDiff[i];}; // Return a pointer to the low-gain LEDRef profile difference
+ TProfile * GetPedLEDRefProfileHighGainDiff(int i) {ValidateComparisonProfiles(); return (TProfile*)fPedestalLEDRefHighGainDiff[i];}; // Return a pointer to the high-gain LEDRef profile difference
TProfile2D * GetPeakProfileLowGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainDiff[i];}; // Return a pointer to the low-gain peak-pedestal profile difference
TProfile2D * GetPeakProfileHighGainDiff(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainDiff[i];}; // Return a pointer to the high-gain peak-pedestal profile difference
// Ratio to references:
TProfile2D * GetPedProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalLowGainRatio[i];}; // Return a pointer to the low-gain pedestal profile ratio
TProfile2D * GetPedProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPedestalHighGainRatio[i];}; // Return a pointer to the high-gain pedestal profile ratio
+ TProfile * GetPedLEDRefProfileLowGainRatio(int i) {ValidateComparisonProfiles(); return (TProfile*)fPedestalLEDRefLowGainRatio[i];}; // Return a pointer to the low-gain LEDRef profile ratio
+ TProfile * GetPedLEDRefProfileHighGainRatio(int i) {ValidateComparisonProfiles(); return (TProfile*)fPedestalLEDRefHighGainRatio[i];}; // Return a pointer to the high-gain LEDRef profile ratio
TProfile2D * GetPeakProfileLowGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedLowGainRatio[i];}; // Return a pointer to the low-gain peak-pedestal profile ratio
TProfile2D * GetPeakProfileHighGainRatio(int i){ValidateComparisonProfiles(); return (TProfile2D*)fPeakMinusPedHighGainRatio[i];}; // Return a pointer to the high-gain peak-pedestal profile ratio
int GetColumns() const {return fColumns;}; //The number of columns per module
int GetRows() const {return fRows;}; //The number of rows per module
+ int GetLEDRefs() const {return fLEDRefs;}; //The number of LED references/monitors per module
int GetModules() const {return fModules;}; //The number of modules
int GetRowMin() const {return fRowMin;}; //for histo def.
int GetRowMax() const {return fRowMax;}; //for histo def.
//since we have only around 12 objects (maximum) in the array anyway.
TObjArray fPedestalLowGain; // pedestal info for low gain
TObjArray fPedestalHighGain; // pedestal info for high gain
- TObjArray fPedestalRMSLowGain; // pedestal rms info for low gain
- TObjArray fPedestalRMSHighGain; // pedestal rms info for high gain
+ TObjArray fPedestalLEDRefLowGain; // pedestal LEDRef info for low gain
+ TObjArray fPedestalLEDRefHighGain; // pedestal LEDRef info for high gain
TObjArray fPeakMinusPedLowGain; // (peak-pedestal) info for low gain
TObjArray fPeakMinusPedHighGain; // (peak-pedestal) info for high gain
//The difference of profiles between this and the reference object
TObjArray fPedestalLowGainDiff; //!
TObjArray fPedestalHighGainDiff; //!
+ TObjArray fPedestalLEDRefLowGainDiff; //!
+ TObjArray fPedestalLEDRefHighGainDiff; //!
TObjArray fPeakMinusPedLowGainDiff; //!
TObjArray fPeakMinusPedHighGainDiff; //!
//The ratio of profiles between this and the reference object
TObjArray fPedestalLowGainRatio; //!
TObjArray fPedestalHighGainRatio; //!
+ TObjArray fPedestalLEDRefLowGainRatio; //!
+ TObjArray fPedestalLEDRefHighGainRatio; //!
TObjArray fPeakMinusPedLowGainRatio; //!
TObjArray fPeakMinusPedHighGainRatio; //!
kDetType fDetType; //The detector type for this object
int fColumns; //The number of columns per module
int fRows; //The number of rows per module
+ int fLEDRefs; //The number of LED references/monitors per module
int fModules; //The number of modules
- int fRowMin; // Mimimum Row number
+ int fRowMin; // Minimum Row number
int fRowMax; // Maximum now number
int fRowMultiplier; // Multiplication factor to get proper row range between PHOS and EMCAL
TString fCaloString; // id for which detector type we have
//Constants needed by the class: EMCAL ones are kept in AliEMCALGeoParams.h
static const int fgkPhosRows = 64; // number of rows per module for PHOS
static const int fgkPhosCols = 56; // number of columns per module for PHOS
+ static const int fgkPhosLEDRefs = 1; // no LED monitor channels for PHOS, set to 1 just to keep code simpler (also create LEDRef histos for PHOS)
static const int fgkPhosModules = 5; // number of modules for PHOS
-
- ClassDef(AliCaloCalibPedestal, 7)
+
+ ClassDef(AliCaloCalibPedestal, 8)
};
--- /dev/null
+// some global var/constants
+const Int_t kNSM = 4; // for first LHC run
+const Int_t kNRCU = 2;
+AliCaloAltroMapping *fMapping[4]; // 1 for each side (A/C) and each RCU (0/1), i.e. 2*2 total
+const Int_t kNBranch = 2;
+const Int_t kNFEC = 10; // 0..9, when including LED Ref
+const Int_t kNChip = 5; // really 0,2..4, i.e. skip #1
+const Int_t kNChan = 16;
+Float_t fMeanPed[kNSM][kNRCU][kNBranch][kNFEC][kNChip][kNChan];
+Float_t fRmsPed[kNSM][kNRCU][kNBranch][kNFEC][kNChip][kNChan];
+//
+const int kNStrips = 24; // per SM
+Int_t fHWAddrLEDRef[kNStrips][2]; // [2] is for Low/High gain
+
+// help methods
+void GetPedVal(const Int_t iSM, const Int_t igain, const TProfile2D *h2);
+void GetPedValLEDRef(const Int_t iSM, const Int_t igain, const TProfile *h);
+void PrintScript();
+void Clear();
+Int_t GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain);
+Int_t GetHWAddressLEDRef(Int_t istrip, Int_t igain);
+void DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan);
+void GetMapping();
+void CreateMappingLEDRef();
+
+// main method
+void
+GeneratePedestalScript(const char * filename = "alien/Run113790_113790_v1_s0.root")
+{
+ // get the DA info/object
+ TFile *file = TFile::Open(filename);
+ AliCaloCalibPedestal *emcCalibPedestal = AliCDBEntry->GetObject();
+
+ // Get mapping file info, and clear arrays
+ Clear();
+ GetMapping();
+ CreateMappingLEDRef();
+
+ // Store the pedestal info
+ for (Int_t iSM=0; iSM<kNSM; iSM++) {
+ GetPedVal( iSM, 0, emcCalibPedestal->GetPedProfileLowGain(iSM) );
+ GetPedVal( iSM, 1, emcCalibPedestal->GetPedProfileHighGain(iSM) );
+ GetPedValLEDRef( iSM, 0, emcCalibPedestal->GetPedLEDRefProfileLowGain(iSM) );
+ GetPedValLEDRef( iSM, 1, emcCalibPedestal->GetPedLEDRefProfileHighGain(iSM) );
+ }
+
+ // Generate the needed scripts
+ PrintScript();
+
+}
+
+void
+GetPedVal(const Int_t iSM, const Int_t igain, const TProfile2D *h2)
+{
+ Int_t isect = iSM / 2; //
+ Int_t iside = iSM % 2; // A or C side
+ Int_t nCols = h2->GetNbinsX();
+ Int_t nRows = h2->GetNbinsY();
+ // debug print
+ printf("GetPedVal: iSM %d isect %d iside %d igain %d nRows %d nCols %d\n",
+ iSM, isect, iside, igain, nRows, nCols);
+
+ Int_t hwAddress = 0;
+ Int_t iRCU = 0;
+ Int_t branch = 0;
+ Int_t FEC = 0;
+ Int_t chip = 0;
+ Int_t chan = 0;
+
+ Int_t icol = 0;
+ Int_t irow = 0;
+ Int_t bin = 0;
+
+ for (icol=0; icol<nCols; icol++) {
+ for (irow=0; irow<nRows; irow++) {
+
+ hwAddress = GetHWAddress(iside, icol, irow, igain, iRCU);
+ DecodeHWAddress(hwAddress, branch, FEC, chip, chan);
+ bin = h2->FindBin(icol, irow);
+
+ // store the values
+ fMeanPed[iSM][iRCU][branch][FEC][chip][chan] = h2->GetBinContent(bin);
+ fRmsPed[iSM][iRCU][branch][FEC][chip][chan] = h2->GetBinError(bin);
+ }
+ }
+
+ return;
+}
+
+
+void
+GetPedValLEDRef(const Int_t iSM, const Int_t igain, const TProfile *h)
+{
+ Int_t isect = iSM / 2; //
+ Int_t iside = iSM % 2; // A or C side
+ Int_t nStrips = h->GetNbinsX();
+
+ // debug print
+ printf("GetPedValLEDRef: iSM %d isect %d iside %d igain %d nStrips %d\n",
+ iSM, isect, iside, igain, nStrips);
+
+ Int_t hwAddress = 0;
+ Int_t iRCU = 0; // always true for LED Ref FEE
+ Int_t branch = 0;
+ Int_t FEC = 0;
+ Int_t chip = 0;
+ Int_t chan = 0;
+
+ Int_t icol = 0;
+ Int_t irow = 0;
+ Int_t bin = 0;
+
+ for (int istrip=0; istrip<nStrips; istrip++) {
+
+ hwAddress = GetHWAddressLEDRef(istrip, igain);
+ DecodeHWAddress(hwAddress, branch, FEC, chip, chan);
+ bin = h->FindBin(istrip);
+
+ // store the values
+ fMeanPed[iSM][iRCU][branch][FEC][chip][chan] = h->GetBinContent(bin);
+ fRmsPed[iSM][iRCU][branch][FEC][chip][chan] = h->GetBinError(bin);
+ }
+
+ return;
+}
+
+void
+PrintScript()
+{
+ const char * sideStr[] = {"A","C"};
+ const char * branchStr[] = {"A","B"};
+ int VFPED = 0x06;
+ int RCUWrite = 0x200000;
+
+ char filename[100];
+ char scriptLine[200];
+
+ Int_t iSM = 0;
+ Int_t iRCU = 0;
+ Int_t ibranch = 0;
+ Int_t iFEC = 0;
+ Int_t ichip = 0;
+ Int_t ichan = 0;
+ Int_t Ped = 0;
+
+ for (iSM=0; iSM<kNSM; iSM++) {
+ int iside = iSM % 2;
+ int isect = iSM / 2;
+ for (iRCU=0; iRCU<kNRCU; iRCU++) {
+ sprintf(filename, "setSM%1s%dRCU%d.scr",
+ sideStr[iside], isect, iRCU);
+ ofstream fout(filename);
+ int nscriptLines = 0;
+
+ for (ibranch=0; ibranch<kNBranch; ibranch++) {
+ int firstFEC = 1;
+ if (ibranch==0 && iRCU==0) { // extra LED Ref FEE in this location
+ firstFEC = 0;
+ }
+
+ for (iFEC=firstFEC; iFEC<kNFEC; iFEC++) { // FEC 1..9 (or 0..9)
+ for (ichip=0; ichip<kNChip; ichip++) { // ALTRO 0,2,3,4
+ if (ichip!=1) {
+ for (ichan=0; ichan<kNChan; ichan++) {
+
+ if (iFEC!=0 || (ichan<8 || ichan>11)) {
+
+ Ped = TMath::Nint(fMeanPed[iSM][iRCU][ibranch][iFEC][ichip][ichan]);
+ //
+ int writeAddr = (ibranch << 16) | (iFEC << 12) | (ichip << 9) |
+ (ichan << 5) | VFPED | RCUWrite;
+ sprintf(scriptLine, "w 0x%04x 0x%06x # Branch %s, Card %d, Altro %d, Chan %d",
+ nscriptLines, writeAddr, branchStr[ibranch],
+ iFEC, ichip, ichan);
+ fout << scriptLine << endl;
+ nscriptLines++;
+
+ int writeVal = (Ped | RCUWrite);
+ sprintf(scriptLine, "w 0x%04x 0x%06x # Pedestal 0x%x = %d",
+ nscriptLines, writeVal, Ped, Ped);
+ fout << scriptLine << endl;
+ nscriptLines++;
+
+ }
+ }
+ }
+ }
+ }
+ }
+ // ending, with execute and update step..
+ sprintf(scriptLine, "w 0x%04x 0x380000 # End of the sequence",
+ nscriptLines);
+ fout << scriptLine << endl;
+ nscriptLines++;
+
+ sprintf(scriptLine, "w 0x%04x 0x3F0000 # End of the instruction memory",
+ nscriptLines);
+ fout << scriptLine << endl;
+ nscriptLines++;
+
+ fout << "wait 100 us" << endl;
+ fout << "w 0x5304 0x0 \# execute and update registers" << endl;
+ fout.close();
+ } // iRCU
+ }// iSM
+
+ return;
+}
+
+void
+Clear()
+{
+ for (Int_t iSM=0; iSM<kNSM; iSM++) {
+ for (Int_t iRCU=0; iRCU<kNRCU; iRCU++) {
+ for (Int_t ibranch=0; ibranch<kNBranch; ibranch++) {
+ for (Int_t iFEC=0; iFEC<kNFEC; iFEC++) {
+ for (Int_t ichip=0; ichip<kNChip; ichip++) {
+ for (Int_t ichan=0; ichan<kNChan; ichan++) {
+ fMeanPed[iSM][iRCU][ibranch][iFEC][ichip][ichan] = 0;
+ fRmsPed[iSM][iRCU][ibranch][iFEC][ichip][ichan] = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (int istrip=0; istrip<kNStrips; istrip++) {
+ fHWAddrLEDRef[istrip][0] = 0;
+ fHWAddrLEDRef[istrip][1] = 0;
+ }
+
+ return;
+}
+
+void
+DecodeHWAddress(Int_t hwAddr, Int_t & branch, Int_t & FEC, Int_t & chip, Int_t & chan)
+{
+ chan = hwAddr & 0xf;
+ chip = (hwAddr >> 4) & 0x7;
+ FEC = (hwAddr >> 7) & 0xf;
+ branch = (hwAddr >> 11) & 0x1;
+ return;
+}
+
+Int_t
+GetHWAddress(Int_t iside, Int_t icol, Int_t irow, Int_t igain, Int_t & iRCU)
+{
+ iRCU = -111;
+
+ //RCU0
+ if (0<=irow&&irow<8) iRCU=0; // first cable row
+ else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half;
+ //second cable row
+ //RCU1
+ else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half;
+ //second cable row
+ else if(16<=irow&&irow<24) iRCU=1; // third cable row
+
+ // swap for odd=C side, to allow us to cable both sides the same
+ Int_t iRCUSide = iRCU;
+ if (iside == 1) {
+ iRCU = 1 - iRCU;
+ iRCUSide = iRCU + 2; // to make it map file index
+ }
+ Int_t hwAddress = fMapping[iRCUSide]->GetHWAddress(irow, icol, igain);
+
+ return hwAddress;
+}
+
+Int_t
+GetHWAddressLEDRef(Int_t istrip, Int_t igain)
+{
+ Int_t iRCU = 0; // for both sides; LED ref info is the same for both sides
+ Int_t caloflag = 3; // AliCaloRawStreamV3::kLEDMonData;
+
+ Int_t hwAddress = fHWAddrLEDRef[istrip][igain];
+
+ return hwAddress;
+}
+
+void
+GetMapping()
+{
+ TString sides[]={"A","C"};
+ // Read mapping files from $ALICE_ROOT/CALO/mapping/*.data
+ TString path = gSystem->Getenv("ALICE_ROOT");
+ path += "/EMCAL/mapping/RCU";
+ TString path2;
+ for(Int_t j = 0; j < 2; j++){ // sides
+ for(Int_t i = 0; i < 2; i++) { // RCU
+ path2 = path;
+ path2 += i;
+ path2 += sides[j];
+ path2 += ".data";
+ printf("Mapping file: %s\n",path2.Data());
+ fMapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
+ }
+ }
+ return;
+}
+
+void
+CreateMappingLEDRef()
+{
+ Int_t iRCU = 0; // for both sides; LED ref info is the same for both sides
+ Int_t caloflag = 3; // AliCaloRawStreamV3::kLEDMonData;
+
+ Int_t maxAddr = 1 << 7; // LED Ref FEE is in FEC pos 0, i.e. addr space 0..127
+
+ int nLEDRefFEEChan = 0;
+
+ Int_t branch = 0;
+ Int_t FEC = 0;
+ Int_t chip = 0;
+ Int_t chan = 0;
+ for (int hwaddr = 0; hwaddr<maxAddr; hwaddr++) {
+
+ DecodeHWAddress(hwaddr, branch, FEC, chip, chan);
+ if ( (chip!=1 && chip<kNChip) && // ALTROs 0,2,3,4
+ (chan<8 || chan>11) ) { // actual installed LED Ref FEE channels
+
+ int istrip = fMapping[iRCU]->GetPad(hwaddr);
+ int igain = fMapping[iRCU]->GetPadRow(hwaddr);
+ int iflag = fMapping[iRCU]->GetSector(hwaddr);
+ if (iflag == caloflag) {
+ fHWAddrLEDRef[istrip][igain] = hwaddr;
+ nLEDRefFEEChan++;
+ }
+ }
+ }
+
+ cout << " nLEDRefFEEChan " << nLEDRefFEEChan << endl;
+}