Changeset 1209 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 01/22/02 17:32:15 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MFillH.cc
r1082 r1209 30 30 // histogram which is derived from MH can be filled with this task. // 31 31 // // 32 // You must specifiy the parameter container with which data the histogram // 33 // container should be filled, and the histogram container which has // 34 // to be filled. This can be done by either specifing the name of the // 35 // objects in the parameter list or by specifiing a pointer to the object. // 36 // (s. Constructor) // 32 // There are two options to use: // 33 // // 34 // 1) You specifiy the parameter container with which data the // 35 // histogram container should be filled, and the histogram container // 36 // which has to be filled. This can be done by either specifing the // 37 // name of the objects in the parameter list or by specifiing a pointer // 38 // to the object. (s. Constructor) // // 39 // // 40 // 2) You specify the name and/or type of the histogram to become filled. // 41 // Any other action imust be taken by the histogram class. // 42 // // 43 // PreProcess: In the preprocessing of this task we setup all pointers // 44 // to instances which are needed and call FillSetup of the // 45 // histogram class with the parameter list as an argument. // 46 // // 47 // Process: The process function calls the Fill member function of the // 48 // histogram class instance (inheriting from MH) with either // 49 // a NULL pointer or a pointer to the corresponding container // 50 // as an argument. // 37 51 // // 38 52 // WARNING: // … … 81 95 // Constructor. 82 96 // 83 // - par is the name of the parameter container which should be filled into 84 // the histogram 85 // - hist is the name of the histogram container (which must have been 86 // derived from MH) 87 // 88 MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title) 97 // 1) - par is the name of the parameter container which should be filled into 98 // the histogram 99 // - hist is the name of the histogram container (which must have been 100 // derived from MH) 101 // 102 // In this case MH::Fill is called with a pointer to the corresponding 103 // histogram instance. 104 // 105 // 2) - hist is the name and/or type of the histogram. 106 // 1) The name and type is identical, eg: "MHHillas" 107 // 2) They are not identical, eg: "MyHistogram [MHHillas]" 108 // This searches for a class instance of MHHillas with the name 109 // "MyHistogram". If it doesn't exist one is created. 110 // 111 // In this case PreProcess calls MH::SetupFill with a pointer to the 112 // parameter list and MH::Fill is called with a NULL-pointer. 113 // 114 MFillH::MFillH(const char *hist, const char *par, const char *name, const char *title) 89 115 { 90 116 Init(name, title); 91 117 92 118 fHName = hist; 119 fParContainerName = par; 120 } 121 122 // -------------------------------------------------------------------------- 123 // 124 // Constructor. 125 // 126 // 1) - par is a pointer to the instance of your parameter container from which 127 // the data should be used to fill the histogram. 128 // - hist is the name of the histogram container (which must have been 129 // derived from MH) 130 // 131 // In this case MH::Fill is called with a pointer to the corresponding 132 // histogram instance. 133 // 134 // 2) - hist is the name and/or type of the histogram. 135 // 1) The name and type is identical, eg: "MHHillas" 136 // 2) They are not identical, eg: "MyHistogram [MHHillas]" 137 // This searches for a class instance of MHHillas with the name 138 // "MyHistogram". If it doesn't exist one is created. Everything 139 // which is between the first '[' and the last ']' in the string 140 // is used as the histogram type. 141 // 142 // In this case PreProcess calls MH::SetupFill with a pointer to the 143 // parameter list and MH::Fill is called with a NULL-pointer. 144 // 145 // 146 MFillH::MFillH(const char *hist, const MParContainer *par, const char *name, const char *title) 147 { 148 Init(name, title); 149 150 fHName = hist; 151 fParContainer = par; 152 fParContainerName = par->GetName(); 153 } 154 155 // -------------------------------------------------------------------------- 156 // 157 // Constructor. 158 // 159 // - par is a pointer to the instance of your parameter container from which 160 // the data should be used to fill the histogram. 161 // - hist is a pointer to the instance of your histogram container (which must 162 // have been derived from MH) into which the data should flow 163 // 164 MFillH::MFillH(MH *hist, const char *par, const char *name, const char *title) 165 { 166 Init(name, title); 167 168 fH = hist; 169 fHName = hist->GetName(); 93 170 fParContainerName = par; 94 171 } … … 103 180 // derived from MH) 104 181 // 105 MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title) 106 { 107 Init(name, title); 108 109 fHName = hist; 110 fParContainer = par; 111 fParContainerName = par->GetName(); 112 } 113 114 // -------------------------------------------------------------------------- 115 // 116 // Constructor. 117 // 118 // - par is a pointer to the instance of your parameter container from which 119 // the data should be used to fill the histogram. 120 // - hist is a pointer to the instance of your histogram container (which must 121 // have been derived from MH) into which the data should flow 122 // 123 MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title) 124 { 125 Init(name, title); 126 127 fH = hist; 128 fHName = hist->GetName(); 129 fParContainerName = par; 130 } 131 132 // -------------------------------------------------------------------------- 133 // 134 // Constructor. 135 // 136 // - par is a pointer to the instance of your parameter container from which 137 // the data should be used to fill the histogram. 138 // - hist is the name of the histogram container (which must have been 139 // derived from MH) 140 // 141 MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title) 182 MFillH::MFillH(MH *hist, const MParContainer *par, const char *name, const char *title) 142 183 { 143 184 Init(name, title); … … 147 188 fParContainer = par; 148 189 fParContainerName = par->GetName(); 190 } 191 192 TString MFillH::ExtractName(const char *name) const 193 { 194 TString type = name; 195 196 const Ssiz_t first = type.First('['); 197 const Ssiz_t last = type.First(']'); 198 199 if (!first || !last || first>=last) 200 return type; 201 202 return type.Remove(first).Strip(TString::kBoth); 203 } 204 205 TString MFillH::ExtractClass(const char *name) const 206 { 207 TString type = name; 208 209 const Ssiz_t first = type.First('['); 210 const Ssiz_t last = type.First(']'); 211 212 if (!first || !last || first>=last) 213 return type; 214 215 const Ssiz_t length = last-first-1; 216 217 TString strip = fHName(first+1, length); 218 return strip.Strip(TString::kBoth); 149 219 } 150 220 … … 159 229 Bool_t MFillH::PreProcess(MParList *pList) 160 230 { 161 if (!fParContainer) 231 // 232 // Try to get the histogram container with name fHName from list 233 // or create one with this name 234 // 235 if (!fH) 162 236 { 163 fParContainer = (MParContainer*)pList->FindObject(fParContainerName); 164 if (!fParContainer) 237 const TString cls = ExtractClass(fHName); 238 const TString name = ExtractName(fHName); 239 240 TObject *obj = pList->FindCreateObj(cls, name); 241 if (!obj) 242 return kFALSE; 243 244 // 245 // We were successfull getting it. Check whether it really inherits 246 // from MH, FindCreateObj does only check for inheritance from 247 // 'type'. 248 // 249 if (!obj->InheritsFrom(MH::Class())) 165 250 { 166 *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl; 251 *fLog << err << dbginf << obj->GetName() << " doesn't inherit "; 252 *fLog << "from MH - cannot be used for MFillH... aborting." << endl; 167 253 return kFALSE; 168 254 } 255 256 fH = (MH*)obj; 169 257 } 170 258 171 if (!fH) 259 // 260 // Now we have the histogram container available. Try to Setup Fill. 261 // 262 if (!fH->SetupFill(pList)) 172 263 { 173 fH = (MH*)pList->FindCreateObj(fHName); 174 if (!fH) 175 return kFALSE; 176 } 177 178 if (!fH->InheritsFrom("MH")) 179 { 180 *fLog << err << dbginf << fH->GetDescriptor() << " "; 181 *fLog << "doesn't inherit from MH - cannot be used for MFillH... aborting." << endl; 264 *fLog << err << dbginf << "Error: calling SetupFill for "; 265 *fLog << fH->GetDescriptor() << "... aborting." << endl; 182 266 return kFALSE; 183 267 } 184 268 185 return kTRUE; 269 // 270 // If also a parameter container is already set we are done. 271 // 272 if (fParContainer) 273 return kTRUE; 274 275 // 276 // If a name is given try to find the input container in the 277 // list. If it could not be found we cannot proceed. 278 // 279 fParContainer = (MParContainer*)pList->FindObject(fParContainerName); 280 if (fParContainer) 281 return kTRUE; 282 283 *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl; 284 return kFALSE; 186 285 } 187 286 … … 192 291 Bool_t MFillH::Process() 193 292 { 194 fH->Fill(fParContainer); 195 196 return kTRUE; 293 return fH->Fill(fParContainer); 197 294 } 198 295 -
trunk/MagicSoft/Mars/mhist/MFillH.h
r1015 r1209 18 18 TString fHName; 19 19 20 TString ExtractName(const char *name) const; 21 TString ExtractClass(const char *name) const; 22 20 23 void Init(const char *name, const char *title); 21 24 22 25 public: 23 MFillH(const char * par, const char *hist,const char *name=NULL, const char *title=NULL);24 MFillH(const MParContainer *par, const char *hist, const char *name=NULL, const char *title=NULL);25 MFillH( const char *par, MH *hist,const char *name=NULL, const char *title=NULL);26 MFillH( const MParContainer *par, MH *hist,const char *name=NULL, const char *title=NULL);26 MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL); 27 MFillH(const char *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL); 28 MFillH(MH *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL); 29 MFillH(MH *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL); 27 30 28 31 Bool_t PreProcess(MParList *pList); -
trunk/MagicSoft/Mars/mhist/MHHillas.h
r1207 r1209 27 27 TObject *DrawClone(Option_t *opt=NULL) const; 28 28 29 ClassDef(MHHillas, 1) // Container which h ilds hostograms for the Hillas parameters29 ClassDef(MHHillas, 1) // Container which holds histograms for length and width 30 30 }; 31 31 -
trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
r1208 r1209 100 100 // -------------------------------------------------------------------------- 101 101 // 102 // Draw clones of all fourhistograms. So that the object can be deleted102 // Draw clones of all two histograms. So that the object can be deleted 103 103 // and the histograms are still visible in the canvas. 104 104 // The cloned object are deleted together with the canvas if the canvas is … … 108 108 TObject *MHHillasSrc::DrawClone(Option_t *opt) const 109 109 { 110 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of HillasParameters",110 TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters", 111 111 350, 500); 112 112 c->Divide(1, 2); 113 114 // FIXME: Display Source position 113 115 114 116 gROOT->SetSelectedPad(NULL); … … 131 133 // -------------------------------------------------------------------------- 132 134 // 133 // Creates a new canvas and draws the fourhistograms into it.135 // Creates a new canvas and draws the two histograms into it. 134 136 // Be careful: The histograms belongs to this object and won't get deleted 135 137 // together with the canvas. … … 138 140 { 139 141 if (!gPad) 140 MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500); 142 MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500); 143 144 // FIXME: Display Source position 141 145 142 146 gPad->Divide(1, 2); -
trunk/MagicSoft/Mars/mhist/MHHillasSrc.h
r1208 r1209 27 27 TObject *DrawClone(Option_t *opt=NULL) const; 28 28 29 ClassDef(MHHillasSrc, 1) // Container which h ilds hostograms for the Hillasparameters29 ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters 30 30 }; 31 31
Note:
See TracChangeset
for help on using the changeset viewer.