Skip to content
Snippets Groups Projects
Commit d721dced authored by Vardan Tadevosyan's avatar Vardan Tadevosyan Committed by Stephen A. Wood
Browse files

Add saving raw data for HMS calorimeter calibration into file.

parent ca8268ff
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ class THcShHit { ...@@ -35,7 +35,7 @@ class THcShHit {
UInt_t GetBlkNumber() {return BlkNumber;} UInt_t GetBlkNumber() {return BlkNumber;}
void Print(); void Print(ostream & ostrm);
}; };
THcShHit::THcShHit() { THcShHit::THcShHit() {
...@@ -57,10 +57,12 @@ THcShHit::THcShHit(Double_t adc_pos, Double_t adc_neg, ...@@ -57,10 +57,12 @@ THcShHit::THcShHit(Double_t adc_pos, Double_t adc_neg,
THcShHit::~THcShHit() { }; THcShHit::~THcShHit() { };
void THcShHit::Print() { void THcShHit::Print(ostream & ostrm) {
cout << "Hit: ADCpos =" << ADCpos << " ADCneg =" << ADCneg // ostrm << "Hit: ADCpos =" << ADCpos << " ADCneg =" << ADCneg
<< " Epos =" << Epos << " Eneg =" << Eneg // << " Epos =" << Epos << " Eneg =" << Eneg
<< " BlkNumber=" << BlkNumber << endl; // << " BlkNumber=" << BlkNumber << endl;
ostrm << ADCpos << " " << ADCneg << " " << Epos << " " << Eneg << " "
<< BlkNumber << endl;
}; };
struct pmt_hit {Double_t signal; UInt_t channel;}; struct pmt_hit {Double_t signal; UInt_t channel;};
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include <iterator> #include <iterator>
#include <iostream> #include <iostream>
#include <fstream>
using namespace std; using namespace std;
...@@ -46,7 +47,7 @@ class THcShTrack { ...@@ -46,7 +47,7 @@ class THcShTrack {
UInt_t GetNhits() {return Hits.size();}; UInt_t GetNhits() {return Hits.size();};
void Print(); void Print(ostream & ostrm);
// Bool_t CheckHitNumber(); // Bool_t CheckHitNumber();
...@@ -126,14 +127,15 @@ THcShHit* THcShTrack::GetHit(UInt_t k) { ...@@ -126,14 +127,15 @@ THcShHit* THcShTrack::GetHit(UInt_t k) {
return *it; return *it;
} }
void THcShTrack::Print() { void THcShTrack::Print(ostream & ostrm) {
cout << "ShTrack: P=" << P << " X=" << X << " Xp=" << Xp // ostrm << "ShTrack: P=" << P << " X=" << X << " Xp=" << Xp
<< " Y=" << Y << " Yp=" << Yp << endl; // << " Y=" << Y << " Yp=" << Yp << endl;
// << " Y=" << Y << " Yp=" << Yp << " Nhits=" << Nhits << endl; // ostrm << "Hits size=" << Hits.size() << endl;
cout << "Hits size=" << Hits.size() << endl; ostrm << P << " " << X << " " << Xp << " " << Y << " " << Yp << " "
<< Hits.size() << endl;
for (THcShHitIt iter = Hits.begin(); iter != Hits.end(); iter++) { for (THcShHitIt iter = Hits.begin(); iter != Hits.end(); iter++) {
(*iter)->Print(); (*iter)->Print(ostrm);
}; };
}; };
......
...@@ -27,7 +27,6 @@ class THcShowerCalib { ...@@ -27,7 +27,6 @@ class THcShowerCalib {
THcShowerCalib(); THcShowerCalib();
~THcShowerCalib(); ~THcShowerCalib();
void ExtractData();
void Init(); void Init();
void ReadShRawTrack(THcShTrack &trk, UInt_t ientry); void ReadShRawTrack(THcShTrack &trk, UInt_t ientry);
void CalcThresholds(); void CalcThresholds();
...@@ -35,6 +34,7 @@ class THcShowerCalib { ...@@ -35,6 +34,7 @@ class THcShowerCalib {
void SolveAlphas(); void SolveAlphas();
void FillHEcal(); void FillHEcal();
void SaveAlphas(); void SaveAlphas();
void SaveRawData();
TH1F* hEunc; TH1F* hEunc;
TH1F* hEuncSel; TH1F* hEuncSel;
...@@ -85,120 +85,25 @@ THcShowerCalib::~THcShowerCalib() { ...@@ -85,120 +85,25 @@ THcShowerCalib::~THcShowerCalib() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void THcShowerCalib::ExtractData() { void THcShowerCalib::SaveRawData() {
// Extract data for calibration from the Root file. // Output raw data into file for debug purposes.
// Loop over ntuples to get track parameters and calorimeter
// hit quantities.
char* fname = Form("Root_files/hcal_calib_%d.root",fRunNumber); cout << "SaveRawData: Output raw data into hcal_calib.raw_data." << endl;
cout << "THcShowerCalib::ExtractData: fname= " << fname << endl;
//Reset ROOT and connect tree file
gROOT->Reset();
// TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fname);
TFile *f = new TFile(fname);
// if (!f) {
// f = new TFile(fname);
// }
TTree* tree;
f->GetObject("T",tree);
//Declaration of leaves types
// Calorimeter ADC signals.
Double_t H_cal_1pr_aneg_p[THcShTrack::fNrows];
Double_t H_cal_1pr_apos_p[THcShTrack::fNrows];
Double_t H_cal_2ta_aneg_p[THcShTrack::fNrows];
Double_t H_cal_2ta_apos_p[THcShTrack::fNrows];
Double_t H_cal_3ta_aneg_p[THcShTrack::fNrows];
Double_t H_cal_3ta_apos_p[THcShTrack::fNrows];
Double_t H_cal_4ta_aneg_p[THcShTrack::fNrows];
Double_t H_cal_4ta_apos_p[THcShTrack::fNrows];
// Track parameters.
Double_t H_cal_trp; ofstream fout;
Double_t H_cal_trx; fout.open("hcal_calib.raw_data",ios::out);
Double_t H_cal_trxp;
Double_t H_cal_try;
Double_t H_cal_tryp;
// Set branch addresses.
tree->SetBranchAddress("H.cal.1pr.aneg_p",H_cal_1pr_aneg_p);
tree->SetBranchAddress("H.cal.1pr.apos_p",H_cal_1pr_apos_p);
tree->SetBranchAddress("H.cal.2ta.aneg_p",H_cal_2ta_aneg_p);
tree->SetBranchAddress("H.cal.2ta.apos_p",H_cal_2ta_apos_p);
tree->SetBranchAddress("H.cal.3ta.aneg_p",H_cal_3ta_aneg_p);
tree->SetBranchAddress("H.cal.3ta.apos_p",H_cal_3ta_apos_p);
tree->SetBranchAddress("H.cal.4ta.aneg_p",H_cal_4ta_aneg_p);
tree->SetBranchAddress("H.cal.4ta.apos_p",H_cal_4ta_apos_p);
tree->SetBranchAddress("H.cal.trp",&H_cal_trp);
tree->SetBranchAddress("H.cal.trx",&H_cal_trx);
tree->SetBranchAddress("H.cal.trxp",&H_cal_trxp);
tree->SetBranchAddress("H.cal.try",&H_cal_try);
tree->SetBranchAddress("H.cal.tryp",&H_cal_tryp);
Long64_t nentries = tree->GetEntries(); THcShTrack trk;
cout << "THcShowerCalib::ExtractData: nentries= " << nentries << endl;
// Output stream.
char* FName = Form("raw_data/%d_raw.dat",fRunNumber); for (UInt_t ientry=0; ientry<fNentries; ientry++) {
cout << "ExtractData: FName=" << FName << endl; ReadShRawTrack(trk, ientry);
ofstream output; trk.SetEs(falphaC);
output.open(FName,ios::out); trk.Print(fout);
}
// Loop over ntuples.
Long64_t nbytes = 0;
for (Long64_t i=0; i<nentries;i++) {
nbytes += tree->GetEntry(i);
Int_t nhit = 0;
for (Int_t j=0; j<THcShTrack::fNrows; j++) {
if (H_cal_1pr_apos_p[j]>0. || H_cal_1pr_aneg_p[j]>0.) nhit++;
if (H_cal_2ta_apos_p[j]>0. || H_cal_2ta_aneg_p[j]>0.) nhit++;
if (H_cal_3ta_apos_p[j]>0. || H_cal_3ta_aneg_p[j]>0.) nhit++;
if (H_cal_4ta_apos_p[j]>0. || H_cal_4ta_aneg_p[j]>0.) nhit++;
}
output << nhit << " " << H_cal_trp << " "
<< H_cal_trx << " " << H_cal_trxp << " "
<< H_cal_try << " " << H_cal_tryp << endl;
for (Int_t j=0; j<THcShTrack::fNrows; j++) {
if (H_cal_1pr_apos_p[j]>0. || H_cal_1pr_aneg_p[j]>0.)
output << H_cal_1pr_apos_p[j] << " " << H_cal_1pr_aneg_p[j] << " "
<< j+1 << endl;
}
for (Int_t j=0; j<THcShTrack::fNrows; j++) {
if (H_cal_2ta_apos_p[j]>0. || H_cal_2ta_aneg_p[j]>0.)
output << H_cal_2ta_apos_p[j] << " " << H_cal_2ta_aneg_p[j] << " "
<< j+1 + THcShTrack::fNrows << endl;
}
for (Int_t j=0; j<THcShTrack::fNrows; j++) {
if (H_cal_3ta_apos_p[j]>0. || H_cal_3ta_aneg_p[j]>0.)
output << H_cal_3ta_apos_p[j] << " " << H_cal_3ta_aneg_p[j] << " "
<< j+1 + 2*THcShTrack::fNrows << endl;
}
for (Int_t j=0; j<THcShTrack::fNrows; j++) {
if (H_cal_4ta_apos_p[j]>0. || H_cal_4ta_aneg_p[j]>0.)
output << H_cal_4ta_apos_p[j] << " " << H_cal_4ta_aneg_p[j] << " "
<< j+1 + 3*THcShTrack::fNrows << endl;
}
} // over entries fout.close();
f->Close();
output.close();
cout << "THcShowerCalib::ExtractData: nbytes= " << nbytes << endl;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -287,7 +192,7 @@ void THcShowerCalib::CalcThresholds() { ...@@ -287,7 +192,7 @@ void THcShowerCalib::CalcThresholds() {
ReadShRawTrack(trk, ientry); ReadShRawTrack(trk, ientry);
// trk.Print(); // trk.Print(cout);
// getchar(); // getchar();
trk.SetEs(falpha0); trk.SetEs(falpha0);
...@@ -452,7 +357,7 @@ void THcShowerCalib::ComposeVMs() { ...@@ -452,7 +357,7 @@ void THcShowerCalib::ComposeVMs() {
if (Enorm>fLoThr && Enorm<fHiThr) { if (Enorm>fLoThr && Enorm<fHiThr) {
trk.SetEs(falpha1); // Set energies with unit gains for now. trk.SetEs(falpha1); // Set energies with unit gains for now.
// trk.Print(); // trk.Print(cout);
fe0 += trk.GetP(); // Accumulate track momenta. fe0 += trk.GetP(); // Accumulate track momenta.
...@@ -463,7 +368,7 @@ void THcShowerCalib::ComposeVMs() { ...@@ -463,7 +368,7 @@ void THcShowerCalib::ComposeVMs() {
for (UInt_t i=0; i<trk.GetNhits(); i++) { for (UInt_t i=0; i<trk.GetNhits(); i++) {
THcShHit* hit = trk.GetHit(i); THcShHit* hit = trk.GetHit(i);
// hit->Print(); // hit->Print(cout);
UInt_t nb = hit->GetBlkNumber(); UInt_t nb = hit->GetBlkNumber();
...@@ -723,7 +628,7 @@ void THcShowerCalib::FillHEcal() { ...@@ -723,7 +628,7 @@ void THcShowerCalib::FillHEcal() {
for (UInt_t ientry=0; ientry<fNentries; ientry++) { for (UInt_t ientry=0; ientry<fNentries; ientry++) {
ReadShRawTrack(trk, ientry); ReadShRawTrack(trk, ientry);
// trk.Print(); // trk.Print(cout);
trk.SetEs(falphaC); // use 'constrained' calibration constants trk.SetEs(falphaC); // use 'constrained' calibration constants
// trk.SetEs(falphaU); // trk.SetEs(falphaU);
......
...@@ -11,13 +11,13 @@ void hcal_calib(Int_t RunNumber) { ...@@ -11,13 +11,13 @@ void hcal_calib(Int_t RunNumber) {
THcShowerCalib theShowerCalib(RunNumber); THcShowerCalib theShowerCalib(RunNumber);
// theShowerCalib.ExtractData(); // Extract data from the Root file theShowerCalib.Init(); // Initialize constants adn variables
theShowerCalib.Init(); // Initialize constants adn variables theShowerCalib.CalcThresholds(); // Thresholds on the uncalibrated Edep/P
theShowerCalib.CalcThresholds(); // Thresholds on the uncalibrated Edep/P theShowerCalib.ComposeVMs(); // Compute vectors amd matrices for calib.
theShowerCalib.ComposeVMs(); // Compute vectors amd matrices for calib. theShowerCalib.SolveAlphas(); // Solve for the calibration constants
theShowerCalib.SolveAlphas(); // Solve for the calibration constants theShowerCalib.SaveAlphas(); // Save the constants
theShowerCalib.FillHEcal(); // Fill histograms theShowerCalib.SaveRawData(); // Save raw data into file for debug purposes
theShowerCalib.SaveAlphas(); // Save the constants theShowerCalib.FillHEcal(); // Fill histograms
// Plot histograms // Plot histograms
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment