46 if( !the_hist )
return;
71 ncnt.assign( nwire, 0 );
72 nhit.assign( nwire, 0 );
74 if( hist_nhit ) hist_nhit->Reset();
75 if( hist_eff ) hist_eff->Reset();
110 if( !
IsOK() )
return -1;
112 for(
auto& thePlane :
fVDCvar ) {
113 assert( thePlane.nwire > 0 );
114 thePlane.ncnt.assign( thePlane.nwire, 0 );
115 thePlane.nhit.assign( thePlane.nwire, 0 );
118 if( !thePlane.hist_nhit ) {
120 TString title =
"Num hits " + thePlane.histname;
122 thePlane.hist_nhit =
new TH1F(
name, title, nmax, -1, nmax-1 );
124 if( !thePlane.hist_eff ) {
126 TString title = thePlane.histname +
" efficiency";
127 thePlane.hist_eff =
new TH1F(
name, title,
128 thePlane.nwire, 0, thePlane.nwire );
150 const char*
const here =
"Init";
159 for(
auto& thePlane :
fVDCvar ) {
160 assert( !thePlane.name.IsNull() );
162 if( !thePlane.pvar ) {
164 thePlane.name.Data() );
177 const char*
const here =
"Process";
179 if( !
IsOK() )
return -1;
184 for(
auto& thePlane :
fVDCvar ) {
186 if( !thePlane.pvar )
continue;
188 Int_t nwire = thePlane.nwire;
192 Int_t nhit = thePlane.pvar->GetLen();
193 thePlane.hist_nhit->Fill(nhit);
197 }
else if( nhit > nwire ) {
202 for(
Int_t i = 0; i < nhit; ++i ) {
204 if( wire >= 0 && wire < nwire ) {
205 fWire.push_back(wire);
212 if( ngh2 >= nwire )
continue;
215 Int_t awire = wire+1;
216 thePlane.ncnt[awire]++;
218 thePlane.nhit[awire]++;
223 thePlane.hist_eff->Reset();
224 for(
Int_t i = 0; i < nwire; ++i ) {
225 if( thePlane.ncnt[i] != 0 ) {
227 static_cast<Double_t>(thePlane.ncnt[i]);
228 thePlane.hist_eff->Fill(i,xeff);
254 const char*
const here =
"ReadDatabase";
255 const char*
const separators =
", \t";
256 const Int_t NPAR = 3;
268 const DBRequest request[] = {
269 {
"vdcvars", &configstr, kTString },
274 status =
LoadDB(
f, date, request );
281 if( status !=
kOK ) {
285 if( configstr.
Length() == 0 ) {
286 Error(
Here(
here),
"No VDC variables defined. Fix database." );
290 unique_ptr<TObjArray> vdcvars( configstr.
Tokenize(separators) );
291 Int_t nparams = vdcvars->GetLast()+1;
293 Error(
Here(
here),
"No VDC variable names in vdcvars = %s. Fix database.",
297 if( nparams % NPAR != 0 ) {
298 Error(
Here(
here),
"Incorrect number of parameters in vdcvars. "
299 "Have %d, but must be a multiple of %d. Fix database.",
306 for(
Int_t ip = 0; ip < nparams; ip += NPAR ) {
307 const TString&
name = GetObjArrayString(params,ip);
308 const TString& histname = GetObjArrayString(params,ip+1);
309 Int_t nwire = GetObjArrayString(params,ip+2).Atoi();
310 if(
name.IsNull() ) {
311 Error(
Here(
here),
"Missing global variable name at vdcvars[%d]. "
312 "Fix database.", ip );
317 "Fix database.", ip );
321 Error(
Here(
here),
"Illegal number of wires = %d for VDC variable %s. "
322 "Fix database.", nwire,
name.Data() );
326 for(
auto& thePlane :
fVDCvar ) {
327 if( thePlane.name ==
name ) {
329 "Fix database.",
name.Data() );
332 if( thePlane.histname == histname ) {
334 "Fix database.", histname.
Data() );
360 for(
auto& thePlane :
fVDCvar ) {
361 if( thePlane.hist_nhit )
362 thePlane.hist_nhit->Write();
363 if( thePlane.hist_eff )
364 thePlane.hist_eff->Write();
R__EXTERN class THaVarList * gHaVars
static const char *const here
static void SafeDeleteHist(const TString &name, TH1F *&the_hist)
const TString nhit_suffix("nhit")
const TString eff_suffix("eff")
Bool_t InheritsFrom(const char *cl) const override
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
virtual const char * Here(const char *) const
virtual FILE * OpenFile(const TDatime &date)
virtual void Print(Option_t *opt="") const
virtual void Clear(Option_t *opt="")
virtual THaVar * Find(const char *name) const
virtual const char * GetName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual TClass * IsA() const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
void Reset(Option_t *opt="")
void Reset(Option_t *opt="")
virtual Int_t ReadDatabase(const TDatime &date)
std::vector< Short_t > fWire
VDCeff(const char *name, const char *description)
virtual Int_t Process(const THaEvData &)
virtual Int_t End(THaRunBase *r=nullptr)
std::vector< bool > fHitWire
std::vector< VDCvar_t > fVDCvar
virtual Int_t Begin(THaRunBase *r=nullptr)
Double_t Min(Double_t a, Double_t b)
Double_t Ceil(Double_t x)
Double_t Max(Double_t a, Double_t b)