//#include "Riostream.h"
//#include "TFile.h"
+#include "TMath.h"
#include "TH1F.h"
#include "TTree.h"
#include "TRandom.h"
#include "AliLoader.h"
#include "AliLog.h"
-#include "AliRunDigitizer.h"
+#include "AliDigitizationInput.h"
#include "AliRunLoader.h"
#include "AliRun.h"
#include "AliTOFcalib.h"
-//#include "AliTOFChannelOnline.h"
-#include "AliTOFChannelOffline.h"
+//#include "AliTOFChannelOnlineArray.h"
+//#include "AliTOFChannelOnlineStatusArray.h"
+//#include "AliTOFChannelOffline.h"
#include "AliTOFDigitizer.h"
#include "AliTOFdigit.h"
#include "AliTOFHitMap.h"
#include "AliTOFSDigit.h"
#include "AliTOF.h"
-extern TDirectory *gDirectory;
-//extern TFile *gFile;
extern TRandom *gRandom;
extern AliRun *gAlice;
}
//___________________________________________
-AliTOFDigitizer::AliTOFDigitizer(AliRunDigitizer* manager):
- AliDigitizer(manager),
+AliTOFDigitizer::AliTOFDigitizer(AliDigitizationInput* digInput):
+ AliDigitizer(digInput),
fDigits(new TClonesArray("AliTOFdigit",4000)),
fSDigitsArray(new TClonesArray("AliTOFSDigit",1000)),
fhitMap(0x0),
//---------------------------------------------------------------------
-void AliTOFDigitizer::Exec(Option_t* /*option*/)
+void AliTOFDigitizer::Digitize(Option_t* /*option*/)
{
//
// Perform digitization and merging.
AliTOF * tof = (AliTOF *) gAlice->GetDetector("TOF") ;
//Make branches
- char branchname[20];
- sprintf (branchname, "%s", tof->GetName ());
+
+ const Int_t kSize = 20;
+ char branchname[kSize];
+ snprintf(branchname,kSize,"%s", tof->GetName ());
- AliRunLoader* outrl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+ AliRunLoader* outrl = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
if (outrl == 0x0)
{
AliError("Can not find Run Loader in output folder.");
// Loop over files to digitize
- for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
+ for (Int_t inputFile=0; inputFile<fDigInput->GetNinputs();
inputFile++) {
ReadSDigit(inputFile);
}
treeD->Fill();
AliDebug(2,"----------------------------------------");
- AliInfo(Form("%d digits have been created", fDigits->GetEntriesFast()));
+ AliDebug(1,Form("%d digits have been created", fDigits->GetEntriesFast()));
AliDebug(2,"----------------------------------------");
outgime->WriteDigits("OVERWRITE");
// get the total number of collected sdigits
Int_t ndig = fSDigitsArray->GetEntriesFast();
+ Int_t vol[5]={-1,-1,-1,-1,-1}; // location for a digit
+ Int_t digit[4] = {0,0,0,0}; // TOF digit variables
+ Int_t tracknum[AliTOFSDigit::kMAXDIGITS]; // contributing tracks for the current slot
+ for (Int_t aa=0; aa<AliTOFSDigit::kMAXDIGITS; aa++) tracknum[aa] = -1;
+
for (Int_t k = 0; k < ndig; k++) {
- Int_t vol[5]; // location for a digit
for (Int_t i=0; i<5; i++) vol[i] = -1;
// Get the information for this digit
// start loop on number of slots for current sdigit
for (Int_t islot = 0; islot < nslot; islot++) {
- Int_t digit[4] = {-1,-1,-1,-1}; // TOF digit variables
- Int_t tracknum[AliTOFSDigit::kMAXDIGITS]; // contributing tracks for the current slot
+ for (Int_t aa=0; aa<4; aa++) digit[aa] = 0; // TOF digit variables
+ for (Int_t aa=0; aa<AliTOFSDigit::kMAXDIGITS; aa++) tracknum[aa] = -1;
Int_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
Int_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
static TClonesArray sdigitsClonesArray("AliTOFSDigit", 1000);
sdigitsClonesArray.Clear();
- // get the treeS from manager
- AliRunLoader* rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+ // get the treeS from digInput
+ AliRunLoader* rl = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inputFile));
if (rl == 0x0)
{
AliError(Form("Can not find Run Loader in input %d folder.",inputFile));
if(!tofBranch){
AliFatal(Form("TOF branch not found for input %d",inputFile));
+ return;
}
tofBranch->SetAddress(&sdigitsDummyContainer);
// Loop through all entries in the tree
Int_t nbytes = 0;
+ Int_t vol[5]; // location for a sdigit
+ for (Int_t i=0; i<5; i++) vol[i] = -1;
+
for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
// Import the tree
for (Int_t k=0; k<ndig; k++) {
AliTOFSDigit *tofSdigit= (AliTOFSDigit*) sdigitsDummyContainer->UncheckedAt(k);
- Int_t vol[5]; // location for a sdigit
for (Int_t i=0; i<5; i++) vol[i] = -1;
// check the sdigit volume
//_____________________________________________________________________________
-void AliTOFDigitizer::CollectSDigit(AliTOFSDigit * sdigit)
+void AliTOFDigitizer::CollectSDigit(const AliTOFSDigit * const sdigit)
{
//
// Add a TOF sdigit in container
//_____________________________________________________________________________
void AliTOFDigitizer::InitDecalibration() const {
//
- //
+ // Initialize TOF digits decalibration
//
+ fCalib->Init();
+ /*
fCalib->CreateCalArrays();
fCalib->ReadSimHistoFromCDB("TOF/Calib", -1); // use AliCDBManager's number
fCalib->ReadParOfflineFromCDB("TOF/Calib", -1); // use AliCDBManager's number
+ */
+}
+//---------------------------------------------------------------------
+void AliTOFDigitizer::DecalibrateTOFSignal() {
+ //
+ // Decalibrate TOF signals according to OCDB parameters
+ //
+
+ Double_t time=0., tot=0., corr=0.;
+ Int_t deltaBC=0, l0l1=0, tdcBin=0;
+ Int_t index = -1;
+ Int_t detId[5] ={-1,-1,-1,-1,-1};
+ UInt_t timestamp=0;
+
+ Int_t ndigits = fDigits->GetEntriesFast();
+ // Loop on TOF Digits
+ for (Int_t i=0;i<ndigits;i++){
+ AliTOFdigit * dig = (AliTOFdigit*)fDigits->At(i);
+ detId[0] = dig->GetSector();
+ detId[1] = dig->GetPlate();
+ detId[2] = dig->GetStrip();
+ detId[3] = dig->GetPadz();
+ detId[4] = dig->GetPadx();
+ dig->SetTdcND(dig->GetTdc()); // save the non decalibrated time
+
+ index = AliTOFGeometry::GetIndex(detId); // The channel index
+
+ // Read Calibration parameters from the CDB
+ // get digit info
+ time = dig->GetTdc() * AliTOFGeometry::TdcBinWidth(); /* ps */
+ tot = dig->GetToT() * AliTOFGeometry::ToTBinWidth() * 1.e-3; /* ns */
+ deltaBC = 0;//dig->GetDeltaBC();
+ l0l1 = 0;//dig->GetL0L1Latency();
+
+ // get correction
+ corr = fCalib->GetTimeCorrection(index, tot, deltaBC, l0l1, timestamp); /* ps */
+ AliDebug(2, Form("calibrate index %d: time=%f (ps) tot=%f (ns) deltaBC=%d l0l1=%d timestamp=%d corr=%f (ps)",
+ index, time, tot, deltaBC, l0l1, timestamp, corr));
+
+ // apply time correction
+ time += corr;
+
+ // convert in TDC bins and set digit
+ //tdcBin = (Int_t)(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+ tdcBin = TMath::Nint(time / AliTOFGeometry::TdcBinWidth()); //the corrected time (tdc counts)
+ dig->SetTdc(tdcBin);
+
+ }
+
+ AliDebug(1,"Simulating miscalibrated digits");
+
+ return;
}
+
//---------------------------------------------------------------------
-void AliTOFDigitizer::DecalibrateTOFSignal(){
+/*
+void AliTOFDigitizer::DecalibrateTOFSignal(){ // Old implementation
// Read Calibration parameters from the CDB
return;
}
-
+*/