46 const char* description ) :
47 TNamed(
name,description), fPrefix(nullptr), fStatus(kNotinit),
48 fDebug(0), fIsInit(false), fIsSetup(false), fProperties(0),
49 fOKOut(false), fInitDate(19950101,0), fNEventsWithWarnings(0),
60 : fPrefix(nullptr), fStatus(kNotinit), fDebug(0), fIsInit(false),
61 fIsSetup(false), fProperties(), fOKOut(false), fNEventsWithWarnings(0),
115 ntot += fMessage.second;
120 <<
"warnings, " << ntot <<
" total warnings"
122 << R
"/( Call Print("WARN") for channel list. )/"
123 << "Re-run with fDebug>0 for per-event details.";
173 const char* def_prefix,
174 const char* comment_subst )
const
181 const char* def_prefix,
182 const char* comment_subst )
const
189 EMode mode,
const char* def_prefix,
190 const char* comment_subst )
const
197 here.Append(
"::DefineVarsFromList");
205 const char* def_prefix,
209 const char* comment_subst )
219 action =
"deleted (this is safe when exiting)";
221 "No variables %s.", action.
Data() );
236 const auto *item =
static_cast<const VarDef*
>(list);
237 while( item && item->name ) {
239 name.Append( item->name );
244 const auto *item =
static_cast<const RVarDef*
>(list);
245 while( item && item->name ) {
247 name.Append( item->name );
259 const char* classname,
274 static const char*
const here =
"FindModule";
275 static const char*
const anaobj =
"THaAnalysisObject";
287 while( (obj = next()) ) {
289 auto*
module = static_cast<THaAnalysisObject*>(obj);
291 auto*
module = dynamic_cast<THaAnalysisObject*>(obj);
294 TString prefix =
module->GetPrefixName();
296 module->MakePrefix();
297 prefix =
module->GetPrefixName();
320 if( classname && *classname && strcmp(classname,anaobj) != 0 &&
330 if( !aobj->IsOK() ) {
349 const char* classname =
"UnknownClass";
357 const char* fmt, va_list va)
const
369 ::ErrorHandler(level, location.
Data(), fmt, va);
408 :
std::runtime_error(
"Error reading database"),
425 static const char*
const here =
"Init";
448 if(
IsA()->GetMethodAllAny(
"ReadDatabase") !=
449 gROOT->GetClass(
"THaAnalysisObject")->GetMethodAllAny(
"ReadDatabase") ) {
457 "Database not read.");
463 Error(
Here(
here),
"Cannot open database file db_%sdat",
e.filename);
465 Error(
Here(
here),
"Error while reading file db_%sdat",
e.filename);
468 catch(
const std::bad_alloc& ) {
472 catch(
const std::exception&
e ) {
473 Error(
Here(
here),
"Exception \"%s\" caught in ReadDatabase. "
474 "Module not initialized. Check database or call expert.",
479 Info(
Here(
here),
"Not re-reading database for same date.");
525 if( basename && *basename ) {
597 "Cannot set an empty object name. Name not set.");
655 nom[0] = den[0] = xax.
X();
656 nom[3] = den[3] = xax.
Y();
657 nom[6] = den[6] = xax.
Z();
658 nom[1] = den[1] = yax.
X();
659 nom[4] = den[4] = yax.
Y();
660 nom[7] = den[7] = yax.
Z();
661 den[2] = -ray_vect.
X();
662 den[5] = -ray_vect.
Y();
663 den[8] = -ray_vect.
Z();
665 Double_t det1 = den[0]*(den[4]*den[8]-den[7]*den[5])
666 -den[3]*(den[1]*den[8]-den[7]*den[2])
667 +den[6]*(den[1]*den[5]-den[4]*den[2]);
668 if(
fabs(det1) < 1
e-5 )
671 nom[2] = ray_start.
X()-
org.X();
672 nom[5] = ray_start.
Y()-
org.Y();
673 nom[8] = ray_start.
Z()-
org.Z();
674 Double_t det2 = nom[0]*(nom[4]*nom[8]-nom[7]*nom[5])
675 -nom[3]*(nom[1]*nom[8]-nom[7]*nom[2])
676 +nom[6]*(nom[1]*nom[5]-nom[4]*nom[2]);
679 intersect = ray_start +
length*ray_vect;
694 th_sph =
acos( tmp );
695 tmp =
sqrt(1.0 - tmp*tmp);
696 ph_sph = (
fabs(tmp) < 1
e-6 ) ? 0.0 :
acos(
sqrt(1.0-ct*ct)*cp/tmp );
697 if( th_geo/twopi-
floor(th_geo/twopi) > 0.5 ) ph_sph =
TMath::Pi() - ph_sph;
698 if( ph_geo/twopi-
floor(ph_geo/twopi) > 0.5 ) ph_sph = -ph_sph;
712 if(
fabs(ct) > 1
e-6 ) {
713 th_geo =
atan( st/ct*cp );
714 if( cp>0.0 && th_geo<0.0 ) th_geo +=
TMath::Pi();
715 else if( cp<0.0 && th_geo>0.0 ) th_geo -=
TMath::Pi();
718 if( cp<0.0 ) th_geo = -th_geo;
720 ph_geo =
acos(
sqrt( st*st*cp*cp + ct*ct ));
721 if( ph_sph/twopi -
floor(ph_sph/twopi) > 0.5 ) ph_geo = -ph_geo;
738 return OpenDBFile(
"run", date,
ClassNameHere(
"OpenDBFile()"),
744 const DBRequest* req,
Int_t search )
const {
749 here.Append(
"::LoadDB");
755void THaAnalysisObject::DebugPrint(
const DBRequest* list )
const
763 ios_base::fmtflags fmt = cout.flags();
764 for(
const auto *it = list; it->name; ++it )
766 for(
const auto *it = list; it->name; ++it ) {
767 cout <<
" " << std::left << setw(static_cast<int>(maxw)) << it->name;
768 size_t maxc = it->nelem;
769 if( maxc == 0 ) maxc = 1;
770 if( it->type == kDoubleV )
771 maxc = ((vector<Double_t>*)it->var)->size();
772 else if( it->type == kFloatV )
773 maxc = ((vector<Float_t>*)it->var)->size();
774 else if( it->type == kIntV )
775 maxc = ((vector<Int_t>*)it->var)->size();
776 for(
size_t i=0; i<maxc; ++i ) {
783 cout << ((
Float_t*)it->var)[i];
786 cout << ((
Int_t*)it->var)[i];
789 cout << ((vector<Int_t>*)it->var)->at(i);
792 cout << ((vector<Float_t>*)it->var)->at(i);
795 cout << ((vector<Double_t>*)it->var)->at(i);
808void THaAnalysisObject::WriteValue( T val,
int p,
int w )
811 ios_base::fmtflags fmt = cout.flags();
812 streamsize prec = cout.precision();
813 if( std::is_floating_point<T>::value && val < kBig )
814 cout << fixed << setprecision(p) << setw(w) << val;
816 val != numeric_limits<T>::max() && val < 10 *
static_cast<T>(w) &&
817 (std::is_unsigned<T>::value || -val < 10 *
static_cast<T>(w)) )
818 cout << setw(w) << val;
822 cout.precision(prec);
826template void THaAnalysisObject::WriteValue<Double_t>(
Double_t val,
int p=0,
int w=5 );
827template void THaAnalysisObject::WriteValue<Float_t>(
Float_t val,
int p=0,
int w=5 );
828template void THaAnalysisObject::WriteValue<Int_t>(
Int_t val,
int p=0,
int w=5 );
829template void THaAnalysisObject::WriteValue<UInt_t>(
UInt_t val,
int p=0,
int w=5 );
845 if( opt && strstr(opt,
"WARN") !=
nullptr && !
fMessages.empty() ) {
847 string::size_type
len =
name.length();
850 cout <<
"Module \"" <<
name <<
"\" encountered warnings:" << endl;
851 for(
const auto& fMessage :
fMessages ) {
852 cout <<
" " << fMessage.first <<
": " << fMessage.second <<
" times" << endl;
863 while(
TObject* obj = next() ) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
R__EXTERN class THaVarList * gHaVars
static const char *const here
Bool_t InheritsFrom(const char *cl) const override
virtual Int_t GetSize() const
virtual void SetDebug(Int_t level)
static void GeoToSph(Double_t th_geo, Double_t ph_geo, Double_t &th_sph, Double_t &ph_sph)
virtual Int_t ReadRunDatabase(const TDatime &date)
virtual void SetNameTitle(const char *name, const char *title)
virtual Int_t Begin(THaRunBase *r=nullptr)
static void SphToGeo(Double_t th_sph, Double_t ph_sph, Double_t &th_geo, Double_t &ph_geo)
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual Int_t InitOutput(THaOutput *)
virtual Int_t End(THaRunBase *r=nullptr)
virtual const char * Here(const char *) const
const char * GetPrefix() const
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
virtual Int_t ReadDatabase(const TDatime &date)
std::map< std::string, UInt_t > fMessages
virtual const char * ClassNameHere(const char *) const
virtual void MakePrefix()
TString GetPrefixName() const
static Bool_t IntersectPlaneWithRay(const TVector3 &xax, const TVector3 &yax, const TVector3 &org, const TVector3 &ray_start, const TVector3 &ray_vect, Double_t &length, TVector3 &intersect)
void SetConfig(const char *label)
virtual FILE * OpenRunDBFile(const TDatime &date)
const char * GetClassName() const
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
virtual ~THaAnalysisObject()
UInt_t fNEventsWithWarnings
virtual FILE * OpenFile(const TDatime &date)
static void PrintObjects(Option_t *opt="")
virtual void Clear(Option_t *="")
virtual const char * GetDBFileName() const
Int_t DefineVariablesWrapper(EMode mode=kDefine)
virtual void SetName(const char *name)
virtual void Print(Option_t *opt="") const
virtual Int_t RemoveName(const char *name)
virtual Int_t DefineVariables(const VarDef *list, const char *prefix="", const char *caller="")
static const Long64_t kInvalidInt
void Add(TObject *obj) override
TObject * Remove(const TObjLinkPtr_t &lnk)
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void SetName(const char *name)
TClass * IsA() const override
virtual const char * GetName() const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual const char * GetTitle() const
virtual TClass * IsA() const
virtual void Info(const char *method, const char *msgfmt,...) const
static Bool_t Initialized()
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(char c, Ssiz_t rep=1)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
database_error(Int_t st, const char *fnam)
unsigned long long ULong64_t
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< PromoteType< T > > floor(const RVec< T > &v)
RVec< PromoteType< T > > acos(const RVec< T > &v)
RVec< PromoteType< T > > atan(const RVec< T > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
Expr< UnaryOp< Sqrt< T >, Expr< A, T, D, D2, R >, T >, T, D, D2, R > sqrt(const Expr< A, T, D, D2, R > &rhs)
Expr< UnaryOp< Fabs< T >, Expr< A, T, D, D2, R >, T >, T, D, D2, R > fabs(const Expr< A, T, D, D2, R > &rhs)
Double_t Max(Double_t a, Double_t b)