From 904625f3ccaa37bf3652bd6a1702a8e43b8c8463 Mon Sep 17 00:00:00 2001 From: Vardan Tadevosyan <tadevosn@jlab.org> Date: Wed, 15 May 2013 09:11:16 -0400 Subject: [PATCH] Added reading calibration constants and pedestal thresholds --- examples/PARAM/general.param | 2 + examples/hodtest.C | 4 +- setup.csh | 3 - src/THcShower.cxx | 153 +++++++++++++++++++++++++++++++++++ src/THcShower.h | 22 +++-- 5 files changed, 175 insertions(+), 9 deletions(-) diff --git a/examples/PARAM/general.param b/examples/PARAM/general.param index c327a18..91b4ebd 100644 --- a/examples/PARAM/general.param +++ b/examples/PARAM/general.param @@ -26,3 +26,5 @@ raddeg=3.14159265/180 #include "PARAM/haero.param" #include "PARAM/hdc.param" #include "PARAM/hdriftmap.param" +#include "PARAM/hcal.param" + diff --git a/examples/hodtest.C b/examples/hodtest.C index 982e284..dc58902 100644 --- a/examples/hodtest.C +++ b/examples/hodtest.C @@ -63,8 +63,10 @@ // Eventually need to learn to skip over, or properly analyze // the pedestal events - run->SetEventRange(1,2000);// Physics Event number, does not + // run->SetEventRange(1,2000);// Physics Event number, does not // include scaler or control events + // run->SetEventRange(1,999999); + run->SetEventRange(1,1); // Define the analysis parameters analyzer->SetEvent( event ); diff --git a/setup.csh b/setup.csh index 2b3f8f3..52fc454 100644 --- a/setup.csh +++ b/setup.csh @@ -15,6 +15,3 @@ if ( ! ($?LD_LIBRARY_PATH) ) then setenv LD_LIBRARY_PATH "" endif setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${ANALYZER}:${HCANALYZER}" - - - diff --git a/src/THcShower.cxx b/src/THcShower.cxx index 7bce97a..fca64ee 100644 --- a/src/THcShower.cxx +++ b/src/THcShower.cxx @@ -171,6 +171,7 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) }; gHcParms->LoadParmValues((DBRequest*)&list, prefix); } + YPos = new Double_t* [fNLayers]; for(Int_t i=0;i<fNLayers;i++) { YPos[i] = new Double_t [fNBlocks[i]]; @@ -180,6 +181,7 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) }; gHcParms->LoadParmValues((DBRequest*)&list, prefix); } + for(Int_t i=0;i<fNLayers;i++) { cout << "Plane " << fLayerNames[i] << ":" << endl; cout << " Block thickness: " << BlockThick[i] << endl; @@ -191,8 +193,159 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) cout << " " << YPos[i][j]; } cout << endl; + } + //Calibration related parameters (from hcal.param). + + fNtotBlocks=0; //total number of blocks + for (Int_t i=0; i<fNLayers; i++) fNtotBlocks += fNBlocks[i]; + + cout << "Total number of blocks in he calorimeter: " << fNtotBlocks << endl; + + //Pedestal limits from hcal.param. + fCalPosPedLimit = new Int_t [fNtotBlocks]; + fCalNegPedLimit = new Int_t [fNtotBlocks]; + + //Calibration constants + fCalPosCalConst = new Double_t [fNtotBlocks]; + fCalNegCalConst = new Double_t [fNtotBlocks]; + + //Read in parameters from hcal.param + Double_t hcal_pos_cal_const[fNtotBlocks]; + // Double_t hcal_pos_gain_ini[fNtotBlocks]; + // Double_t hcal_pos_gain_cur[fNtotBlocks]; + Int_t hcal_pos_ped_limit[fNtotBlocks]; + Double_t hcal_pos_gain_cor[fNtotBlocks]; + + Double_t hcal_neg_cal_const[fNtotBlocks]; + // Double_t hcal_neg_gain_ini[fNtotBlocks]; + // Double_t hcal_neg_gain_cur[fNtotBlocks]; + Int_t hcal_neg_ped_limit[fNtotBlocks]; + Double_t hcal_neg_gain_cor[fNtotBlocks]; + + DBRequest list[]={ + {"cal_pos_cal_const", hcal_pos_cal_const, kDouble, fNtotBlocks}, + // {"cal_pos_gain_ini", hcal_pos_gain_ini, kDouble, fNtotBlocks}, + // {"cal_pos_gain_cur", hcal_pos_gain_cur, kDouble, fNtotBlocks}, + {"cal_pos_ped_limit", hcal_pos_ped_limit, kInt, fNtotBlocks}, + {"cal_pos_gain_cor", hcal_pos_gain_cor, kDouble, fNtotBlocks}, + {"cal_neg_cal_const", hcal_neg_cal_const, kDouble, fNtotBlocks}, + // {"cal_neg_gain_ini", hcal_neg_gain_ini, kDouble, fNtotBlocks}, + // {"cal_neg_gain_cur", hcal_neg_gain_cur, kDouble, fNtotBlocks}, + {"cal_neg_ped_limit", hcal_neg_ped_limit, kInt, fNtotBlocks}, + {"cal_neg_gain_cor", hcal_neg_gain_cor, kDouble, fNtotBlocks}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list, prefix); + + //+++ + + cout << "hcal_pos_cal_const:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_pos_cal_const[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + // cout << "hcal_pos_gain_ini:" << endl; + // for (Int_t j=0; j<fNLayers; j++) { + // for (Int_t i=0; i<fNBlocks[j]; i++) { + // cout << hcal_pos_gain_ini[j*fNBlocks[j]+i] << " "; + // }; + // cout << endl; + // }; + + // cout << "hcal_pos_gain_cur:" << endl; + // for (Int_t j=0; j<fNLayers; j++) { + // for (Int_t i=0; i<fNBlocks[j]; i++) { + // cout << hcal_pos_gain_cur[j*fNBlocks[j]+i] << " "; + // }; + // cout << endl; + // }; + + cout << "hcal_pos_ped_limit:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_pos_ped_limit[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + cout << "hcal_pos_gain_cor:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_pos_gain_cor[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + //--- + + cout << "hcal_neg_cal_const:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_neg_cal_const[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + // cout << "hcal_neg_gain_ini:" << endl; + // for (Int_t j=0; j<fNLayers; j++) { + // for (Int_t i=0; i<fNBlocks[j]; i++) { + // cout << hcal_neg_gain_ini[j*fNBlocks[j]+i] << " "; + // }; + // // cout << endl; + // }; + + // cout << "hcal_neg_gain_cur:" << endl; + // for (Int_t j=0; j<fNLayers; j++) { + // for (Int_t i=0; i<fNBlocks[j]; i++) { + // cout << hcal_neg_gain_cur[j*fNBlocks[j]+i] << " "; + // }; + // cout << endl; + // }; + + cout << "hcal_neg_ped_limit:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_neg_ped_limit[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + cout << "hcal_neg_gain_cor:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << hcal_neg_gain_cor[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + //Calibration constants in GeV per ADC channel. + + for (Int_t i=0; i<fNtotBlocks; i++) { + fCalPosCalConst[i] = hcal_pos_cal_const[i] * hcal_pos_gain_cor[i]; + fCalNegCalConst[i] = hcal_neg_cal_const[i] * hcal_neg_gain_cor[i]; + } + + cout << "fCalPosCalConst:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << fCalPosCalConst[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + + cout << "fCalNegCalConst:" << endl; + for (Int_t j=0; j<fNLayers; j++) { + for (Int_t i=0; i<fNBlocks[j]; i++) { + cout << fCalNegCalConst[j*fNBlocks[j]+i] << " "; + }; + cout << endl; + }; + fIsInit = true; return kOK; diff --git a/src/THcShower.h b/src/THcShower.h index 27a91da..808271a 100644 --- a/src/THcShower.h +++ b/src/THcShower.h @@ -38,20 +38,31 @@ public: friend class THaScCalib; THcShower(); // for ROOT I/O + protected: + Int_t fAnalyzePedestals; - // Calibration + + // Number of events for pedestal calculations. + Int_t* fCalPosPedLimit; + Int_t* fCalNegPedLimit; + + // Calibration constants + Double_t* fCalPosCalConst; + Double_t* fCalNegCalConst; // Per-event data // Potential Hall C parameters. Mostly here for demonstration + char** fLayerNames; Int_t fNLayers; Int_t fNRows; - Double_t* fNLayerZPos; // Z position of front of shower counter layers + Double_t* fNLayerZPos; // Z position of front of shower counter layers Double_t* BlockThick; // Thickness of shower counter blocks, blocks - Int_t* fNBlocks; // Number of shower counter blocks per layer + Int_t* fNBlocks; // Number of shower counter blocks per layer + Int_t fNtotBlocks; // Total number of shower counter blocks Double_t** YPos; //X,Y positions of shower counter blocks Double_t* XPos; @@ -59,6 +70,7 @@ protected: TClonesArray* fTrackProj; // projection of track onto scintillator plane // and estimated match to TOF paddle + // Useful derived quantities // double tan_angle, sin_angle, cos_angle; @@ -84,9 +96,9 @@ protected: enum ESide { kLeft = 0, kRight = 1 }; virtual Double_t TimeWalkCorrection(const Int_t& paddle, - const ESide side); + const ESide side); -void Setup(const char* name, const char* description); + void Setup(const char* name, const char* description); ClassDef(THcShower,0) // Generic hodoscope class }; -- GitLab