// //
////////////////////////////////////////////////////////////////////////////
-#include <TF1.h>
-#include <TFile.h>
-#include <TGeoGlobalMagField.h>
#include <TGeoManager.h>
#include <TList.h>
#include <TMath.h>
-#include <TROOT.h>
#include <TRandom.h>
-#include <TTask.h>
#include <TTree.h>
-#include <TVector.h>
#include "AliRun.h"
#include "AliMC.h"
#include "AliRunLoader.h"
#include "AliLoader.h"
#include "AliConfig.h"
-#include "AliMagF.h"
#include "AliRunDigitizer.h"
#include "AliRunLoader.h"
#include "AliLoader.h"
#include "AliLog.h"
+
#include "AliTRD.h"
#include "AliTRDhit.h"
#include "AliTRDdigitizer.h"
-
#include "AliTRDarrayDictionary.h"
#include "AliTRDarrayADC.h"
#include "AliTRDarraySignal.h"
#include "AliTRDCommonParam.h"
#include "AliTRDfeeParam.h"
#include "AliTRDmcmSim.h"
+#include "AliTRDdigitsParam.h"
+
#include "Cal/AliTRDCalROC.h"
#include "Cal/AliTRDCalDet.h"
,fSDigitsManagerList(0)
,fTRD(0)
,fGeo(0)
+ ,fMcmSim(new AliTRDmcmSim)
,fEvent(0)
,fMasks(0)
,fCompress(kTRUE)
// AliTRDdigitizer default constructor
//
- Init();
-
}
//_____________________________________________________________________________
,fSDigitsManagerList(0)
,fTRD(0)
,fGeo(0)
+ ,fMcmSim(new AliTRDmcmSim)
,fEvent(0)
,fMasks(0)
,fCompress(kTRUE)
// AliTRDdigitizer constructor
//
- Init();
-
}
//_____________________________________________________________________________
,fSDigitsManagerList(0)
,fTRD(0)
,fGeo(0)
+ ,fMcmSim(new AliTRDmcmSim)
,fEvent(0)
,fMasks(0)
,fCompress(kTRUE)
// AliTRDdigitizer constructor
//
- Init();
-
}
//_____________________________________________________________________________
,fSDigitsManagerList(0)
,fTRD(0)
,fGeo(0)
+ ,fMcmSim(new AliTRDmcmSim)
,fEvent(0)
,fMasks(0)
,fCompress(kTRUE)
// AliTRDdigitizer constructor
//
- Init();
-
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDdigitizer::Init()
-{
- //
- // Initialize the digitizer with default values
- //
-
- fRunLoader = 0;
- fDigitsManager = 0;
- fSDigitsManager = 0;
- fSDigitsManagerList = 0;
- fTRD = 0;
- fGeo = 0;
-
- fEvent = 0;
- fMasks = 0;
- fCompress = kTRUE;
- fSDigits = kFALSE;
- fMergeSignalOnly = kFALSE;
-
- return AliDigitizer::Init();
-
}
//_____________________________________________________________________________
,fSDigitsManagerList(0)
,fTRD(0)
,fGeo(0)
+ ,fMcmSim(new AliTRDmcmSim)
,fEvent(0)
,fMasks(0)
,fCompress(d.fCompress)
fDigitsManager = 0;
}
- if (fDigitsManager) { //typo? fSDigitsManager?
- delete fSDigitsManager;
+ if (fSDigitsManager) {
+ // s-digitsmanager will be deleted via list
fSDigitsManager = 0;
}
fMasks = 0;
}
+ if (fMcmSim) {
+ delete fMcmSim;
+ fMcmSim = 0;
+ }
+
if (fGeo) {
delete fGeo;
fGeo = 0;
}
//_____________________________________________________________________________
-void AliTRDdigitizer::Exec(Option_t *option)
+void AliTRDdigitizer::Exec(const Option_t * const option)
{
//
// Executes the merging
}
//_____________________________________________________________________________
-Bool_t AliTRDdigitizer::Open(AliRunLoader *runLoader, Int_t nEvent)
+Bool_t AliTRDdigitizer::Open(AliRunLoader * const runLoader, Int_t nEvent)
{
//
// Opens a ROOT-file with TRD-hits and reads in the hit-tree
Int_t *nhit = new Int_t[kNdet];
AliTRDarraySignal *signals = 0x0;
+
+ //
+ if (calibration->GetNumberOfTimeBinsDCS() != AliTRDSimParam::Instance()->GetNTimeBins()) {
+ AliWarning(Form("Number of time bins is different to OCDB value [SIM=%d, OCDB=%d]"
+ ,AliTRDSimParam::Instance()->GetNTimeBins()
+ ,calibration->GetNumberOfTimeBinsDCS()));
+ }
// Sort all hits according to detector number
if (!SortHits(hits,nhit)) {
AliError("Sorting hits failed");
+ delete [] hits;
+ delete [] nhit;
return kFALSE;
}
// Convert the hits of the current detector to detector signals
if (!ConvertHits(det,hits[det],nhit[det],signals)) {
AliError(Form("Conversion of hits failed for detector=%d",det));
+ delete [] hits;
+ delete [] nhit;
+ delete signals;
+ signals = 0x0;
return kFALSE;
}
// Convert the detector signals to digits or s-digits
if (!ConvertSignals(det,signals)) {
AliError(Form("Conversion of signals failed for detector=%d",det));
+ delete [] hits;
+ delete [] nhit;
+ delete signals;
+ signals = 0x0;
return kFALSE;
}
} // for: detector
+ if (!fSDigits) {
+ if (AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
+ if (trklLoader->Tree())
+ trklLoader->WriteData("OVERWRITE");
+ }
+ }
+
delete [] hits;
delete [] nhit;
+ // Save the values for the raw data headers
+ fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
+ fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
+
return kTRUE;
}
TTree *hitTree = gimme->TreeH();
if (hitTree == 0x0) {
AliError("Can not get TreeH");
+ delete [] lhit;
return kFALSE;
}
fTRD->SetTreeAddress();
}
//_____________________________________________________________________________
-Bool_t AliTRDdigitizer::ConvertHits(Int_t det, Float_t *hits, Int_t nhit
+Bool_t AliTRDdigitizer::ConvertHits(Int_t det
+ , const Float_t * const hits
+ , Int_t nhit
, AliTRDarraySignal *signals)
{
//
* commonParam->GetSamplingFrequency())) - 1;
}
- Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
+ Int_t nTimeTotal = simParam->GetNTimeBins();
Float_t samplingRate = commonParam->GetSamplingFrequency();
Float_t elAttachProp = simParam->GetElAttachProp() / 100.0;
if (!Signal2ADC(det,signals)) {
return kFALSE;
}
+ // Run digital processing for digits
+ RunDigitalProcessing(det);
}
// Compress the arrays
Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
- Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
+ Int_t nTimeTotal = simParam->GetNTimeBins();
// The gainfactor calibration objects
const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
// Check whether pad is masked
// Bridged pads are not considered yet!!!
- if (calibration->IsPadMasked(det,col,row)) {
+ if (calibration->IsPadMasked(det,col,row) || calibration->IsPadNotConnected(det,col,row)) {
continue;
}
} // for: col
} // for: row
- // Run the digital processing in the MCM
- RunDigitalProcessing(digits, det);
-
return kTRUE;
}
Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
- Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
+ Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
// Get the container for the digits of this detector
}
+//_____________________________________________________________________________
+Bool_t AliTRDdigitizer::Digits2SDigits(AliTRDdigitsManager * const manDig
+ , AliTRDdigitsManager * const manSDig)
+{
+ //
+ // Converts digits into s-digits. Needed for embedding into real data.
+ //
+
+ AliDebug(1,"Start converting digits to s-digits");
+
+ if (!fGeo) {
+ fGeo = new AliTRDgeometry();
+ }
+
+ AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
+ if (!calibration) {
+ AliFatal("Could not get calibration object");
+ return kFALSE;
+ }
+
+ AliTRDSimParam *simParam = AliTRDSimParam::Instance();
+ if (!simParam) {
+ AliFatal("Could not get simulation parameters");
+ return kFALSE;
+ }
+
+ // Converts number of electrons to fC
+ const Double_t kEl2fC = 1.602e-19 * 1.0e15;
+
+ // Coupling factor
+ Double_t coupling = simParam->GetPadCoupling()
+ * simParam->GetTimeCoupling();
+ // Electronics conversion factor
+ Double_t convert = kEl2fC
+ * simParam->GetChipGain();
+ // ADC conversion factor
+ Double_t adcConvert = simParam->GetADCoutRange()
+ / simParam->GetADCinRange();
+ // The electronics baseline in mV
+ Double_t baseline = simParam->GetADCbaseline()
+ / adcConvert;
+ // The electronics baseline in electrons
+ //Double_t baselineEl = baseline
+ // / convert;
+
+ // The gainfactor calibration objects
+ //const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet();
+ //AliTRDCalROC *calGainFactorROC = 0;
+ //Float_t calGainFactorDetValue = 0.0;
+
+ Int_t row = 0;
+ Int_t col = 0;
+ Int_t time = 0;
+
+ for (Int_t det = 0; det < AliTRDgeometry::Ndet(); det++) {
+
+ Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
+ Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
+ Int_t nTimeTotal = manDig->GetDigitsParam()->GetNTimeBins(det);
+
+ // Get the calibration objects
+ //calGainFactorROC = calibration->GetGainFactorROC(det);
+ //calGainFactorDetValue = calGainFactorDet->GetValue(det);
+
+ // Get the digits
+ AliTRDarrayADC *digits = (AliTRDarrayADC *) manDig->GetDigits(det);
+
+ if (!manSDig->HasSDigits()) {
+ AliError("SDigits manager has no s-digits");
+ return kFALSE;
+ }
+ // Get the s-digits
+ AliTRDarraySignal *sdigits = (AliTRDarraySignal *) manSDig->GetSDigits(det);
+ AliTRDarrayDictionary *tracks0 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,0);
+ AliTRDarrayDictionary *tracks1 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,1);
+ AliTRDarrayDictionary *tracks2 = (AliTRDarrayDictionary *) manSDig->GetDictionary(det,2);
+ // Allocate memory space for the digits buffer
+ sdigits->Allocate(nRowMax,nColMax,nTimeTotal);
+ tracks0->Allocate(nRowMax,nColMax,nTimeTotal);
+ tracks1->Allocate(nRowMax,nColMax,nTimeTotal);
+ tracks2->Allocate(nRowMax,nColMax,nTimeTotal);
+
+ // Keep the digits param
+ manSDig->GetDigitsParam()->SetNTimeBinsAll(manDig->GetDigitsParam()->GetNTimeBins(0));
+ manSDig->GetDigitsParam()->SetADCbaselineAll(manDig->GetDigitsParam()->GetADCbaseline(0));
+
+ if (digits->HasData()) {
+
+ digits->Expand();
+
+ // Create the sdigits for this chamber
+ for (row = 0; row < nRowMax; row++ ) {
+ for (col = 0; col < nColMax; col++ ) {
+
+ // The gain factors
+ //Float_t padgain = calGainFactorDetValue
+ // * calGainFactorROC->GetValue(col,row);
+
+ for (time = 0; time < nTimeTotal; time++) {
+
+ Short_t adcVal = digits->GetData(row,col,time);
+ Double_t signal = (Double_t) adcVal;
+ // ADC -> signal in mV
+ signal /= adcConvert;
+ // Subtract baseline in mV
+ signal -= baseline;
+ // Signal in mV -> signal in #electrons
+ signal /= convert;
+ // Gain factor
+ //signal /= padgain; // Not needed for real data
+ // Pad and time coupling
+ signal /= coupling;
+
+ sdigits->SetData(row,col,time,signal);
+ tracks0->SetData(row,col,time,0);
+ tracks1->SetData(row,col,time,0);
+ tracks2->SetData(row,col,time,0);
+
+ } // for: time
+
+ } // for: col
+ } // for: row
+
+ } // if: has data
+
+ sdigits->Compress(0);
+ tracks0->Compress();
+ tracks1->Compress();
+ tracks2->Compress();
+
+ // No compress just remove
+ manDig->RemoveDigits(det);
+ manDig->RemoveDictionaries(det);
+
+ } // for: det
+
+ return kTRUE;
+
+}
+
//_____________________________________________________________________________
Bool_t AliTRDdigitizer::SDigits2Digits()
{
AliDebug(1,"Only one input file.");
}
- Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
Int_t iMerge = 0;
while (mergeSDigitsManager) {
iMerge++;
-
+
// Loop through the detectors
for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
+ Int_t nTimeTotal = fSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet);
+ if (mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet) != nTimeTotal) {
+ AliError(Form("Mismatch in the number of time bins [%d,%d] in detector %d"
+ ,nTimeTotal
+ ,mergeSDigitsManager->GetDigitsParam()->GetNTimeBins(iDet)
+ ,iDet));
+ return kFALSE;
+ }
+
Int_t nRowMax = fGeo->GetPadPlane(iDet)->GetNrows();
Int_t nColMax = fGeo->GetPadPlane(iDet)->GetNcols();
fSDigitsManager->RemoveDigits(det);
fSDigitsManager->RemoveDictionaries(det);
+ // Run digital processing
+ RunDigitalProcessing(det);
+
// Compress the arrays
CompressOutputArrays(det);
} // for: detector numbers
+ if (AliDataLoader *trklLoader = AliRunLoader::Instance()->GetLoader("TRDLoader")->GetDataLoader("tracklets")) {
+ if (trklLoader->Tree())
+ trklLoader->WriteData("OVERWRITE");
+ }
+
+ // Save the values for the raw data headers
+ fDigitsManager->GetDigitsParam()->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins());
+ fDigitsManager->GetDigitsParam()->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline());
return kTRUE;
Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows();
Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols();
- Int_t nTimeTotal = calibration->GetNumberOfTimeBins();
+ Int_t nTimeTotal = AliTRDSimParam::Instance()->GetNTimeBins();
Int_t row = 0;
Int_t col = 0;
}
//_____________________________________________________________________________
-void AliTRDdigitizer::RunDigitalProcessing(AliTRDarrayADC *digits, Int_t det)
+void AliTRDdigitizer::RunDigitalProcessing(Int_t det)
{
//
// Run the digital processing in the TRAP
AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
- //Create and initialize the mcm object
- AliTRDmcmSim* mcmfast = new AliTRDmcmSim();
+ AliTRDarrayADC *digits = fDigitsManager->GetDigits(det);
+ if (!digits)
+ return;
//Call the methods in the mcm class using the temporary array as input
for(Int_t rob = 0; rob < digits->GetNrow() / 2; rob++)
{
for(Int_t mcm = 0; mcm < 16; mcm++)
{
- mcmfast->Init(det, rob, mcm);
- mcmfast->SetData(digits);
- mcmfast->Filter();
- if (feeParam->GetTracklet())
- mcmfast->Tracklet();
- mcmfast->ZSMapping();
- mcmfast->WriteData(digits);
+ fMcmSim->Init(det, rob, mcm);
+ fMcmSim->SetDataByPad(digits, fDigitsManager);
+ fMcmSim->Filter();
+ if (feeParam->GetTracklet()) {
+ fMcmSim->Tracklet();
+ fMcmSim->StoreTracklets();
+ }
+ fMcmSim->ZSMapping();
+ fMcmSim->WriteData(digits);
}
}
-
- delete mcmfast;
}
+