11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
15 #include <TSpectrum.h>
24 : FairTask(
"Panda HypGeGammaAna Task"), xpeaks(0), ypeaks(0), fHitGe(0), fMCGam(0), fHitSi(0), fHitTargetOther(0)
31 : FairTask(
"Panda HypGeGammaAna Task"), xpeaks(0), ypeaks(0), fHitGe(0), fMCGam(0), fHitSi(0), fHitTargetOther(0)
93 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Starting Init of HypGe Gamma Ana" << endl;
96 ioman = FairRootManager::Instance();
98 cout <<
"-E- PndEmcHitProducer::Init: "
99 <<
"RootManager not instantiated!" << endl;
104 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Getting FairRootManager finished" << endl;
107 fMcTr = (TClonesArray*)
ioman->GetObject(
"MCTrack");
108 fGe = (TClonesArray*)
ioman->GetObject(
"HypGePoint");
109 fGeAl = (TClonesArray*)
ioman->GetObject(
"HypGeAlPoint");
116 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Getting input arrays finished" << endl;
122 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Full input file name with path: " <<
fName << endl;
123 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Chopping first " <<
fName.Last(
'/')+1 <<
" chars"<< endl;
127 cout <<
"Hyp Ge Gamma Ana:\t" <<
"File name: " <<
fName<< endl;
130 cout <<
"Hyp Ge Gamma Ana:\t" <<
"File name extraction finished" << endl;
147 hAbsorption =
new TH1D(
"hAbsorption",
"Part of Gamma interaction in target system," +
fName, 10,1,11);
148 hAbsorption ->GetXaxis()->SetBinLabel(1,
"Silicon");
149 hAbsorption ->GetXaxis()->SetBinLabel(2,
"Absorber");
150 hAbsorption ->GetXaxis()->SetBinLabel(3,
"HoldingFrame");
151 hAbsorption ->GetXaxis()->SetBinLabel(4,
"Window foil");
152 hAbsorption ->GetXaxis()->SetBinLabel(5,
"beam pipe");
157 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Histogram creation finished" << endl;
178 cout <<
"Hyp Ge Gamma Ana:\tNumber of analyzed events: "<<
NumberOfEvents << endl;
181 Rng =
new TRandom(time(NULL));
182 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Init of HypGe Gamma Ana finished successfully" << endl;
191 TxtFile <<
"Hyp Ge Gamma Ana:\tFile to analyze: \t"<<
ioman->GetInFile()->GetName() << endl;
195 std::cout <<
"-I- gGeoManager = "<<
gGeoManager << std::endl;
202 FairRun* ana = FairRun::Instance();
203 FairRuntimeDb*
rtdb=ana->GetRuntimeDb();
204 std::cout <<
"-I- rtdb = "<<rtdb << std::endl;
210 Double_t EnergyPerCrystal[48] = {0};
213 bool isFirstInteraction = 0;
254 PrimaryDistance = DiffVector.Mag();
255 PrimaryTheta = DiffVector.Theta()*180/
TMath::Pi();
258 if(PrimaryTheta >110 && PrimaryTheta <165 && (StartVolumeName.Contains(
"Sensor") ||StartVolumeName.Contains(
"Absorber") ||StartVolumeName.Contains(
"HoldingFrame") ||StartVolumeName.Contains(
"Window") ||StartVolumeName.Contains(
"Frame")))
260 isFirstInteraction = 1;
261 if (PrimaryDistance >10)
263 cout << PrimaryDistance << endl;
264 cout << PrimaryTheta << endl;
267 cout << StartVolumeName.Data() << endl;
269 PrimaryVertex.Print();
310 if(isFirstInteraction)
312 if(PrimaryTheta >110 && PrimaryTheta <165)
325 if (
fGe->GetEntriesFast())
349 for (Int_t
i=0;
i <
fGe->GetEntriesFast();
i++)
363 CollectedEnergy +=
SmearHit(EnergyPerCrystal[*it]);
366 if (CollectedEnergy > 0)
374 if (
fVerbose >= 2 && CollectedEnergy != 0)
375 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Energy " << CollectedEnergy << endl;
382 cout <<
"Hyp Ge Gamma Ana:\t" <<
"NoHFill: " <<
SetOfCrystalHit.size() << endl;
388 cout <<
"Hyp Ge Gamma Ana:\t"<<
"0 % done!" << endl;
393 cout <<
"Hyp Ge Gamma Ana:\t" <<
"Event Number"<<
EvtCount << endl;
399 cout <<
"Hyp Ge Gamma Ana:\tEvent loop finished" <<endl;
402 cout <<
"Hyp Ge Gamma Ana:\tEntries in spectrum: " <<
hGamEnergy->GetEntries() <<endl;
403 TxtFile <<
"Hyp Ge Gamma Ana:\tEntries in spectrum: \t" <<
hGamEnergy->GetEntries() <<endl;
420 cout <<
"Hyp Ge Gamma Ana:\tAnalysis finished succesfully" << endl;
430 return TMath::ACos((E*E-E*Eprime-Eprime*0.000511)/(E*(E-Eprime)));
436 Double_t SmearedEnergy = Energy +
Rng->Gaus(0,Resolution);
437 return SmearedEnergy;
447 histo->SetXTitle(XTitle.Data());
448 histo->GetXaxis()->SetTitleSize(XTitleSize);
449 histo->GetXaxis()->SetTitleOffset(XTitleOffset);
450 histo->GetXaxis()->SetLabelSize(XLabelSize);
452 histo->SetYTitle(YTitle.Data());
453 histo->GetYaxis()->SetTitleSize(YTitleSize);
454 histo->GetYaxis()->SetTitleOffset(YTitleOffset);
455 histo->GetYaxis()->SetLabelSize(YLabelSize);
459 histo->SetXTitle(XTitle.Data());
460 histo->GetXaxis()->SetTitleSize(XTitleSize);
461 histo->GetXaxis()->SetTitleOffset(XTitleOffset);
462 histo->GetXaxis()->SetLabelSize(XLabelSize);
464 histo->SetYTitle(YTitle.Data());
465 histo->GetYaxis()->SetTitleSize(YTitleSize);
466 histo->GetYaxis()->SetTitleOffset(YTitleOffset);
467 histo->GetYaxis()->SetLabelSize(YLabelSize);
473 GausBG->SetParName(0,
"Ampl");
474 GausBG->SetParName(1,
"x0");
475 GausBG->SetParName(2,
"sigma");
478 GausBG->SetParameter(2,100./100000.);
479 GausBG->SetParLimits(0,0.000001, 1000000);
481 GausBG->SetParLimits(2,1./100000.,1000./100000.);
490 GausBG->SetLineColor(kRed);
496 cout <<
"Hyp Ge Gamma Ana:\tCHi²red of the fit \t"<<
GausBG->GetChisquare() /
GausBG->GetNDF() << endl;
497 cout <<
"Hyp Ge Gamma Ana:\tCHi²red of the fit \t"<<
GausBG->GetChisquare() <<
" "<<
GausBG->GetNDF() << endl;
498 TxtFile <<
"Hyp Ge Gamma Ana:\tCHi²red of the fit \t"<<
GausBG->GetChisquare() /
GausBG->GetNDF() << endl;
499 TxtFile <<
"Hyp Ge Gamma Ana:\tFitparameter Spectrum (model: gausn):" << endl;
500 for (Int_t
i = 0;
i < 3;
i++)
502 TxtFile <<
"Hyp Ge Gamma Ana:\t" <<
GausBG->GetParName(
i) <<
":\t" <<
GausBG->GetParameter(
i) << endl;
506 cout <<
"Hyp Ge Gamma Ana:\tFitparameter Spectrum (model: gausn):" << endl;
507 for (Int_t
i = 0;
i < 3;
i++)
509 cout <<
"Hyp Ge Gamma Ana:\t" <<
GausBG->GetParName(
i) <<
":\t" <<
GausBG->GetParameter(
i) << endl;
515 cout <<
"Hyp Ge Gamma Ana:\tFWHM[keV]: " << FWHM*1000 << endl;
516 TxtFile <<
"Hyp Ge Gamma Ana:\tFWHM[keV]:\t" << FWHM*1000 << endl;
519 cout <<
"Hyp Ge Gamma Ana:\tFull-Energy-Peak-Eff. [%]: " << double(
int(
GausBG->GetParameter(0)*100000/(
NumberOfEvents*2)*100*1000))/1000 <<
" ± " <<
double(
int(
GausBG->GetParError(0)*100000/(
NumberOfEvents*2)*100*1000))/1000 << endl;
520 TxtFile <<
"Hyp Ge Gamma Ana:\tFull-Energy-Peak-Eff. [%]: \t" << double(
int(
GausBG->GetParameter(0)*100000/(
NumberOfEvents*2)*100*1000))/1000 <<
" ± " <<
double(
int(
GausBG->GetParError(0)*100000/(
NumberOfEvents*2)*100*1000))/1000 << endl;
525 TSpectrum *
s =
new TSpectrum(
nPeaks);
529 cout <<
"Hyp Ge Gamma Ana:\tSpectrum search finished: " <<
hGamEnergy->GetEntries() <<endl;
531 xpeaks = s->GetPositionX();
532 ypeaks = s->GetPositionY();
538 cout <<
"Hyp Ge Gamma Ana:\tPeak @ ("<<
xpeaks[
i]<<
"," <<
ypeaks[
i] <<
")" << endl;
557 cout <<
"Hyp Ge Gamma Ana:\tPeak at bin "<<
PeakX << endl;
558 cout <<
"Hyp Ge Gamma Ana:\tPeak bin height"<<
PeakY <<
" ± " <<
DPeakY<< endl;
559 cout <<
"Hyp Ge Gamma Ana:\tSumPeak "<<
SumPeak <<
" ± " <<
DSumPeak << endl;
561 TxtFile <<
"Hyp Ge Gamma Ana:\tPeak at bin \t"<<
PeakX << endl;
596 cout <<
"Hyp Ge Gamma Ana:\tPeak/Compton : "<<
PeakToCompton <<
" ± "<< DPeakToCompton << endl;
597 TxtFile <<
"Hyp Ge Gamma Ana:\tPeak/Compton : \t"<<
PeakToCompton <<
" ± "<< DPeakToCompton << endl;
602 cout <<
"Hyp Ge Gamma Ana:\tSumCompton = 0 -> no PeakToCompton possible!"<<endl;
603 TxtFile <<
"Hyp Ge Gamma Ana:\tSumCompton = 0 -> no PeakToCompton possible!"<<endl;
626 TCanvas* CanGamEnergy =
new TCanvas(
"CanGamEnergy",
"Gamma Energy", 1000,600);
629 TCanvas* CanGamEnergyTarget =
new TCanvas(
"CanGamEnergyTarget",
"Gamma Energy target", 1000,600);
632 TCanvas* CanNoH =
new TCanvas(
"CanNoH",
"Number of Hits", 1000,600);
635 TCanvas* CanTH =
new TCanvas(
"CanTH",
"TH", 1000,600);
638 TCanvas* CanTHPrimary =
new TCanvas(
"CanTHPrimary",
"TH prim", 1000,600);
641 TCanvas* CanAbsorption =
new TCanvas(
"CanAbsorption",
"part of absorption", 1000,600);
644 TCanvas* CanAbsorption2D =
new TCanvas(
"CanAbsorption2D",
"correlation of absorption distance and theta", 1000,600);
void ActivateComptonCalculations(Bool_t isActivated=1)
void HistogramCosmetics(TH1D *histo, TString XTitle, Double_t XTitleSize, Double_t XTitleOffset, Double_t XLabelSize, TString YTitle, Double_t YTitleSize, Double_t YTitleOffset, Double_t YLabelSize)
Double_t CalculatePeakWidth(Double_t Energy)
bool InTargetAbsorbedGammaWouldHitGermanium()
void WriteHistogramsToFile()
void SetTarget(Bool_t TargetAvailable=1)
friend F32vec4 sqrt(const F32vec4 &a)
Double_t PeakWidtchStrechFactor
Double_t invCompton(Double_t E, Double_t Eprime)
void HistogramCosmetics2D(TH2D *histo, TString XTitle, Double_t XTitleSize, Double_t XTitleOffset, Double_t XLabelSize, TString YTitle, Double_t YTitleSize, Double_t YTitleOffset, Double_t YLabelSize)
TVector3 GetMomentum() const
TString fVertexVolumeName
TGeoManager * gGeoManager
PndMCTrack * fMCGamPrimary
Bool_t useOmegaQuadrupolMode
Double_t Compton(Double_t E, Double_t Th)
Double_t iHistoUpperLimit
void SetPeakWidtchStrechFactor(Double_t PeakWidtchStrechFactor_ext=1)
void SetOmegaQuadrupolMode(Bool_t useOmegaQuadrupolMode_ext=1)
Double_t highComptonAngle
std::set< int > SetOfCrystalHit
TClonesArray * fTargetOther
TH1D * hThetaCheckPrimary
PndHypPoint * fHitTargetOther
TH1D * hGamEnergyTargetBackground
Bool_t DoComptonCalculations
Double_t SmearHit(Double_t Energy)
TString GetDetName() const
TH2D * h2AbsorptionDistanceAngle
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
TVector3 GetStartVertex() const
Int_t GetMotherID() const
Int_t GetDetectorID() const
Double_t GetEnergyLoss() const