X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TOF%2FAliTOFDigitizer.cxx;h=aa9eb3dc8b62d921556ac9cc94df5a2314ec35d6;hb=064739fd1ee1ae98d4bee3fa92ddb7034ff6a57b;hp=c1a058bc38db01f037ec4b81fb9786f94b478502;hpb=c630773fea57644d72af47a03c8028b6bd64e6d3;p=u%2Fmrichter%2FAliRoot.git diff --git a/TOF/AliTOFDigitizer.cxx b/TOF/AliTOFDigitizer.cxx index c1a058bc38d..aa9eb3dc8b6 100644 --- a/TOF/AliTOFDigitizer.cxx +++ b/TOF/AliTOFDigitizer.cxx @@ -28,6 +28,7 @@ //#include "Riostream.h" //#include "TFile.h" +#include "TMath.h" #include "TH1F.h" #include "TTree.h" #include "TRandom.h" @@ -35,13 +36,14 @@ #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" @@ -49,8 +51,6 @@ #include "AliTOFSDigit.h" #include "AliTOF.h" -extern TDirectory *gDirectory; -//extern TFile *gFile; extern TRandom *gRandom; extern AliRun *gAlice; @@ -71,8 +71,8 @@ ClassImp(AliTOFDigitizer) } //___________________________________________ -AliTOFDigitizer::AliTOFDigitizer(AliRunDigitizer* manager): - AliDigitizer(manager), +AliTOFDigitizer::AliTOFDigitizer(AliDigitizationInput* digInput): + AliDigitizer(digInput), fDigits(new TClonesArray("AliTOFdigit",4000)), fSDigitsArray(new TClonesArray("AliTOFSDigit",1000)), fhitMap(0x0), @@ -129,7 +129,7 @@ AliTOFDigitizer::~AliTOFDigitizer() //--------------------------------------------------------------------- -void AliTOFDigitizer::Exec(Option_t* /*option*/) +void AliTOFDigitizer::Digitize(Option_t* /*option*/) { // // Perform digitization and merging. @@ -148,35 +148,18 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/) 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."); return; } - /* - outrl->CdGAFile(); - TFile *in=(TFile*)gFile; - TDirectory *savedir=gDirectory; - - - //when fGeom was needed - - if (!in->IsOpen()) { - AliWarning("Geometry file is not open default TOF geometry will be used"); - fGeom = new AliTOFGeometry(); - } - else { - in->cd(); - fGeom = (AliTOFGeometry*)in->Get("TOFgeometry"); - } - - savedir->cd(); - */ AliLoader* outgime = outrl->GetLoader("TOFLoader"); if (outgime == 0x0) { @@ -201,7 +184,7 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/) // Loop over files to digitize - for (Int_t inputFile=0; inputFileGetNinputs(); + for (Int_t inputFile=0; inputFileGetNinputs(); inputFile++) { ReadSDigit(inputFile); } @@ -215,9 +198,9 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/) treeD->Fill(); - AliInfo("----------------------------------------"); - AliInfo(Form("%d digits have been created", fDigits->GetEntriesFast())); - AliInfo("----------------------------------------"); + AliDebug(2,"----------------------------------------"); + AliDebug(1,Form("%d digits have been created", fDigits->GetEntriesFast())); + AliDebug(2,"----------------------------------------"); outgime->WriteDigits("OVERWRITE"); outgime->UnloadDigits(); @@ -237,9 +220,13 @@ void AliTOFDigitizer::CreateDigits() // 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; aa17 || plate<0 || plate >4 || padz<0 || padz>1 || padx<0 || padx>47); - if (isSDigitBad) { - //AliFatal("strange sdigit found"); - AliFatal(Form("strange sdigit found %3i %2i %2i %3i %3i", sector, plate, padz, padx, strip)); - } + if (isSDigitBad) + AliFatal(Form("strange sdigit found %2d %1d %2d %1d %2d", sector, plate, strip, padz, padx)); //------------------------------------------------------- //------------------- Dump section ---------------------- - if(kGetTdc(islot); digit[0]=tdc; Int_t adc=tofsdigit->GetAdc(islot); digit[1]=adc; @@ -304,7 +288,7 @@ void AliTOFDigitizer::CreateDigits() } // end loop on sdigits - end digitizing all collected sdigits //Insert Decalibration - AliInfo("in digitizer, create digits"); + AliDebug(2,"in digitizer, create digits"); DecalibrateTOFSignal(); } @@ -322,8 +306,8 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile ) 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)); @@ -360,6 +344,7 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile ) if(!tofBranch){ AliFatal(Form("TOF branch not found for input %d",inputFile)); + return; } tofBranch->SetAddress(&sdigitsDummyContainer); @@ -369,6 +354,9 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile ) // 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 @@ -380,7 +368,6 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile ) for (Int_t k=0; kUncheckedAt(k); - Int_t vol[5]; // location for a sdigit for (Int_t i=0; i<5; i++) vol[i] = -1; // check the sdigit volume @@ -409,7 +396,7 @@ void AliTOFDigitizer::ReadSDigit(Int_t inputFile ) //_____________________________________________________________________________ -void AliTOFDigitizer::CollectSDigit(AliTOFSDigit * sdigit) +void AliTOFDigitizer::CollectSDigit(const AliTOFSDigit * const sdigit) { // // Add a TOF sdigit in container @@ -424,15 +411,71 @@ void AliTOFDigitizer::CollectSDigit(AliTOFSDigit * sdigit) //_____________________________________________________________________________ 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;iAt(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 @@ -545,10 +588,10 @@ void AliTOFDigitizer::DecalibrateTOFSignal(){ 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: , %i:",dig->GetTdc(),dig->GetToT())); + AliDebug(2,Form(" Final Time and ToT (counts): %d: , %d:",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)); + AliWarning (Form(" The bad Slewed Time(TDC counts)= %d ", tdcCorr)); + AliWarning(Form(" The bad ToT (TDC counts)= %d ", tot)); } } else{ @@ -557,16 +600,14 @@ void AliTOFDigitizer::DecalibrateTOFSignal(){ } } - if(!isToTSimulated){ - AliDebug(1,"Standard Production, no miscalibrated digits"); - }else{ - if(!misCalibPars){ - AliDebug(1,"Standard Production, no miscalibrated digits"); - } - else { - AliDebug(1,"Simulating miscalibrated digits"); - } - } + if(!isToTSimulated) + AliDebug(1,"Standard Production, no miscalibrated digits"); + else + if(!misCalibPars) + AliDebug(1,"Standard Production, no miscalibrated digits"); + else + AliDebug(1,"Simulating miscalibrated digits"); + return; } - +*/