the release.
// return the first strip, as seen by the ALTRO channel, in the
// given range.
//
- ring = Board2Ring(board);
+ ring = Board2Ring(board);
+ UShort_t fsec = board < 16 ? 1 : 0;
switch (ring) {
case 'i':
case 'I':
- sec = ((board / 16) * 10 + (altro < 1 ? 0 : altro < 2 ? 4 : 6)
+ sec = (fsec * 10 + (altro < 1 ? 0 : altro < 2 ? 4 : 6)
+ 2 * (chan / 8) + chan % 2);
str = ((chan % 8) / 2) * 128;
break;
case 'o':
case 'O':
- sec = ((board / 16) * 20 + (altro < 1 ? 0 : altro < 2 ? 8 : 12)
+ sec = (fsec * 20 + (altro < 1 ? 0 : altro < 2 ? 8 : 12)
+ 2 * (chan / 4) + chan % 2);
str = ((chan % 4) / 2) * 128;
break;
// With this information, we can decode the detector coordinates to
// give us a unique hardware address
//
- UInt_t tmp = 0;
+ UInt_t tmp = 0;
+ UShort_t fboard = 0;
switch (ring) {
case 'I':
case 'i':
- board = (sec / 10) * 16;
- altro = (sec % 10) < 4 ? 0 : (sec % 10) < 6 ? 1 : 2;
- tmp = (sec % 10) - (altro == 0 ? 0 : altro == 1 ? 4 : 6);
- chan = 2 * (str / 128) + (sec % 2) + ((tmp / 2) % 2) * 8;
+ fboard = sec < 10 ? 1 : 0;
+ board = fboard * 16;
+ altro = (sec % 10) < 4 ? 0 : (sec % 10) < 6 ? 1 : 2;
+ tmp = (sec % 10) - (altro == 0 ? 0 : altro == 1 ? 4 : 6);
+ chan = 2 * (str / 128) + (sec % 2) + ((tmp / 2) % 2) * 8;
break;
case 'O':
case 'o':
- board = (sec / 20) * 16 + 1;
- altro = (sec % 20) < 8 ? 0 : (sec % 20) < 12 ? 1 : 2;
- tmp = (sec % 20) - (altro == 0 ? 0 : altro == 1 ? 8 : 12);
- chan = 2 * (str / 128) + (sec % 2) + ((tmp / 2) % 4) * 4;
+ fboard = sec < 20 ? 1 : 0;
+ board = fboard * 16 + 1;
+ altro = (sec % 20) < 8 ? 0 : (sec % 20) < 12 ? 1 : 2;
+ tmp = (sec % 20) - (altro == 0 ? 0 : altro == 1 ? 8 : 12);
+ chan = 2 * (str / 128) + (sec % 2) + ((tmp / 2) % 4) * 4;
break;
}
return kTRUE;
#include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H
#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
+#include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
#include <AliESDFMD.h> // ALIESDFMD_H
// #include <AliLog.h>
#include "AliFMDDebug.h" // Better debug macros
if (!fAux) {
fAux = new TCanvas("aux", "Aux");
fAux->SetLogy();
+ fAux->SetFillColor(kWhite);
+ fAux->SetBorderMode(0);
+ fAux->SetBorderSize(0);
Float_t dBin = (range->fHigh - range->fLow) / range->fNbins;
fSpec = new TH1D("spec", "Spectra", range->fNbins,
- range->fLow-dBin/2, range->fHigh-dBin/2);
+ range->fLow-dBin/2, range->fHigh+dBin/2);
fSpecCut = static_cast<TH1*>(fSpec->Clone("specCut"));
+ fSpec->SetXTitle("signal");
+ fSpec->SetYTitle("events");
fSpec->SetFillColor(2);
fSpec->SetFillStyle(3001);
+ fSpecCut->SetXTitle("signal");
+ fSpecCut->SetYTitle("events");
fSpecCut->SetFillColor(4);
fSpecCut->SetFillStyle(3001);
}
// The factor depends on what is
// drawn in the AUX canvas
AliInfo(Form("Noise factor is now %4.1f, pedestal factor %3.1f",
- 10*fFactor->GetMinimum(),fFactor->GetMaximum()));
+ fFactor->GetMinimum(),
+ (fFactor->GetMaximum()-fFactor->GetMaximum())));
Redisplay();
}
UShort_t str = digit->Strip();
Double_t ped = parm->GetPedestal(det,ring, sec, str);
Double_t pedW = parm->GetPedestalWidth(det,ring, sec, str);
- Double_t threshold = (ped * fFactor->GetMaximum()
- + pedW * fFactor->GetMinimum());
+ Double_t threshold = (fFMDReader->IsZeroSuppressed(det-1) ?
+ 0 : (ped * (fFactor->GetMaximum()
+ -fFactor->GetMinimum())
+ + pedW * fFactor->GetMinimum()));
if (threshold > fgkAdcRange.fHigh) threshold = fgkAdcRange.fHigh;
Float_t counts = digit->Counts();
+ if (fFMDReader->IsZeroSuppressed(det-1))
+ counts += fFMDReader->NoiseFactor(det-1) * pedW;
AliFMDDebug(10, ("FMD%d%c[%02d,%03d] counts %4d threshold %4d",
det, ring, sec, str, Int_t(counts), Int_t(threshold)));
TGeoVolume* top = gGeoManager->GetVolume("ALIC");
// TGeoMatrix* matrix = new TGeoTranslation("FMD1 trans", 0, 0, z);
TGeoRotation* rot = new TGeoRotation("FMD1 rotatation");
- rot->RotateZ(-90);
+ rot->RotateZ(90);
TGeoMatrix* matrix = new TGeoCombiTrans("FMD1 trans", 0, 0, z, rot);
AliFMDDebug(5, ("Placing volumes %s and %s in ALIC at z=%f",
fmd1TopVolume->GetName(), fmd1BotVolume->GetName(), z));
holeLW, holeHW, holeD, holeL);
TGeoTrd1* plateShape = new TGeoTrd1("FMD3_cooling_plate",
holeLW, holeHW, .033, holeL);
+ (void*)holeShape;
TGeoRotation* holeRot = new TGeoRotation();
holeRot->SetName("FMD3_cone_hole_rotation");
holeRot->RotateZ(90);
TGeoCombiTrans* holeBaseTrans = new TGeoCombiTrans(holeX, 0, holeZ, holeRot);
holeBaseTrans->SetName("FMD3_cone_hole_base_matrix");
TGeoCombiTrans* plateBaseTrans = new TGeoCombiTrans(plateX, 0,plateZ,holeRot);
- (void*)holeShape;
TGeoVolume* plateVolume = new TGeoVolume("FMD3_cooling_plate",
plateShape, fAl);
plateShape->SetTitle("FMD3 cooling plate");
fStack(0),
fFMDLoader(0),
fReader(0),
+ fFMDReader(0),
fFMD(0),
fESD(0),
fESDEvent(0),
fStack(0),
fFMDLoader(0),
fReader(0),
+ fFMDReader(0),
fFMD(0),
fESD(0),
fESDEvent(0),
else
fReader = new AliRawReaderFile(-1);
#endif
+ fFMDReader = new AliFMDRawReader(fReader, 0);
}
// Optionally, get the geometry
// Possibly load FMD Digit information
if (TESTBIT(fTreeMask, kRaw)) {
- AliInfo("Getting FMD raw data digits");
+ // AliInfo("Getting FMD raw data digits");
if (!fReader->NextEvent()) return kFALSE;
- AliFMDRawReader r(fReader, 0);
+ // AliFMDRawReader r(fReader, 0);
fArrayA->Clear();
- r.ReadAdcs(fArrayA);
+ fFMDReader->ReadAdcs(fArrayA);
AliFMDDebug(1, ("Got a total of %d digits", fArrayA->GetEntriesFast()));
}
fEventCount++;
class AliStack;
class AliRun;
class AliRawReader;
+class AliFMDRawReader;
class AliFMD;
class AliFMDHit;
class AliFMDDigit;
fStack(0),
fFMDLoader(0),
fReader(0),
+ fFMDReader(0),
fFMD(0),
fESD(0),
fESDEvent(0),
@return REference to this */
AliFMDInput& operator=(const AliFMDInput&) { return *this; }
- TString fGAliceFile; // File name of gAlice file
- AliRunLoader* fLoader; // Loader of FMD data
- AliRun* fRun; // Run information
- AliStack* fStack; // Stack of particles
- AliLoader* fFMDLoader; // Loader of FMD data
- AliRawReader* fReader; // Raw data reader
- AliFMD* fFMD; // FMD object
- AliESDFMD* fESD; // FMD ESD data
- AliESDEvent* fESDEvent; // ESD Event object.
- TTree* fTreeE; // Header tree
- TTree* fTreeH; // Hits tree
- TTree* fTreeD; // Digit tree
- TTree* fTreeS; // SDigit tree
- TTree* fTreeR; // RecPoint tree
- TTree* fTreeA; // Raw data tree
- TChain* fChainE; // Chain of ESD's
- TClonesArray* fArrayE; // Event info array
- TClonesArray* fArrayH; // Hit info array
- TClonesArray* fArrayD; // Digit info array
- TClonesArray* fArrayS; // SDigit info array
- TClonesArray* fArrayR; // Rec points info array
- TClonesArray* fArrayA; // Raw data (digits) info array
- AliHeader* fHeader; // Header
- TGeoManager* fGeoManager; // Geometry manager
- Int_t fTreeMask; // Which tree's to load
- TString fRawFile; // Raw input file
- Bool_t fIsInit; // Have we been initialized
- Int_t fEventCount; // Event counter
+ TString fGAliceFile; // File name of gAlice file
+ AliRunLoader* fLoader; // Loader of FMD data
+ AliRun* fRun; // Run information
+ AliStack* fStack; // Stack of particles
+ AliLoader* fFMDLoader; // Loader of FMD data
+ AliRawReader* fReader; // Raw data reader
+ AliFMDRawReader* fFMDReader; // FMD raw reader
+ AliFMD* fFMD; // FMD object
+ AliESDFMD* fESD; // FMD ESD data
+ AliESDEvent* fESDEvent; // ESD Event object.
+ TTree* fTreeE; // Header tree
+ TTree* fTreeH; // Hits tree
+ TTree* fTreeD; // Digit tree
+ TTree* fTreeS; // SDigit tree
+ TTree* fTreeR; // RecPoint tree
+ TTree* fTreeA; // Raw data tree
+ TChain* fChainE; // Chain of ESD's
+ TClonesArray* fArrayE; // Event info array
+ TClonesArray* fArrayH; // Hit info array
+ TClonesArray* fArrayD; // Digit info array
+ TClonesArray* fArrayS; // SDigit info array
+ TClonesArray* fArrayR; // Rec points info array
+ TClonesArray* fArrayA; // Raw data (digits) info array
+ AliHeader* fHeader; // Header
+ TGeoManager* fGeoManager; // Geometry manager
+ Int_t fTreeMask; // Which tree's to load
+ TString fRawFile; // Raw input file
+ Bool_t fIsInit; // Have we been initialized
+ Int_t fEventCount; // Event counter
ClassDef(AliFMDInput,0) //Hits for detector FMD
};
TStyle* style = gStyle;
if (nlevel < 1) nlevel = style->GetNumberOfColors();
fCounts.Set(nlevel);
+ Double_t rr = 1.05 * r;
if (!fFrame) {
// The code-checker thinks this is not using the declaration of
// TH2F - what a morron!
fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId),
- 10, -r, r, 10, -r, r);
+ 100, -rr, rr, 100, -rr, rr);
fFrame->SetStats(kFALSE);
fFrame->Draw();
}
g->SetFillColor(col);
g->SetMarkerSize(i * .2 + .2);
g->SetMarkerStyle(2);
+ g->SetEditable(kFALSE);
g->Draw("same p");
fGraphs.AddAtAndExpand(g, i);
}
TIter next(&fGraphs);
TGraph* g = 0;
Int_t i = 0;
- while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
+ while ((g = static_cast<TGraph*>(next()))) {
+ Int_t cnt = fCounts[i++];
+ if (cnt > 0) {
+ g->Set(cnt);
+ g->SetMarkerSize(i * .2 + .2);
+ }
+ else {
+ g->SetPoint(0,0,0);
+ g->SetMarkerSize(0);
+ }
+ }
+
}
//____________________________________________________________________
void
//
#include "AliFMDPedestalDA.h"
+#include "AliFMDAltroMapping.h"
#include "iostream"
#include "fstream"
#include "AliLog.h"
fNoiseSummary("NoiseSummary","noise",51200,0,51200),
fZSfileFMD1(),
fZSfileFMD2(),
- fZSfileFMD3()
+ fZSfileFMD3(),
+ fMinTimebin(3 * 4 * 3 * 16), // 3 ddls, 4 FECs, 3 Altros, 16 channels
+ fMaxTimebin(3 * 4 * 3 * 16) // 3 ddls, 4 FECs, 3 Altros, 16 channels
{
+ // Default constructor
fOutputFile.open("peds.csv");
fZSfileFMD1.open("ddl3072.csv");
fZSfileFMD2.open("ddl3073.csv");
fNoiseSummary("NoiseSummary","noise",51200,0,51200),
fZSfileFMD1(),
fZSfileFMD2(),
- fZSfileFMD3()
+ fZSfileFMD3(),
+ fMinTimebin(pedDA.fMinTimebin),
+ fMaxTimebin(pedDA.fMaxTimebin)
{
-
+ // Copy constructor
}
//_____________________________________________________________________
AliFMDPedestalDA::~AliFMDPedestalDA()
{
+ // Destructor.
}
//_____________________________________________________________________
void AliFMDPedestalDA::Init()
{
+ // Initialise
SetRequiredEvents(1000);
-
-
+ fMinTimebin.Reset(1024);
+ fMaxTimebin.Reset(-1);
}
//_____________________________________________________________________
UShort_t sec,
UShort_t strip)
{
+ // Add a channel to the containers.
+ //
+ // Parameters:
+ // sectorArray Array of sectors
+ // det Detector
+ // ring Ring
+ // sec Sector
+ // strip Strip
AliFMDParameters* pars = AliFMDParameters::Instance();
- UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
+ UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
TObjArray* sampleArray = new TObjArray(samples);
sampleArray->SetOwner();
for (UInt_t sample = 0; sample < samples; sample++) {
sampleArray->AddAt(hSample, sample);
}
sectorArray->AddAtAndExpand(sampleArray, strip);
-
-
}
//_____________________________________________________________________
void AliFMDPedestalDA::FillChannels(AliFMDDigit* digit)
{
+ // Fill ADC values from a digit into the corresponding histogram.
+ //
+ // Parameters:
+ // digit Digit to fill ADC values for.
UShort_t det = digit->Detector();
Char_t ring = digit->Ring();
UShort_t sec = digit->Sector();
UShort_t strip = digit->Strip();
AliFMDParameters* pars = AliFMDParameters::Instance();
- UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
+ UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
for (UInt_t sample = 0; sample < samples; sample++) {
TH1S* hSample = GetChannel(det, ring, sec, strip, sample);
hSample->Fill(digit->Count(sample));
void AliFMDPedestalDA::Analyse(UShort_t det,
Char_t ring,
UShort_t sec,
- UShort_t strip) {
-
+ UShort_t strip)
+{
+ // Analyse a strip. That is, compute the mean and spread of the ADC
+ // spectra for all strips. Also output on files the values.
+ //
+ // Parameters:
+ // det Detector
+ // ring Ring
+ // sec Sector
+ // strip Strip.
AliFMDParameters* pars = AliFMDParameters::Instance();
- UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
+ Float_t factor = pars->GetPedestalFactor();
+ UInt_t samples = pars->GetSampleRate(det, ring, sec, strip);
for (UShort_t sample = 0; sample < samples; sample++) {
- TH1S* hChannel = GetChannel(det, ring, sec, strip,sample);
+ TH1S* hChannel = GetChannel(det, ring, sec, strip,sample);
if(hChannel->GetEntries() == 0) {
//AliWarning(Form("No entries for FMD%d%c, sector %d, strip %d",
// det,ring,sec,strip));
return;
}
- AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",det,ring,sec,strip,
- hChannel->GetEntries()));
+ AliDebug(50, Form("Fitting FMD%d%c_%d_%d with %d entries",
+ det,ring,sec,strip, hChannel->GetEntries()));
TF1 fitFunc("fitFunc","gausn",0,300);
fitFunc.SetParameters(100,100,1);
hChannel->Fit("fitFunc","Q0+","",10,200);
UShort_t ddl, board, altro, channel;
UShort_t timebin;
- pars->Detector2Hardware(det,ring,sec,strip,sample,ddl,board,altro,channel,timebin);
+ pars->Detector2Hardware(det,ring,sec,strip,sample,
+ ddl,board,altro,channel,timebin);
+ Int_t idx = HWIndex(ddl, board, altro, channel);
+ if (idx >= 0) {
+ fMinTimebin[idx] = TMath::Min(Short_t(timebin), fMinTimebin[idx]);
+ fMaxTimebin[idx] = TMath::Max(Short_t(timebin+1), fMaxTimebin[idx]);
+ }
+ std::ostream* zsFile = 0;
switch(det) {
- case 1:
- fZSfileFMD1 << board << ',' << altro << ',' << channel << ',' << timebin << ','
- << mean << ',' << rms << "\n"; break;
- case 2:
- fZSfileFMD2 << board << ',' << altro << ',' << channel << ',' << timebin << ','
- << mean << ',' << rms << "\n"; break;
- case 3:
- fZSfileFMD3 << board << ',' << altro << ',' << channel << ',' << timebin << ','
- << mean << ',' << rms << "\n"; break;
- default:
- AliWarning("Unknown sample!"); break;
+ case 1: zsFile = &fZSfileFMD1; break;
+ case 2: zsFile = &fZSfileFMD2; break;
+ case 3: zsFile = &fZSfileFMD3; break;
+ default: AliWarning("Unknown sample!"); break;
}
+ *zsFile << board << ','
+ << altro << ','
+ << channel << ','
+ << timebin << ','
+ << mean << ','
+ << rms << ','
+ << factor << "\n"; break;
Float_t chi2ndf = 0;
if(fitFunc.GetNDF())
chi2ndf = fitFunc.GetChisquare() / fitFunc.GetNDF();
+
Int_t sampleToWrite = 2;
+ if (samples == 2) sampleToWrite = 1;
+ else if (samples < 2) sampleToWrite = 0;
- if(pars->GetSampleRate(det,ring,sec,strip)==2)
- sampleToWrite = 1;
+ if(sample != sampleToWrite) continue;
- if(pars->GetSampleRate(det,ring,sec,strip)<2)
- sampleToWrite = 0;
- if(sample==sampleToWrite) {
+ fOutputFile << det << ','
+ << ring << ','
+ << sec << ','
+ << strip << ','
+ << mean << ','
+ << rms << ','
+ << fitFunc.GetParameter(1) << ','
+ << fitFunc.GetParameter(2) << ','
+ << chi2ndf <<"\n";
- fOutputFile << det << ','
- << ring << ','
- << sec << ','
- << strip << ','
- << mean << ','
- << rms << ','
- << fitFunc.GetParameter(1) << ','
- << fitFunc.GetParameter(2) << ','
- << chi2ndf <<"\n";
-
- if(fSaveHistograms ) {
- gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE));
- TH1F* sumPed = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals"));
- TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise"));
- Int_t nStr = (ring == 'I' ? 512 : 256);
- if (!sumPed) {
- sumPed = new TH1F("Pedestals",
- Form("Summary of pedestals in FMD%d%c[%02d]",
+ if(fSaveHistograms ) {
+ gDirectory->cd(GetSectorPath(det, ring, sec, kTRUE));
+ TH1F* sumPed = dynamic_cast<TH1F*>(gDirectory->Get("Pedestals"));
+ TH1F* sumNoise = dynamic_cast<TH1F*>(gDirectory->Get("Noise"));
+ Int_t nStr = (ring == 'I' ? 512 : 256);
+ if (!sumPed) {
+ sumPed = new TH1F("Pedestals",
+ Form("Summary of pedestals in FMD%d%c[%02d]",
+ det, ring, sec),
+ nStr, -.5, nStr-.5);
+ sumPed->SetXTitle("Strip");
+ sumPed->SetYTitle("Pedestal [ADC]");
+ sumPed->SetDirectory(gDirectory);
+ }
+ if (!sumNoise) {
+ sumNoise = new TH1F("Noise",
+ Form("Summary of noise in FMD%d%c[%02d]",
det, ring, sec),
nStr, -.5, nStr-.5);
- sumPed->SetXTitle("Strip");
- sumPed->SetYTitle("Pedestal [ADC]");
- sumPed->SetDirectory(gDirectory);
- }
- if (!sumNoise) {
- sumNoise = new TH1F("Noise",
- Form("Summary of noise in FMD%d%c[%02d]",
- det, ring, sec),
- nStr, -.5, nStr-.5);
- sumNoise->SetXTitle("Strip");
- sumNoise->SetYTitle("Noise [ADC]");
-
- sumNoise->SetDirectory(gDirectory);
- }
- sumPed->SetBinContent(strip+1, mean);
- sumPed->SetBinError(strip+1, rms);
- sumNoise->SetBinContent(strip+1, rms);
-
- if(sumNoise->GetEntries() == nStr)
- sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite);
- if(sumPed->GetEntries() == nStr)
- sumPed->Write(sumPed->GetName(),TObject::kOverwrite);
+ sumNoise->SetXTitle("Strip");
+ sumNoise->SetYTitle("Noise [ADC]");
- fPedSummary.SetBinContent(fCurrentChannel,mean);
-
- fNoiseSummary.SetBinContent(fCurrentChannel,rms);
- fCurrentChannel++;
-
- gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE));
- hChannel->GetXaxis()->SetRange(1,1024);
-
- hChannel->Write();
+ sumNoise->SetDirectory(gDirectory);
}
+ sumPed->SetBinContent(strip+1, mean);
+ sumPed->SetBinError(strip+1, rms);
+ sumNoise->SetBinContent(strip+1, rms);
+
+ if(sumNoise->GetEntries() == nStr)
+ sumNoise->Write(sumNoise->GetName(),TObject::kOverwrite);
+ if(sumPed->GetEntries() == nStr)
+ sumPed->Write(sumPed->GetName(),TObject::kOverwrite);
+
+ fPedSummary.SetBinContent(fCurrentChannel,mean);
+
+ fNoiseSummary.SetBinContent(fCurrentChannel,rms);
+ fCurrentChannel++;
+
+ gDirectory->cd(GetStripPath(det, ring, sec, strip, kTRUE));
+ hChannel->GetXaxis()->SetRange(1,1024);
+
+ hChannel->Write();
}
}
}
//_____________________________________________________________________
void AliFMDPedestalDA::Terminate(TFile* diagFile)
{
+ // Called at the end of a job. Fills in missing time-bins and
+ // closes output files
if(fSaveHistograms) {
diagFile->cd();
fPedSummary.Write();
fNoiseSummary.Write();
}
+ AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
+ if(fZSfileFMD1.is_open()) FillinTimebins(fZSfileFMD1, map->Detector2DDL(1));
+ if(fZSfileFMD2.is_open()) FillinTimebins(fZSfileFMD2, map->Detector2DDL(2));
+ if(fZSfileFMD3.is_open()) FillinTimebins(fZSfileFMD3, map->Detector2DDL(3));
- if(fZSfileFMD1.is_open()) {
- fZSfileFMD1.write("# EOF\n",6);
- fZSfileFMD1.close(); }
- if(fZSfileFMD2.is_open()) {
- fZSfileFMD2.write("# EOF\n",6);
- fZSfileFMD2.close(); }
- if(fZSfileFMD3.is_open()) {
- fZSfileFMD3.write("# EOF\n",6);
- fZSfileFMD3.close(); }
-
+}
+
+//_____________________________________________________________________
+void AliFMDPedestalDA::FillinTimebins(std::ofstream& out, UShort_t ddl)
+{
+ unsigned short boards[] = { 0x0, 0x1, 0x10, 0x11, 0xFFFF };
+ unsigned short* board = boards;
+ while ((*boards) != 0xFFFF) {
+ for (UShort_t altro = 0; altro < 3; altro++) {
+ for (UShort_t channel = 0; channel < 16; channel++) {
+ Int_t idx = HWIndex(ddl, *board, altro, channel);
+ if (idx < 0) {
+ AliWarning(Form("Invalid index for %4d/0x%02x/0x%x/0x%x: %d",
+ ddl, *board, altro, channel, idx));
+ continue;
+ }
+ Short_t min = fMinTimebin[idx];
+ Short_t max = fMaxTimebin[idx];
+
+ // Channel not seen at all.
+ if (min > 1023 || max < 0) continue;
+
+ out << "# Extra timebins for 0x" << std::hex
+ << board << ',' << altro << ',' << channel
+ << " got time-bins " << min << " to " << max-1
+ << std::dec << std::endl;
+
+ for (UShort_t t = 15; t < min; t++)
+ // Write a phony line
+ out << board << "," << altro << "," << channel << ","
+ << t << "," << 1023 << "," << 0 << std::endl;
+
+ for (UShort_t t = max; t < 1024; t++)
+ // Write a phony line
+ out << board << "," << altro << "," << channel << ","
+ << t << "," << 1023 << "," << 0 << std::endl;
+ } // channel loop
+ } // altro loop
+ } // board loop
+ // Write trailer, and close
+ out.write("# EOF\n", 6);
+ out.close();
}
//_____________________________________________________________________
void AliFMDPedestalDA::WriteHeaderToFile()
{
+ // Write headers to output files
AliFMDParameters* pars = AliFMDParameters::Instance();
fOutputFile.write(Form("# %s \n",pars->GetPedestalShuttleID()),13);
fOutputFile.write("# Detector, "
"Mu, "
"Sigma, "
"Chi2/NDF \n", 71);
- fZSfileFMD1.write("# FMD 1 pedestals \n",19);
- fZSfileFMD1.write("# board, "
- "altro, "
- "channel, "
- "timebin, "
- "pedestal, "
- "noise \n", 51);
- fZSfileFMD2.write("# FMD 2 pedestals \n",19);
- fZSfileFMD2.write("# board, "
- "altro, "
- "channel, "
- "timebin, "
- "pedestal, "
- "noise \n", 51);
- fZSfileFMD3.write("# FMD 3 pedestals \n",19);
- fZSfileFMD3.write("# board, "
- "altro, "
- "channel, "
- "timebin, "
- "pedestal, "
- "noise \n", 51);
-
+
+ std::ostream* zss[] = { &fZSfileFMD1, &fZSfileFMD2, &fZSfileFMD3, 0 };
+ for (size_t i = 0; i < 3; i++)
+ *(zss[i]) << "# FMD 1 pedestals \n"
+ << "# board, "
+ << "altro, "
+ << "channel, "
+ << "timebin, "
+ << "pedestal, "
+ << "noise, "
+ << "factor\n";
}
//_____________________________________________________________________
Char_t ring,
UShort_t sec,
UShort_t strip,
- UInt_t sample)
+ UInt_t sample)
{
- UShort_t iring = (ring == 'O' ? 0 : 1);
- TObjArray* detArray = static_cast<TObjArray*>(fDetectorArray.At(det));
- TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(iring));
- TObjArray* secArray = static_cast<TObjArray*>(ringArray->At(sec));
- TObjArray* sampleArray = static_cast<TObjArray*>(secArray->At(strip));
- TH1S* hSample = static_cast<TH1S*>(sampleArray->At(sample));
+ // Get the histogram corresponding to a strip sample.
+ //
+ // Parameters:
+ // det Detector
+ // ring Ring
+ // sec Sector
+ // strip Strip
+ // sample Sample
+ //
+ // Return:
+ // ADC spectra of a strip.
+ UShort_t iring = (ring == 'O' ? 0 : 1);
+ TObjArray* detArray = static_cast<TObjArray*>(fDetectorArray.At(det));
+ TObjArray* ringArray = static_cast<TObjArray*>(detArray->At(iring));
+ TObjArray* secArray = static_cast<TObjArray*>(ringArray->At(sec));
+ TObjArray* sampleArray = static_cast<TObjArray*>(secArray->At(strip));
+ TH1S* hSample = static_cast<TH1S*>(sampleArray->At(sample));
return hSample;
}
#include "TH1.h"
#include "TObjArray.h"
-class AliFMDPedestalDA: public AliFMDBaseDA {
-
- public:
- AliFMDPedestalDA() ;
- AliFMDPedestalDA(const AliFMDPedestalDA & pedDA) ;
+class AliFMDPedestalDA: public AliFMDBaseDA
+{
+public:
+ /**
+ * Constructor.
+ *
+ */
+ AliFMDPedestalDA();
+ /**
+ * Copy constructor
+ *
+ * @param pedDA Object to copy from
+ */
+ AliFMDPedestalDA(const AliFMDPedestalDA & pedDA);
// AliFMDPedestalDA& operator = (const AliFMDPedestalDA & pedDA) ;
+ /**
+ * Destructor
+ *
+ */
virtual ~AliFMDPedestalDA();
+ /**
+ * Initialiser
+ *
+ */
void Init();
- protected:
-
- void AddChannelContainer(TObjArray* sectorArray, UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
+protected:
+ /**
+ * Add a channel to the containers.
+ *
+ * @param sectorArray Array of sectors
+ * @param det Detector
+ * @param ring Ring
+ * @param sec Sector
+ * @param strip Strip
+ */
+ void AddChannelContainer(TObjArray* sectorArray, UShort_t det,
+ Char_t ring, UShort_t sec, UShort_t strip);
+ /**
+ * Fill ADC values from a digit into the corresponding histogram.
+ *
+ * @param digit Digit to fill ADC values for.
+ */
void FillChannels(AliFMDDigit* digit);
+ /**
+ * Analyse a strip. That is, compute the mean and spread of the ADC
+ * spectra for all strips. Also output on files the values.
+ *
+ * @param det Detector
+ * @param ring Ring
+ * @param sec Sector
+ * @param strip Strip.
+ */
void Analyse(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
+ /**
+ * Write headers to files.
+ *
+ */
void WriteHeaderToFile();
+ /**
+ * Called at the end of an event.
+ *
+ */
void FinishEvent() {}
+ /**
+ * Called at the end of a job. Fills in missing time-bins and
+ * closes output files
+ *
+ */
void Terminate(TFile* );
- private:
- TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, UInt_t sample);
-
+private:
+ /**
+ * Get the histogram corresponding to a strip sample.
+ *
+ * @param det Detector
+ * @param ring Ring
+ * @param sec Sector
+ * @param strip Strip
+ * @param sample Sample
+ *
+ * @return ADC spectra of a strip.
+ */
+ TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec,
+ UShort_t strip, UInt_t sample);
+ /**
+ * Calculate the hardware index
+ *
+ * @param ddl DDL number
+ * @param board Board number
+ * @param altro ALTRO number
+ * @param chan Channel number
+ *
+ * @return Index into hardware cache.
+ */
+ Int_t HWIndex(UShort_t ddl, UShort_t board, UShort_t altro,
+ UShort_t chan) const;
+ void FillinTimebins(std::ofstream& out, UShort_t ddl);
+ /** Current strip */
Int_t fCurrentChannel;
+ /** Pedestal summary */
TH1F fPedSummary;
+ /** Noise summary */
TH1F fNoiseSummary;
+ /** Output file for zero-suppression for FMD1 */
std::ofstream fZSfileFMD1;
+ /** Output file for zero-suppression for FMD2 */
std::ofstream fZSfileFMD2;
+ /** Output file for zero-suppression for FMD3 */
std::ofstream fZSfileFMD3;
+ /** The minimum timebin seen for all channels */
+ TArrayS fMinTimebin;
+ /** The maximum timebin seen for all channels */
+ TArrayS fMaxTimebin;
+
ClassDef(AliFMDPedestalDA,0)
-
};
+
+inline Int_t
+AliFMDPedestalDA::HWIndex(UShort_t ddl, UShort_t b, UShort_t a, UShort_t c)const
+{
+ // Save some array entries
+ UShort_t lb = (b > 1 ? b-16+2 : b);
+ const Int_t kNDDL = 3;
+ const Int_t kNBoard = 4;
+ const Int_t kNAltro = 3;
+ const Int_t kNChannel = 16;
+ Int_t idx = c + kNChannel * (a + kNAltro * (lb + kNBoard * ddl));
+ if (idx > kNDDL * kNBoard * kNAltro * kNChannel) return -1;
+ return idx;
+}
+
#endif
+//
+// Local Variables:
+// mode: C++
+// End:
+//
UShort_t stripMin = 0;
UShort_t stripMax = 0; // 127;
UShort_t preSamp = 0; // 14+5;
-
+
+ Int_t oldddl = -1;
UInt_t ddl = 0;
UInt_t rate = 0;
UInt_t last = 0;
UInt_t hwaddr = 0;
// Data array is approx twice the size needed.
UShort_t data[2048];
+ for (size_t i = 0; i < 2048; i++) data[i] = 0; // kUShortMax;
Bool_t isGood = kTRUE;
while (isGood) {
array->GetEntriesFast()));
break;
}
+ if (oldddl != ddl) {
+ fZeroSuppress[ddl] = input.GetZeroSupp();
+ AliFMDDebug(20, ("RCU @ DDL %d zero suppression: %s",
+ ddl, (fZeroSuppress[ddl] ? "yes" : "no")));
- AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
+ // WARNING: We store the noise factor in the 2nd baseline
+ // filters excluded post samples, since we'll never use that
+ // mode.
+ fNoiseFactor[ddl] = input.GetNPostsamples();
+ AliFMDDebug(20, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));
+
+ Int_t nChAddrMismatch = input.GetNChAddrMismatch();
+ Int_t nChLenMismatch = input.GetNChLengthMismatch();
+ if (nChAddrMismatch != 0)
+ AliWarning(Form("Got %d channels with address mis-matches for 0x%03x",
+ nChAddrMismatch, hwaddr));
+ if (nChLenMismatch != 0)
+ AliWarning(Form("Got %d channels with length mis-matches for 0x%03x",
+ nChLenMismatch, hwaddr));
+ oldddl = ddl;
+ }
+ // AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
UShort_t det, sec, samp, board, chip, channel;
Short_t strbase;
stripMin = pars->GetMinStrip(det, ring, sec, strbase);
stripMax = pars->GetMaxStrip(det, ring, sec, strbase);
preSamp = pars->GetPreSamples(det, ring, sec, strbase);
- rate = pars->GetSampleRate(det, ring, sec, strbase);
+ // WARNING: We use the number of pre-samples to store the
+ // oversampling rate in.
+ rate = input.GetNPretriggerSamples();
+ if (rate == 0) rate = pars->GetSampleRate(det, ring, sec, strbase);
// Loop over the `timebins', and make the digits
for (size_t i = 0; i < last; i++) {
// if (i < preSamp) continue;
+ AliFMDDebug(15, ("0x%04x/0x%03x/%04d %4d", ddl, hwaddr, i, data[i]));
Short_t stroff = 0;
map->Timebin2Strip(sec, i, preSamp, rate, stroff, samp);
ddl, hwaddr, i, det, ring, sec, str, samp));
if (str < 0) {
AliFMDDebug(8, ("Got presamples at timebin %d", i));
+ data[i] = 0; // Reset cache
continue;
}
if (lstrip < stripMin || lstrip > stripMax) {
AliFMDDebug(5, ("FMD%d%c[%02d,%03d]-%d out of range (%3d->%3d)",
det, ring, sec, samp, str, stripMin, stripMax));
+ data[i] = 0; // Reset cache
continue;
}
("Setting from FMD%d%c[%2d,%3d]-%d from timebin %4d = %4d",
det, ring, sec, str, samp, i, data[i]));
digit->SetCount(samp, data[i]);
+ data[i] = 0; // Reset cache
}
}
return kTRUE;
@param array Array to read into
@return @c true on success */
virtual Bool_t ReadAdcs(TClonesArray* array);
- /** Read SOD event into a container.
- @param array Array to read into
- @return @c true on success */
+ /**
+ * Read SOD event into passed objects.
+ *
+ * @param samplerate The sample rate object to fill
+ * @param striprange The strip range object to fill
+ * @param pulseSize The pulse size object to fill
+ * @param pulseLength The pulse length (in events) object to fill
+ *
+ * @return @c true on success
+ */
virtual Bool_t ReadSODevent(AliFMDCalibSampleRate* samplerate,
AliFMDCalibStripRange* striprange,
TArrayS &pulseSize,
TArrayS &pulseLength);
+ /**
+ * Check of the data from DDL @a ddl is zero-suppressed
+ *
+ * @param ddl DDL number (0-2)
+ *
+ * @return @c true if the data from this DDL is zero-suppressed.
+ */
+ Bool_t IsZeroSuppressed(UShort_t ddl) const { return fZeroSuppress[ddl]; }
+ /**
+ * The factor used to multiply the noise when making on-line
+ * pedestal subtraction.
+ *
+ * @param ddl DDL number (0-2)
+ *
+ * @return The factor used.
+ */
+ UShort_t NoiseFactor(UShort_t ddl) const { return fNoiseFactor[ddl]; }
+
protected:
AliFMDRawReader(const AliFMDRawReader& o)
: TTask(o),
UShort_t fSampleRate; // The sample rate (if 0, inferred from data)
UChar_t* fData;
ULong_t fNbytes;
+ Bool_t fZeroSuppress[3];
+ UShort_t fNoiseFactor[3];
AliFMDUShortMap fSeen;
ClassDef(AliFMDRawReader, 0) // Read FMD raw data into a cache
break;
}
}
+ // Sanity check - if the total bunch length is less than 1, then
+ // read until we get the next bunch.
+ Int_t b = GetTimeLength();
+ if (b < 1) {
+ AliWarning(Form("Bunch length %0d is less than 0 for "
+ "DDL %4d address 0x%03x",
+ b, ddl, addr));
+ last = 0xFFFF;
+ continue;
+ }
+
+ // Sanity check - if the current time is less than 0, then read
+ // until we get a new bunch.
Int_t t = GetTime();
+ if (t < 0) {
+ AliWarning(Form("Time %0d is less than 0 for DDL %4d address 0x%03x",
+ t, ddl, addr));
+ last = 0xFFFF;
+ continue;
+ }
l = TMath::Max(l, t);
data[t] = signal;
last = 0xFFFF;
#include "AliFMDDebug.h"
#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
+#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
#include "AliFMDDigit.h" // ALIFMDDIGIT_H
#include "AliFMDReconstructor.h" // ALIFMDRECONSTRUCTOR_H
#include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
AliFMDRawReader rawRead(reader, digitsTree);
// rawRead.SetSampleRate(fFMD->GetSampleRate());
rawRead.Exec();
+ AliFMDAltroMapping* map = AliFMDParameters::Instance()->GetAltroMap();
+ for (size_t i = 1; i <= 3; i++) {
+ fZS[i] = rawRead.IsZeroSuppressed(map->Detector2DDL(i));
+ fZSFactor[i] = rawRead.NoiseFactor(map->Detector2DDL(i));
+ }
}
//____________________________________________________________________
// something like that.
AliFMDParameters* param = AliFMDParameters::Instance();
- Float_t ped = param->GetPedestal(digit->Detector(),
- digit->Ring(),
- digit->Sector(),
- digit->Strip());
+ Bool_t zs = fZS[digit->Detector()-1];
+ UShort_t fac = fZSFactor[digit->Detector()-1];
+ Float_t ped = (zs ? 0 :
+ param->GetPedestal(digit->Detector(),
+ digit->Ring(),
+ digit->Sector(),
+ digit->Strip()));
Float_t noise = param->GetPedestalWidth(digit->Detector(),
digit->Ring(),
digit->Sector(),
// else if (digit->Count2() > 0) adc = digit->Count2();
// else adc = digit->Count1();
Int_t adc = digit->Counts();
- Int_t counts = TMath::Max(Int_t(adc - ped), 0);
+ Int_t counts = adc + Int_t(zs ? fac * noise : - ped);
+ counts = TMath::Max(Int_t(counts), 0);
if (counts < noise * fNoiseFactor) counts = 0;
if (counts > 0) AliFMDDebug(15, ("Got a hit strip"));
if (fDiagStep1) fDiagStep1->Fill(adc, counts);
TH1* fDiagStep3; // Diagnostics histogram
TH1* fDiagStep4; // Diagnostics histogram
TH1* fDiagAll; // Diagnostics histogram
+ mutable Bool_t fZS[3]; // Zero-suppredded?
+ mutable UShort_t fZSFactor[3]; // Noise factor for Zero-suppression
private:
ClassDef(AliFMDReconstructor, 3) // class for the FMD reconstruction
void
FullMapping()
{
+ AliGeomManager::LoadGeometry("geometry.root");
AliCDBManager* cdb = AliCDBManager::Instance();
AliFMDParameters* param = AliFMDParameters::Instance();
AliFMDGeometry* geom = AliFMDGeometry::Instance();
cdb->SetDefaultStorage("local://$ALICE_ROOT");
cdb->SetRun(0);
- AliGeomManager::LoadGeometry();
param->Init();
geom->Init();
geom->InitTransformations();
# include <TError.h>
# include <iostream>
#endif
-#define SHOW_ALL 1
+bool show_all=false;
+
//____________________________________________________________________
/** @ingroup ALTRO_test
@param ddl
ok = false;
Warning("TestHWMap", "Sample # differ %d != %d", sam, osam);
}
-#ifndef SHOW_ALL
- if (!ok)
- PrintTrans(det,ring,sec,str,sam,
- ddl,hwaddr,timebin,
- odet,oring,osec,ostr,osam);
-#endif
+
+ if (!show_all) {
+ if (!ok)
+ PrintTrans(det,ring,sec,str,sam,
+ ddl,hwaddr,timebin,
+ odet,oring,osec,ostr,osam);
+ }
}
//____________________________________________________________________
/** @ingroup ALTRO_test
*/
void
-TestAltroMapping(Int_t min=1, Int_t max=3)
+TestAltroMapping(bool sa=false, Int_t min=1, Int_t max=3)
{
+ show_all = sa;
// AliLog::SetModuleDebugLevel("FMD", 1);
// if (min < 1 || min > 3) min = 1;
if (max < min) max = min;
Addr2Str(ddl, hwaddr, timebin));
continue;
}
-#ifdef SHOW_ALL
- PrintTrans(det,ring,sec,str,sam,
- ddl,hwaddr,timebin,
- odet,oring,osec,ostr,osam);
-#endif
+ if (show_all)
+ PrintTrans(det,ring,sec,str,sam,
+ ddl,hwaddr,timebin,
+ odet,oring,osec,ostr,osam);
CheckTrans(det,ring,sec,str,sam,
ddl,hwaddr,timebin,
odet,oring,osec,ostr,osam);
params->UseCompleteHeader(oldFormat);
// Set-up raw readers
- AliRawReader *reader = new AliRawReaderDate(fileName,-1);
+ AliRawReader *reader = AliRawReader::Create(fileName);
// Set-up timer