From 5ef90b4b97b84a1a8ee1f7cec1212b41797d40f2 Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Wed, 19 Sep 2012 16:06:11 -0400 Subject: [PATCH] Get shower counter parameters using DBRequest/LoadParmValues. Change shower plane names from 1z, 2z, 3z, 4z to 1pr, 2ta, 3ta, 4ta to match the names used in the parameters. Fix up histogram names for new plane names. Get rid of duplicate THaNonTrackingDetector::Init call. --- examples/output.def | 38 ++++++------- src/THcShower.cxx | 126 ++++++++++++++------------------------------ 2 files changed, 60 insertions(+), 104 deletions(-) diff --git a/examples/output.def b/examples/output.def index 2f940ea..4de4132 100644 --- a/examples/output.def +++ b/examples/output.def @@ -26,26 +26,26 @@ TH1F hposadc4 'HMS s2y+ ADC hits' H.hod.2y.posadchits 10 0.5 10.5 TH1F hnegadc4 'HMS s2y- ADC hits' H.hod.2y.negadchits 10 0.5 10.5 # ADC hits per Calorimeter layer -TH1F chposadc1 'HMS Cal A+ ADC hits' H.Cal.1z.posadchits 13 0.5 13.5 -TH1F chnegadc1 'HMS Cal A- ADC hits' H.Cal.1z.negadchits 13 0.5 13.5 -TH1F chposadc2 'HMS Cal B+ ADC hits' H.Cal.2z.posadchits 13 0.5 13.5 -TH1F chnegadc2 'HMS Cal B- ADC hits' H.Cal.2z.negadchits 13 0.5 13.5 -TH1F chposadc3 'HMS Cal C+ ADC hits' H.Cal.3z.posadchits 13 0.5 13.5 -TH1F chposadc4 'HMS Cal D+ ADC hits' H.Cal.4z.posadchits 13 0.5 13.5 +TH1F chposadc1 'HMS Cal A+ ADC hits' H.Cal.1pr.posadchits 13 0.5 13.5 +TH1F chnegadc1 'HMS Cal A- ADC hits' H.Cal.1pr.negadchits 13 0.5 13.5 +TH1F chposadc2 'HMS Cal B+ ADC hits' H.Cal.2ta.posadchits 13 0.5 13.5 +TH1F chnegadc2 'HMS Cal B- ADC hits' H.Cal.2ta.negadchits 13 0.5 13.5 +TH1F chposadc3 'HMS Cal C+ ADC hits' H.Cal.3ta.posadchits 13 0.5 13.5 +TH1F chposadc4 'HMS Cal D+ ADC hits' H.Cal.4ta.posadchits 13 0.5 13.5 -TH1F calposadc1 'HMS Cal ADC1' H.Cal.1z.posadc1 150 -50 400 -# TH1F calposadc2 'HMS Cal ADC2' H.Cal.2z.posadc1 150 -50 400 -# TH1F chposadc 'HMS Cal ADC3' H.Cal.1z.posadc3 150 -50 400 -# TH1F chposadc 'HMS Cal ADC4' H.Cal.1z.posadc4 150 -50 400 -# TH1F chposadc 'HMS Cal ADC5' H.Cal.1z.posadc5 150 -50 400 -# TH1F chposadc 'HMS Cal ADC6' H.Cal.1z.posadc6 150 -50 400 -# TH1F chposadc 'HMS Cal ADC7' H.Cal.1z.posadc7 150 -50 400 -# TH1F chposadc 'HMS Cal ADC8' H.Cal.1z.posadc8 150 -50 400 -# TH1F chposadc 'HMS Cal ADC9' H.Cal.1z.posadc9 150 -50 400 -# TH1F chposadc 'HMS Cal ADC10' H.Cal.1z.posadc10 150 -50 400 -# TH1F chposadc 'HMS Cal ADC11' H.Cal.1z.posadc11 150 -50 400 -# TH1F chposadc 'HMS Cal ADC12' H.Cal.1z.posadc12 150 -50 400 -# TH1F chposadc 'HMS Cal ADC13' H.Cal.1z.posadc13 150 -50 400 +TH1F calposadc1 'HMS Cal ADC1' H.Cal.1pr.posadc1 150 -50 400 +# TH1F calposadc2 'HMS Cal ADC2' H.Cal.2ta.posadc1 150 -50 400 +# TH1F chposadc 'HMS Cal ADC3' H.Cal.1pr.posadc3 150 -50 400 +# TH1F chposadc 'HMS Cal ADC4' H.Cal.1pr.posadc4 150 -50 400 +# TH1F chposadc 'HMS Cal ADC5' H.Cal.1pr.posadc5 150 -50 400 +# TH1F chposadc 'HMS Cal ADC6' H.Cal.1pr.posadc6 150 -50 400 +# TH1F chposadc 'HMS Cal ADC7' H.Cal.1pr.posadc7 150 -50 400 +# TH1F chposadc 'HMS Cal ADC8' H.Cal.1pr.posadc8 150 -50 400 +# TH1F chposadc 'HMS Cal ADC9' H.Cal.1pr.posadc9 150 -50 400 +# TH1F chposadc 'HMS Cal ADC10' H.Cal.1pr.posadc10 150 -50 400 +# TH1F chposadc 'HMS Cal ADC11' H.Cal.1pr.posadc11 150 -50 400 +# TH1F chposadc 'HMS Cal ADC12' H.Cal.1pr.posadc12 150 -50 400 +# TH1F chposadc 'HMS Cal ADC13' H.Cal.1pr.posadc13 150 -50 400 #TH1F hdcrawtdc #TH1F hdccuttdc diff --git a/src/THcShower.cxx b/src/THcShower.cxx index 96d94db..6de0e85 100644 --- a/src/THcShower.cxx +++ b/src/THcShower.cxx @@ -37,7 +37,6 @@ THcShower::THcShower( const char* name, const char* description, THaNonTrackingDetector(name,description,apparatus) { // Constructor - Setup(name, description); // fTrackProj = new TClonesArray( "THaTrackProj", 5 ); } @@ -60,11 +59,12 @@ void THcShower::Setup(const char* name, const char* description) fNLayers = 4; // Eventually get # layers and layer names from a DB fLayerNames = new char* [fNLayers]; - for(Int_t i=0;i<fNLayers;i++) {fLayerNames[i] = new char[3];} - strcpy(fLayerNames[0],"1z"); - strcpy(fLayerNames[1],"2z"); - strcpy(fLayerNames[2],"3z"); - strcpy(fLayerNames[3],"4z"); + for(Int_t i=0;i<fNLayers;i++) {fLayerNames[i] = new char[4];} + // Use layer names to help construct parameter names + strcpy(fLayerNames[0],"1pr"); + strcpy(fLayerNames[1],"2ta"); + strcpy(fLayerNames[2],"3ta"); + strcpy(fLayerNames[3],"4ta"); size_t nlen = strlen(name); size_t slen = 0; @@ -92,10 +92,7 @@ THaAnalysisObject::EStatus THcShower::Init( const TDatime& date ) static const char* const here = "Init()"; cout << "THcShower::Init " << GetName() << endl; - - if( THaNonTrackingDetector::Init( date ) ) - return fStatus; - + Setup(GetName(), GetTitle()); // Should probably put this in ReadDatabase as we will know the // maximum number of hits after setting up the detector map @@ -131,6 +128,7 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) // 'date' contains the date/time of the run being analyzed. // static const char* const here = "ReadDatabase()"; + char prefix[2]; // Read data from database // Pull values from the THcParmList instead of reading a database @@ -142,89 +140,47 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) // Will need to determine which spectrometer in order to construct // the parameter names (e.g. hscin_1x_nr vs. sscin_1x_nr) -cout << "THcShower::ReadDatabase called " << GetName() << endl; + cout << "THcShower::ReadDatabase called " << GetName() << endl; - fNLayers = 4; // Hardwire for now + prefix[0]=tolower(GetApparatus()->GetName()[0]); + prefix[1]='\0'; BlockThick = new Double_t [fNLayers]; - - BlockThick[0] = *(Double_t *)gHcParms->Find("hcal_1pr_thick")->GetValuePointer(); - BlockThick[1] = *(Double_t *)gHcParms->Find("hcal_2ta_thick")->GetValuePointer(); - BlockThick[2] = *(Double_t *)gHcParms->Find("hcal_3ta_thick")->GetValuePointer(); - BlockThick[3] = *(Double_t *)gHcParms->Find("hcal_4ta_thick")->GetValuePointer(); - -cout << "Block thickness: " << BlockThick[2] << endl; - -fNBlocks = new Int_t [fNLayers]; - - fNBlocks[0] = *(Int_t *)gHcParms->Find("hcal_1pr_nr")->GetValuePointer(); - fNBlocks[1] = *(Int_t *)gHcParms->Find("hcal_2ta_nr")->GetValuePointer(); - fNBlocks[2] = *(Int_t *)gHcParms->Find("hcal_3ta_nr")->GetValuePointer(); - fNBlocks[3] = *(Int_t *)gHcParms->Find("hcal_4ta_nr")->GetValuePointer(); - - cout << "Number of blocks per layer: " << fNBlocks[2] << endl; - + fNBlocks = new Int_t [fNLayers]; fNLayerZPos = new Double_t [fNLayers]; - - fNLayerZPos[0] = *(Double_t *)gHcParms->Find("hcal_1pr_zpos")->GetValuePointer(); - fNLayerZPos[1] = *(Double_t *)gHcParms->Find("hcal_2ta_zpos")->GetValuePointer(); - fNLayerZPos[2] = *(Double_t *)gHcParms->Find("hcal_3ta_zpos")->GetValuePointer(); - fNLayerZPos[3] = *(Double_t *)gHcParms->Find("hcal_4ta_zpos")->GetValuePointer(); - -cout << "Z Position: " << fNLayerZPos[2] << endl; - XPos = new Double_t [2*fNLayers]; - XPos[0] = *(Double_t *)gHcParms->Find("hcal_1pr_left")->GetValuePointer(); - XPos[1] = *(Double_t *)gHcParms->Find("hcal_1pr_right")->GetValuePointer(); - XPos[2] = *(Double_t *)gHcParms->Find("hcal_2ta_left")->GetValuePointer(); - XPos[3] = *(Double_t *)gHcParms->Find("hcal_2ta_right")->GetValuePointer(); - XPos[4] = *(Double_t *)gHcParms->Find("hcal_3ta_left")->GetValuePointer(); - XPos[5] = *(Double_t *)gHcParms->Find("hcal_3ta_right")->GetValuePointer(); - XPos[6] = *(Double_t *)gHcParms->Find("hcal_4ta_left")->GetValuePointer(); - XPos[7] = *(Double_t *)gHcParms->Find("hcal_4ta_right")->GetValuePointer(); - -cout << "X Positions: " << XPos[0] << ", " << XPos[1] << endl; - - YPos = new Double_t* [4]; - cout << "Y Positions:"; - - Double_t* p; - Int_t ilayer; - - ilayer = 0; - p = (Double_t *)gHcParms->Find("hcal_1pr_top")->GetValuePointer(); - YPos[ilayer] = new Double_t [fNBlocks[ilayer]]; - // Print out some parameters just to demonstrate that it works - - for(Int_t i=0;i<fNBlocks[ilayer];i++) { - YPos[ilayer][i] = p[i]; - cout << " " << YPos[ilayer][i]; - } - cout << endl; - - ilayer = 1; - p = (Double_t *)gHcParms->Find("hcal_2ta_top")->GetValuePointer(); - YPos[ilayer] = new Double_t [fNBlocks[ilayer]]; - - for(Int_t i=0;i<fNBlocks[ilayer];i++) { - YPos[ilayer][i] = p[i]; + for(Int_t i=0;i<fNLayers;i++) { + DBRequest list[]={ + {Form("cal_%s_thick",fLayerNames[i]), &BlockThick[i], kDouble}, + {Form("cal_%s_nr",fLayerNames[i]), &fNBlocks[i], kInt}, + {Form("cal_%s_zpos",fLayerNames[i]), &fNLayerZPos[i], kDouble}, + {Form("cal_%s_left",fLayerNames[i]), &XPos[2*i], kDouble}, + {Form("cal_%s_right",fLayerNames[i]), &XPos[2*i+1], kDouble}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list, prefix); } - - ilayer = 2; - p = (Double_t *)gHcParms->Find("hcal_3ta_top")->GetValuePointer(); - YPos[ilayer] = new Double_t [fNBlocks[ilayer]]; - - for(Int_t i=0;i<fNBlocks[ilayer];i++) { - YPos[ilayer][i] = p[i]; + YPos = new Double_t* [fNLayers]; + for(Int_t i=0;i<fNLayers;i++) { + YPos[i] = new Double_t [fNBlocks[i]]; + DBRequest list[]={ + {Form("cal_%s_top",fLayerNames[i]),YPos[i], kDouble, fNBlocks[i]}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list, prefix); } - - ilayer = 3; - p = (Double_t *)gHcParms->Find("hcal_4ta_top")->GetValuePointer(); - YPos[ilayer] = new Double_t [fNBlocks[ilayer]]; - - for(Int_t i=0;i<fNBlocks[ilayer];i++) { - YPos[ilayer][i] = p[i]; + for(Int_t i=0;i<fNLayers;i++) { + cout << "Plane " << fLayerNames[i] << ":" << endl; + cout << " Block thickness: " << BlockThick[i] << endl; + cout << " NBlocks : " << fNBlocks[i] << endl; + cout << " Z Position : " << fNLayerZPos[i] << endl; + cout << " X Positions : " << XPos[2*i] << ", " << XPos[2*i+1] << endl; + cout << " Y Positions :"; + for(Int_t j=0; j<fNBlocks[i]; j++) { + cout << " " << YPos[i][j]; + } + cout << endl; } fIsInit = true; -- GitLab