Skip to content
Snippets Groups Projects
Commit 78f980bf authored by sawjlab's avatar sawjlab
Browse files

Merge pull request #22 from sawjlab/report_stuff

Report stuff
parents 49b5e3f8 929daa55
Branches
Tags
No related merge requests found
......@@ -71,6 +71,7 @@
analyzer->SetOutFile( "hodtest.root" );
analyzer->SetOdefFile("output.def");
analyzer->SetCutFile("hodtest_cuts.def"); // optional
analyzer->SetCountMode(2);// Counter event number same as gen_event_ID_number
// File to record cuts accounting information
// analyzer->SetSummaryFile("summary_example.log"); // optional
......
......@@ -28,6 +28,14 @@ a c-style format after the expression.
The HMS reconstruction coefficient file name is {h_recon_coeff_filename}
The names of the HMS drift chamber planes are: {hdc_plane_names}
DC Events: {hdc_tot_events}
Hit in chamber: {hdc_cham_hits[0]/hdc_tot_events:%.3f} {hdc_cham_hits[1]/hdc_tot_events:%.3f}
Hit in plane: {hdc_hits_per_plane[0]/hdc_tot_events:%.3f} {hdc_hits_per_plane[1]/hdc_tot_events:%.3f} {hdc_hits_per_plane[2]/hdc_tot_events:%.3f} {hdc_hits_per_plane[3]/hdc_tot_events:%.3f} {hdc_hits_per_plane[4]/hdc_tot_events:%.3f} {hdc_hits_per_plane[5]/hdc_tot_events:%.3f} {hdc_hits_per_plane[6]/hdc_tot_events:%.3f} {hdc_hits_per_plane[7]/hdc_tot_events:%.3f} {hdc_hits_per_plane[8]/hdc_tot_events:%.3f} {hdc_hits_per_plane[9]/hdc_tot_events:%.3f} {hdc_hits_per_plane[10]/hdc_tot_events:%.3f} {hdc_hits_per_plane[11]/hdc_tot_events:%.3f}
Run #{gen_run_number}
first event = {gen_run_starting_event:%7d}
last event = {gen_event_id_number:%7d}
Later, such things as hardware scalers will be added to the set of variables
that can be used in expressions.
......
......@@ -22,6 +22,7 @@
//////////////////////////////////////////////////////////////////////////
#include "THcAnalyzer.h"
#include "THaRunBase.h"
#include "THaBenchmark.h"
#include "TList.h"
#include "THcParmList.h"
......@@ -74,8 +75,11 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
if(!ostr.is_open()) {
cout << "Error opening report output file " << ofile << endl;
return;
}
LoadInfo(); // Load some run information into gHcParms
// In principle, we should allow braces to be escaped. But for
// now we won't. Existing template files don't seem to output
// any braces
......@@ -115,8 +119,12 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
format = "%f";
}
}
if(format[format.length()-1] == 'd') {
replacement=Form(format.c_str(),TMath::Nint(value));
} else {
replacement=Form(format.c_str(),value);
}
}
// cout << "Replacement:" << replacement << endl;
line.replace(start,end-start+1,replacement);
}
......@@ -128,6 +136,46 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
return;
}
//_____________________________________________________________________________
void THcAnalyzer::LoadInfo()
{
// Copy some run information into gHcParms variables so that in can
// be used in reports.
// For example run number, first event analyzed, number of events, etc.
Int_t* runnum;
Int_t* firstevent;
Int_t* lastevent;
THaVar* varptr;
varptr = gHcParms->Find("gen_run_number");
if(varptr) {
runnum = (Int_t*) varptr->GetValuePointer(); // Assume correct type
} else {
runnum = new Int_t[1];
gHcParms->Define("gen_run_number","Run Number", *runnum);
}
*runnum = fRun->GetNumber();
varptr = gHcParms->Find("gen_run_starting_event");
if(varptr) {
firstevent = (Int_t*) varptr->GetValuePointer(); // Assume correct type
} else {
firstevent = new Int_t[1];
gHcParms->Define("gen_run_starting_event","First event analyzed", *firstevent);
}
// May not agree with engine event definintions
*firstevent = fRun->GetFirstEvent();
varptr = gHcParms->Find("gen_event_id_number");
if(varptr) {
lastevent = (Int_t*)varptr->GetValuePointer(); // Assume correct type
} else {
lastevent = new Int_t[1];
gHcParms->Define("gen_event_id_number","Last event analyzed", *lastevent);
}
// Not accurate
*lastevent = fRun->GetFirstEvent()+fRun->GetNumAnalyzed();
}
//_____________________________________________________________________________
......
......@@ -27,6 +27,7 @@ protected:
private:
// THcAnalyzer( const THcAnalyzer& );
// THcAnalyzer& operator=( const THcAnalyzer& );
void LoadInfo();
ClassDef(THcAnalyzer,0) //Hall C Analyzer Standard Event Loop
......
......@@ -80,18 +80,17 @@ void THcDC::Setup(const char* name, const char* description)
{
static const char* const here = "Setup";
char prefix[2];
THaApparatus *app = GetApparatus();
if(app) {
cout << app->GetName() << endl;
fPrefix[0]=tolower(app->GetName()[0]);
fPrefix[1]='\0';
} else {
cout << "No apparatus found" << endl;
fPrefix[0]='\0';
}
prefix[0]=tolower(app->GetName()[0]);
prefix[1]='\0';
string planenamelist;
DBRequest list[]={
{"dc_num_planes",&fNPlanes, kInt},
......@@ -102,7 +101,7 @@ void THcDC::Setup(const char* name, const char* description)
{0}
};
gHcParms->LoadParmValues((DBRequest*)&list,prefix);
gHcParms->LoadParmValues((DBRequest*)&list,fPrefix);
cout << planenamelist << endl;
cout << "Drift Chambers: " << fNPlanes << " planes in " << fNChambers << " chambers" << endl;
......@@ -164,6 +163,7 @@ THaAnalysisObject::EStatus THcDC::Init( const TDatime& date )
static const char* const here = "Init()";
Setup(GetName(), GetTitle()); // Create the subdetectors here
EffInit();
// Should probably put this in ReadDatabase as we will know the
// maximum number of hits after setting up the detector map
......@@ -231,7 +231,6 @@ Int_t THcDC::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
......@@ -243,10 +242,6 @@ Int_t THcDC::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)
prefix[0]=tolower(GetApparatus()->GetName()[0]);
prefix[1]='\0';
delete [] fXCenter; fXCenter = new Double_t [fNChambers];
delete [] fYCenter; fYCenter = new Double_t [fNChambers];
delete [] fMinHits; fMinHits = new Int_t [fNChambers];
......@@ -311,7 +306,7 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
{"debugtrackprint", &fdebugtrackprint , kInt},
{0}
};
gHcParms->LoadParmValues((DBRequest*)&list,prefix);
gHcParms->LoadParmValues((DBRequest*)&list,fPrefix);
if(fNTracksMaxFP <= 0) fNTracksMaxFP = 10;
// if(fNTracksMaxFP > HNRACKS_MAX) fNTracksMaxFP = NHTRACKS_MAX;
cout << "Plane counts:";
......@@ -453,6 +448,7 @@ Int_t THcDC::Decode( const THaEvData& evdata )
}
cout << endl;
}
Eff(); // Accumlate statistics
return fNhits;
}
......@@ -473,6 +469,7 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks )
// Apply corrections and reconstruct the complete hits.
//
// static const Double_t sqrt2 = TMath::Sqrt(2.);
for(Int_t i=0;i<fNChambers;i++) {
fChambers[i]->FindSpacePoints();
fChambers[i]->CorrectHitTimes();
......@@ -974,5 +971,49 @@ Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane)
return(DpsiFun);
}
//_____________________________________________________________________________
Int_t THcDC::End(THaRunBase* run)
{
// EffCalc();
}
//_____________________________________________________________________________
void THcDC::EffInit()
{
// Create, and initialize counters used to calculate
// efficiencies. Register the counters in gHcParms so that the
// variables can be used in end of run reports.
delete [] fNChamHits; fNChamHits = new Int_t [fNChambers];
delete [] fHitsPerPlane; fHitsPerPlane = new Int_t [fNPlanes];
fTotEvents = 0;
for(Int_t i=0;i<fNChambers;i++) {
fNChamHits[i] = 0;
}
for(Int_t i=0;i<fNPlanes;i++) {
fHitsPerPlane[i] = 0;
}
gHcParms->Define(Form("%sdc_tot_events",fPrefix),"Total DC Events",fTotEvents);
gHcParms->Define(Form("%sdc_cham_hits[%d]",fPrefix,fNChambers),"N events with hits per chamber",*fNChamHits);
gHcParms->Define(Form("%sdc_hits_per_plane[%d]",fPrefix,fNPlanes),"N events with hits per plane",*fHitsPerPlane);
cout << Form("%sdc_hits_per_plane[%d]",fPrefix,fNPlanes) << endl;
}
//_____________________________________________________________________________
void THcDC::Eff()
{
// Accumulate statistics for efficiency calculations
fTotEvents++;
for(Int_t i=0;i<fNChambers;i++) {
if(fChambers[i]->GetNHits()>0) fNChamHits[i]++;
}
for(Int_t i=0;i<fNPlanes;i++) {
if(fPlanes[i]->GetNHits() > 0) fHitsPerPlane[i]++;
}
return;
}
ClassImp(THcDC)
////////////////////////////////////////////////////////////////////////////////
......@@ -84,6 +84,7 @@ protected:
// Calibration
// Hall C Parameters
char fPrefix[2];
Int_t fNPlanes; // Total number of DC planes
char** fPlaneNames;
Int_t fNChambers;
......@@ -137,6 +138,11 @@ protected:
Double_t* fSigma;
Double_t** fPlaneCoeffs;
// For accumulating statitics for efficiencies
Int_t fTotEvents;
Int_t* fNChamHits;
Int_t* fHitsPerPlane;
// Useful derived quantities
// double tan_angle, sin_angle, cos_angle;
......@@ -155,6 +161,9 @@ protected:
void LinkStubs();
void TrackFit();
Double_t DpsiFun(Double_t ray[4], Int_t plane);
Int_t End(THaRunBase* run);
void EffInit();
void Eff();
void Setup(const char* name, const char* description);
......
......@@ -44,7 +44,7 @@ public:
virtual void Clear( Option_t* opt="" );
// Int_t GetNHits() const { return fNhit; }
Int_t GetNHits() const { return fNhits; }
Int_t GetNSpacePoints() const { return(fNSpacePoints);}
Int_t GetNTracks() const { return fTrackProj->GetLast()+1; }
const TClonesArray* GetTrackHits() const { return fTrackProj; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment