FairRoot/PandaRoot
PndEmcMakeDigi.cxx
Go to the documentation of this file.
1 //----------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: //
4 // Description:
5 // Class PndEmcMakeDigi. This class takes array of EmcHit's and produce
6 // an array of EmcDigis.
7 // It is convenient to study reconstruction algoritms without
8 // disturbance from digitization
9 //----------------------------------------------------------------------
10 
11 #include "PndEmcMakeDigi.h"
12 
13 #include "PndEmcDigi.h"
14 #include "PndEmcGeoPar.h"
15 #include "PndEmcDigiPar.h"
16 #include "PndEmcRecoPar.h"
17 #include "PndEmcMapper.h"
18 #include "PndEmcStructure.h"
19 
20 #include "FairRootManager.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
23 
24 #include "TClonesArray.h"
25 #include "TRandom.h"
26 #include "TROOT.h"
27 
28 #include <iostream>
29 //#include <map>
30 
31 using std::cout;
32 using std::endl;
33 using std::fstream;
34 
36  fHitArray(0), fDigiArray(0), fThreshold(0), fDigiPosMethod(""), fEmcDigiRescaleFactor(0), fEmcDigiPositionDepthPWO(0), fEmcDigiPositionDepthShashlyk(0), fUseDigiEffectiveSmearing(0), fDetectedPhotonsPerMeV(0), fNPhotoElectronsPerMeVAPDBarrel(0), fNPhotoElectronsPerMeVAPDBWD(0), fNPhotoElectronsPerMeVVPT(0), fSensitiveAreaAPD(0), fSensitiveAreaVPT(0), fQuantumEfficiencyAPD(0), fQuantumEfficiencyVPT(0), fExcessNoiseFactorAPD(0), fExcessNoiseFactorVPT(0), fIncoherent_elec_noise_width_GeV_APD(0), fIncoherent_elec_noise_width_GeV_VPT(0), fMapVersion(0), fGeoPar(new PndEmcGeoPar()), fDigiPar(new PndEmcDigiPar()), fRecoPar(new PndEmcRecoPar())
37 {
38  fDigiPosMethod="depth";// "surface" or "depth"
40  SetPersistency(storedigis);
41 }
42 
43 //--------------
44 // Destructor --
45 //--------------
47 {
48 }
49 
50 
61 {
62  // Get RootManager
63  FairRootManager* ioman = FairRootManager::Instance();
64  if ( ! ioman )
65  {
66  cout << "-E- PndEmcMakeDigi::Init: "
67  << "RootManager not instantiated!" << endl;
68  return kFATAL;
69  }
70 
71  // Get input array
72  fHitArray =dynamic_cast<TClonesArray *> (ioman->GetObject("EmcHit"));
73  if ( ! fHitArray ) {
74  cout << "-W- PndEmcMakeDigi::Init: "
75  << "No EmcHit array!" << endl;
76  return kERROR;
77  }
78 
79  // Create and register output array
80 /* fDigiArray = new TClonesArray("PndEmcDigi");
81  ioman->Register("EmcDigi","Emc",fDigiArray,fStoreDigis);*/
82  fDigiArray = ioman->Register("EmcDigi", "PndEmcDigi", "Emc", GetPersistency());
83 
86  if (!fDigiPosMethod.compare("surface"))
87  {
89  }
90  else if (!fDigiPosMethod.compare("depth"))
91  {
94  }
95  else
96  {
97  cout << "-W- PndEmcMakeDigi::Init: "
98  << "Unknown digi position method!" << endl;
99  return kERROR;
100  }
101 
102  // The following parameters define if energy of hit will be copied to digi or it will be smeared
113 
117 
118 
119  // Calculate number of photoelectrons for APD and VPT
120  // The number fDetectedPhotonsPerMeV is the measured number of photoelectrons with PM covering the whole rear surface divided by quantum efficiency of PM (18%)
121  // To estimate Number of photoelectrons in barrel the rare surface is taken equal for all the crystals 745 mm^2, which is average surface, hovewer it varies depending on the type of the crystal
122  // For forward and backward endcap rear surface is equal 26x26=676 mm^2
123  // Therefore the different number of photoelectrons are used with APD for barrel and backward endcap
127 
128  cout << "-I- PndEmcMakeDigi: Intialization successfull" << endl;
129 
130  return kSUCCESS;
131 }
132 
141 void PndEmcMakeDigi::Exec(Option_t*)
142 {
143  // Reset output array
144  if ( ! fDigiArray ) Fatal("Exec", "No Digi Array");
145  fDigiArray->Delete();
146 
147  // Variable declaration
148  PndEmcHit* theHit = NULL;
149 
150  // Loop over PndEmcHits to add them to correspondent wavefoorms
151  Int_t nHits = fHitArray->GetEntriesFast();
152 
153  //cout<<"Hit array contains "<<nHits<< " hits"<<endl;
154  for (Int_t iHit=0; iHit<nHits; iHit++) {
155  theHit = (PndEmcHit*) fHitArray->At(iHit);
156  int detId=theHit->GetDetectorID();
157  Double_t energy=theHit->GetEnergy();
158 
159  Int_t trackId=theHit->GetRefIndex();
160  Double_t time=theHit->GetTime();
161 
162  // Smear hit energy as sigma/E=sqrt((a/sqrt(E))^2+(E_noise/E)^2)
163  // i.e stochastic and noise term of energy resolution are taken into account
165  int module = theHit->GetModule();
166  Double_t a,sigma_E;
167  switch (module){
168  case 1: // Barrel
169  a=sqrt(fExcessNoiseFactorAPD/(fNPhotoElectronsPerMeVAPDBarrel*1e3)); // 1e3 is conversion from MeV to GeV
170  sigma_E=sqrt(pow(a/sqrt(energy),2)+pow(fIncoherent_elec_noise_width_GeV_APD/energy,2));
171  break;
172  case 2: // Barrel
173  a=sqrt(fExcessNoiseFactorAPD/(fNPhotoElectronsPerMeVAPDBarrel*1e3)); // 1e3 is conversion from MeV to GeV
174  sigma_E=sqrt(pow(a/sqrt(energy),2)+pow(fIncoherent_elec_noise_width_GeV_APD/energy,2));
175  break;
176  case 7: // Proto60
177  a=sqrt(fExcessNoiseFactorAPD/(fNPhotoElectronsPerMeVAPDBarrel*1e3)); // 1e3 is conversion from MeV to GeV
178  sigma_E=sqrt(pow(a/sqrt(energy),2)+pow(fIncoherent_elec_noise_width_GeV_APD/energy,2));
179 
180  break;
181  case 3: // FWD endcap
182  a=sqrt(fExcessNoiseFactorVPT/(fNPhotoElectronsPerMeVVPT*1e3)); // 1e3 is conversion from MeV to GeV
183  sigma_E=sqrt(pow(a/sqrt(energy),2)+pow(fIncoherent_elec_noise_width_GeV_VPT/energy,2));
184  break;
185  case 4: // BWD endcap
186  a=sqrt(fExcessNoiseFactorAPD/(fNPhotoElectronsPerMeVAPDBWD*1e3)); // 1e3 is conversion from MeV to GeV
187  sigma_E=sqrt(pow(a/sqrt(energy),2)+pow(fIncoherent_elec_noise_width_GeV_APD/energy,2));
188  break;
189  case 5: // shashlyk
190  // sigma/E=5.6/E+2.4/sqrt(E)+1.3 (%)
191  sigma_E=sqrt(pow(0.056/energy,2)+pow(0.024/sqrt(energy),2)+0.013);
192  break;
193  default:
194  std::cout<<"PndEmcMakeDigi::Exec - Unknown module number in EMC digitization"<<std::endl;
195  abort();
196  }
197 
198  energy= gRandom->Gaus(energy,sigma_E*energy);
199  }
201  Double_t nPhotons=(energy*1e3*fDetectedPhotonsPerMeV);
202  if(theHit->GetModule()==7&&theHit->GetRow()==4&&theHit->GetCrystal()==5){
203  energy= gRandom->Gaus(0,fIncoherent_elec_noise_width_GeV_VPT)+(gRandom->PoissonD(nPhotons)/1.0e3)/fDetectedPhotonsPerMeV;
204  }else{
205  energy= gRandom->Gaus(0,fIncoherent_elec_noise_width_GeV_APD)+(gRandom->PoissonD(nPhotons)/1.0e3)/fDetectedPhotonsPerMeV;
206  }
207  }
208 
209  if (energy>fThreshold&& detId>0)
210  {
211  AddDigi(trackId,detId, energy, time,iHit);
212  }
213  }
214 
215 }
216 
227 PndEmcDigi* PndEmcMakeDigi::AddDigi(Int_t trackID, Int_t detID, Float_t energy, Float_t time, Int_t hitIndex)
228 {
229  TClonesArray& clref = *fDigiArray;
230  Int_t size = clref.GetEntriesFast();
231  PndEmcDigi* newDigi = new(clref[size]) PndEmcDigi(trackID, detID, energy, time, hitIndex);
232  newDigi->SetTimeStamp(FairRootManager::Instance()->GetEventTime() + time*1.e9);
233  return newDigi;
234 }
235 
237 {
238  // Get run and runtime database
239  FairRun* run = FairRun::Instance();
240  if ( ! run ) Fatal("SetParContainers", "No analysis run");
241 
242  FairRuntimeDb* db = run->GetRuntimeDb();
243  if ( ! db ) Fatal("SetParContainers", "No runtime database");
244 
245  // Get Emc geometry parameter container
246  fGeoPar = (PndEmcGeoPar*) db->getContainer("PndEmcGeoPar");
247  // Get Emc digitisation parameter container
248  fDigiPar = (PndEmcDigiPar*) db->getContainer("PndEmcDigiPar");
249  // Get Emc reconstruction parameter container
250  fRecoPar = (PndEmcRecoPar*) db->getContainer("PndEmcRecoPar");
251 
252 }
253 
255 {
256  SetPersistency(val);
257  return;
258 }
259 
260 
261 
262 void PndEmcMakeDigi::SetDigiPosMethod(const std::string& digiPosMethod)
263 {
264  fDigiPosMethod = digiPosMethod;
265 }
266 const std::string& PndEmcMakeDigi::GetDigiPosMethod() const
267 {
268  return fDigiPosMethod;
269 }
270 
271 
PndEmcRecoPar * fRecoPar
Reconstruction parameter container.
Double_t fThreshold
Double_t GetQuantumEfficiencyVPT()
Definition: PndEmcDigiPar.h:21
Short_t GetCrystal() const
Definition: PndEmcHit.h:60
Double_t GetEmcDigiPositionDepthShashlyk()
Definition: PndEmcRecoPar.h:25
static void selectDigiPositionMethod(PositionMethod, double positionDepthPWO=0., double positionDepthShahslyk=0., double rescaleFactor=1.)
Definition: PndEmcDigi.cxx:153
Int_t run
Definition: autocutx.C:47
Double_t GetIncoherent_elec_noise_width_GeV_VPT()
Definition: PndEmcDigiPar.h:27
represents the reconstructed hit of one emc crystal
Definition: PndEmcDigi.h:40
Double_t fSensitiveAreaAPD
const std::string & GetDigiPosMethod() const
Double_t fEmcDigiPositionDepthShashlyk
virtual InitStatus Init()
Init Task.
Double_t GetQuantumEfficiencyAPD()
Definition: PndEmcDigiPar.h:20
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
Double_t GetIncoherent_elec_noise_width_GeV_APD()
Definition: PndEmcDigiPar.h:26
virtual ~PndEmcMakeDigi()
Double_t fExcessNoiseFactorVPT
Int_t GetUseDigiEffectiveSmearing()
Definition: PndEmcDigiPar.h:49
void SetPersistency(Bool_t val=kTRUE)
Double_t fNPhotoElectronsPerMeVAPDBWD
Double_t fQuantumEfficiencyAPD
Double_t fEmcDigiRescaleFactor
PndEmcDigiPar * fDigiPar
Digitisation parameter container.
virtual void Exec(Option_t *opt)
Runs the task.
Double_t GetEnergyDigiThreshold()
Definition: PndEmcDigiPar.h:42
PndEmcMakeDigi(Bool_t storedigis=kTRUE)
void InitEmcMapper()
TClonesArray * fDigiArray
Double_t fIncoherent_elec_noise_width_GeV_APD
Double_t GetSensitiveAreaAPD()
Definition: PndEmcDigiPar.h:18
std::string fDigiPosMethod
Int_t a
Definition: anaLmdDigi.C:126
int nHits
Definition: RiemannTest.C:16
PndEmcGeoPar * fGeoPar
Geometry parameter container.
Double_t
void SetDigiPosMethod(const std::string &digiPosMethod)
virtual Double_t GetEnergy() const
Definition: PndEmcHit.h:54
parameter set of Emc digitisation
Definition: PndEmcDigiPar.h:12
Double_t fIncoherent_elec_noise_width_GeV_VPT
Double_t fDetectedPhotonsPerMeV
void SetStorageOfData(Bool_t val)
Method to specify whether digis are stored or not.
Double_t fSensitiveAreaVPT
Double_t GetDetectedPhotonsPerMeV()
Definition: PndEmcDigiPar.h:16
Double_t fNPhotoElectronsPerMeVAPDBarrel
Double_t fQuantumEfficiencyVPT
virtual Double_t GetTime() const
Definition: PndEmcHit.h:55
represents the deposited energy of one emc crystal from simulation
Definition: PndEmcHit.h:26
Double_t GetExcessNoiseFactorVPT()
Definition: PndEmcDigiPar.h:24
Short_t GetRow() const
Definition: PndEmcHit.h:59
virtual void SetParContainers()
Double_t GetExcessNoiseFactorAPD()
Definition: PndEmcDigiPar.h:23
TClonesArray * fHitArray
Double_t fEmcDigiPositionDepthPWO
ClassImp(PndAnaContFact)
Int_t fUseDigiEffectiveSmearing
static PndEmcStructure * Instance()
Double_t fExcessNoiseFactorAPD
Short_t GetModule() const
Definition: PndEmcHit.h:58
Double_t fNPhotoElectronsPerMeVVPT
Double_t GetSensitiveAreaVPT()
Definition: PndEmcDigiPar.h:19
Task to create PndEmcDigi from PndEmcHit.
Parameter set for Emc Reco.
Definition: PndEmcRecoPar.h:12
PndEmcDigi * AddDigi(Int_t trackID, Int_t detID, Float_t energy, Float_t time, Int_t hitIndex)
Adds a PndEmcDigi to to fDigiArray and returns it.
Double_t energy
Definition: plot_dirc.C:15
Double_t GetEmcDigiPositionDepthPWO()
Definition: PndEmcRecoPar.h:24