//---------------------------------------------------------------------- // File and Version Information: // $Id: // // Description: // Class PndEmcWaveformToDigi. Module to take the ADC waveforms and produces digi. // // Software developed for the BaBar Detector at the SLAC B-Factory. // Adapted for the PANDA experiment at GSI // // Author List: // Phil Strother Original Author // Dima Melnichuk - adaption for PANDA // Copyright Information: // Copyright (C) 1996 Imperial College // //---------------------------------------------------------------------- #include "PndEmcWaveformToDigi.h" #include "PndEmcWaveform.h" #include "PndEmcDigi.h" #include "PndEmcDigiPar.h" #include "PndEmcRecoPar.h" #include "PndEmcAsicPulseshape.h" #include "PndEmcPSAParabolic.h" #include "PndEmcPSAMatchedDigiFilter.h" #include "FairRootManager.h" #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "TClonesArray.h" #include "TStopwatch.h" #include //#include using std::cout; using std::endl; using std::fstream; PndEmcWaveformToDigi::PndEmcWaveformToDigi(Int_t verbose, Bool_t storedigis): fWaveformArray(new TClonesArray()), fDigiArray(new TClonesArray()), fSampleRate(0), fSampleRate_PMT(0), fEnergyDigiThreshold(0), fASIC_Shaping_int_time(0), fPMT_Shaping_int_time(0), fPMT_Shaping_diff_time(0), fCrystal_time_constant(0), fShashlyk_time_constant(0), fNumber_of_samples_in_waveform(0), fNumber_of_samples_in_waveform_pmt(0), fDigiPosMethod(0), fEmcDigiRescaleFactor(0), fEmcDigiPositionDepthPWO(0), fEmcDigiPositionDepthShashlyk(0), fPulseshape(0), fPulseshape_pmt(0), fpsaAlgorithm(0), fpsaAlgorithm_pmt(0), fDigiPar(new PndEmcDigiPar()), fRecoPar(new PndEmcRecoPar()), fVerbose(verbose), fStoreDigis(storedigis), fWfNormalisation(0), fWfNormalisation_pmt(0), fTimeOrderedDigi(kFALSE) { fDigiPosMethod="depth";// "surface" or "depth" fEmcDigiRescaleFactor=1.08; //fPndEmcDigiPositionDepth=6.2; } //-------------- // Destructor -- //-------------- PndEmcWaveformToDigi::~PndEmcWaveformToDigi() { if (fDataBuffer!= 0) delete fDataBuffer; } InitStatus PndEmcWaveformToDigi::Init() { // Get RootManager FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { cout << "-E- PndEmcWaveformToDigi::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array fWaveformArray = (TClonesArray*) ioman->GetObject("EmcWaveform"); if ( ! fWaveformArray ) { cout << "-W- PndEmcWaveformToDigi::Init: " << "No PndEmcWaveform array!" << endl; return kERROR; } // Create and register output array // fDigiArray = new TClonesArray("PndEmcDigi"); // ioman->Register("EmcDigi","Emc",fDigiArray,fStoreDigis); fDataBuffer = new PndEmcDigiWriteoutBuffer("EmcDigi", "Emc", fStoreDigis); fDataBuffer = (PndEmcDigiWriteoutBuffer*)ioman->RegisterWriteoutBuffer("EmcDigi", fDataBuffer); fDataBuffer->ActivateBuffering(fTimeOrderedDigi); fSampleRate=fDigiPar->GetSampleRate(); fSampleRate_PMT=fDigiPar->GetSampleRate_PMT(); fASIC_Shaping_int_time=fDigiPar->GetASIC_Shaping_int_time(); //s fPMT_Shaping_int_time=fDigiPar->GetPMT_Shaping_int_time(); //s fPMT_Shaping_diff_time=fDigiPar->GetPMT_Shaping_diff_time(); //s fCrystal_time_constant=fDigiPar->GetCrystal_time_constant(); //s fShashlyk_time_constant=fDigiPar->GetShashlyk_time_constant(); //s fNumber_of_samples_in_waveform=fDigiPar->GetNumber_of_samples_in_waveform(); fNumber_of_samples_in_waveform_pmt=fDigiPar->GetNumber_of_samples_in_waveform_pmt(); fEnergyDigiThreshold=fDigiPar->GetEnergyDigiThreshold(); fEmcDigiPositionDepthPWO=fRecoPar->GetEmcDigiPositionDepthPWO(); fEmcDigiPositionDepthShashlyk=fRecoPar->GetEmcDigiPositionDepthShashlyk(); cout<<"fEmcDigiPositionDepthPWO: "< params; params.push_back(30); // width params.push_back(fSampleRate); // Sample rate fpsaAlgorithm = new PndEmcPSAMatchedDigiFilter(params,fPulseshape); } if(fpsaAlgorithm_pmt == NULL){ // Pulse shape analysis algorithm. // Simple parabolic fit. fpsaAlgorithm_pmt = new PndEmcPSAParabolic(); } // Determine normalisation constant for PndEmcWaveform PndEmcWaveform *tmpwaveform=new PndEmcWaveform(0,101010001, fNumber_of_samples_in_waveform); PndEmcWaveform *tmpwaveform2=new PndEmcWaveform(0,101010001, fNumber_of_samples_in_waveform_pmt); PndEmcHit *gevHit=new PndEmcHit(); gevHit->SetEnergy(1.0); gevHit->SetTime(0.); tmpwaveform->UpdateWaveform(gevHit, 0, false, 1., 0., fSampleRate, fPulseshape); tmpwaveform2->UpdateWaveform(gevHit, 0, false, 1., 0., fSampleRate_PMT, fPulseshape_pmt); Double_t tmpPeakPosition; Double_t tmpPeakPosition2; fpsaAlgorithm->Process(tmpwaveform,fWfNormalisation,tmpPeakPosition); fpsaAlgorithm_pmt->Process(tmpwaveform2,fWfNormalisation_pmt,tmpPeakPosition2); delete tmpwaveform; delete tmpwaveform2; cout << "-I- PndEmcWaveformToDigi: Intialization successfull" << endl; return kSUCCESS; } void PndEmcWaveformToDigi::Exec(Option_t* opt) { TStopwatch timer; if (fVerbose>2){ timer.Start(); } Double_t EventTime = FairRootManager::Instance()->GetEventTime(); Double_t peakPosition; Double_t energy; Double_t digi_time; Int_t hitIndex; Int_t nHits; Int_t detId; Int_t trackId; Int_t module; Int_t nWaveforms = fWaveformArray->GetEntriesFast(); PndEmcAbsPSA *thePSA; Double_t theEnergyNorm; Double_t theSampleRate; //cout<<"PndEmcWaveformToDigi: "<At(iWaveform); hitIndex=theWaveform->GetHitIndex(); detId=theWaveform->GetDetectorId(); trackId=theWaveform->GetTrackId(); module=theWaveform->GetModule(); Double_t timeshift; // how maximum is shifted if(module == 5){ thePSA = fpsaAlgorithm_pmt; theEnergyNorm = fWfNormalisation_pmt; theSampleRate = fSampleRate_PMT; } else { thePSA = fpsaAlgorithm; theEnergyNorm = fWfNormalisation; theSampleRate = fSampleRate; } nHits = thePSA->Process(theWaveform); for(Int_t i = 0 ; i< nHits; i++){ thePSA->GetHit(i,energy,peakPosition); energy/=theEnergyNorm; digi_time=peakPosition/fSampleRate*1e9;//ns if (energy>fEnergyDigiThreshold) { Double_t timestamp=EventTime+digi_time; PndEmcDigi* myDigi = new PndEmcDigi(trackId,detId, energy, timestamp, hitIndex); myDigi->AddLink(FairLink("EmcWaveform", iWaveform)); fDataBuffer->FillNewData(myDigi, 300, 300); // 300 ns if (fVerbose>2){ cout<<"timestamp="<GetRuntimeDb(); if ( ! db ) Fatal("SetParContainers", "No runtime database"); // Get Emc digitisation parameter container fDigiPar = (PndEmcDigiPar*) db->getContainer("PndEmcDigiPar"); // Get Emc reconstruction parameter container fRecoPar = (PndEmcRecoPar*) db->getContainer("PndEmcRecoPar"); } void PndEmcWaveformToDigi::SetStorageOfData(Bool_t val) { fStoreDigis = val; return; } ClassImp(PndEmcWaveformToDigi)