Skip to content
Snippets Groups Projects
Commit 98144df7 authored by Stephen Wood's avatar Stephen Wood Committed by Eric Pooser
Browse files

Script and Config file for GEM analysis (#219)

Needs https://github.com/JeffersonLab/hcana_gem installed and built
  in ../hcana_gem and thishcana_gem.sh or thishcana_gem.csh to have been
  sourced.
parent 7a446296
No related branches found
No related tags found
No related merge requests found
block P.gem.*
#include "DEF-files/SHMS/PRODUCTION/pstackana_production.def"
#GEM analysis configure file
#===============================================================
# DAQ setting
#===============================================================
TIMESAMPLE: 21
#===============================================================
# runType
#===============================================================
RUNTYPE: PHYSICS
#RUNTYPE: PEDESTAL
#RUNTYPE: RAWDATA
#===============================================================
# path to the mapping file to be loaded
#===============================================================
MAPPING: ../hcana_gem/config/mapping.cfg
#===============================================================
# path to save pedestal root file
#===============================================================
SAVEPED: ../hcana_gem/pedestal/pedestal.root
#===============================================================
# path to load pedestal root file
#===============================================================
LOADPED: ../hcana_gem/pedestal/pedestal.root
#LOADPED: ./pedestal/pedestal_20160617_owl_run1401.root
#===============================================================
# number of events to be analyzed,
# affect both pedestal run and physics run
#===============================================================
NEVENTPED: -1
#===============================================================
# Physics cut
#===============================================================
#---------------------------
#scintillator timing cut
UseScinTDC: 1
UseHyCalPosMatch: 0
UseHycalTimingCut: 1
#TDCChannel: S1
#TDCChannel: S2
#TDCChannel: S1andS2
TDCChannel: S1orS2
TDCValueStart: 7700
TDCValueEnd: 7800
//2
#TDCValueStart: 7600
#TDCValueEnd: 7800
//1
#TDCValueStart: 7000
#TDCValueEnd: 8000
#----------------------------
#HyCal Cut
#Energy Cut
HycalEnergy: 200
#HyCalTDCGroupQuantity: 1
#HyCalTDCGroup: W25
HyCalTDCGroupQuantity: 4
HyCalTDCGroup: W33, W34, W27, W28
#HyCalTDCGroup: W35, W25, W22, G11 # format: use comma
#timing , need to have TDC group channels,
UseHycalTimingCut: 1
#HyCalTimingCutStart: 7200
#HyCalTimingCutEnd: 7500
#W302 TDC Group W12
HyCalTimingCutStart: 7000
HyCalTimingCutEnd: 7500
# results directory
PHYSRESULTS: root_file/result.root
#===============================================================
# Input File
#===============================================================
NFILE: 1
# this line for multiple files
#INPUTFILE: /home/xbai/w/R/hallcgem/test_135_xin_comsmic.evio, 1, 1
# this line fine single file
#INPUTFILE: /home/daq/data/test_135_xin_comsmic.dat
# INPUTFILE: /home/saw/ROOT/data/GEM/shms_all_00899.dat
INPUTFILE: /home/siplu/GIT/JLAB/HcAna/hallc_replay/raw/shms_all_00899.dat
R__LOAD_LIBRARY(libGEM.so);
void replay_gem_shms (Int_t RunNumber = 0, Int_t MaxEvent = 0) {
// Get RunNumber and MaxEvent if not provided.
if(RunNumber == 0) {
cout << "Enter a Run Number (-1 to exit): ";
cin >> RunNumber;
if( RunNumber<=0 ) return;
}
if(MaxEvent == 0) {
cout << "\nNumber of Events to analyze: ";
cin >> MaxEvent;
if(MaxEvent == 0) {
cerr << "...Invalid entry\n";
exit;
}
}
// Create file name patterns.
const char* RunFileNamePattern = "shms_all_%05d.dat";
vector<TString> pathList;
pathList.push_back(".");
pathList.push_back("./raw");
pathList.push_back("./cache");
const char* ROOTFileNamePattern = "ROOTfiles/shms_replay_gem_%d_%d.root";
// Load global parameters
// Add variables to global list.
gHcParms->Define("gen_run_number", "Run Number", RunNumber);
gHcParms->AddString("g_ctp_database_filename", "DBASE/SHMS/STD/standard.database");
// Load varibles from files to global list.
gHcParms->Load(gHcParms->GetString("g_ctp_database_filename"), RunNumber);
// g_ctp_parm_filename and g_decode_map_filename should now be defined.
gHcParms->Load(gHcParms->GetString("g_ctp_kinematics_filename"), RunNumber);
gHcParms->Load(gHcParms->GetString("g_ctp_parm_filename"));
gHcParms->Load(gHcParms->GetString("g_ctp_calib_filename"));
// Load params for SHMS trigger configuration
gHcParms->Load("PARAM/TRIG/tshms.param");
// Load the Hall C detector map
gHcDetectorMap = new THcDetectorMap();
gHcDetectorMap->Load("MAPS/SHMS/DETEC/STACK/shms_stack.map");
// Add trigger apparatus
THaApparatus* TRG = new THcTrigApp("T", "TRG");
gHaApps->Add(TRG);
// Add trigger detector to trigger apparatus
THcTrigDet* shms = new THcTrigDet("shms", "SHMS Trigger Information");
TRG->AddDetector(shms);
// Set up the equipment to be analyzed.
THaApparatus* SHMS = new THcHallCSpectrometer("P", "SHMS");
gHaApps->Add(SHMS);
// Add Noble Gas Cherenkov to SHMS apparatus
THcCherenkov* ngcer = new THcCherenkov("ngcer", "Noble Gas Cherenkov");
SHMS->AddDetector(ngcer);
// Add drift chambers to SHMS apparatus
THcDC* dc = new THcDC("dc", "Drift Chambers");
SHMS->AddDetector(dc);
// Add hodoscope to SHMS apparatus
THcHodoscope* hod = new THcHodoscope("hod", "Hodoscope");
SHMS->AddDetector(hod);
// Add Heavy Gas Cherenkov to SHMS apparatus
THcCherenkov* hgcer = new THcCherenkov("hgcer", "Heavy Gas Cherenkov");
SHMS->AddDetector(hgcer);
// Add Aerogel Cherenkov to SHMS apparatus
THcAerogel* aero = new THcAerogel("aero", "Aerogel");
SHMS->AddDetector(aero);
// Add calorimeter to SHMS apparatus
THcShower* cal = new THcShower("cal", "Calorimeter");
SHMS->AddDetector(cal);
// Add GEM to SHMS apparatus
// Add handler for GEM data
THcGEM* gem = new THcGEM("gem","GEM data");
// gem->SetEvtType(1);
gem->SetConfigFile("SCRIPTS/SHMS/GEM/gem_hcana.cfg");
SHMS->AddDetector(gem);
// Include golden track information
THaGoldenTrack* gtr = new THaGoldenTrack("P.gtr", "SHMS Golden Track", "P");
gHaPhysics->Add(gtr);
// Add Rastered Beam Apparatus
THaApparatus* beam = new THcRasteredBeam("P.rb", "Rastered Beamline");
gHaApps->Add(beam);
// Add Physics Module to calculate primary (scattered beam - usually electrons) kinematics
THcPrimaryKine* kin = new THcPrimaryKine("P.kin", "SHMS Single Arm Kinematics", "P", "P.rb");
gHaPhysics->Add(kin);
// Add event handler for prestart event 125.
THcConfigEvtHandler* ev125 = new THcConfigEvtHandler("HC", "Config Event type 125");
gHaEvtHandlers->Add(ev125);
// Add event handler for EPICS events
THaEpicsEvtHandler* hcepics = new THaEpicsEvtHandler("epics", "HC EPICS event type 180");
gHaEvtHandlers->Add(hcepics);
// Add event handler for scaler events
THcScalerEvtHandler* pscaler = new THcScalerEvtHandler("P", "Hall C scaler event type 1");
pscaler->AddEvtType(1);
pscaler->SetUseFirstEvent(kTRUE);
gHaEvtHandlers->Add(pscaler);
// Set up the analyzer - we use the standard one,
// but this could be an experiment-specific one as well.
// The Analyzer controls the reading of the data, executes
// tests/cuts, loops over Acpparatus's and PhysicsModules,
// and executes the output routines.
THcAnalyzer* analyzer = new THcAnalyzer;
// A simple event class to be output to the resulting tree.
// Creating your own descendant of THaEvent is one way of
// defining and controlling the output.
THaEvent* event = new THaEvent;
// Define the run(s) that we want to analyze.
// We just set up one, but this could be many.
char RunFileName[100];
sprintf(RunFileName, RunFileNamePattern, RunNumber);
THaRun* run = new THaRun( pathList, Form(RunFileNamePattern, RunNumber) );
// Set to read in Hall C run database parameters
run->SetRunParamClass("THcRunParameters");
// Eventually need to learn to skip over, or properly analyze
// the pedestal events
run->SetEventRange(1, MaxEvent); // Physics Event number, does not
// include scaler or control events.
run->SetNscan(1);
run->SetDataRequired(0x7);
run->Print();
// Define the analysis parameters
TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber, MaxEvent);
analyzer->SetCountMode(2); // 0 = counter is # of physics triggers
// 1 = counter is # of all decode reads
// 2 = counter is event number
analyzer->SetEvent(event);
// Set EPICS event type
analyzer->SetEpicsEvtType(180);
// Define crate map
analyzer->SetCrateMapFileName("MAPS/db_cratemap.dat");
// Define output ROOT file
analyzer->SetOutFile(ROOTFileName.Data());
// Define DEF-file
analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_gem.def");
// Define cuts file
analyzer->SetCutFile("DEF-files/SHMS/PRODUCTION/pstackana_production_cuts.def"); // optional
// File to record accounting information for cuts
analyzer->SetSummaryFile(Form("REPORT_OUTPUT/SHMS/GEM/summary_gem_%d_%d.report", RunNumber, MaxEvent)); // optional
// Start the actual analysis.
analyzer->Process(run);
// Create report file from template
analyzer->PrintReport("TEMPLATES/SHMS/PRODUCTION/pstackana_production.template",
Form("REPORT_OUTPUT/SHMS/GEM/replay_shms_gem_%d_%d.report", RunNumber, MaxEvent)); // optional
}
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