#include "AliMUONDigitizerV3.h"
-#include "AliCDBManager.h"
-#include "AliCodeTimer.h"
-#include "AliLog.h"
#include "AliMUON.h"
#include "AliMUONCalibrationData.h"
#include "AliMUONConstants.h"
#include "AliMUONDigit.h"
#include "AliMUONLogger.h"
-#include "AliMUONTriggerEfficiencyCells.h"
#include "AliMUONTriggerElectronics.h"
#include "AliMUONTriggerStoreV1.h"
#include "AliMUONVCalibParam.h"
#include "AliMUONVDigitStore.h"
+#include "AliMUONGeometryTransformer.h" //ADDED for trigger noise
+
#include "AliMpCDB.h"
+#include "AliMpSegmentation.h"
#include "AliMpCathodType.h"
#include "AliMpConstants.h"
#include "AliMpDEIterator.h"
#include "AliMpDEManager.h"
#include "AliMpIntPair.h"
#include "AliMpPad.h"
-#include "AliMpSegmentation.h"
#include "AliMpStationType.h"
#include "AliMpVSegmentation.h"
+
+#include "AliCDBManager.h"
+#include "AliCodeTimer.h"
+#include "AliLog.h"
#include "AliRun.h"
#include "AliRunDigitizer.h"
#include "AliRunLoader.h"
+
#include <Riostream.h>
#include <TF1.h>
#include <TFile.h>
#include <TString.h>
#include <TSystem.h>
-#include "AliMUONGeometryTransformer.h" //ADDED for trigger noise
-
//-----------------------------------------------------------------------------
/// \class AliMUONDigitizerV3
/// The digitizer is performing the transformation to go from SDigits (digits
fIsInitialized(kFALSE),
fCalibrationData(0x0),
fTriggerProcessor(0x0),
-fTriggerEfficiency(0x0),
-fNoiseFunction(0x0),
fNoiseFunctionTrig(0x0),
- fGenerateNoisyDigits(generateNoisyDigits),
- fLogger(new AliMUONLogger(1000)),
+fGenerateNoisyDigits(generateNoisyDigits),
+fLogger(new AliMUONLogger(1000)),
fTriggerStore(new AliMUONTriggerStoreV1),
fDigitStore(0x0),
-fOutputDigitStore(0x0)
+fOutputDigitStore(0x0),
+fInputDigitStore(0x0)
{
/// Ctor.
AliDebug(1,Form("AliRunDigitizer=%p",fManager));
+
}
//_____________________________________________________________________________
AliDebug(1,"dtor");
- delete fCalibrationData;
+ // delete fCalibrationData;
delete fTriggerProcessor;
- delete fNoiseFunction;
delete fNoiseFunctionTrig;
delete fTriggerStore;
delete fDigitStore;
delete fOutputDigitStore;
-
+ delete fInputDigitStore;
+
AliInfo("Summary of messages");
fLogger->Print();
Int_t manuChannel = digit.ManuChannel();
-
-
- Int_t adc = DecalibrateTrackerDigit(*pedestal,*gain,manuChannel,charge,addNoise);
+ Int_t adc = DecalibrateTrackerDigit(*pedestal,*gain,manuChannel,charge,addNoise,
+ digit.IsNoiseOnly());
digit.SetADC(adc);
}
-//_____________________________________________________________________________
-void
-AliMUONDigitizerV3::ApplyResponseToTriggerDigit(const AliMUONVDigitStore& digitStore,
- AliMUONVDigit& digit)
-{
- /// \todo add comment
-
- if ( !fTriggerEfficiency ) return;
-
- if (digit.IsEfficiencyApplied()) return;
-
- AliMUONVDigit* correspondingDigit = FindCorrespondingDigit(digitStore,digit);
-
- if (!correspondingDigit) return; //reject bad correspondences
-
- Int_t detElemId = digit.DetElemId();
-
- AliMpSegmentation* segmentation = AliMpSegmentation::Instance();
- const AliMpVSegmentation* segment[2] =
- {
- segmentation->GetMpSegmentation(detElemId,AliMp::GetCathodType(digit.Cathode())),
- segmentation->GetMpSegmentation(detElemId,AliMp::GetCathodType(correspondingDigit->Cathode()))
- };
-
- AliMpPad pad[2] =
- {
- segment[0]->PadByIndices(AliMpIntPair(digit.PadX(),digit.PadY()),kTRUE),
- segment[1]->PadByIndices(AliMpIntPair(correspondingDigit->PadX(),correspondingDigit->PadY()),kTRUE)
- };
-
- Int_t p0(1);
- if (digit.Cathode()==0) p0=0;
-
- AliMpIntPair location = pad[p0].GetLocation(0);
- Int_t nboard = location.GetFirst();
-
- Bool_t isTrig[2];
-
- fTriggerEfficiency->IsTriggered(detElemId, nboard,
- isTrig[0], isTrig[1]);
- digit.EfficiencyApplied(kTRUE);
- correspondingDigit->EfficiencyApplied(kTRUE);
-
- if (!isTrig[digit.Cathode()])
- {
- digit.SetCharge(0);
- }
-
- if ( &digit != correspondingDigit )
- {
- if (!isTrig[correspondingDigit->Cathode()])
- {
- correspondingDigit->SetCharge(0);
- }
- }
-}
-
//_____________________________________________________________________________
void
AliMUONDigitizerV3::ApplyResponse(const AliMUONVDigitStore& store,
{
ApplyResponseToTrackerDigit(*digit,kAddNoise);
}
- else
- {
- ApplyResponseToTriggerDigit(store,*digit);
- }
+
if ( digit->ADC() > 0 || digit->Charge() > 0 )
{
filteredStore.Add(*digit,AliMUONVDigitStore::kIgnore);
const AliMUONVCalibParam& gains,
Int_t channel,
Float_t charge,
- Bool_t addNoise)
+ Bool_t addNoise,
+ Bool_t noiseOnly)
{
/// Decalibrate (i.e. go from charge to adc) a tracker digit, given its
/// pedestal and gain parameters.
Float_t pedestalMean = pedestals.ValueAsFloat(channel,0);
Float_t pedestalSigma = pedestals.ValueAsFloat(channel,1);
+ AliDebugClass(1,Form("DE %04d MANU %04d CH %02d PEDMEAN %7.2f PEDSIGMA %7.2f",
+ pedestals.ID0(),pedestals.ID1(),channel,pedestalMean,pedestalSigma));
+
Float_t a0 = gains.ValueAsFloat(channel,0);
Float_t a1 = gains.ValueAsFloat(channel,1);
Int_t thres = gains.ValueAsInt(channel,2);
Int_t adc(0);
- if ( padc > 0 )
- {
- Float_t adcNoise = 0.0;
+ Float_t adcNoise = 0.0;
- if ( addNoise ) adcNoise = gRandom->Gaus(0.0,pedestalSigma);
+ if ( addNoise )
+ {
+ if ( noiseOnly )
+ {
+ adcNoise = NoiseFunction()->GetRandom()*pedestalSigma;
+ }
+ else
+ {
+ adcNoise = gRandom->Gaus(0.0,pedestalSigma);
+ }
+ }
- adc = TMath::Nint(padc + pedestalMean + adcNoise);
+ adc = TMath::Nint(padc + pedestalMean + adcNoise + 0.5);
+
+ if ( adc < TMath::Nint(pedestalMean + fgkNSigmas*pedestalSigma + 0.5) )
+ {
+ adc = 0;
}
// be sure we stick to 12 bits.
return adc;
}
+//_____________________________________________________________________________
+void
+AliMUONDigitizerV3::CreateInputDigitStore()
+{
+ /// Create an input digit store, and check that all input files
+ /// actually contains the same type of AliMUONVDigitStore
+
+ fInputDigitStore = 0x0;
+
+ for ( Int_t iFile = 0; iFile < fManager->GetNinputs(); ++iFile )
+ {
+ AliLoader* inputLoader = GetLoader(fManager->GetInputFolderName(iFile));
+
+ inputLoader->LoadSDigits("READ");
+
+ TTree* iTreeS = inputLoader->TreeS();
+ if (!iTreeS)
+ {
+ AliFatal(Form("Could not get access to input file #%d",iFile));
+ }
+
+ AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
+
+ if (!fInputDigitStore)
+ {
+ fInputDigitStore = inputStore;
+ }
+ else
+ {
+ if ( inputStore->IsA() != fInputDigitStore->IsA() )
+ {
+ AliFatal("Got different types of AliMUONVDigitStore here. Please implement me.");
+ }
+ }
+ }
+}
+
//_____________________________________________________________________________
void
AliMUONDigitizerV3::Exec(Option_t*)
{
AliFatal(Form("Could not get access to input file #%d",iFile));
}
-
- AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
- inputStore->Connect(*iTreeS);
+
+ if (!fInputDigitStore)
+ {
+ CreateInputDigitStore();
+ }
+ fInputDigitStore->Connect(*iTreeS);
iTreeS->GetEvent(0);
- MergeWithSDigits(fDigitStore,*inputStore,fManager->GetMask(iFile));
+ MergeWithSDigits(fDigitStore,*fInputDigitStore,fManager->GetMask(iFile));
inputLoader->UnloadSDigits();
- delete inputStore;
+ fInputDigitStore->Clear();
}
// At this point, we do have digit arrays (one per chamber) which contains
fOutputDigitStore->Clear();
}
-//_____________________________________________________________________________
-AliMUONVDigit*
-AliMUONDigitizerV3::FindCorrespondingDigit(const AliMUONVDigitStore& digitStore,
- AliMUONVDigit& digit) const
-{
- /// Find, if it exists, the digit corresponding to digit.Hit(), in the
- /// other cathode
-
- AliCodeTimerAuto("")
-
- TIter next(digitStore.CreateIterator());
- AliMUONVDigit* d;
-
- while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
- {
- if ( d->DetElemId() == digit.DetElemId() &&
- d->Hit() == digit.Hit() &&
- d->Cathode() != digit.Cathode() )
- {
- return d;
- }
- }
- return 0x0;
-}
-
//_____________________________________________________________________________
void
AliCodeTimerAuto("")
- if ( !fNoiseFunction )
- {
- fNoiseFunction = new TF1("AliMUONDigitizerV3::fNoiseFunction","gaus",
- fgkNSigmas,fgkNSigmas*10);
-
- fNoiseFunction->SetParameters(1,0,1);
- }
-
for ( Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i )
{
AliMpDEIterator it;
d->SetPadXY(ix,iy);
- Float_t pedestalMean = pedestals->ValueAsFloat(manuChannel,0);
- Float_t pedestalSigma = pedestals->ValueAsFloat(manuChannel,1);
-
- Double_t ped = fNoiseFunction->GetRandom()*pedestalSigma;
-
- d->SetCharge(TMath::Nint(ped+pedestalMean+0.5));
+ d->SetCharge(0.0); // charge is zero, the ApplyResponseToTrackerDigit will add the noise
d->NoiseOnly(kTRUE);
- ApplyResponseToTrackerDigit(*d,kFALSE);
+ ApplyResponseToTrackerDigit(*d,kTRUE);
if ( d->ADC() > 0 )
{
Bool_t ok = digitStore.Add(*d,AliMUONVDigitStore::kDeny);
return kFALSE;
}
- Int_t runnumber = AliCDBManager::Instance()->GetRun();
-
- if ( ! AliMpCDB::LoadMpSegmentation() )
- {
+ // Load mapping
+ if ( ! AliMpCDB::LoadDDLStore() ) {
AliFatal("Could not access mapping from OCDB !");
}
- if ( ! AliMpCDB::LoadDDLStore() )
- {
- AliFatal("Could not access DDL Store from OCDB !");
- }
-
- fCalibrationData = new AliMUONCalibrationData(runnumber);
+ if (!fCalibrationData)
+ AliFatal("Calibration data object not defined");
+
if ( !fCalibrationData->Pedestals() )
{
AliFatal("Could not access pedestals from OCDB !");
{
AliFatal("Could not access gains from OCDB !");
}
- fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
- if ( muon()->GetTriggerEffCells() )
- {
- fTriggerEfficiency = fCalibrationData->TriggerEfficiency();
- if ( fTriggerEfficiency )
- {
- AliDebug(1, "Will apply trigger efficiency");
- }
- else
- {
- AliFatal("I was requested to apply trigger efficiency, but I could "
- "not get it !");
- }
- }
+
+ AliInfo("Using trigger configuration from CDB");
+
+ fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
AliDebug(1, Form("Will %s generate noise-only digits for tracker",
(fGenerateNoisyDigits ? "":"NOT")));
}
}
}
+
+//_____________________________________________________________________________
+TF1*
+AliMUONDigitizerV3::NoiseFunction()
+{
+ /// Return noise function
+ static TF1* f = 0x0;
+ if (!f)
+ {
+ f = new TF1("AliMUONDigitizerV3::NoiseFunction","gaus",fgkNSigmas,fgkNSigmas*10);
+ f->SetParameters(1,0,1);
+ }
+ return f;
+}
+