28 #include "FairEventHeader.h"
29 #include "FairRootManager.h"
30 #include "FairFileSource.h"
31 #include "FairRunAna.h"
32 #include "FairRuntimeDb.h"
34 #include "TClonesArray.h"
35 #include "TStopwatch.h"
43 #include "TGraphErrors.h"
55 , fEnergyDigiThreshold(0)
56 , fASIC_Shaping_int_time(0)
57 , fPMT_Shaping_int_time(0)
58 , fPMT_Shaping_diff_time(0)
59 , fCrystal_time_constant(0)
60 , fShashlyk_time_constant(0)
61 , fNumber_of_samples_in_waveform(0)
62 , fNumber_of_samples_in_waveform_pmt(0)
64 , fEmcDigiRescaleFactor(0)
65 , fEmcDigiPositionDepthPWO(0)
66 , fEmcDigiPositionDepthShashlyk(0)
70 , fpsaAlgorithm_pmt(0)
71 , fpsaAlgorithm_fwd(0)
77 , fTimeOrderedDigi(kFALSE)
79 , fWfNormalisation_fwd(0)
80 , fWfNormalisation_pmt(0)
81 , fDigitizationVersion2(kFALSE)
116 FairRootManager* ioman = FairRootManager::Instance();
119 cout <<
"-E- PndEmcWaveformToDigi::Init: "
120 <<
"RootManager not instantiated!" << endl;
126 fWaveformArray =
dynamic_cast<TClonesArray *
>( ioman->GetObject(
"EmcSortedWaveform"));
127 if (!FairRunAna::Instance()->IsTimeStamp()) {
128 cout <<
"-W- PndEmcWaveformToDigi::Init: "
129 <<
"Task running timebased, but run not running timebased" << endl;
132 fWaveformArray =
dynamic_cast<TClonesArray *
> (ioman->GetObject(
"EmcWaveform"));
138 cout <<
"-W- PndEmcWaveformToDigi::Init: "
139 <<
"No PndEmcWaveform array!" << endl;
182 cout <<
"-W- PndEmcWaveformToDigi::Init: "
183 <<
"Unknown digi position method!" << endl;
229 theAlg2->
init(newParams);
246 theAlg1->
init(newParams);
264 theAlg3->
init(newParams);
279 std::vector<Double_t> params;
280 params.push_back(30);
321 cout <<
"-I- PndEmcWaveformToDigi: Intialization successfull" << endl;
343 Double_t fevtTime = FairRootManager::Instance()->GetEventTime();
347 cout<<
"=======================PndEmcWaveformToDigi======================="<<endl;
348 std::cout<<
"Event NO. #"<<
fEventNo<<
", event time # "<<fevtTime <<std::endl;
351 if(FairRunAna::Instance()->IsTimeStamp()){
355 cout<<
"--I-- time-based simulation, read data to later #"<<time_length<<
" ns"<<endl;
356 fWaveformArray = FairRootManager::Instance()->GetData(
"EmcSortedWaveform"
358 , fevtTime + time_length);
365 std::cout<<
"fWaveformArray size #"<<nWaveforms<<std::endl;
375 Double_t fdigiEnergy(0.), fdigiTime(0.), theSampleRate, minT(1e10), maxT(-1e10);
376 Int_t hitIndex,
nHits, detId, trackId, i_digi(0), fMod;
380 for (Int_t iWaveform=0; iWaveform<nWaveforms; iWaveform++)
388 if(theWaveform->GetTimeStamp() < minT ) minT = theWaveform->GetTimeStamp();
389 if(theWaveform->GetTimeStamp() > maxT ) maxT = theWaveform->GetTimeStamp();
394 }
else if(fMod == 3){
403 const std::vector<Int_t>& evtList = theWaveform->
GetEvtList();
406 std::cout<<
"The wave#"<<iWaveform<<
" includes "<<evtList.size()<<
" events #";
407 for(
size_t i=0;
i< evtList.size(); ++
i){
408 std::cout<<evtList[
i]<<
" ";
413 nHits = thePSA->
Process(theWaveform);
416 std::cout<<
"detID#"<<theWaveform->
GetDetectorId()<<
", hits#"<<nHits<<std::endl;
427 fdigiTime = theWaveform->GetTimeStamp();
432 cout<<
"wave #"<<iWaveform<<
", WaveformTime#" << theWaveform->GetTimeStamp() <<
", mod#"<<fMod<<
", theSampleRate#"<<theSampleRate<<
", shift#"<<
fTimeShift<<endl;
433 cout<<
"fdigiEnergy#"<<fdigiEnergy<<
", fdigiTime#"<<fdigiTime<<
", evtTime#"<<fevtTime<<
", diffT#"<<(fdigiTime-fevtTime)<<endl;
445 myDigi =
new((*fDigiArray)[i_digi++])
PndEmcDigi(trackId,detId, fdigiEnergy, fdigiTime, hitIndex);
448 myDigi->AddLink(FairLink(
"EmcWaveform", iWaveform));
452 Int_t nOldSize =
fDigiArray->GetEntriesFast();
455 for(Int_t iDigi = 0; iDigi < nDigi; ++iDigi)
459 new((*fDigiArray)[i_digi++])
PndEmcDigi(*copy);
465 Int_t nNewSize =
fDigiArray->GetEntriesFast();
466 std::cout<<nNewSize<<
" digis, "<<nOldSize<<
" <--waveform, "<<nDigi<<
" <--previous event."<<std::endl;
467 cout<<
"=======================PndEmcWaveformToDigi======================="<<endl;
480 cout <<
"PndEmcWaveformToDigi, Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
488 FairRun*
run = FairRun::Instance();
489 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
491 FairRuntimeDb* db = run->GetRuntimeDb();
492 if ( ! db ) Fatal(
"SetParContainers",
"No runtime database");
521 std::cout<<
"========================================================="<<std::endl;
522 std::cout<<
"PndEmcWaveformToDigi::FinishTask"<<std::endl;
523 std::cout<<
"========================================================="<<std::endl;
524 std::cout<<
"Total waveforms# "<<
totNumOfWave<<std::endl;
525 std::cout<<
"Total expected hits# "<<
totExpHits<<std::endl;
526 std::cout<<
"Total fpga hits# "<<
totHits<<std::endl;
528 std::cout<<
"========================================================="<<std::endl;
601 Float_t resolution=0.01*energy+0.0163*
sqrt(energy);
602 return gRandom->Gaus(energy,resolution);
Int_t GetBarrelMAFilterLength()
virtual void init(PndEmcPSAFPGASampleAnalyser::SampleAnalyserParams ¶ms)
Int_t GetForwardMWDFilterUsed()
Double_t GetEmcDigiPositionDepthShashlyk()
Int_t GetForwardCFDelayLength()
Double_t GetPMT_Shaping_diff_time()
static void selectDigiPositionMethod(PositionMethod, double positionDepthPWO=0., double positionDepthShahslyk=0., double rescaleFactor=1.)
static TClonesArray * fDigiArrayTBD
Int_t GetForwardCFFitterLength()
Int_t GetNumber_of_samples_in_waveform()
Pulseshape analysis for ADC waveforms.
virtual Double_t GetEnergy() const
represents the reconstructed hit of one emc crystal
Int_t GetShashylikCFFitterLength()
friend F32vec4 sqrt(const F32vec4 &a)
Double_t val[nBoxes][nFEBox]
Int_t GetShashylikMWDFilterUsed()
Double_t GetBarrelPulseThreshold()
virtual Int_t Process(const PndEmcWaveform *waveform)=0
Find Hits in Waveform.
Double_t GetCrystal_time_constant()
void SetPersistency(Bool_t val=kTRUE)
Pulseshape analysis for ADC waveforms.
Double_t GetForwardMWDFilterLifeT()
Double_t GetShashylikCFFilterRatio()
Double_t GetBarrelCFFilterRatio()
Int_t GetBarrelMWDFilterUsed()
virtual void GetHit(Int_t i, Double_t &energy, Double_t &time)=0
Get energy and time of hit.
static void InitDigiArrayTBD()
Double_t GetASIC_Shaping_int_time()
Pulseshape from an CRRC-Shaper.
Double_t GetEnergyDigiThreshold()
Double_t GetSampleRate_FWD()
Int_t GetBarrelMWDFilterLength()
Int_t GetForwardCFFilterLength()
virtual CalibrationStatus_t Calibrate(Double_t &Energy, Long_t detId, Int_t SignalNr=1)=0
Apply CrystalCalibration to Energy of Crystal derId.
void SetEnergy(Double32_t energy)
Int_t GetShashylikCFFilterLength()
Int_t GetShashylikCFDelayLength()
Pulseshape from an APFEL ASIC preamplifier shaper.
Int_t GetShashylikMWDFilterLength()
Int_t GetBarrelCFFilterLength()
virtual void SetCalibration(Int_t ModId, Double_t cal, Int_t SignalNr=1, Double_t overflow=-1)
Set Calibration for a Module.
virtual void setBaselineInterval(int anl_start, int bl_stop)
parameter set of Emc digitisation
Double_t GetShashylikPulseThreshold()
Double_t GetFWD_Shaping_int_time()
Double_t GetShashylikMWDFilterLifeT()
Int_t GetBarrelCFDelayLength()
Int_t GetForwardMWDFilterLength()
Class to simulate a Calibration.
virtual void SetEnergy(Double32_t energy)
Int_t GetShashylikMAFilterLength()
Int_t GetForwardMAFilterLength()
Baseclass for pulseshapeanalysis ( featureextraction )
virtual void enable_mwd_filter(bool flag)
Int_t GetNumber_of_samples_in_waveform_fwd()
represents the deposited energy of one emc crystal from simulation
virtual Bool_t Init()
Init.
Double_t GetFWD_time_constant()
Double_t GetForwardCFFilterRatio()
Double_t GetSampleRate_PMT()
static PndEmcStructure * Instance()
virtual void SetTime(Double32_t time)
Double_t GetBarrelMWDFilterLifeT()
Double_t GetShashlyk_time_constant()
cout<<"the Event No is "<< i<< endl;{{if(hit_array->GetEntriesFast()!=mc_array->GetEntriesFast()) continue;PndSdsHit *hit=(PndSdsHit *) hit_array-> At(j)
Int_t GetBarrelCFFitterLength()
Int_t GetNumber_of_samples_in_waveform_pmt()
Double_t GetPMT_Shaping_int_time()
Parameter set for Emc Reco.
Double_t GetForwardPulseThreshold()
Double_t GetEmcDigiPositionDepthPWO()