Skip to content
Snippets Groups Projects
Commit d84cc29c authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Added tree io in analyzer and used with THcHodoscope

- Each detector should override ManualInitTree(TTree*)
- This method should be used to add branches to the tree
- These branches should be data members of the detector.
parent c72b4826
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,9 @@ hodoscope array, not just one plane.
#include "TClonesArray.h"
#include "TMath.h"
#include "THaOutput.h"
#include "TTree.h"
#include "THaTrackProj.h"
#include <vector>
......@@ -173,7 +176,7 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date )
// maximum number of hits after setting up the detector map
// But it needs to happen before the sub detectors are initialized
// so that they can get the pointer to the hitlist.
_det_logger->info("Hodo tdc ref time cut = {} {}", fTDC_RefTimeCut, fADC_RefTimeCut);
_det_logger->info("Hodo TDC and ADC ref time cut = {} {}", fTDC_RefTimeCut, fADC_RefTimeCut);
//cout << " Hodo tdc ref time cut = " << fTDC_RefTimeCut << " " << fADC_RefTimeCut << endl;
InitHitList(fDetMap, "THcRawHodoHit", fDetMap->GetTotNumChan()+1,
......@@ -190,6 +193,7 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date )
}
}
// Why not std::vector?
fNScinHits = new Int_t [fNPlanes];
fGoodPlaneTime = new Bool_t [fNPlanes];
fNPlaneTime = new Int_t [fNPlanes];
......@@ -547,23 +551,37 @@ Int_t THcHodoscope::DefineVariables( EMode mode )
RVarDef vars[] = {
// Move these into THcHallCSpectrometer using track fTracks
{"beta", "Beta including track info", "fBeta"},
{"betanotrack", "Beta from scintillator hits", "fBetaNoTrk"},
{"betachisqnotrack", "Chi square of beta from scintillator hits", "fBetaNoTrkChiSq"},
{"fpHitsTime", "Time at focal plane from all hits", "fFPTimeAll"},
{"starttime", "Hodoscope Start Time", "fStartTime"},
{"goodstarttime", "Hodoscope Good Start Time (logical flag)", "fGoodStartTime"},
{"goodscinhit", "Hit in fid area", "fGoodScinHits"},
{"TimeHist_Sigma", "", "fTimeHist_Sigma"},
{"TimeHist_Peak", "", "fTimeHist_Peak"},
{"TimeHist_Hits", "", "fTimeHist_Hits"},
{"beta" , "Beta including track info" , "fBeta" } ,
{"betanotrack" , "Beta from scintillator hits" , "fBetaNoTrk" } ,
{"betachisqnotrack" , "Chi square of beta from scintillator hits" , "fBetaNoTrkChiSq" } ,
{"fpHitsTime" , "Time at focal plane from all hits" , "fFPTimeAll" } ,
{"starttime" , "Hodoscope Start Time" , "fStartTime" } ,
{"goodstarttime" , "Hodoscope Good Start Time (logical flag)" , "fGoodStartTime" } ,
{"goodscinhit" , "Hit in fid area" , "fGoodScinHits" } ,
{"TimeHist_Sigma" , "" , "fTimeHist_Sigma" } ,
{"TimeHist_Peak" , "" , "fTimeHist_Peak" } ,
{"TimeHist_Hits" , "" , "fTimeHist_Hits" } ,
{ 0 }
};
return DefineVarsFromList( vars, mode );
// return kOK;
}
//_____________________________________________________________________________
Int_t THcHodoscope::ManualInitTree( TTree* t ){
// The most direct path to the output tree!!!
std::string app_name = GetApparatus()->GetName();
std::string det_name = GetName();
std::string branch_name = (app_name + "_" + det_name + "_data");
_det_logger->info("THcHodoscope::ManualInitTree : Adding branch, {}, to output tree", branch_name);
if (t) {
t->Branch(branch_name.c_str(), &_basic_data, 32000, 99);
}
return 0;
}
//_____________________________________________________________________________
THcHodoscope::~THcHodoscope()
{
// Destructor. Remove variables from global list.
......@@ -805,6 +823,9 @@ void THcHodoscope::EstimateFocalPlaneTime()
fTimeHist_Peak= tmin;
fTimeHist_Sigma= hTime->GetRMS();
fTimeHist_Hits= hTime->Integral();
_basic_data.fTimeHist_Peak = fTimeHist_Peak ;
_basic_data.fTimeHist_Sigma = fTimeHist_Sigma;
_basic_data.fTimeHist_Hits = fTimeHist_Hits ;
for(Int_t ip=0;ip<fNumPlanesBetaCalc;ip++) {
goodplanetime[ip] = kFALSE;
Int_t nphits=fPlanes[ip]->GetNScinHits();
......@@ -1868,6 +1889,8 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks )
if (theTrack->GetIndex()==0) {
fBeta=theTrack->GetBeta();
fFPTimeAll=theTrack->GetFPTime();
_basic_data.fBeta = fBeta;
_basic_data.fFPTimeAll = fFPTimeAll;
Double_t shower_track_enorm = theTrack->GetEnergy()/theTrack->GetP();
for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++ ){
Double_t pl_xypos=0;
......
......@@ -35,15 +35,39 @@
class THaScCalib;
namespace hallc {
namespace data {
struct Hodoscope {
double fBeta = 0.0;
double fBetaNoTrk = 0.0;
double fBetaNoTrkChiSq = 0.0;
double fFPTimeAll = 0.0;
double fStartTime = 0.0;
double fTimeHist_Sigma = 0.0;
double fTimeHist_Peak = 0.0;
double fTimeHist_Hits = 0.0;
bool fGoodStartTime = 0;
bool fGoodScinHits = 0;
ClassDef(Hodoscope,1)
};
} // namespace data
}
class THcHodoscope : public hcana::ConfigLogging<THaNonTrackingDetector>, public THcHitList {
public:
hallc::data::Hodoscope _basic_data;
THcHodoscope( const char* name, const char* description = "",
THaApparatus* a = NULL );
virtual ~THcHodoscope();
virtual Int_t Decode( const THaEvData& );
virtual EStatus Init( const TDatime& run_time );
virtual Int_t ManualInitTree( TTree* t );
virtual void Clear( Option_t* opt="" );
virtual Int_t CoarseProcess( TClonesArray& tracks );
......@@ -146,6 +170,8 @@ protected:
// Way too many data members!!!!!
// Get rid of junk!
// Why does this need to be here?
// bad design
THcCherenkov* fCherenkov;
Int_t fTDC_RefTimeCut;
......
......@@ -276,7 +276,7 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date )
fADCDiagCut = 50.0;
fCosmicFlag=0;
gHcParms->LoadParmValues((DBRequest*)&list,prefix);
if (fCosmicFlag==1) cout << " setup for cosmics in scint plane"<< endl;
if (fCosmicFlag==1) _det_logger->info("THcScintillatorPlane: setup for cosmics in scint plane");
// cout << " cosmic flag = " << fCosmicFlag << endl;
// fetch the parameter from the temporary list
......@@ -471,6 +471,7 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode )
} //end debug statement
RVarDef vars[] = {
{"betterTest", "List of positive TDC counter numbers.", "frPosTdcTimeRawBetter"}, //Hodo+ raw TDC occupancy
{"nhits", "Number of paddle hits (passed TDC && ADC Min and Max cuts for either end)", "GetNScinHits() "},
{"posTdcCounter", "List of positive TDC counter numbers.", "frPosTdcTimeRaw.THcSignalHit.GetPaddleNumber()"}, //Hodo+ raw TDC occupancy
......
......@@ -83,6 +83,8 @@ class THcScintillatorPlane : public THaSubDetector {
TClonesArray* frNegADCPeds;
TClonesArray* fHodoHits;
std::vector<double> frPosTdcTimeRawBetter;
TClonesArray* frPosTdcTimeRaw;
TClonesArray* frPosAdcPedRaw;
TClonesArray* frPosAdcPulseIntRaw;
......
......@@ -12,6 +12,10 @@
#pragma link C++ namespace hallc;
#pragma link C++ namespace hcana;
#pragma link C++ namespace hallc::data;
#pragma link C++ class hallc::data::Hodoscope+;
#pragma link C++ global gHcParms;
#pragma link C++ global gHcDetectorMap;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment