16 #include <JANA/JParameterManager.h>
40 int main(
int narg,
char *argv[])
49 JEventLoop *loop =
new JEventLoop(dapp);
50 loop->GetJEvent().SetRunNumber(
RUN);
55 cerr <<
"Unable to find DBeamCurrent_factory!" << endl;
70 uint32_t Ntrips = fac->
trip.size();
74 double last_Ibeam = 0.0;
79 double delta_t = b.t - last_t;
82 Ion_sum += delta_t*last_Ibeam;
89 double Ibeam_avg = Ion_sum/Ion_t;
92 cout <<
"--------------------------------------------" << endl;
93 cout <<
"Electron Beam Trip Report" << endl;
95 cout <<
" Run: " <<
RUN << endl;
96 cout <<
"total time of run: " << t_total <<
" sec" << endl;
97 cout <<
" beam ON time: " << Ion_t <<
" sec (" << 100.0*Ion_t/t_total <<
"%)" << endl;
98 cout <<
" fiducial time: " << t_fiducial <<
" sec (" << 100.0*t_fiducial/t_total <<
"%)" << endl;
101 cout <<
" t range: " <<
T_MIN <<
" - " <<
T_MAX <<
" sec (" << 100.0*(
T_MAX-
T_MIN)/t_total <<
"%)" << endl;
102 cout <<
" Nboundaries: " << Nboundaries <<
" (current changed by >3nA)" << endl;
103 cout <<
" Ntrips: " << Ntrips << endl;
104 cout <<
" trips/hr: " << (float)Ntrips/(
float)(
T_MAX -
T_MIN)*3600.0 << endl;
105 cout <<
" avg. Ibeam ON: " << Ibeam_avg <<
" nA" << endl;
109 cout <<
"Trip/recover times relative to start of run in seconds:" << endl;
110 cout <<
"tripped recovered off" << endl;
111 cout <<
"------- -------- -------" << endl;
113 for(
auto t : fac->
trip){
115 if( i < fac->recover.size())
125 cout <<
"--------------------------------------------" << endl;
137 cout<<
"Usage:"<<endl;
138 cout<<
" hdbeam_current [options] run"<<endl;
140 cout<<
" options:"<<endl;
141 cout<<
" -h, --help Show this Usage statement"<<endl;
146 cout<<
" -trips Report times of all identified trips" << endl;
147 cout<<
" -tbuffer # Set the buffer time to exclude near trips (sec)"<<endl;
148 cout<<
" -tmin # Set the minimum of the time range (sec)"<<endl;
149 cout<<
" -tmax # Set the maximum of the time range (sec)"<<endl;
150 cout<<
" -Ion # Set the beam current threshold for \"ON\" (nA)"<<endl;
153 "This will query the CCDB for electron the beam trip map for the \n"
154 "given run number. The CCDB is filled from the EPICS archive using \n"
155 "the mySampler program to interpolate values from the IBCAD00CRCUR6 \n"
156 "current monitor. Changes in the beam current greater than 3nA are \n"
157 "written to the archive as \"boundaries\". The above options can be\n"
158 "used to interpret these boundaries in terms of beam trips. A \n"
159 "fiducial time range is made from the regions between the trips with \n"
160 "excluding a buffer just before trip and just after a recovery. This \n"
161 "is intended to cut out regions where the beam may be slightly astray. \n"
167 "The -tmin and -tmax options allow one to specify a time range in which\n"
168 "to integrate fiducial time. If no minimum or maximum time are specified\n"
169 "then the full time range of the run is used.\n"
171 "Note that this functionality also exists within sim-recon via the\n"
172 "DBeamCurrent objects and their \"is_fudicial\" flag. The \n"
173 "DBeamCurrent_factory class can also be used to integrate the fiducial\n"
174 "time in a run or given time range via the IntegratedFiducialTime()\n"
177 "This utility is meant to give quick, easy access to the same information\n"
178 "without having to write a special sim-recon program.\n" << endl;
187 for(
int i=1; i<narg; i++){
189 string next(i<narg-1 ? argv[i+1]:
"");
190 float argf = atof(next.c_str());
191 bool used_next =
false;
199 if(arg==
"-tmin" ){used_next=
true;
T_MIN = argf;}
200 if(arg==
"-tmax" ){used_next=
true;
T_MAX = argf;}
203 if(arg==
"-h" || arg==
"--help"){
Usage(); exit(0);}
210 if(arg[0] !=
'-')
RUN =atoi(argv[i]);
sprintf(text,"Post KinFit Cut")
double IntegratedTime(void)
vector< Boundary > boundaries
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
double IntegratedFiducialTime(double t_start=0.0, double t_end=0.0)
void ParseCommandLineArgs(int narg, char *argv[], vector< char * > &unused_args)
jerror_t init(void)
Called once at program start.
void Usage(JApplication &app)
int main(int argc, char *argv[])