1 #include "CategoryManager.hxx" 21 void CategoryManager::AddCategory(
const std::string& categ_name,
int ntypes, std::string* names,
int* codes,
int* colors,
bool multi,
bool noWarning,
bool addNOTRUTH,
bool addSAND){
29 std::cerr <<
"WARNING: category '" << categ_name <<
"' already exists !!! Replacing properties..." << std::endl;
35 categ->
_name = categ_name;
40 for (
int i=0;i<ntypes;i++) {
41 if ( ! noWarning && addSAND && codes[i]==CATSAND) {
42 std::cerr <<
"ERROR in CategoryManager::AddCategory: for category '" << categ_name
43 <<
"' user type " << i <<
" '" << names[i] <<
"' has same code " << codes[i]
44 <<
" as the automatic SAND muon type. Please use a different code !!!" << std::endl;
46 if ( ! noWarning && addNOTRUTH && codes[i]==CATNOTRUTH) {
47 std::cerr <<
"ERROR in CategoryManager::AddCategory: for category '" << categ_name
48 <<
"' user type " << i <<
" '" << names[i] <<
"' has same code " << codes[i]
49 <<
" as the automatic NO TRUTH type. Please use a different code !!!" << std::endl;
53 type.
_name = names[i];
54 type.
_code = codes[i];
66 type.
_name = NAMENOTRUTH;
67 type.
_code = CATNOTRUTH;
77 typeSand.
_name = NAMESAND;
78 typeSand.
_code = CATSAND;
91 std::cout <<
"cannot copy category '" << categ_name <<
"' because it does not exist !!!" << std::endl;
96 const UInt_t NMAXTYPES=50;
100 std::string names[NMAXTYPES];
101 Int_t codes[NMAXTYPES];
102 Int_t colors[NMAXTYPES];
104 for (Int_t i=0;i<ntypes;i++){
111 AddCategory(categ_name2, ntypes, names, codes, colors, multi);
122 ReadClonesArray(file);
145 std::cout <<
"-------- Available track categories -------" << std::endl;
146 std::map< std::string, TrackCategoryDefinition* >::iterator it;
148 std::string categ_name = it->first;
149 std::cout <<
" - " << categ_name << std::endl;
151 std::cout <<
"-------------------------------------------" << std::endl;
160 std::cout <<
"Category " << categ <<
" hasn't been set!" << std::endl;
163 std::cout <<
" --------------------------------------------------------" << std::endl;
164 std::cout <<
" Types for '" << categ <<
"' category" << std::endl;
168 for (
unsigned int i = 0; i < types.size(); i++) {
170 std::cout << std::setw(25) << type.
_name << std::setw(15) <<
"code " << type.
_code << std::setw(15) <<
"color " << type.
_color << std::endl;
173 std::cout <<
"-------------------------------------------" << std::endl;
174 std::cout << std::endl;
182 std::map< std::string, TrackCategoryDefinition* >::iterator it;
186 for (
unsigned int i=0;i<categ.
GetNTypes();i++)
206 std::cout <<
"Category '" << categ <<
"' is a multi-type category" << std::endl;
220 std::cout <<
"Category '" << categ <<
"' is a single-type category" << std::endl;
bool _enabled
Is this type enabled?
void SetCategoryType(int index, bool ok)
Set the type for the actual track.
bool IsMultiType()
Is this a multi-type category ? (Can several types coexist?)
void AddCategory(const std::string &name, int ntypes, std::string *names, int *codes, int *colors, bool multi=false, bool noWarning=false, bool addNOTRUTH=true, bool addSAND=true)
int GetCode(const std::string &categ)
Get the actual code for this category.
int _code
The unique code for this type ("muon==13", ...).
bool CheckCategoryType(const std::string &categ, int index)
void AddType(TrackTypeDefinition &type)
Add a new type to this category.
int _order
The order in which it should appear when plotting.
TrackCategoryDefinition & GetCategory(const std::string &categ)
Get a specific category.
void DumpCategories()
Dump the map of track categories.
std::map< std::string, TrackCategoryDefinition * > & GetCategories()
Get the map of track categories.
int _color
The color to be displayed for tracks of this type.
void ResetCurrentCategories()
Reset the properties of the current track.
Int_t _NObjects
The number of steps that were added.
int GetCode()
Get the code for the actual track in this category.
std::string _name
The name of this type ("muon", "electron", ...). It will be displayed in the legend.
void SetCode(int code, int defaultcode=-999)
unsigned int GetNTypes()
Number of types defined for this category.
std::vector< TrackTypeDefinition > & GetCategoryTypes()
Get the types defined for this category.
bool _ready
Whether the categories are ready.
void CopyCategory(const std::string &categ_name, const std::string &categ_name2)
Copy an existing Category into another with a different name.
CategoryManager()
Private constructor as this is a singleton.
bool HasCategory(const std::string &categ)
Has this category been added?
void DumpCategory(const std::string &categ)
Dump the options stored for the given category.
std::map< std::string, TrackCategoryDefinition * > _track_category_map
The internal map of categories and the names they were registered with.
This namespace contains useful functions for analyses related to kinematics.
std::string _name
The name of this category (e.g. "particle").
void ReadCategories(const std::string &file)
Build the categories from a root file.
bool CheckCategoryType(int index)
Check if the actual track is of this type.