* provided "as is" without express or implied warranty. *
**************************************************************************/
-//_________________________________________________________________________
-// This is a TTask that makes TOF-Digits out of TOF-SDigits.
-// The simulation of the detector is performed at sdigits level:
-// during digitization the unique task is the sum of all sdigits in the
-// same pad.
-// Digits are written to TreeD in branch "TOF".
-//
-// -- Author : F. Pierella (Bologna University) pierella@bo.infn.it
-//////////////////////////////////////////////////////////////////////////////
-
-
-#include <stdlib.h>
-#include <Riostream.h>
-#include <TTree.h>
-#include <TVector.h>
-#include <TObjArray.h>
-#include <TFile.h>
-#include <TDirectory.h>
-#include <TRandom.h>
-#include "TF1.h"
+//_________________________________________________________________________//
+// //
+// This is a TTask that makes TOF-Digits out of TOF-SDigits. //
+// The simulation of the detector is performed at sdigits level: //
+// during digitization the unique task is the sum of all sdigits in the //
+// same pad. //
+// Digits are written to TreeD in branch "TOF". //
+// //
+// -- Author : F. Pierella (Bologna University) pierella@bo.infn.it //
+// //
+//_________________________________________________________________________//
+
+#include "Riostream.h"
+
+#include "TFile.h"
#include "TH1F.h"
-#include "TList.h"
+#include "TTree.h"
#include "TRandom.h"
-#include "AliLog.h"
-#include "AliRun.h"
-#include "AliRunLoader.h"
#include "AliLoader.h"
-#include "AliDigitizer.h"
+#include "AliLog.h"
#include "AliRunDigitizer.h"
-#include "AliPDG.h"
+#include "AliRunLoader.h"
+#include "AliRun.h"
-#include "AliTOF.h"
+#include "AliTOFCal.h"
+#include "AliTOFcalib.h"
+#include "AliTOFChannel.h"
#include "AliTOFDigitizer.h"
-#include "AliTOFSDigitizer.h"
-#include "AliTOFhit.h"
#include "AliTOFdigit.h"
-#include "AliTOFSDigit.h"
#include "AliTOFHitMap.h"
-#include "AliTOFChannel.h"
-#include "AliTOFCal.h"
#include "AliTOFGeometryV5.h"
+#include "AliTOFSDigit.h"
+#include "AliTOF.h"
+
+extern TDirectory *gDirectory;
+extern TFile *gFile;
+extern TRandom *gRandom;
+
+extern AliRun *gAlice;
+
ClassImp(AliTOFDigitizer)
//___________________________________________
- AliTOFDigitizer::AliTOFDigitizer() :AliDigitizer()
+ AliTOFDigitizer::AliTOFDigitizer() :
+ AliDigitizer(),
+ fGeom(0x0),
+ fDigits(0x0),
+ fSDigitsArray(0x0),
+ fhitMap(0x0)
{
// Default ctor - don't use it
- fDigits=0;
- fSDigitsArray=0;
- fhitMap=0;
- fGeom=0x0;
}
//___________________________________________
-AliTOFDigitizer::AliTOFDigitizer(AliRunDigitizer* manager)
- :AliDigitizer(manager)
+AliTOFDigitizer::AliTOFDigitizer(AliRunDigitizer* manager):
+ AliDigitizer(manager),
+ fGeom(0x0),
+ fDigits(0x0),
+ fSDigitsArray(0x0),
+ fhitMap(0x0)
+{
+ //ctor with RunDigitizer
+}
+
+//------------------------------------------------------------------------
+AliTOFDigitizer::AliTOFDigitizer(const AliTOFDigitizer &source):
+ AliDigitizer(source),
+ fGeom(0x0),
+ fDigits(0),
+ fSDigitsArray(0),
+ fhitMap(0)
+{
+ // copy constructor
+ this->fDigits=source.fDigits;
+ this->fSDigitsArray=source.fSDigitsArray;
+ this->fhitMap=source.fhitMap;
+ this->fGeom=source.fGeom;
+
+}
+
+//------------------------------------------------------------------------
+ AliTOFDigitizer& AliTOFDigitizer::operator=(const AliTOFDigitizer &source)
{
- fDigits=0;
- fSDigitsArray=0;
- fhitMap=0;
- fGeom=0x0;
+ // ass. op.
+ this->fDigits=source.fDigits;
+ this->fSDigitsArray=source.fSDigitsArray;
+ this->fhitMap=source.fhitMap;
+ this->fGeom=source.fGeom;
+ return *this;
+
}
//------------------------------------------------------------------------
//------------------- Dump section ----------------------
if(k<ndump){
- cout << k << "-th | " << "Sector " << sector << " | Plate " << plate << " | Strip " << strip << " | PadZ " << padz << " | PadX " << padx << endl;
- cout << k << "-th sdigit" << endl;
- cout << "----------------------------------------------------"<< endl;
+ AliInfo(Form("%2i-th | Sector %2i | Plate %1i | Strip %2i | PadZ %1i | PadX %2i ", k, sector, plate, strip, padz, padx));
+ AliInfo(Form("%2i-th", k));
+ AliInfo("----------------------------------------------------");
}
// ------------------------------------------------------
// start loop on number of slots for current sdigit
for (Int_t islot = 0; islot < nslot; islot++) {
- Float_t digit[2]; // TOF digit variables
- Int_t tracknum[kMAXDIGITS]; // contributing tracks for the current slot
+ Int_t digit[4] = {-1,-1,-1,-1}; // TOF digit variables
+ Int_t tracknum[AliTOFSDigit::kMAXDIGITS]; // contributing tracks for the current slot
- Float_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
- Float_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
+ Int_t tdc=tofsdigit->GetTdc(islot); digit[0]=tdc;
+ Int_t adc=tofsdigit->GetAdc(islot); digit[1]=adc;
tracknum[0]=tofsdigit->GetTrack(islot,0);
tracknum[1]=tofsdigit->GetTrack(islot,1);
}
//_____________________________________________________________________________
-void AliTOFDigitizer::InitDecalibration( AliTOFcalib *calib){
- calib->ReadSimParFromCDB("TOF/CDB", 1);
+void AliTOFDigitizer::InitDecalibration( AliTOFcalib *calib) const {
+ calib->ReadSimParFromCDB("TOF/Calib", -1); // use AliCDBManager's number
}
//---------------------------------------------------------------------
void AliTOFDigitizer::DecalibrateTOFSignal( AliTOFcalib *calib){
AliTOFCal * cal= calib->GetTOFCalSimArray();
- AliInfo(Form("Size of AliTOFCal = %i",cal->NPads()));
- for (Int_t ipad = 0 ; ipad<cal->NPads(); ipad++){
- AliTOFChannel *CalChannel = cal->GetChannel(ipad);
- Float_t par[6];
- for (Int_t j = 0; j<6; j++){
- par[j]=CalChannel->GetSlewPar(j);
- }
- }
+ AliDebug(2,Form("Size of AliTOFCal = %i",cal->NPads()));
// Initialize Quantities to Simulate ToT Spectra
-
TH1F * hToT= calib->GetTOFSimToT();
Int_t nbins = hToT->GetNbinsX();
- Float_t Delta = hToT->GetBinWidth(1);
- Float_t maxch = hToT->GetBinLowEdge(nbins)+Delta;
+ Float_t delta = hToT->GetBinWidth(1);
+ Float_t maxch = hToT->GetBinLowEdge(nbins)+delta;
Float_t minch = hToT->GetBinLowEdge(1);
Float_t max=0,min=0; //maximum and minimum value of the distribution
Int_t maxbin=0,minbin=0; //maximum and minimum bin of the distribution
+
for (Int_t ii=nbins; ii>0; ii--){
if (hToT->GetBinContent(ii)!= 0) {
- max = maxch - (nbins-ii-1)*Delta;
+ max = maxch - (nbins-ii-1)*delta;
maxbin = ii;
break;}
}
for (Int_t j=1; j<nbins; j++){
if (hToT->GetBinContent(j)!= 0) {
- min = minch + (j-1)*Delta;
+ min = minch + (j-1)*delta;
minbin = j;
break;}
}
- Float_t MaxToT=max;
- Float_t MinToT=min;
- Float_t MaxToTDistr=hToT->GetMaximum();
-
+ Float_t maxToT=max;
+ Float_t minToT=min;
+
+ Float_t maxToTDistr=hToT->GetMaximum();
+
+ AliDebug (1, Form(" The minimum ToT = %f", minToT));
+ AliDebug (1, Form(" The maximum ToT = %f", maxToT));
+ AliDebug (1, Form(" The maximum peak in ToT = %f", maxToTDistr));
+
// Loop on TOF Digits
- Bool_t dbEntry=kFALSE;
+ Bool_t isToTSimulated=kFALSE;
+ Bool_t misCalibPars=kFALSE;
+ if(hToT->GetEntries()>0)isToTSimulated=kTRUE;
Int_t ndigits = fDigits->GetEntriesFast();
for (Int_t i=0;i<ndigits;i++){
AliTOFdigit * dig = (AliTOFdigit*)fDigits->At(i);
detId[2] = dig->GetStrip();
detId[3] = dig->GetPadz();
detId[4] = dig->GetPadx();
- // For Data with no Miscalibration, set ToT signal == Adc
- dig->SetToT(dig->GetAdc());
- if(hToT->GetEntries()>0){
+ dig->SetTdcND(dig->GetTdc()); // save the non decalibrated time
+ if(isToTSimulated){
+
+ //A realistic ToT Spectrum was found in input,
+ //decalibrated TOF Digits likely to be simulated....
+
+ Int_t index = calib->GetIndex(detId); // The channel index
+ AliTOFChannel *calChannel = cal->GetChannel(index); //retrieve the info
+ Float_t timedelay = calChannel->GetDelay(); //The global channel delay
+ Float_t par[6]; // time slewing parameters
+
+ //check whether we actually ask for miscalibration
+
+ if(timedelay!=0)misCalibPars=kTRUE;
+ for (Int_t j = 0; j<6; j++){
+ par[j]=calChannel->GetSlewPar(j);
+ if(par[j]!=0)misCalibPars=kTRUE;
+ }
+ AliDebug(2,Form(" Calib Pars = %f, %f, %f, %f, %f, %f ",par[0],par[1],par[2],par[3],par[4],par[5]));
+ // Now generate Realistic ToT distribution from TestBeam Data.
+ // Tot is in ns, assuming a Matching Window of 10 ns.
+
+ Float_t simToT = 0;
Float_t trix = 0;
Float_t triy = 0;
- Float_t SimToT = 0;
- while (SimToT <= triy){
+ Double_t timeCorr;
+ Double_t tToT;
+ while (simToT <= triy){
trix = gRandom->Rndm(i);
triy = gRandom->Rndm(i);
- trix = (MaxToT-MinToT)*trix + MinToT;
- triy = MaxToTDistr*triy;
+ trix = (maxToT-minToT)*trix + minToT;
+ triy = maxToTDistr*triy;
Int_t binx=hToT->FindBin(trix);
- SimToT=hToT->GetBinContent(binx);
+ simToT=hToT->GetBinContent(binx);
+ }
+ // the generated ToT (ns)
+ tToT= (Double_t) trix; // to apply slewing we start from ns..
+ // transform TOF signal in ns
+ AliDebug(2,Form(" The Initial Time (counts): %i: ",dig->GetTdc()));
+ AliDebug(2,Form(" Time before miscalibration (ps) %e: ",dig->GetTdc()*AliTOFGeometry::TdcBinWidth()));
+ // add slewing effect
+ timeCorr=par[0] + tToT*(par[1] +tToT*(par[2] +tToT*(par[3] +tToT*(par[4] +tToT*par[5]))));
+ AliDebug(2,Form(" The Time slewing (ns): %f: ",timeCorr));
+ // add global time shift
+ timeCorr = timeCorr + timedelay;
+ AliDebug(2,Form(" The Time Slewing+ delay (ns): %f: ",timeCorr));
+ //convert to ps
+ timeCorr*=1E3;
+ Double_t timeMis = (Double_t)(dig->GetTdc())*AliTOFGeometry::TdcBinWidth();
+ timeMis = timeMis+timeCorr;
+ AliDebug(2,Form(" The Miscalibrated time (ps): %e: ",timeMis));
+
+ // now update the digit info
+
+ Int_t tdcCorr= (Int_t)(timeMis/AliTOFGeometry::TdcBinWidth());
+ AliDebug(2,Form(" Final Time (counts): %i: ",tdcCorr));
+ // Setting Decalibrated Time signal (TDC counts)
+ dig->SetTdc(tdcCorr);
+ // Setting realistic ToT signal (TDC counts)
+ tToT*=1E3; //back to ps
+ Int_t tot=(Int_t)(tToT/AliTOFGeometry::ToTBinWidth());//(factor 1E3 as input ToT is in ns)
+ dig->SetToT(tot);
+ AliDebug(2,Form(" Final Time and ToT (counts): %i: ",dig->GetTdc(),dig->GetToT()));
+ if(tdcCorr<0){
+ AliWarning (Form(" The bad Slewed Time(TDC counts)= %i ", tdcCorr));
+ AliWarning(Form(" The bad ToT (TDC counts)= %i ", tot));
}
- // Setting realistic ToT signal (only for Miscalibrated Data)
- dig->SetToT(trix);
}
- Int_t index = calib->GetIndex(detId);
- AliTOFChannel *CalChannel = cal->GetChannel(index);
- Float_t par[6];
- for (Int_t j = 0; j<6; j++){
- par[j]=CalChannel->GetSlewPar(j);
- if(par[j]!=0)dbEntry=kTRUE;
+ else{
+ // For Data with no Miscalibration, set ToT signal == Adc
+ dig->SetToT((Int_t)(dig->GetAdc()/AliTOFGeometry::ToTBinWidth())); //remove the factor 10^3 just to have a reasonable ToT range for raw data simulation even in the case of non-realistic ToT distribution (n.b. fAdc is practically an arbitrary quantity, and ToT has no impact on the TOF reco for non-miscalibrated digits)
}
-
- Float_t ToT= dig->GetToT();
- dig->SetTdcND(dig->GetTdc());
- Float_t tdc = ((dig->GetTdc())*AliTOFGeometry::TdcBinWidth()+32)*1.E-3; //tof signal in ns
- Float_t timeoffset=par[0] + ToT*par[1] +ToT*ToT*par[2] +ToT*ToT*ToT*par[3] +ToT*ToT*ToT*ToT*par[4] +ToT*ToT*ToT*ToT*ToT*par[5];
- Float_t timeSlewed = tdc + timeoffset;
- // Setting Decalibrated Time signal
- dig->SetTdc((timeSlewed*1E3-32)/AliTOFGeometry::TdcBinWidth());
}
- if(hToT->GetEntries()<=0 || !dbEntry){
- AliInfo("Standard Production, no miscalibrated digits");
+ if(!isToTSimulated){
+ AliDebug(1,"Standard Production, no miscalibrated digits");
}else{
- AliInfo("Miscalibrated digits");
+ if(!misCalibPars){
+ AliDebug(1,"Standard Production, no miscalibrated digits");
+ }
+ else {
+ AliDebug(1,"Simulating miscalibrated digits");
+ }
}
-
return;
}