//---------------------------------------------------------------------- // File and Version Information: // $Id: // // Description: // Class PndEmcHitsToWaveform. Module to take the hit list for the // calorimeter and make ADC waveforms from them. // // 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 "PndEmcHitsToWaveform.h" #include "FairEventHeader.h" #include "PndEmcHit.h" #include "PndEmcWaveform.h" #include "PndEmcAsicPulseshape.h" #include "PndEmcMapper.h" #include "PndEmcStructure.h" #include "PndEmcDigiPar.h" #include "PndEmcGeoPar.h" #include "PndEmcDataTypes.h" #include "TRandom.h" #include "FairRootManager.h" #include "FairRunAna.h" #include "FairRun.h" #include "FairRuntimeDb.h" #include "TGraph.h" #include "TFile.h" #include "TStopwatch.h" #include "TROOT.h" #include "TClonesArray.h" #include #include #include "PndEmcWaveformWriteoutBuffer.h" //#include //#include //typedef std::pair Element; //std::map > WaveformMap; using std::cout; using std::endl; using std::fstream; //#define TIMEBASEDSIM PndEmcHitsToWaveform::PndEmcHitsToWaveform(Int_t verbose, Bool_t storewaves): fHitArray(0), fWaveformArray(0), fOneBitResolution(0), fOneBitResolutionBW(0), fOneBitResolutionPMT(0), fNBits(0), fDetectedPhotonsPerMeV(0), fDetectedPhotonsPerMeV_PMT(0), fNPhotoElectronsPerMeVAPDBarrel(0), fNPhotoElectronsPerMeVAPDBWD(0), fNPhotoElectronsPerMeVVPT(0), fNPhotoElectronsPerMeVPMT(0), fSensitiveAreaAPD(0), fSensitiveAreaVPT(0), fQuantumEfficiencyAPD(0), fQuantumEfficiencyVPT(0), fQuantumEfficiencyPMT(0), fExcessNoiseFactorAPD(0), fExcessNoiseFactorVPT(0), fExcessNoiseFactorPMT(0), fIncoherent_elec_noise_width_GeV_APD(0), fIncoherent_elec_noise_width_GeV_VPT(0), fEnergyRange(0), fEnergyRangeBW(0), fFirstSamplePhase(0), fNumber_of_samples_in_waveform(0), fNumber_of_samples_in_waveform_pmt(0), fASIC_Shaping_int_time(0), fPMT_Shaping_int_time(0), fPMT_Shaping_diff_time(0), fCrystal_time_constant(0), fShashlyk_time_constant(0), fShashlykSamplingFactor(0), fSampleRate(0), fSampleRate_PMT(0), fUse_shaped_noise(0), fUse_photon_statistic(0), fNoiseAllChannels(0), fMapVersion(0), fFirstADCBinTime(0), fGevPeakAnalogue(0), fGevPeakAnalogue_PMT(0), fDigiPar(new PndEmcDigiPar()), fGeoPar(new PndEmcGeoPar()), fVerbose(verbose), fStoreWaves(storewaves), fTimeOrderedWaveform(kFALSE), fDataBuffer(0) { } //-------------- // Destructor -- //-------------- PndEmcHitsToWaveform::~PndEmcHitsToWaveform() { // delete fw_endcap_noise; delete pulseshape1; delete pulseshape2; delete pulseshape3; } InitStatus PndEmcHitsToWaveform::Init() { // Get RootManager FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { cout << "-E- PndEmcHitsToWaveform::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array fHitArray = (TClonesArray*) ioman->GetObject("EmcHit"); if ( ! fHitArray ) { cout << "-W- PndEmcHitsToWaveform::Init: " << "No EmcHit array!" << endl; return kERROR; } if(fTimeOrderedWaveform){ // Create and register output buffer fDataBuffer = new PndEmcWaveformWriteoutBuffer("EmcWaveform", "Emc", fStoreWaves); fDataBuffer->ActivateBuffering(fTimeOrderedWaveform); fDataBuffer->SetVerbose(3); ioman->RegisterWriteoutBuffer("EmcWaveform", fDataBuffer); fDataBuffer->SaveToTree(kTRUE); }else{ // Create and register output array fWaveformArray = new TClonesArray("PndEmcWaveform"); ioman->Register("EmcWaveform","Emc",fWaveformArray,fStoreWaves); } cout << "-I- PndEmcHitsToWaveform: Intialization successfull" << endl; fNBits=fDigiPar->GetNBits(); fDetectedPhotonsPerMeV=fDigiPar->GetDetectedPhotonsPerMeV(); fDetectedPhotonsPerMeV_PMT=fDigiPar->GetDetectedPhotonsPerMeV_PMT(); fSensitiveAreaAPD=fDigiPar->GetSensitiveAreaAPD(); fSensitiveAreaVPT=fDigiPar->GetSensitiveAreaVPT(); fQuantumEfficiencyAPD=fDigiPar->GetQuantumEfficiencyAPD(); fQuantumEfficiencyVPT=fDigiPar->GetQuantumEfficiencyVPT(); fQuantumEfficiencyPMT=fDigiPar->GetQuantumEfficiencyPMT(); fExcessNoiseFactorAPD=fDigiPar->GetExcessNoiseFactorAPD(); fExcessNoiseFactorVPT=fDigiPar->GetExcessNoiseFactorVPT(); fExcessNoiseFactorPMT = fDigiPar->GetExcessNoiseFactorPMT(); fIncoherent_elec_noise_width_GeV_APD=fDigiPar->GetIncoherent_elec_noise_width_GeV_APD(); //GeV fIncoherent_elec_noise_width_GeV_VPT=fDigiPar->GetIncoherent_elec_noise_width_GeV_VPT(); //GeV fEnergyRange=fDigiPar->GetEnergyRange(); //GeV fEnergyRangeBW=fDigiPar->GetEnergyRangeBW(); //GeV fFirstSamplePhase=fDigiPar->GetFirstSamplePhase(); fNumber_of_samples_in_waveform=fDigiPar->GetNumber_of_samples_in_waveform(); fNumber_of_samples_in_waveform_fwd=fDigiPar->GetNumber_of_samples_in_waveform_fwd(); fNumber_of_samples_in_waveform_pmt=fDigiPar->GetNumber_of_samples_in_waveform_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 fFWD_Shaping_int_time=fDigiPar->GetFWD_Shaping_int_time(); //s fFWD_time_constant=fDigiPar->GetFWD_time_constant(); //s fCrystal_time_constant=fDigiPar->GetCrystal_time_constant(); //s fShashlyk_time_constant=fDigiPar->GetShashlyk_time_constant(); //s fShashlykSamplingFactor=fDigiPar->GetShashlykSamplingFactor(); fSampleRate=fDigiPar->GetSampleRate(); fSampleRate_PMT=fDigiPar->GetSampleRate_PMT(); fSampleRate_FWD=fDigiPar->GetSampleRate_FWD(); fUse_shaped_noise=fDigiPar->GetUse_shaped_noise(); fUse_photon_statistic=fDigiPar->GetUse_photon_statistic(); fNoiseAllChannels=fDigiPar->GetNoiseAllChannels(); fDigiPar->printParams(); // Test how parameters were read from DB. cout<<"EMC digitisation parameters "<GetMapperVersion()<InitEmcMapper(); PndEmcStructure::Instance(); //fUse_shaped_noise = 0; //fNumber_of_samples_in_waveform = 64; //fNumber_of_samples_in_waveform_FWD = 64; // Calculate 1 bit resolution (in units of FADC amplitude) PndEmcWaveform *tmpwaveform1=new PndEmcWaveform(0,101010001, fNumber_of_samples_in_waveform); pulseshape1 =new PndEmcAsicPulseshape(fASIC_Shaping_int_time,fCrystal_time_constant); PndEmcWaveform *tmpwaveform2=new PndEmcWaveform(0,101010001, fNumber_of_samples_in_waveform_pmt); pulseshape2 =new PndEmcCRRCPulseshape(fPMT_Shaping_int_time,fPMT_Shaping_diff_time,fShashlyk_time_constant); PndEmcWaveform *tmpwaveform3=new PndEmcWaveform(0,101010001, fNumber_of_samples_in_waveform_fwd);//length 10 pulseshape3 =new PndEmcAsicPulseshape(fFWD_Shaping_int_time, fFWD_time_constant);//LNP raw signal, decay time constant 25 microseconds //temp parameters; //fSampleRate_FWD = 100e6;//100 MHz fGevPeakAnalogue = tmpwaveform1->GetScale(fSampleRate, pulseshape1); fGevPeakAnalogue_PMT = tmpwaveform2->GetScale(fSampleRate_PMT, pulseshape2); fGevPeakAnalogue_FWD = tmpwaveform3->GetScale(fSampleRate_FWD, pulseshape3);//forward endcap,100 MHz // cout<<" -I- PndEmcHitsToWaveform::Init:=========== "<Delete(); } Double_t EventTime = FairRootManager::Instance()->GetEventTime();//nano seconds Int_t nHits = fHitArray->GetEntriesFast(); Int_t evtNo = FairRun::Instance()->GetEventHeader()->GetMCEntryNumber(); if (fVerbose>1){ cout<<"**************************************"<GetNData() : fWaveformArray->GetEntriesFast()) < waveformInd; Int_t NumOfSamples; // Loop over PndEmcHits to add them to correspondent waveforms // fWaveformInd contains indexes of detectors for which Waveforms are created //PndEmcAsicPulseshape *pulseshape= new PndEmcAsicPulseshape(fASIC_Shaping_int_time,fCrystal_time_constant); //PndEmcAbsPulseshape *pulseshape2=new PndEmcCRRCPulseshape(fPMT_Shaping_int_time,fPMT_Shaping_diff_time,fShashlyk_time_constant); //PndEmcAbsPulseshape *pulseshape3=new PndEmcAsicPulseshape(10.e-9,25e-6);//fCrystal_time_constant = decay time constant 25 micorseconds Double_t sampleRate; Double_t TimeMin = 99999.; Double_t TimeMax = 0.; Double_t WaveformTimeStamp(0.); Double_t TimeError(0.); Double_t EnergyError(0.); Int_t detId, module, MCTrackID; HowManyHit += nHits; for (Int_t iHit=0; iHitAt(iHit); module = theHit->GetModule(); if(module > 5) { std::cout<<" UpdateWaveform: Unknown module number "<GetRuntimeDb(); if ( ! db ) Fatal("SetParContainers", "No runtime database"); // Get Emc geometry parameter container fGeoPar = (PndEmcGeoPar*) db->getContainer("PndEmcGeoPar"); // Get Emc digitisation parameter container fDigiPar = (PndEmcDigiPar*) db->getContainer("PndEmcDigiPar"); } // ----- Private method AddWaveform -------------------------------------------- /*PndEmcWaveform* PndEmcHitsToWaveform::AddWaveform(Int_t detID, Int_t iHit,Int_t numOfSamples){ TClonesArray& clref = *fWaveformArray; Int_t size = clref.GetEntriesFast(); return new(clref[size]) PndEmcWaveform(0,detID,numOfSamples,iHit); }*/ PndEmcWaveform* PndEmcHitsToWaveform::AddWaveform(Int_t detID, Int_t iHit, Int_t numOfSamples, Double_t timeStamp, Double_t sampleRate, Int_t MCTrackID) { nWaveformProduced ++; PndEmcWaveform* thisWave(0); if(fTimeOrderedWaveform){ thisWave = new PndEmcWaveform(MCTrackID,detID,sampleRate, numOfSamples, iHit, timeStamp); }else{ TClonesArray& clref = *fWaveformArray; Int_t size = clref.GetEntriesFast(); thisWave = new(clref[size]) PndEmcWaveform(MCTrackID,detID,sampleRate, numOfSamples,iHit, timeStamp); } return thisWave; } void PndEmcHitsToWaveform::SetStorageOfData(Bool_t val) { fStoreWaves = val; return; } void PndEmcHitsToWaveform::FinishTask() { std::cout<<"==================================================="<Write(); } } ClassImp(PndEmcHitsToWaveform)