fTimeR(0.),
fChi2(0.),
fNDF(0),
- fTriggerDigit(kFALSE)
+ fDigitType(kUnknown)
{
// default ctor
// Need to initialise for reading old files
- fPrimary = new Int_t[fNMaxPrimary] ;
+ fPrimary = new Int_t[fNMaxPrimary] ;
fDEPrimary = new Float_t[fNMaxPrimary] ;
- fIparent = new Int_t[fNMaxiparent] ;
- fDEParent = new Float_t[fNMaxiparent] ;
+ fIparent = new Int_t[fNMaxiparent] ;
+ fDEParent = new Float_t[fNMaxiparent] ;
for ( Int_t i = 0; i < fNMaxPrimary ; i++) {
- fPrimary[i] = -1 ;
+ fPrimary[i] = -1 ;
fDEPrimary[i] = 0 ;
}
for ( Int_t i = 0; i < fNMaxiparent ; i++) {
- fIparent[i] = -1 ;
+ fIparent[i] = -1 ;
fDEParent[i] = 0 ;
}
}
//____________________________________________________________________________
-AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Bool_t trigger, Int_t index, Float_t dE)
+AliEMCALDigit::AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Int_t type, Int_t index, Float_t dE)
: AliDigitNew(),
fAmpFloat(digEnergy),
fNSamples(0),
- fSamples(0x0),
+ fSamples(0x0),
fNSamplesHG(0),
fSamplesHG(0x0),
fNprimary(0),
fTimeR(time),
fChi2(0.),
fNDF(0),
- fTriggerDigit(trigger)
+ fDigitType(type)
{
// ctor with all data
fIndexInList = index ;
// data member
- fPrimary = new Int_t[fNMaxPrimary] ;
+ fPrimary = new Int_t[fNMaxPrimary] ;
fDEPrimary = new Float_t[fNMaxPrimary] ;
- fIparent = new Int_t[fNMaxiparent] ;
- fDEParent = new Float_t[fNMaxiparent] ;
+ fIparent = new Int_t[fNMaxiparent] ;
+ fDEParent = new Float_t[fNMaxiparent] ;
if( primary != -1){
fNprimary = 1 ;
fPrimary[0] = primary ;
//____________________________________________________________________________
AliEMCALDigit::AliEMCALDigit(const AliEMCALDigit & digit)
: AliDigitNew(digit),
- fAmpFloat(digit.fAmpFloat),
- fNSamples(digit.fNSamples),
- fSamples(0x0),
+ fAmpFloat(digit.fAmpFloat),
+ fNSamples(digit.fNSamples),
+ fSamples(0x0),
fNSamplesHG(digit.fNSamplesHG),
fSamplesHG(0x0),
fNprimary(digit.fNprimary),
fTimeR(digit.fTimeR),
fChi2(digit.fChi2),
fNDF(digit.fNDF),
- fTriggerDigit(digit.fTriggerDigit)
+ fDigitType(digit.fDigitType)
{
// copy ctor
Bool_t AliEMCALDigit::GetFALTROSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
{
//Get FALTRO sample in time bin iSample
- if (iSample >= fNSamples || iSample < 0 || !fTriggerDigit) return kFALSE;
+ if (iSample >= fNSamples || iSample < 0 || fDigitType==kTrigger) return kFALSE;
amp = fSamples[iSample] & 0xFFF;
timeBin = (fSamples[iSample] >> 12) & 0xFF;
Bool_t AliEMCALDigit::GetALTROSampleLG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
{
//Get Low Gain ALTRO sample in time bin iSample
- if (iSample >= fNSamples || iSample < 0 || fTriggerDigit) return kFALSE;
+ if (iSample >= fNSamples || iSample < 0 || fDigitType==kLG) return kFALSE;
amp = fSamples[iSample] & 0xFFF;
timeBin = (fSamples[iSample] >> 12) & 0xFF;
Bool_t AliEMCALDigit::GetALTROSampleHG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
{
//Get High Gain ALTRO sample in time bin iSample
- if (iSample >= fNSamplesHG || iSample < 0 || fTriggerDigit) return kFALSE;
+ if (iSample >= fNSamplesHG || iSample < 0 || fDigitType==kHG) return kFALSE;
amp = fSamplesHG[iSample] & 0xFFF;
timeBin = (fSamplesHG[iSample] >> 12) & 0xFF;
void AliEMCALDigit::Print(const Option_t* /*opt*/) const
{
//Print
- printf("===\nDigit id: %4d / Energy %2.3f ; Time %e ; Time samples %d ; Chi2 %2.3f, NDF %d, Trigger? %d \n",
- fId, fAmpFloat,fTime, fNSamples, fChi2, fNDF, fTriggerDigit);
- if(fTriggerDigit){
+ printf("===\nDigit id: %4d / Energy %2.3f ; Time %e ; Time samples %d ; Chi2 %2.3f, NDF %d, Type? %d \n",
+ fId, fAmpFloat,fTime, fNSamples, fChi2, fNDF, fDigitType);
+ if(fDigitType==kTrigger){
printf("FALTRO: ");
for (Int_t i=0; i < GetNFALTROSamples(); i++)
{
public:
AliEMCALDigit() ;
- AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Bool_t trigger,Int_t index = -1, Float_t dE = 0) ;
+ AliEMCALDigit(Int_t primary, Int_t iparent, Int_t id, Float_t digEnergy, Float_t time, Int_t type,Int_t index = -1, Float_t dE = 0) ;
AliEMCALDigit(const AliEMCALDigit & digit) ;
virtual ~AliEMCALDigit() ;
AliEMCALDigit operator*(Float_t factor) ;
const AliEMCALDigit& operator = (const AliEMCALDigit &) {return *this;}
+ enum digitType{kUnknown=-1, kHG=0, kLG=1, kLGnoHG=2, kTrigger=3};
+
Int_t Compare(const TObject * obj) const ;
Float_t GetAmplitude() const { if(!fAmp)return fAmpFloat ; else return fAmp ;}//Keep backward compatibility.
Float_t GetEta() const ;
Float_t GetChi2(void) const { return fChi2 ;}
Int_t GetNDF(void) const { return fNDF ;}
Bool_t IsSortable() const { return kTRUE ;}
- Bool_t IsTriggerDigit() const { return fTriggerDigit ;}
+ Int_t GetType() const { return fDigitType ;}
- void SetAmp(Int_t amp) { fAmp = amp ;} //old
- void SetAmplitude(Float_t amp) { fAmpFloat = amp ;}
- void SetId(Int_t id) { fId = id ;}
- void SetTime(Float_t time) { fTime = time ;}
- void SetTimeR(Float_t time) { fTimeR = time ;}
- void SetChi2(Float_t chi) { fChi2 = chi ;}
- void SetNDF(Int_t ndf) { fNDF = ndf ;}
- void SetTriggerDigit(Bool_t b) { fTriggerDigit = b ;}
+ void SetAmp(Int_t amp) { fAmp = amp ;} //old
+ void SetAmplitude(Float_t amp) { fAmpFloat = amp ;}
+ void SetId(Int_t idt) { fId = idt ;}
+ void SetTime(Float_t time) { fTime = time ;}
+ void SetTimeR(Float_t time) { fTimeR = time ;}
+ void SetChi2(Float_t chi) { fChi2 = chi ;}
+ void SetNDF(Int_t ndf) { fNDF = ndf ;}
+ void SetType(Int_t t) { fDigitType = t ;}
void ShiftPrimary(Int_t shift); // shift to separate different TreeK in merging
//Raw time sample
//ALTRO
- Int_t GetNALTROSamplesLG() const {if(!fTriggerDigit)return fNSamples; else return 0;}
+ Int_t GetNALTROSamplesLG() const {if(fDigitType==kLG)return fNSamples; else return 0;}
Bool_t GetALTROSampleLG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const;
- Int_t GetNALTROSamplesHG() const {if(!fTriggerDigit) return fNSamplesHG; else return 0;}
+ Int_t GetNALTROSamplesHG() const {if(fDigitType==kHG) return fNSamplesHG; else return 0;}
Bool_t GetALTROSampleHG(const Int_t iSample, Int_t& timeBin, Int_t& amp) const;
//FALTRO, trigger. Same data members as Low Gain
Int_t GetNFALTROSamples() const
- {if(fTriggerDigit) return fNSamples; else return 0;}
+ {if(fDigitType==kTrigger) return fNSamples; else return 0;}
Bool_t GetFALTROSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const ;
void SetALTROSamplesHG (const Int_t nSamplesHG, Int_t *samplesHG);
void SetALTROSamplesLG (const Int_t nSamplesLG, Int_t *samplesLG);
- void SetFALTROSamples (const Int_t nSamples, Int_t *samples) { if(fTriggerDigit) SetALTROSamplesLG(nSamples, samples);}
+ void SetFALTROSamples (const Int_t nSamples, Int_t *samples) { if(fDigitType==kTrigger) SetALTROSamplesLG(nSamples, samples);}
void Print(const Option_t* /*opt*/) const;
Float_t fTimeR ; // Earliest time: to be used by Digits2Raw
//Fit quality parameters
Float_t fChi2; // Fit Chi aquare
- Int_t fNDF; // Fit Number of Degrees of Freedom
+ Int_t fNDF; // Fit Number of Degrees of Freedom
- Bool_t fTriggerDigit; // This is a trigger digit or not
+ Int_t fDigitType; // This is a trigger digit(0), HG (1) or LG (3)
- ClassDef(AliEMCALDigit,4) // Digit in EMCAL
+ ClassDef(AliEMCALDigit,5) // Digit in EMCAL
} ;
AliEMCALRawUtils::AliEMCALRawUtils(fitAlgorithm fitAlgo)
: fHighLowGainFactor(0.), fOrder(0), fTau(0.), fNoiseThreshold(0),
fNPedSamples(0), fGeom(0), fOption(""),
- fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),fUseFALTRO(kFALSE),fRawAnalyzer(0)
+ fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),
+ fTimeMin(-1.),fTimeMax(1.),
+ fUseFALTRO(kFALSE),fRawAnalyzer(0)
{
//These are default parameters.
AliEMCALRawUtils::AliEMCALRawUtils(AliEMCALGeometry *pGeometry, fitAlgorithm fitAlgo)
: fHighLowGainFactor(0.), fOrder(0), fTau(0.), fNoiseThreshold(0),
fNPedSamples(0), fGeom(pGeometry), fOption(""),
- fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),fUseFALTRO(kFALSE),fRawAnalyzer()
+ fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),
+ fTimeMin(-1.),fTimeMax(1.),
+ fUseFALTRO(kFALSE),fRawAnalyzer()
{
//
// Initialize with the given geometry - constructor required by HLT
fOption(rawU.fOption),
fRemoveBadChannels(rawU.fRemoveBadChannels),
fFittingAlgorithm(rawU.fFittingAlgorithm),
+ fTimeMin(rawU.fTimeMin),fTimeMax(rawU.fTimeMax),
fUseFALTRO(rawU.fUseFALTRO),
fRawAnalyzer(rawU.fRawAnalyzer)
{
fOption = rawU.fOption;
fRemoveBadChannels = rawU.fRemoveBadChannels;
fFittingAlgorithm = rawU.fFittingAlgorithm;
+ fTimeMin = rawU.fTimeMin;
+ fTimeMax = rawU.fTimeMax;
fUseFALTRO = rawU.fUseFALTRO;
fRawAnalyzer = rawU.fRawAnalyzer;
fMapping[0] = rawU.fMapping[0];
} // end while over channel
} //end while over DDL's, of input stream
+ TrimDigits(digitsArr);
+
return ;
}
//____________________________________________________________________________
void AliEMCALRawUtils::AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples)
{
- new((*digitsArr)[digitsArr->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
-
- // Int_t idx = digitsArr->GetEntriesFast()-1;
- // AliEMCALRawDigit* d = (AliEMCALRawDigit*)digitsArr->At(idx);
+ //Add raw sample to raw digit
+ new((*digitsArr)[digitsArr->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
+
+ // Int_t idx = digitsArr->GetEntriesFast()-1;
+ // AliEMCALRawDigit* d = (AliEMCALRawDigit*)digitsArr->At(idx);
}
//____________________________________________________________________________
AliEMCALDigit *digit = 0, *tmpdigit = 0;
TIter nextdigit(digitsArr);
while (digit == 0 && (tmpdigit = (AliEMCALDigit*) nextdigit())) {
- if (tmpdigit->GetId() == id)
- digit = tmpdigit;
+ if (tmpdigit->GetId() == id) digit = tmpdigit;
}
if (!digit) { // no digit existed for this tower; create one
- if (lowGain && amp > fgkOverflowCut)
- amp *= fHighLowGainFactor;
- Int_t idigit = digitsArr->GetEntries();
- new((*digitsArr)[idigit]) AliEMCALDigit( -1, -1, id, amp, time, kFALSE, idigit) ;
- }
+ Int_t type = AliEMCALDigit::kHG; // use enum in AliEMCALDigit
+ if (lowGain) {
+ amp *= fHighLowGainFactor;
+ type = AliEMCALDigit::kLGnoHG;
+ }
+ Int_t idigit = digitsArr->GetEntries();
+ new((*digitsArr)[idigit]) AliEMCALDigit( -1, -1, id, amp, time, type, idigit) ;
+ AliDebug(2,Form("Add digit Id %d for the first time, type %d", id, type));
+ }//digit added first time
else { // a digit already exists, check range
- // (use high gain if signal < cut value, otherwise low gain)
- if (lowGain) { // new digit is low gain
- if (digit->GetAmplitude() > fgkOverflowCut) { // use if stored digit is out of range
- digit->SetAmplitude(fHighLowGainFactor * amp);
- digit->SetTime(time);
- }
+ // (use high gain if signal < cut value, otherwise low gain)
+ if (lowGain) { // new digit is low gain
+ if (digit->GetAmplitude() > fgkOverflowCut) { // use if previously stored (HG) digit is out of range
+ digit->SetAmplitude(fHighLowGainFactor * amp);
+ digit->SetTime(time);
+ digit->SetType(AliEMCALDigit::kLG);
+ AliDebug(2,Form("Add LG digit ID %d for the second time, type %d", digit->GetId(), digit->GetType()));
+ }
+ }//new low gain digit
+ else { // new digit is high gain
+ if (amp < fgkOverflowCut) { // new digit is high gain; use if not out of range
+ digit->SetAmplitude(amp);
+ digit->SetTime(time);
+ digit->SetType(AliEMCALDigit::kHG);
+ AliDebug(2,Form("Add HG digit ID %d for the second time, type %d", digit->GetId(), digit->GetType()));
+ }
+ else { // HG out of range, just change flag value to show that HG did exist
+ digit->SetType(AliEMCALDigit::kLG);
+ AliDebug(2,Form("Change LG digit to HG, ID %d, type %d", digit->GetId(), digit->GetType()));
+ }
+ }//new high gain digit
+ }//digit existed replace it
+
+}
+
+//____________________________________________________________________________
+void AliEMCALRawUtils::TrimDigits(TClonesArray *digitsArr)
+{
+ // Remove digits with only low gain and large time
+
+ AliEMCALDigit *digit = 0;
+ Int_t n = 0;
+ Int_t nDigits = digitsArr->GetEntriesFast();
+ TIter nextdigit(digitsArr);
+ while ((digit = (AliEMCALDigit*) nextdigit())) {
+
+ //Check if only LG existed, remove if so
+ if (digit->GetType() == AliEMCALDigit::kLGnoHG) {
+ AliDebug(1,Form("Remove digit with id %d, LGnoHG",digit->GetId()));
+ digitsArr->Remove(digit);
}
- else if (amp < fgkOverflowCut) { // new digit is high gain; use if not out of range
- digit->SetAmplitude(amp);
- digit->SetTime(time);
+ //Check if time if too large or too small, remove if so
+ else if(fTimeMin > digit->GetTime() || fTimeMax < digit->GetTime()) {
+ digitsArr->Remove(digit);
+ AliDebug(1,Form("Remove digit with id %d, Bad Time %e",digit->GetId(), digit->GetTime()));
}
- }
+ //Good digit, just reassign the index of the digit in case there was a previous removal
+ else {
+ digit->SetIndexInList(n);
+ n++;
+ }
+ }//while
+
+ digitsArr->Compress();
+ AliDebug(1,Form("N Digits before trimming : %d; after array compression %d",nDigits,digitsArr->GetEntriesFast()));
+
}
-
+
//____________________________________________________________________________
void AliEMCALRawUtils::FitRaw(const Int_t firstTimeBin, const Int_t lastTimeBin, Float_t & amp, Float_t & time, Bool_t & fitDone) const
{ // Fits the raw signal time distribution
void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Float_t amp, Float_t time);
void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples);
+ void TrimDigits(TClonesArray *digitsArr);
// Signal shape parameters
Double_t GetRawFormatHighLowGainFactor() const { return fHighLowGainFactor ;}
Double_t GetRawFormatTau() const { return fTau ; }
Int_t GetNoiseThreshold() const { return fNoiseThreshold; }
Int_t GetNPedSamples() const { return fNPedSamples; }
+
// get methods for fast fit simulation
Int_t GetPedestalValue() const {return fgPedestalValue;}
Double_t GetFEENoise() const {return fgFEENoise;}
Bool_t GetRemoveBadChannels() const {return fRemoveBadChannels;}
Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
+ Float_t GetTimeMax() const {return fTimeMax ;}
+ Float_t GetTimeMin() const {return fTimeMin ;}
Bool_t UseFALTRO() const {return fUseFALTRO; }
-
+
void SetRawFormatHighLowGainFactor(Double_t val) {fHighLowGainFactor=val;}
void SetRawFormatOrder(Int_t val) {fOrder=val; }
void SetRawFormatTau(Double_t val) {fTau=val; }
void SetNPedSamples(Int_t val) {fNPedSamples=val; }
void SetRemoveBadChannels(Bool_t val) {fRemoveBadChannels=val; }
void SetFittingAlgorithm(Int_t val) ;
+ void SetTimeMin(Float_t t) {fTimeMin = t ;}
+ void SetTimeMax(Float_t t) {fTimeMax = t ;}
void SetFALTROUsage(Bool_t val) {fUseFALTRO=val; }
// set methods for fast fit simulation
Double_t fTau ; // tau parameter of gamma function for the RO signal
Int_t fNoiseThreshold; // threshold to consider signal or noise
Int_t fNPedSamples; // number of samples to use in pedestal calculation
-
+
static const Int_t fgkOverflowCut = 950; // cut to discriminate overflowed channels
static const Int_t fgkRawSignalOverflow = 0x3FF; // maximum signal (10 bits)
static Int_t fgTimeBins; // number of sampling bins of the raw RO signal
static Int_t fgPedestalValue; // pedestal value for Digits2Raw
static Double_t fgFEENoise; // electronics noise in ADC units
- AliEMCALGeometry* fGeom; //geometry
- AliAltroMapping* fMapping[4]; //only two for now
+ AliEMCALGeometry* fGeom; // geometry
+ AliAltroMapping* fMapping[4]; // only two for now
TString fOption; //! option passed from Reconstructor
- Bool_t fRemoveBadChannels; // select if bad channels are removed before fitting
- Int_t fFittingAlgorithm; // select the fitting algorithm
- Bool_t fUseFALTRO; // use FALTRO and pass it to the digits
+ Bool_t fRemoveBadChannels; // select if bad channels are removed before fitting
+ Int_t fFittingAlgorithm; // select the fitting algorithm
+ Float_t fTimeMin; // minimum threshold for the time of the signal
+ Float_t fTimeMax; // maximum threshold for the time of the signal
+ Bool_t fUseFALTRO; // use FALTRO and pass it to the digits
AliCaloRawAnalyzer *fRawAnalyzer; // e.g. for sample selection for fits
- ClassDef(AliEMCALRawUtils,6) // utilities for raw signal fitting
+ ClassDef(AliEMCALRawUtils,7) // utilities for raw signal fitting
};
#endif
fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
+ fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
+ fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax());
fgRawUtils->Raw2Digits(rawReader,digitsArr,fPedestalData,digitsTrg);