Skip to content
Snippets Groups Projects
Commit 5e6c6dca authored by Mark Jones's avatar Mark Jones
Browse files

Merge branch 'develop' of github.com:JeffersonLab/hcana into mkj

parents b6587dad 78f980bf
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
analyzer->SetOutFile( "hodtest.root" ); analyzer->SetOutFile( "hodtest.root" );
analyzer->SetOdefFile("output.def"); analyzer->SetOdefFile("output.def");
analyzer->SetCutFile("hodtest_cuts.def"); // optional analyzer->SetCutFile("hodtest_cuts.def"); // optional
analyzer->SetCountMode(2);// Counter event number same as gen_event_ID_number
// File to record cuts accounting information // File to record cuts accounting information
// analyzer->SetSummaryFile("summary_example.log"); // optional // analyzer->SetSummaryFile("summary_example.log"); // optional
......
...@@ -28,6 +28,14 @@ a c-style format after the expression. ...@@ -28,6 +28,14 @@ a c-style format after the expression.
The HMS reconstruction coefficient file name is {h_recon_coeff_filename} The HMS reconstruction coefficient file name is {h_recon_coeff_filename}
The names of the HMS drift chamber planes are: {hdc_plane_names} 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 Later, such things as hardware scalers will be added to the set of variables
that can be used in expressions. that can be used in expressions.
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#include "THcAnalyzer.h" #include "THcAnalyzer.h"
#include "THaRunBase.h"
#include "THaBenchmark.h" #include "THaBenchmark.h"
#include "TList.h" #include "TList.h"
#include "THcParmList.h" #include "THcParmList.h"
...@@ -74,8 +75,11 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile) ...@@ -74,8 +75,11 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
if(!ostr.is_open()) { if(!ostr.is_open()) {
cout << "Error opening report output file " << ofile << endl; 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 // In principle, we should allow braces to be escaped. But for
// now we won't. Existing template files don't seem to output // now we won't. Existing template files don't seem to output
// any braces // any braces
...@@ -115,7 +119,11 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile) ...@@ -115,7 +119,11 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
format = "%f"; format = "%f";
} }
} }
replacement=Form(format.c_str(),value); 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; // cout << "Replacement:" << replacement << endl;
line.replace(start,end-start+1,replacement); line.replace(start,end-start+1,replacement);
...@@ -128,6 +136,46 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile) ...@@ -128,6 +136,46 @@ void THcAnalyzer::PrintReport(const char* templatefile, const char* ofile)
return; 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,7 +27,8 @@ protected: ...@@ -27,7 +27,8 @@ protected:
private: private:
// THcAnalyzer( const THcAnalyzer& ); // THcAnalyzer( const THcAnalyzer& );
// THcAnalyzer& operator=( const THcAnalyzer& ); // THcAnalyzer& operator=( const THcAnalyzer& );
void LoadInfo();
ClassDef(THcAnalyzer,0) //Hall C Analyzer Standard Event Loop ClassDef(THcAnalyzer,0) //Hall C Analyzer Standard Event Loop
}; };
......
...@@ -80,18 +80,17 @@ void THcDC::Setup(const char* name, const char* description) ...@@ -80,18 +80,17 @@ void THcDC::Setup(const char* name, const char* description)
{ {
static const char* const here = "Setup"; static const char* const here = "Setup";
char prefix[2];
THaApparatus *app = GetApparatus(); THaApparatus *app = GetApparatus();
if(app) { if(app) {
cout << app->GetName() << endl; cout << app->GetName() << endl;
fPrefix[0]=tolower(app->GetName()[0]);
fPrefix[1]='\0';
} else { } else {
cout << "No apparatus found" << endl; cout << "No apparatus found" << endl;
fPrefix[0]='\0';
} }
prefix[0]=tolower(app->GetName()[0]);
prefix[1]='\0';
string planenamelist; string planenamelist;
DBRequest list[]={ DBRequest list[]={
{"dc_num_planes",&fNPlanes, kInt}, {"dc_num_planes",&fNPlanes, kInt},
...@@ -102,7 +101,7 @@ void THcDC::Setup(const char* name, const char* description) ...@@ -102,7 +101,7 @@ void THcDC::Setup(const char* name, const char* description)
{0} {0}
}; };
gHcParms->LoadParmValues((DBRequest*)&list,prefix); gHcParms->LoadParmValues((DBRequest*)&list,fPrefix);
cout << planenamelist << endl; cout << planenamelist << endl;
cout << "Drift Chambers: " << fNPlanes << " planes in " << fNChambers << " chambers" << endl; cout << "Drift Chambers: " << fNPlanes << " planes in " << fNChambers << " chambers" << endl;
...@@ -164,7 +163,8 @@ THaAnalysisObject::EStatus THcDC::Init( const TDatime& date ) ...@@ -164,7 +163,8 @@ THaAnalysisObject::EStatus THcDC::Init( const TDatime& date )
static const char* const here = "Init()"; static const char* const here = "Init()";
Setup(GetName(), GetTitle()); // Create the subdetectors here Setup(GetName(), GetTitle()); // Create the subdetectors here
EffInit();
// Should probably put this in ReadDatabase as we will know the // Should probably put this in ReadDatabase as we will know the
// maximum number of hits after setting up the detector map // maximum number of hits after setting up the detector map
THcHitList::InitHitList(fDetMap, "THcRawDCHit", 1000); THcHitList::InitHitList(fDetMap, "THcRawDCHit", 1000);
...@@ -231,7 +231,6 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) ...@@ -231,7 +231,6 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
// 'date' contains the date/time of the run being analyzed. // 'date' contains the date/time of the run being analyzed.
// static const char* const here = "ReadDatabase()"; // static const char* const here = "ReadDatabase()";
char prefix[2];
// Read data from database // Read data from database
// Pull values from the THcParmList instead of reading a database // Pull values from the THcParmList instead of reading a database
...@@ -243,10 +242,6 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) ...@@ -243,10 +242,6 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
// Will need to determine which spectrometer in order to construct // Will need to determine which spectrometer in order to construct
// the parameter names (e.g. hscin_1x_nr vs. sscin_1x_nr) // 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 [] fXCenter; fXCenter = new Double_t [fNChambers];
delete [] fYCenter; fYCenter = new Double_t [fNChambers]; delete [] fYCenter; fYCenter = new Double_t [fNChambers];
delete [] fMinHits; fMinHits = new Int_t [fNChambers]; delete [] fMinHits; fMinHits = new Int_t [fNChambers];
...@@ -311,7 +306,7 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) ...@@ -311,7 +306,7 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
{"debugtrackprint", &fdebugtrackprint , kInt}, {"debugtrackprint", &fdebugtrackprint , kInt},
{0} {0}
}; };
gHcParms->LoadParmValues((DBRequest*)&list,prefix); gHcParms->LoadParmValues((DBRequest*)&list,fPrefix);
if(fNTracksMaxFP <= 0) fNTracksMaxFP = 10; if(fNTracksMaxFP <= 0) fNTracksMaxFP = 10;
// if(fNTracksMaxFP > HNRACKS_MAX) fNTracksMaxFP = NHTRACKS_MAX; // if(fNTracksMaxFP > HNRACKS_MAX) fNTracksMaxFP = NHTRACKS_MAX;
cout << "Plane counts:"; cout << "Plane counts:";
...@@ -453,6 +448,7 @@ Int_t THcDC::Decode( const THaEvData& evdata ) ...@@ -453,6 +448,7 @@ Int_t THcDC::Decode( const THaEvData& evdata )
} }
cout << endl; cout << endl;
} }
Eff(); // Accumlate statistics
return fNhits; return fNhits;
} }
...@@ -473,6 +469,7 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks ) ...@@ -473,6 +469,7 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks )
// Apply corrections and reconstruct the complete hits. // Apply corrections and reconstruct the complete hits.
// //
// static const Double_t sqrt2 = TMath::Sqrt(2.); // static const Double_t sqrt2 = TMath::Sqrt(2.);
for(Int_t i=0;i<fNChambers;i++) { for(Int_t i=0;i<fNChambers;i++) {
fChambers[i]->FindSpacePoints(); fChambers[i]->FindSpacePoints();
fChambers[i]->CorrectHitTimes(); fChambers[i]->CorrectHitTimes();
...@@ -974,5 +971,49 @@ Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane) ...@@ -974,5 +971,49 @@ Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane)
return(DpsiFun); 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) ClassImp(THcDC)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -84,6 +84,7 @@ protected: ...@@ -84,6 +84,7 @@ protected:
// Calibration // Calibration
// Hall C Parameters // Hall C Parameters
char fPrefix[2];
Int_t fNPlanes; // Total number of DC planes Int_t fNPlanes; // Total number of DC planes
char** fPlaneNames; char** fPlaneNames;
Int_t fNChambers; Int_t fNChambers;
...@@ -137,6 +138,11 @@ protected: ...@@ -137,6 +138,11 @@ protected:
Double_t* fSigma; Double_t* fSigma;
Double_t** fPlaneCoeffs; Double_t** fPlaneCoeffs;
// For accumulating statitics for efficiencies
Int_t fTotEvents;
Int_t* fNChamHits;
Int_t* fHitsPerPlane;
// Useful derived quantities // Useful derived quantities
// double tan_angle, sin_angle, cos_angle; // double tan_angle, sin_angle, cos_angle;
...@@ -155,6 +161,9 @@ protected: ...@@ -155,6 +161,9 @@ protected:
void LinkStubs(); void LinkStubs();
void TrackFit(); void TrackFit();
Double_t DpsiFun(Double_t ray[4], Int_t plane); 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); void Setup(const char* name, const char* description);
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
virtual void Clear( Option_t* opt="" ); 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 GetNSpacePoints() const { return(fNSpacePoints);}
Int_t GetNTracks() const { return fTrackProj->GetLast()+1; } Int_t GetNTracks() const { return fTrackProj->GetLast()+1; }
const TClonesArray* GetTrackHits() const { return fTrackProj; } const TClonesArray* GetTrackHits() const { return fTrackProj; }
......
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