46 #include "AliCDBManager.h"
47 #include "AliCodeTimer.h"
50 #include "AliDigitizationInput.h"
51 #include "AliLoader.h"
52 #include "AliRunLoader.h"
54 #include <Riostream.h>
114 Int_t generateNoisyDigits)
115 : AliDigitizer(digInput),
116 fIsInitialized(kFALSE),
117 fCalibrationData(0x0),
118 fTriggerProcessor(0x0),
119 fNoiseFunctionTrig(0x0),
120 fGenerateNoisyDigits(generateNoisyDigits),
124 fOutputDigitStore(0x0),
125 fInputDigitStores(0x0),
127 fTriggerEfficiency(0x0),
128 fTriggerUtilities(0x0),
133 AliDebug(1,Form(
"AliDigitizationInput=%p",fDigInput));
153 AliInfo(
"Summary of messages");
170 Float_t charge = digit.
Charge();
175 fLogger->
Log(
"CHECK ME ! WAS NOT SUPPOSED TO BE HERE !!! ARE YOU RECONSTRUCTING OLD SIMULATIONS ? ");
176 AliError(
"CHECK ME ! WAS NOT SUPPOSED TO BE HERE !!! ARE YOU RECONSTRUCTING OLD SIMULATIONS ? ");
184 Int_t manuId = digit.
ManuId();
189 fLogger->
Log(Form(
"%s:%d:Could not get pedestal for DE=%4d manuId=%4d. Disabling.",
223 Int_t localCircuit = digit.
ManuId();
225 Int_t cathode = digit.
Cathode();
226 Int_t trigCh = detElemId/100 - 11;
230 AliDebug(1,Form(
"detElemId %i cath %i board %i strip %i is masked %i\n", detElemId, cathode, localCircuit, strip, isMasked));
239 Int_t arrayIndex =
GetArrayIndex(cathode, trigCh, localCircuit);
244 Bool_t isTrig[2] = {kTRUE, kTRUE};
246 Int_t arrayIndexBend =
GetArrayIndex(0, trigCh, localCircuit);
247 Int_t arrayIndexNonBend =
GetArrayIndex(1, trigCh, localCircuit);
251 AliDebug(1,Form(
"detElemId %i cath %i board %i strip %i efficiency %i\n", detElemId, cathode, localCircuit, strip,
fEfficiencyResponse[arrayIndex]));
271 filteredStore.
Clear();
273 const Bool_t kAddNoise = kTRUE;
280 while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
286 Bool_t addNoise = kAddNoise;
287 if (digit->IsConverted()) addNoise = kFALSE;
294 if ( digit->ADC() > 0 || digit->Charge() > 0 )
319 static const Int_t kMaxADC = (1<<12)-1;
327 Float_t pedestalMean = pedestals.
ValueAsFloat(channel,0);
328 Float_t pedestalSigma = pedestals.
ValueAsFloat(channel,1);
330 AliDebugClass(2,Form(
"DE %04d MANU %04d CH %02d PEDMEAN %7.2f PEDSIGMA %7.2f",
331 pedestals.
ID0(),pedestals.
ID1(),channel,pedestalMean,pedestalSigma));
333 if ( qual <= 0 )
return 0;
335 Float_t chargeThres = a0*thres;
337 Float_t padc = charge/a0;
343 Float_t adcNoise = 0.0;
353 adcNoise = gRandom->Gaus(0.0,pedestalSigma);
357 adc = TMath::Nint(padc + pedestalMean + adcNoise + 0.5);
359 if ( adc < TMath::Nint(pedestalMean +
fgNSigmas*pedestalSigma + 0.5) )
362 if ( !addNoise || (addNoise && noiseOnly) )
364 AliDebugClass(1,Form(
" DE %04d Manu %04d Channel %02d "
365 " a0 %7.2f thres %04d ped %7.2f pedsig %7.2f adcNoise %7.2f "
366 " charge=%7.2f padc=%7.2f adc=%04d ZS=%04d fgNSigmas=%e addNoise %d noiseOnly %d ",
367 pedestals.
ID0(),pedestals.
ID1(),channel,
368 a0, thres, pedestalMean, pedestalSigma, adcNoise,
370 TMath::Nint(pedestalMean +
fgNSigmas*pedestalSigma + 0.5),
395 AliFatal(
"Should be called only once !");
402 for ( Int_t iFile = 0; iFile < fDigInput->GetNinputs(); ++iFile )
404 AliLoader* inputLoader =
GetLoader(fDigInput->GetInputFolderName(iFile));
406 inputLoader->LoadSDigits(
"READ");
408 TTree* iTreeS = inputLoader->TreeS();
411 AliFatal(Form(
"Could not get access to input file #%d",iFile));
428 AliCodeTimerAuto(
"",0)
430 if ( fDigInput->GetNinputs() == 0 )
432 AliWarning(
"No input set. Nothing to do.");
438 AliError(
"Not initialized. Cannot perform the work. Sorry");
442 Int_t nInputFiles = fDigInput->GetNinputs();
444 AliLoader* outputLoader =
GetLoader(fDigInput->GetOutputFolderName());
446 outputLoader->MakeDigitsContainer();
448 TTree* oTreeD = outputLoader->TreeD();
452 AliFatal(
"Cannot create output TreeD");
458 for ( Int_t iFile = 0; iFile < nInputFiles; ++iFile )
460 AliLoader* inputLoader =
GetLoader(fDigInput->GetInputFolderName(iFile));
462 inputLoader->LoadSDigits(
"READ");
464 TTree* iTreeS = inputLoader->TreeS();
467 AliFatal(Form(
"Could not get access to input file #%d",iFile));
483 inputLoader->UnloadSDigits();
520 AliError(Form(
"Could not make branch : Digit %d Trigger %d",okD,okT));
531 outputLoader->WriteDigits(
"OVERWRITE");
533 outputLoader->UnloadDigits();
550 AliCodeTimerAuto(
"",0)
560 for ( Int_t cathode = 0; cathode < 2; ++cathode )
572 Int_t detElemId, Int_t cathode)
579 Int_t nofPads = seg->
NofPads();
584 static const Double_t kProbToBeOutsideNsigmas = TMath::Erfc(
fgNSigmas/TMath::Sqrt(2.0)) / 2. ;
586 Int_t nofNoisyPads = TMath::Nint(kProbToBeOutsideNsigmas*nofPads);
587 if ( !nofNoisyPads )
return;
590 TMath::Nint(gRandom->Gaus(nofNoisyPads,
591 nofNoisyPads/TMath::Sqrt(nofNoisyPads)));
593 AliDebug(3,Form(
"DE %d cath %d nofNoisyPads %d",detElemId,cathode,nofNoisyPads));
595 for ( Int_t i = 0; i < nofNoisyPads; ++i )
602 ix = gRandom->Integer(maxIx+1);
603 iy = gRandom->Integer(maxIy+1);
633 fLogger->
Log(
"Collision while adding noiseOnly digit");
666 Int_t nofNoisyPads = 50;
668 Float_t r=-1, fi = 0., gx, gy, x, y, z, xg01, yg01, zg, xg02, yg02;
671 AliDebug(3,Form(
"Chamber %d nofNoisyPads %d",chamberId,nofNoisyPads));
673 for ( Int_t i = 0; i < nofNoisyPads; ++i )
678 Bool_t isOk = kFALSE;
679 Int_t detElemId = -1;
683 fi = 2. * TMath::Pi() * gRandom->Rndm();
685 gx = r * TMath::Cos(fi);
686 gy = r * TMath::Sin(fi);
695 GetTransformer()->Local2Global(currDetElemId, -deltax, -deltay, 0, xg01, yg01, zg);
696 GetTransformer()->Local2Global(currDetElemId, deltax, deltay, 0, xg02, yg02, zg);
697 Float_t xg1 = xg01, xg2 = xg02, yg1 = yg01, yg2 = yg02;
706 if(gx>=xg1 && gx<=xg2 && gy>=yg1 && gy<=yg2){
707 detElemId = currDetElemId;
708 GetTransformer()->Global2Local(detElemId, gx, gy, 0, x, y, z);
710 if(!pad[0].IsValid())
continue;
721 for ( Int_t cathode = 0; cathode < 2; ++cathode ){
724 d[cathode] = digitStore.
CreateDigit(detElemId,manuId,manuChannel,cathode);
725 ix = pad[cathode].
GetIx();
726 iy = pad[cathode].
GetIy();
732 AliDebug(3,Form(
"Adding a pure noise digit :"));
737 fLogger->
Log(
"Collision while adding TriggerNoise digit");
755 AliDebug(2,Form(
"Getting access to folder %s",folderName.Data()));
756 AliLoader* loader = AliRunLoader::GetDetectorLoader(
"MUON",folderName.Data());
759 AliError(Form(
"Could not get MuonLoader from folder %s",folderName.Data()));
777 AliError(
"Object already initialized.");
783 AliError(
"fDigInput is null !");
789 AliFatal(
"Could not access mapping from OCDB !");
793 AliFatal(
"Calibration data object not defined");
797 AliFatal(
"Could not access pedestals from OCDB !");
800 AliInfo(
"Using trigger configuration from CDB");
804 AliDebug(1, Form(
"Will %s generate noise-only digits for tracker",
809 if (
muon()->GetTriggerEffCells() ) {
811 AliDebug(1,
"Will apply trigger efficiency");
838 if ( !outputStore ) outputStore = input.
Create();
843 while ( ( sdigit = static_cast<AliMUONVDigit*>(next()) ) )
853 AliError(
"Could not add digit in merge mode");
867 f->SetParameters(1,0,1);
880 AliError(
"Cannot work (e.g. decalibrate) without recoparams !");
virtual Int_t ManuChannel() const =0
The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for tri...
The iterator over detection elements.
static Float_t InvalidFloatValue()
Return 1E38 as invalid float value.
TF1 * fNoiseFunctionTrig
! function to get noise disribution on trig. chambers
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
Interface for a digit container.
void Print(Option_t *opt="") const
Implementation of AliMUONVTriggerStore.
static AliMpSegmentation * Instance(Bool_t warn=true)
virtual Float_t ValueAsFloat(Int_t i, Int_t j=0) const =0
static Int_t NTrackingCh()
Return number of tracking chambers.
virtual Int_t NofPads() const =0
Return the number of pads in the detection element.
Int_t fGenerateNoisyDigits
! whether or not we should generate noise-only digits for tracker (1) and trigger (2) ...
TFile f("CalibObjects.root")
virtual Int_t ADC() const =0
Raw ADC value of this digit.
Int_t Log(const char *message)
AliMUONRecoParam * fRecoParam
! reco params (to know how to decalibrate) (not owner)
virtual void Digitize(Option_t *opt="")
Bool_t fIsInitialized
are we initialized ?
AliMUONLogger * fLogger
for noise-only digit generation and zero-suppression
static Bool_t LoadDDLStore(Bool_t warn=false)
Int_t CurrentDEId() const
AliDetector class for MUON subsystem providing simulation data management.
Int_t GetArrayIndex(Int_t cathode, Int_t trigCh, Int_t localCircuit)
Class with MUON reconstruction parameters.
Utilities for trigger (check if pad is masked)
void ApplyResponseToTriggerDigit(AliMUONVDigit &digit)
virtual Bool_t IsChargeInFC() const
Whether this digit has charge in femto coulomb (see note 1 in AliMUONVDigit.cxx)
virtual void SetCharge(Float_t q)=0
Set the charge of this digit.
virtual Float_t Charge() const =0
The charge of this digit, calibrated or not depending on IsCalibrated()
static Float_t DefaultA0()
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
virtual Double_t GetDimensionY() const =0
Return the y half-sizes of the detection element.
virtual void NoiseOnly(Bool_t=kTRUE)
Set the noiseOnly status.
virtual TIterator * CreateIterator() const =0
Create an iterator to loop over all our digits.
AliMUONVDigitStore * fDigitStore
! temporary digits
AliMUONTriggerChamberEfficiency * fTriggerEfficiency
! trigger efficiency map
Int_t GetManuChannel() const
Manager class for muon trigger electronics.
A logger that keeps track of the number of times a message appeared.
Container of calibration values for a given number of channels.
static Int_t DecalibrateTrackerDigit(const AliMUONVCalibParam &pedestals, Int_t channel, Float_t charge, Bool_t addNoise=kFALSE, Bool_t noiseOnly=kFALSE)
void ApplyResponse(const AliMUONVDigitStore &store, AliMUONVDigitStore &filteredStore)
void IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trigBend, Bool_t &trigNonBend) const
virtual AliMUONVDigitStore * Create() const =0
Create an (empty) object of the same concrete class as *this.
virtual void SetADC(Int_t adc)=0
Set the ADC value.
void MergeWithSDigits(AliMUONVDigitStore *&digitStore, const AliMUONVDigitStore &input, Int_t mask)
virtual Int_t MaxPadIndexY() const =0
Return maximum pad index in Y direction.
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
Bool_t IsMasked(const AliMUONVDigit &digit) const
virtual Int_t ID0() const
First id of this object.
virtual Int_t ID1() const
Second id of this object (might not be required)
AliMUONTriggerUtilities * fTriggerUtilities
! Trigger utilities for masks
static Float_t DefaultCapa()
static AliMp::StationType GetStationType(Int_t detElemId)
void GenerateNoisyDigitsForTrigger(AliMUONVDigitStore &digitStore)
const AliMUONGeometryTransformer * GetGeometryTransformer() const
virtual ~AliMUONDigitizerV3()
static Float_t DefaultADC2MV()
virtual Double_t GetDimensionX() const =0
Return the x half-sizes of the detection element.
virtual void SetPadXY(Int_t padx, Int_t pady)=0
Set the ix and iy of this digit.
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
static Int_t NTriggerCh()
Return number of trigger chambers.
Int_t GetLocalBoardId(Int_t i) const
AliMUONVStore * Pedestals() const
Get the pedestal store.
AliMUONTriggerEfficiencyCells * TriggerEfficiency() const
Get the trigger efficiency map.
virtual Bool_t IsNoiseOnly() const =0
Whether this (simulated) digit is purely noise.
TObjArray * fInputDigitStores
! input digit stores (one per input file
static Int_t NCh()
Return number of chambers.
Bool_t IsValid() const
Return validity.
void GenerateNoisyDigits(AliMUONVDigitStore &digitStore)
static Double_t fgNSigmas
number of sigmas above ped to use
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
Single entry point to access MUON calibration data.
AliMUONCalibrationData * fCalibrationData
! pointer to access calib parameters
The abstract base class for the segmentation.
AliMUONVTriggerStore * fTriggerStore
! trigger objects
virtual Int_t MaxPadIndexX() const =0
Return maximum pad index in X direction.
AliLoader * GetLoader(const TString &foldername)
virtual Int_t ManuId() const =0
The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger) ...
TArrayI fEfficiencyResponse
! Local board efficiency response
void CreateInputDigitStores()
Class which encapsuate all information about a pad.
Calculate, apply and possibly draw trigger chamber efficiency.
virtual void Clear(Option_t *opt="")=0
Clear ourselves (i.e. Reset)
virtual void Digits2Trigger(const AliMUONVDigitStore &digitStore, AliMUONVTriggerStore &triggerStore)
virtual AliMUONVDigit * CreateDigit(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t cathode) const =0
Create a digit.
Digitizer (from SDigit to Digit), performing digit de-calibration.
static TF1 * NoiseFunction()
static Int_t NTriggerCircuit()
Return number of trigger circuits.
Int_t GetLocalBoardChannel(Int_t i) const
virtual Bool_t Connect(TTree &tree, Bool_t alone=kTRUE) const
Connect us to a TTree (only valid if CanConnect()==kTRUE)
void SetCalibrationData(AliMUONCalibrationData *calibrationData, AliMUONRecoParam *recoParam)
Set calibration (and recoparam) data.
void GenerateNoisyDigitsForOneCathode(AliMUONVDigitStore &digitStore, Int_t detElemId, Int_t cathode)
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.
void ApplyResponseToTrackerDigit(AliMUONVDigit &digit, Bool_t addNoise)
AliMUONTriggerElectronics * fTriggerProcessor
pointer to the trigger part of the job
virtual void PatchTracks(Int_t)
Patch track with a mask.
AliMUONVDigitStore * fOutputDigitStore
! digits we'll output to disk