From 951d1ee02f87c1503eaf2d1c3dddf1d859b60de6 Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Tue, 3 Nov 2015 09:03:17 -0500 Subject: [PATCH] Make ascii art showing hit patterns in Shower Array Enable by defining HITPIC in THcShowerArray.h --- src/THcShowerArray.cxx | 70 ++++++++++++++++++++++++++++++++++++++++++ src/THcShowerArray.h | 9 ++++++ 2 files changed, 79 insertions(+) diff --git a/src/THcShowerArray.cxx b/src/THcShowerArray.cxx index 2c57c51..740a3b3 100644 --- a/src/THcShowerArray.cxx +++ b/src/THcShowerArray.cxx @@ -25,6 +25,7 @@ #include <iostream> #include <fstream> + using namespace std; ClassImp(THcShowerArray) @@ -104,6 +105,14 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) fA = new Double_t[fNelem]; fP = new Double_t[fNelem]; +#ifdef HITPIC + hitpic = new char*[fNRows]; + for(Int_t row=0;row<fNRows;row++) { + hitpic[row] = new char[NPERLINE*(fNColumns+1)+2]; + } + piccolumn=0; +#endif + return kOK; } @@ -183,6 +192,8 @@ Int_t THcShowerArray::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t ihit = nexthit; + Int_t ngood = 0; + Int_t threshold = 100; while(ihit < nrawhits) { THcRawShowerHit* hit = (THcRawShowerHit *) rawhits->At(ihit); @@ -194,11 +205,70 @@ Int_t THcShowerArray::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } else { fA[hit->fCounter-1] = hit->GetData(0); } + if(fA[hit->fCounter-1] > threshold) { + ngood++; + } // Do other stuff like comparison to thresholds, signal hits, energy sums ihit++; } + +#if 0 + if(ngood > 0) { + cout << "+"; + for(Int_t column=0;column<fNColumns;column++) { + cout << "-"; + } + cout << "+" << endl; + for(Int_t row=0;row<fNRows;row++) { + cout << "|"; + for(Int_t column=0;column<fNColumns;column++) { + Int_t counter = column*fNRows + row; + if(fA[counter]>threshold) { + cout << "X"; + } else { + cout << " "; + } + } + cout << "|" << endl; + } + } +#endif +#ifdef HITPIC + if(ngood > 0) { + for(Int_t row=0;row<fNRows;row++) { + if(piccolumn==0) { + hitpic[row][0] = '|'; + } + for(Int_t column=0;column<fNColumns;column++) { + Int_t counter = column*fNRows+row; + if(fA[counter] > threshold) { + hitpic[row][piccolumn*(fNColumns+1)+column+1] = 'X'; + } else { + hitpic[row][piccolumn*(fNColumns+1)+column+1] = ' '; + } + hitpic[row][(piccolumn+1)*(fNColumns+1)] = '|'; + } + } + piccolumn++; + if(piccolumn==NPERLINE) { + cout << "+"; + for(Int_t pc=0;pc<NPERLINE;pc++) { + for(Int_t column=0;column<fNColumns;column++) { + cout << "-"; + } + cout << "+"; + } + cout << endl; + for(Int_t row=0;row<fNRows;row++) { + hitpic[row][(piccolumn+1)*(fNColumns+1)+1] = '\0'; + cout << hitpic[row] << endl; + } + piccolumn = 0; + } + } +#endif return(ihit); } diff --git a/src/THcShowerArray.h b/src/THcShowerArray.h index 681e886..1bdbacc 100644 --- a/src/THcShowerArray.h +++ b/src/THcShowerArray.h @@ -1,6 +1,11 @@ #ifndef ROOT_THcShowerArray #define ROOT_THcShowerArray +//#define HITPIC 1 +#ifdef HITPIC +#define NPERLINE 5 +#endif + ////////////////////////////////////////////////////////////////////////////// // // THcShowerArray @@ -54,6 +59,10 @@ public: protected: +#ifdef HITPIC + char **hitpic; + Int_t piccolumn; +#endif Double_t* fA; // [fNelem] ADC amplitude of blocks Double_t* fP; // [fNelem] Event by event pedestals -- GitLab