From 85dd8ba6afbe99007a7ef002608505a4cf63e512 Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Thu, 21 Mar 2013 15:19:08 -0400 Subject: [PATCH] Histogram every shower counter channel. Started with Simon's code, but reworked: Use podd style arrays in RVarDef. Get plane names (1pr, 2ta, 3ta, 4ta) from parameter file. Get block counts from parameters instead of hardwiring. Rename histogram names to be A,B,C,D 1-13, instead of 1-52 --- examples/PARAM/hcana.param | 5 +- examples/output.def | 97 +++++++++++++++++--- src/THcHodoscope.cxx | 2 +- src/THcShower.cxx | 60 +++++++----- src/THcShower.h | 4 +- src/THcShowerPlane.cxx | 182 +++++++++++++------------------------ src/THcShowerPlane.h | 17 +--- 7 files changed, 193 insertions(+), 174 deletions(-) diff --git a/examples/PARAM/hcana.param b/examples/PARAM/hcana.param index e8fb336..d7f6f97 100644 --- a/examples/PARAM/hcana.param +++ b/examples/PARAM/hcana.param @@ -5,9 +5,12 @@ hhodo_num_planes = 4 -hshower_num_layers = 4 +hcal_num_layers = 4 haero_num_pairs = 8 # Names of planes so that parameter names can be constructed hdc_plane_names = "1x1 1y1 1u1 1v1 1y2 1x2 2x1 2y1 2u1 2v1 2y2 2x2" + +hcal_layer_names = "1pr 2ta 3ta 4ta" + diff --git a/examples/output.def b/examples/output.def index 8369d6c..bbacccd 100644 --- a/examples/output.def +++ b/examples/output.def @@ -34,19 +34,90 @@ 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.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 +#Calorimeter ADC channels +TH1F hcaladc_A1p 'HMS Cal ADC A1p - PED' H.Cal.1pr.apos_p[0] 150 50 500 +TH1F hcaladc_A2p 'HMS Cal ADC A2p - PED' H.Cal.1pr.apos_p[1] 150 50 500 +TH1F hcaladc_A3p 'HMS Cal ADC A3p - PED' H.Cal.1pr.apos_p[2] 150 50 500 +TH1F hcaladc_A4p 'HMS Cal ADC A4p - PED' H.Cal.1pr.apos_p[3] 150 50 500 +TH1F hcaladc_A5p 'HMS Cal ADC A5p - PED' H.Cal.1pr.apos_p[4] 150 50 500 +TH1F hcaladc_A6p 'HMS Cal ADC A6p - PED' H.Cal.1pr.apos_p[5] 150 50 500 +TH1F hcaladc_A7p 'HMS Cal ADC A7p - PED' H.Cal.1pr.apos_p[6] 150 50 500 +TH1F hcaladc_A8p 'HMS Cal ADC A8p - PED' H.Cal.1pr.apos_p[7] 150 50 500 +TH1F hcaladc_A9p 'HMS Cal ADC A9p - PED' H.Cal.1pr.apos_p[8] 150 50 500 +TH1F hcaladc_A10p 'HMS Cal ADC A10p - PED' H.Cal.1pr.apos_p[9] 150 50 500 +TH1F hcaladc_A11p 'HMS Cal ADC A11p - PED' H.Cal.1pr.apos_p[10] 150 50 500 +TH1F hcaladc_A12p 'HMS Cal ADC A12p - PED' H.Cal.1pr.apos_p[11] 150 50 500 +TH1F hcaladc_A13p 'HMS Cal ADC A13p - PED' H.Cal.1pr.apos_p[12] 150 50 500 + +TH1F hcaladc_B1p 'HMS Cal ADC B1p - PED' H.Cal.2ta.apos_p[0] 150 50 500 +TH1F hcaladc_B2p 'HMS Cal ADC B2p - PED' H.Cal.2ta.apos_p[1] 150 50 500 +TH1F hcaladc_B3p 'HMS Cal ADC B3p - PED' H.Cal.2ta.apos_p[2] 150 50 500 +TH1F hcaladc_B4p 'HMS Cal ADC B4p - PED' H.Cal.2ta.apos_p[3] 150 50 500 +TH1F hcaladc_B5p 'HMS Cal ADC B5p - PED' H.Cal.2ta.apos_p[4] 150 50 500 +TH1F hcaladc_B6p 'HMS Cal ADC B6p - PED' H.Cal.2ta.apos_p[5] 150 50 500 +TH1F hcaladc_B7p 'HMS Cal ADC B7p - PED' H.Cal.2ta.apos_p[6] 150 50 500 +TH1F hcaladc_B8p 'HMS Cal ADC B8p - PED' H.Cal.2ta.apos_p[7] 150 50 500 +TH1F hcaladc_B9p 'HMS Cal ADC B9p - PED' H.Cal.2ta.apos_p[8] 150 50 500 +TH1F hcaladc_B10p 'HMS Cal ADC B10p - PED' H.Cal.2ta.apos_p[9] 150 50 500 +TH1F hcaladc_B11p 'HMS Cal ADC B11p - PED' H.Cal.2ta.apos_p[10] 150 50 500 +TH1F hcaladc_B12p 'HMS Cal ADC B12p - PED' H.Cal.2ta.apos_p[11] 150 50 500 +TH1F hcaladc_B13p 'HMS Cal ADC B13p - PED' H.Cal.2ta.apos_p[12] 150 50 500 + +TH1F hcaladc_C1p 'HMS Cal ADC C1p - PED' H.Cal.3ta.apos_p[0] 150 50 500 +TH1F hcaladc_C2p 'HMS Cal ADC C2p - PED' H.Cal.3ta.apos_p[1] 150 50 500 +TH1F hcaladc_C3p 'HMS Cal ADC C3p - PED' H.Cal.3ta.apos_p[2] 150 50 500 +TH1F hcaladc_C4p 'HMS Cal ADC C4p - PED' H.Cal.3ta.apos_p[3] 150 50 500 +TH1F hcaladc_C5p 'HMS Cal ADC C5p - PED' H.Cal.3ta.apos_p[4] 150 50 500 +TH1F hcaladc_C6p 'HMS Cal ADC C6p - PED' H.Cal.3ta.apos_p[5] 150 50 500 +TH1F hcaladc_C7p 'HMS Cal ADC C7p - PED' H.Cal.3ta.apos_p[6] 150 50 500 +TH1F hcaladc_C8p 'HMS Cal ADC C8p - PED' H.Cal.3ta.apos_p[7] 150 50 500 +TH1F hcaladc_C9p 'HMS Cal ADC C9p - PED' H.Cal.3ta.apos_p[8] 150 50 500 +TH1F hcaladc_C10p 'HMS Cal ADC C10p - PED' H.Cal.3ta.apos_p[9] 150 50 500 +TH1F hcaladc_C11p 'HMS Cal ADC C11p - PED' H.Cal.3ta.apos_p[10] 150 50 500 +TH1F hcaladc_C12p 'HMS Cal ADC C12p - PED' H.Cal.3ta.apos_p[11] 150 50 500 +TH1F hcaladc_C13p 'HMS Cal ADC C13p - PED' H.Cal.3ta.apos_p[12] 150 50 500 + +TH1F hcaladc_D1p 'HMS Cal ADC D1p - PED' H.Cal.4ta.apos_p[0] 150 50 500 +TH1F hcaladc_D2p 'HMS Cal ADC D2p - PED' H.Cal.4ta.apos_p[1] 150 50 500 +TH1F hcaladc_D3p 'HMS Cal ADC D3p - PED' H.Cal.4ta.apos_p[2] 150 50 500 +TH1F hcaladc_D4p 'HMS Cal ADC D4p - PED' H.Cal.4ta.apos_p[3] 150 50 500 +TH1F hcaladc_D5p 'HMS Cal ADC D5p - PED' H.Cal.4ta.apos_p[4] 150 50 500 +TH1F hcaladc_D6p 'HMS Cal ADC D6p - PED' H.Cal.4ta.apos_p[5] 150 50 500 +TH1F hcaladc_D7p 'HMS Cal ADC D7p - PED' H.Cal.4ta.apos_p[6] 150 50 500 +TH1F hcaladc_D8p 'HMS Cal ADC D8p - PED' H.Cal.4ta.apos_p[7] 150 50 500 +TH1F hcaladc_D9p 'HMS Cal ADC D9p - PED' H.Cal.4ta.apos_p[8] 150 50 500 +TH1F hcaladc_D10p 'HMS Cal ADC D10p - PED' H.Cal.4ta.apos_p[9] 150 50 500 +TH1F hcaladc_D11p 'HMS Cal ADC D11p - PED' H.Cal.4ta.apos_p[10] 150 50 500 +TH1F hcaladc_D12p 'HMS Cal ADC D12p - PED' H.Cal.4ta.apos_p[11] 150 50 500 +TH1F hcaladc_D13p 'HMS Cal ADC D13p - PED' H.Cal.4ta.apos_p[12] 150 50 500 + +TH1F hcaladc_A1n 'HMS Cal ADC A1n - PED' H.Cal.1pr.aneg_p[0] 150 50 500 +TH1F hcaladc_A2n 'HMS Cal ADC A2n - PED' H.Cal.1pr.aneg_p[1] 150 50 500 +TH1F hcaladc_A3n 'HMS Cal ADC A3n - PED' H.Cal.1pr.aneg_p[2] 150 50 500 +TH1F hcaladc_A4n 'HMS Cal ADC A4n - PED' H.Cal.1pr.aneg_p[3] 150 50 500 +TH1F hcaladc_A5n 'HMS Cal ADC A5n - PED' H.Cal.1pr.aneg_p[4] 150 50 500 +TH1F hcaladc_A6n 'HMS Cal ADC A6n - PED' H.Cal.1pr.aneg_p[5] 150 50 500 +TH1F hcaladc_A7n 'HMS Cal ADC A7n - PED' H.Cal.1pr.aneg_p[6] 150 50 500 +TH1F hcaladc_A8n 'HMS Cal ADC A8n - PED' H.Cal.1pr.aneg_p[7] 150 50 500 +TH1F hcaladc_A9n 'HMS Cal ADC A9n - PED' H.Cal.1pr.aneg_p[8] 150 50 500 +TH1F hcaladc_A10n 'HMS Cal ADC A10n - PED' H.Cal.1pr.aneg_p[9] 150 50 500 +TH1F hcaladc_A11n 'HMS Cal ADC A11n - PED' H.Cal.1pr.aneg_p[10] 150 50 500 +TH1F hcaladc_A12n 'HMS Cal ADC A12n - PED' H.Cal.1pr.aneg_p[11] 150 50 500 +TH1F hcaladc_A13n 'HMS Cal ADC A13n - PED' H.Cal.1pr.aneg_p[12] 150 50 500 + +TH1F hcaladc_B1n 'HMS Cal ADC B1n - PED' H.Cal.2ta.aneg_p[0] 150 50 500 +TH1F hcaladc_B2n 'HMS Cal ADC B2n - PED' H.Cal.2ta.aneg_p[1] 150 50 500 +TH1F hcaladc_B3n 'HMS Cal ADC B3n - PED' H.Cal.2ta.aneg_p[2] 150 50 500 +TH1F hcaladc_B4n 'HMS Cal ADC B4n - PED' H.Cal.2ta.aneg_p[3] 150 50 500 +TH1F hcaladc_B5n 'HMS Cal ADC B5n - PED' H.Cal.2ta.aneg_p[4] 150 50 500 +TH1F hcaladc_B6n 'HMS Cal ADC B6n - PED' H.Cal.2ta.aneg_p[5] 150 50 500 +TH1F hcaladc_B7n 'HMS Cal ADC B7n - PED' H.Cal.2ta.aneg_p[6] 150 50 500 +TH1F hcaladc_B8n 'HMS Cal ADC B8n - PED' H.Cal.2ta.aneg_p[7] 150 50 500 +TH1F hcaladc_B9n 'HMS Cal ADC B9n - PED' H.Cal.2ta.aneg_p[8] 150 50 500 +TH1F hcaladc_B10n 'HMS Cal ADC B10n - PED' H.Cal.2ta.aneg_p[9] 150 50 500 +TH1F hcaladc_B11n 'HMS Cal ADC B11n - PED' H.Cal.2ta.aneg_p[10] 150 50 500 +TH1F hcaladc_B12n 'HMS Cal ADC B12n - PED' H.Cal.2ta.aneg_p[11] 150 50 500 +TH1F hcaladc_B13n 'HMS Cal ADC B13n - PED' H.Cal.2ta.aneg_p[12] 150 50 500 #TH1F hdcrawtdc #TH1F hdccuttdc diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index de6278f..4d09ccf 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -615,7 +615,7 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) fGoodStartTime=kFALSE; fStartTime=fStartTimeCenter; } - cout <<" stats = "<<fGoodStartTime<<" "<<nfptimes<<" fStartTime = "<<fStartTime<<endl; + // cout <<" stats = "<<fGoodStartTime<<" "<<nfptimes<<" fStartTime = "<<fStartTime<<endl; // fRawHitList is TClones array of THcHodoscopeHit objects #if 0 for(Int_t ihit = 0; ihit < fNRawHits ; ihit++) { diff --git a/src/THcShower.cxx b/src/THcShower.cxx index 6de0e85..7bce97a 100644 --- a/src/THcShower.cxx +++ b/src/THcShower.cxx @@ -38,6 +38,7 @@ THcShower::THcShower( const char* name, const char* description, { // Constructor // fTrackProj = new TClonesArray( "THaTrackProj", 5 ); + fNLayers = 0; // No layers until we make them } //_____________________________________________________________________________ @@ -50,31 +51,38 @@ THcShower::THcShower( ) : void THcShower::Setup(const char* name, const char* description) { - static const char* const here = "Setup()"; - static const char* const message = - "Must construct %s detector with valid name! Object construction failed."; + char prefix[2]; + + prefix[0] = tolower(GetApparatus()->GetName()[0]); + prefix[1] = '\0'; + + string layernamelist; + DBRequest list[]={ + {"cal_num_layers", &fNLayers, kInt}, + {"cal_layer_names", &layernamelist, kString}, + {0} + }; - // Base class constructor failed? - if( IsZombie()) return; + gHcParms->LoadParmValues((DBRequest*)&list,prefix); + cout << layernamelist << endl; + cout << "Shower Counter: " << fNLayers << " layers" << endl; + + vector<string> layer_names = vsplit(layernamelist); + + if(layer_names.size() != (UInt_t) fNLayers) { + cout << "ERROR: Number of layers " << fNLayers << " doesn't agree with number of layer names " << layer_names.size() << endl; + // Should quit. Is there an official way to quit? + } - 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[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; - for(Int_t i=0;i < fNLayers;i++) - {slen = TMath::Max(slen,strlen(fLayerNames[i]));} - size_t len = nlen+slen+1; - - // Probably shouldn't assume that description is defined - char* desc = new char[strlen(description)+50+slen]; + for(Int_t i=0;i<fNLayers;i++) { + fLayerNames[i] = new char[layer_names[i].length()]; + strcpy(fLayerNames[i], layer_names[i].c_str()); + } + + char *desc = new char[strlen(description)+100]; fPlanes = new THcShowerPlane* [fNLayers]; + for(Int_t i=0;i < fNLayers;i++) { strcpy(desc, description); strcat(desc, " Plane "); @@ -108,11 +116,13 @@ THaAnalysisObject::EStatus THcShower::Init( const TDatime& date ) return fStatus=status; } } - // Will need to determine which apparatus it belongs to and use the - // appropriate detector ID in the FillMap call - if( gHcDetectorMap->FillMap(fDetMap, "HCAL") < 0 ) { + + char EngineDID[] = " CAL"; + EngineDID[0] = toupper(GetApparatus()->GetName()[0]); + + if( gHcDetectorMap->FillMap(fDetMap, EngineDID) < 0 ) { Error( Here(here), "Error filling detectormap for %s.", - "HCAL"); + EngineDID); return kInitError; } diff --git a/src/THcShower.h b/src/THcShower.h index 9926c63..27a91da 100644 --- a/src/THcShower.h +++ b/src/THcShower.h @@ -33,7 +33,8 @@ public: Int_t GetNTracks() const { return fTrackProj->GetLast()+1; } const TClonesArray* GetTrackHits() const { return fTrackProj; } - + + Int_t GetNBlocks(Int_t plane) const { return fNBlocks[plane-1];} friend class THaScCalib; THcShower(); // for ROOT I/O @@ -47,6 +48,7 @@ protected: // 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* BlockThick; // Thickness of shower counter blocks, blocks Int_t* fNBlocks; // Number of shower counter blocks per layer diff --git a/src/THcShowerPlane.cxx b/src/THcShowerPlane.cxx index 643a4f4..0afc59c 100644 --- a/src/THcShowerPlane.cxx +++ b/src/THcShowerPlane.cxx @@ -36,7 +36,11 @@ THcShowerPlane::THcShowerPlane( const char* name, // Normal constructor with name and description fPosADCHits = new TClonesArray("THcSignalHit",13); fNegADCHits = new TClonesArray("THcSignalHit",13); - fPosADC1 = new TClonesArray("THcSignalHit",13); + + //#if ROOT_VERSION_CODE < ROOT_VERSION(5,32,0) + // fPosADCHitsClass = fPosADCHits->GetClass(); + // fNegADCHitsClass = fNegADCHits->GetClass(); + //#endif fLayerNum = layernum; } @@ -47,7 +51,11 @@ THcShowerPlane::~THcShowerPlane() // Destructor delete fPosADCHits; delete fNegADCHits; - delete fPosADC1; + + delete [] fA_Pos; + delete [] fA_Neg; + delete [] fA_Pos_p; + delete [] fA_Neg_p; } THaAnalysisObject::EStatus THcShowerPlane::Init( const TDatime& date ) @@ -91,7 +99,19 @@ Int_t THcShowerPlane::ReadDatabase( const TDatime& date ) strcat(parname,"_nr"); cout << " Getting value of SHOWER!!!" << parname << endl; -fNelem = 13; + + // Retrieve parameters we need from parent class + THcShower* fParent; + + fParent = (THcShower*) GetParent(); + + fNelem = fParent->GetNBlocks(fLayerNum); + + fA_Pos = new Float_t[fNelem]; + fA_Neg = new Float_t[fNelem]; + fA_Pos_p = new Float_t[fNelem]; + fA_Neg_p = new Float_t[fNelem]; + // fNelem = *(Int_t *)gHcParms->Find(parname)->GetValuePointer(); // // parname[plen]='\0'; @@ -120,79 +140,17 @@ Int_t THcShowerPlane::DefineVariables( EMode mode ) if( mode == kDefine && fIsSetup ) return kOK; fIsSetup = ( mode == kDefine ); -/* -char spos1[256]; -char spos2[256]; -char spos3[256]; - - // Register variables in global list - RVarDef vars[15]; - vars[0] = "posadchits", "List of Positive ADC hits", - "fPosADCHits.THcSignalHit.GetPaddleNumber()"; - - vars[1] = "negadchits", "List of Negative ADC hits", - "fNegADCHits.THcSignalHit.GetPaddleNumber()"; - - for(Int_t i=2;i<15;i++){ - sprintf(spos1,"posadc1%d",i-1); - sprintf(spos2,"ADC%d hits",i-1); - sprintf(spos3,"fPosADC1[%d].THcSignalHit.Get",i-1); - vars[i] = spos1,spos2,spos3; - } - -*/ -fA = new Float_t[13]; - -char spos1[256]; -char spos2[256]; -char spos3[256]; - -sprintf(spos1,"posadc%d",1); -sprintf(spos2,"ADC%d hits",1); -sprintf(spos3,"fPosADC%d.THcSignalHit.GetPaddleNumber()",1); -Double_t *fa = new Double_t[4]; -fa[0] = 0.0; -fa[1] = 1.0; -fa[2] = 2.0; -fa[3] = 3.0; - -RVarDef vars[4]; - -vars[0].name = "posadchits"; -vars[0].desc = "List of Positive ADC hits"; -vars[0].def = "fPosADCHits.THcSignalHit.GetPaddleNumber()"; - -vars[1].name = "negadchits"; -vars[1].desc = "List of Negative ADC hits"; -vars[1].def = "fNegADCHits.THcSignalHit.GetPaddleNumber()"; - -vars[2].name = "posadc1"; -vars[2].desc = "ADC1 hits"; -//vars[2].def = "fA"; -vars[2].def = "fPosADC1.THcSignalHit.GetPaddleNumber()"; - -// vars[2].name = spos1; -// vars[2].desc = spos2; -// vars[2].def = spos3; - - -vars[3].name = NULL; -vars[3].desc = NULL; -vars[3].def = NULL; - - -/* // Register variables in global list RVarDef vars[] = { - {"posadchits", "List of Positive ADC hits", - "fPosADCHits.THcSignalHit.GetPaddleNumber()"}, - {"negadchits", "List of Negative ADC hits", - "fNegADCHits.THcSignalHit.GetPaddleNumber()"}, - {"posadc1", "ADC1 hits", - "fPosADC1.THcSignalHit.GetPaddleNumber()"}, + {"posadchits", "List of Positive ADC hits","fPosADCHits.THcSignalHit.GetPaddleNumber()"}, + {"negadchits", "List of Negative ADC hits","fNegADCHits.THcSignalHit.GetPaddleNumber()"}, + {"apos", "Raw Positive ADC Amplitudes", "fA_Pos"}, + {"aneg", "Raw Negative ADC Amplitudes", "fA_Neg"}, + {"apos_p", "Ped-subtracted Positive ADC Amplitudes", "fA_Pos_p"}, + {"aneg_p", "Ped-subtracted Negative ADC Amplitudes", "fA_Neg_p"}, { 0 } }; -*/ + return DefineVarsFromList( vars, mode ); } @@ -203,7 +161,6 @@ void THcShowerPlane::Clear( Option_t* ) // Clears the hit lists fPosADCHits->Clear(); fNegADCHits->Clear(); - fPosADC1->Clear(); } //_____________________________________________________________________________ @@ -238,66 +195,49 @@ Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t nNegADCHits=0; fPosADCHits->Clear(); fNegADCHits->Clear(); - fPosADC1->Clear(); -//-------Thresholds values are taken from ENGINE -double hcal_new_threshold_pos[52] = { -// 485.7,505.7,407.8,513.6,547.2,343.0,437.5,420.2,444.6,354.7,498.4,251.9,565.3, -// 430.5,485.1,286.7,388.4,425.9,452.1,486.8,456.3,285.9,381.8,250.9,261.6,424.7, -// 361.4,378.9,431.3,224.0,488.2,352.9,436.3,379.9,343.9,432.8,462.8,252.3,427.0, -// 399.9,296.9,378.6,367.4,514.9,564.8,561.5,475.8,390.1,433.9,334.4,407.4,516.2}; - -470.7+12.6, 490.7+24.1, 392.8+12.1, 498.6+10.9, 532.2+14.1, 328.0+14.5, 422.5+14.0, 405.2+12.5, 429.6+11.4, 339.7+12.9, 483.4+14.8, 236.9+11.5, 550.3+10.0, -415.5+12.5, 470.1+16.3, 271.7+11.7, 373.4+11.5, 410.9+10.7, 437.1+10.3, 471.8+10.0, 441.3+10.0, 270.9+11.0, 366.8+10.0, 235.9+12.5, 246.6+10.0, 409.7+11.6, -346.4+13.2, 363.9+11.1, 416.3+10.1, 209.0+10.0, 473.2+12.5, 337.9+14.4, 421.3+10.0, 364.9+10.1, 328.9+17.9, 417.8+11.6, 447.8+16.5, 237.3+11.5, 412.0+11.4, -349.9+50.0, 281.9+11.2, 363.6+18.1, 352.4+14.7, 499.9+14.7, 549.8+15.3, 546.5+14.6, 460.8+13.6, 375.1+13.4, 418.9+11.0, 319.4+14.1, 392.4+12.2, 501.2+16.0}; - - -double hcal_new_threshold_neg[52] = { -520.8+10.0, 472.0+15.9, 450.6+15.1, 451.5+12.9, 523.0+14.0, 553.3+15.9, 573.0+17.7, 494.9+14.3, 493.8+16.2, 487.8+12.2, 436.5+16.1, 438.0+10.0, 573.1+13.5, -527.4+11.8, 465.0+13.7, 460.1+13.6, 390.8+12.7, 552.3+16.7, 623.3+13.1, 549.3+13.3, 632.9+10.0, 479.7+12.1, 481.9+10.3, 412.3+15.0, 410.4+11.8, 635.1+12.6}; + for(Int_t i=0;i<fNelem;i++) { + fA_Pos[i] = 0; + fA_Neg[i] = 0; + fA_Pos_p[i] = 0; + fA_Neg_p[i] = 0; + } -CalADC1File = fopen("adc1_new.dat", "a"); -//fprintf(CalADC1File, "%d\n", 1); Int_t nrawhits = rawhits->GetLast()+1; Int_t ihit = nexthit; - //cout << "nrawhits = " << nrawhits << endl; - //cout << "nexthit = " << nexthit << endl; + //cout << "nrawhits = " << nrawhits << endl; + //cout << "nexthit = " << nexthit << endl; while(ihit < nrawhits) { THcShowerHit* hit = (THcShowerHit *) rawhits->At(ihit); -//cout << "fplane = " << hit->fPlane << " Num = " << fLayerNum << endl; + //cout << "fplane = " << hit->fPlane << " Num = " << fLayerNum << endl; if(hit->fPlane > fLayerNum) { break; } + + // Should probably check that counter # is in range + fA_Pos[hit->fCounter-1] = hit->fADC_pos; + fA_Neg[hit->fCounter-1] = hit->fADC_neg; -if(hit->fCounter == 1){ -THcSignalHit *sighit1 = (THcSignalHit*) fPosADC1->ConstructedAt(nPosADCHits++); - -//THcSignalHit *sighit1 = (THcSignalHit*) fA[1]->ConstructedAt(nPosADCHits++); - sighit1->Set(1,(Int_t)(hit->fADC_pos - 470.7)); -//fprintf(CalADC1File, "%d\n", hit->fADC_pos); -} + fA_Pos_p[hit->fCounter-1] = hit->fADC_pos - fPosPed[hit->fCounter -1]; + fA_Neg_p[hit->fCounter-1] = hit->fADC_neg - fNegPed[hit->fCounter -1]; -double thresh_pos = fPosThresh[hit->fCounter -1]; -//double thresh_pos = hcal_new_threshold_pos[hit->fCounter + 13*(hit->fPlane -1) -1]; -if(hit->fADC_pos > thresh_pos) { - THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++); + double thresh_pos = fPosThresh[hit->fCounter -1]; + if(hit->fADC_pos > thresh_pos) { + THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++); - sighit->Set(hit->fCounter, hit->fADC_pos); -} + sighit->Set(hit->fCounter, hit->fADC_pos); + } -double thresh_neg = fNegThresh[hit->fCounter -1]; -//double thresh_neg = hcal_new_threshold_neg[hit->fCounter + 13*(hit->fPlane -1) -1]; -if(hit->fADC_neg > thresh_neg) { - THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++); - sighit->Set(hit->fCounter, hit->fADC_neg); -} + double thresh_neg = fNegThresh[hit->fCounter -1]; + if(hit->fADC_neg > thresh_neg) { + THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++); + sighit->Set(hit->fCounter, hit->fADC_neg); + } ihit++; } -fclose(CalADC1File); return(ihit); } //_____________________________________________________________________________ @@ -307,11 +247,11 @@ Int_t THcShowerPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit) // arrays for calculating pedestals. Int_t nrawhits = rawhits->GetLast()+1; - // cout << "THcScintillatorPlane::AcculatePedestals " << fLayerNum << " " << nexthit << "/" << nrawhits << endl; + // cout << "THcScintillatorPlane::AcculatePedestals " << fLayerNum << " " << nexthit << "/" << nrawhits << endl; Int_t ihit = nexthit; while(ihit < nrawhits) { THcShowerHit* hit = (THcShowerHit *) rawhits->At(ihit); -//cout << "fPlane = " << hit->fPlane << " Limit = " << fPlaneNum << endl; + //cout << "fPlane = " << hit->fPlane << " Limit = " << fPlaneNum << endl; if(hit->fPlane > fLayerNum) { break; } @@ -355,14 +295,14 @@ void THcShowerPlane::CalculatePedestals( ) // Positive tubes fPosPed[i] = ((Double_t) fPosPedSum[i]) / TMath::Max(1, fPosPedCount[i]); fPosSig[i] = sqrt((fPosPedSum2[i] - 2.*fPosPed[i]*fPosPedSum[i])/TMath::Max(1, fPosPedCount[i]) + fPosPed[i]*fPosPed[i]); - // fPosThresh[i] = fPosPed[i] + 15; - fPosThresh[i] = fPosPed[i] + TMath::Min(50., TMath::Max(10., 3.*fPosSig[i])); + // fPosThresh[i] = fPosPed[i] + 15; + fPosThresh[i] = fPosPed[i] + TMath::Min(50., TMath::Max(10., 3.*fPosSig[i])); // Negative tubes fNegPed[i] = ((Double_t) fNegPedSum[i]) / TMath::Max(1, fNegPedCount[i]); fNegSig[i] = sqrt((fNegPedSum2[i] - 2.*fNegPed[i]*fNegPedSum[i])/TMath::Max(1, fNegPedCount[i]) + fNegPed[i]*fNegPed[i]); - // fNegThresh[i] = fNegPed[i] + 15; - fNegThresh[i] = fNegPed[i] + TMath::Min(50., TMath::Max(10., 3.*fNegSig[i])); + // fNegThresh[i] = fNegPed[i] + 15; + fNegThresh[i] = fNegPed[i] + TMath::Min(50., TMath::Max(10., 3.*fNegSig[i])); // cout << i+1 << " " << 3.*fPosSig[i] << " " << 3.*fNegSig[i] << endl; } diff --git a/src/THcShowerPlane.h b/src/THcShowerPlane.h index 8ecde52..7e4c196 100644 --- a/src/THcShowerPlane.h +++ b/src/THcShowerPlane.h @@ -48,24 +48,17 @@ class THcShowerPlane : public THaSubDetector { protected: - -// TClonesArray* fPosADC1[13]; - - - Float_t* fA; // [fNelem] Array of ADC amplitudes of blocks -TClonesArray* fPosADC1; -TClonesArray* fPosADC[13]; + Float_t* fA_Pos; // [fNelem] Array of ADC amplitudes of blocks + Float_t* fA_Neg; // [fNelem] Array of ADC amplitudes of blocks + Float_t* fA_Pos_p; // [fNelem] Array of pedestal subtracted ADC amplitudes + Float_t* fA_Neg_p; // [fNelem] Array of pedestal subtracted ADC amplitudes TClonesArray* fPosADCHits; TClonesArray* fNegADCHits; - FILE* CalADC1File; - Int_t fLayerNum; -Int_t fPlaneNum; /* Which plane am I 1-4 */ - Int_t fNelem; /* Need since we don't inherit from - detector base class */ + Int_t fPlaneNum; /* Which plane am I 1-4 */ Int_t fNPedestalEvents; /* Number of pedestal events */ Int_t fMinPeds; /* Only analyze/update if num events > */ Int_t *fPosPedSum; /* Accumulators for pedestals */ -- GitLab