Changeset 1209
- Timestamp:
- 01/22/02 17:32:15 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1208 r1209 8 8 * mfilter/MFAlpha.[h,cc]: 9 9 - added 10 11 * mfilter/MFill.[h,cc]: 12 - implemented a new calling style which allows you to let MFillH 13 create the necessary histogram objects 14 15 * mmain/MAnalysis.cc, macros/MagicHillas.C: 16 - changed to new stylish MHillas parameter containers 10 17 11 18 -
trunk/MagicSoft/Mars/macros/MagicHillas.C
r1152 r1209 24 24 25 25 26 void MagicHillas(const char *filename=" data/camera.root")26 void MagicHillas(const char *filename="~/data/Gamma*.root") 27 27 { 28 28 // … … 46 46 plist.AddToList(&geomcam); 47 47 48 MPedestalCam pedest; 49 plist.AddToList(&pedest); 48 // 49 // Craete the object which hlods the source positions in the camera 50 // plain in respect to which the image parameters will be calculated. 51 // For real data the containers will be filled by a task. 52 // 53 MSrcPosCam source("Source") 54 source.SetXY(0, 0); 55 56 MSrcPosCam antisrc("AntiSrc"); 57 antisrc.SetXY(240, 0); 58 59 plist.AddToList(&source); 60 plist.AddToList(&antisrc); 50 61 51 62 // 52 63 // Now setup the tasks and tasklist: 53 // 54 // 1) read in the data from a magic root file MReadTree 55 // 2) calculate number of cerenkov photons MCerPhotCalc 56 // 3) clean the image MImgCleanStd 57 // 4) calculate hillas MHillasCalc 58 // 5) fill the hillas into the histograms MFillH 59 // 60 64 // --------------------------------- 61 65 // 62 66 // The first argument is the tree you want to read. … … 65 69 // CalEvents: Calibration Events 66 70 // 67 MReadMarsFile read("Events", filename);71 MReadMarsFile read("Events", filename); 68 72 69 73 MMcPedestalCopy pcopy; … … 73 77 MBlindPixelCalc blind; 74 78 MHillasCalc hcalc; 75 M FillH hfill("MHillas", "MHHillas");76 M FillH sfill("MHillas", "MHStarMap");79 MHillasSrcCalc csrc1("Source", "HillasSource"); 80 MHillasSrcCalc csrc2("AntiSrc", "HillasAntiSrc"); 77 81 78 // 79 // Crete and setup Tasklist 80 // 82 MFillH hfill("MHHillas", "MHillas"); 83 MFillH sfill("MHStarMap", "MHillas"); 84 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource"); 85 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc"); 86 81 87 MWriteRootFile write("hillas.root"); 82 write.AddContainer("MHillas"); 88 write.AddContainer("MHillas", "Hillas"); 89 write.AddContainer("HillasSource", "Hillas"); 90 write.AddContainer("HillasAntiSrc", "Hillas"); 83 91 write.AddContainer("MHStarMap"); 84 92 … … 90 98 tlist.AddToList(&blind); 91 99 tlist.AddToList(&hcalc); 100 tlist.AddToList(&csrc1); 101 tlist.AddToList(&csrc2); 92 102 tlist.AddToList(&hfill); 93 103 tlist.AddToList(&sfill); 104 tlist.AddToList(&hfill2s); 105 tlist.AddToList(&hfill2a); 94 106 tlist.AddToList(&write); 95 107 … … 112 124 // 113 125 plist.FindObject("MHHillas")->DrawClone(); 126 plist.FindObject("HistSource")->DrawClone(); 127 plist.FindObject("HistAntiSrc")->DrawClone(); 114 128 plist.FindObject("MHStarMap")->DrawClone(); 115 129 } -
trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc
r1203 r1209 67 67 if (!fHillas) 68 68 { 69 *fLog << dbginf << "MHillas not found... aborting." << endl;69 *fLog << err << dbginf << "MHillas not found... aborting." << endl; 70 70 return kFALSE; 71 71 } … … 74 74 if (!fSrcPos) 75 75 { 76 *fLog << dbginf << "MSrcPosCam missing in Parameter List... aborting." << endl;76 *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl; 77 77 return kFALSE; 78 78 } -
trunk/MagicSoft/Mars/mfilter/MFAlpha.h
r1208 r1209 4 4 ///////////////////////////////////////////////////////////////////////////// 5 5 // // 6 // MFAlpha //6 // MFAlpha // 7 7 // // 8 8 ///////////////////////////////////////////////////////////////////////////// … … 37 37 Bool_t Process(); 38 38 39 ClassDef(MFAlpha, 0) // A Filter for the Level 1 Trigger39 ClassDef(MFAlpha, 0) // A Filter for cuts in fabs(alpha) 40 40 }; 41 41 -
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 -
trunk/MagicSoft/Mars/mmain/MAnalysis.cc
r1170 r1209 132 132 #include "MBlindPixelCalc.h" 133 133 #include "MHillasCalc.h" 134 #include "MHillasSrcCalc.h" 135 #include "MSrcPosCam.h" 134 136 #include "MFillH.h" 135 137 #include "MEvtLoop.h" … … 161 163 plist.AddToList(&geomcam); 162 164 163 MPedestalCam pedest; 164 plist.AddToList(&pedest); 165 MSrcPosCam source("Source"); 166 source.SetXY(0, 0); 167 168 MSrcPosCam antisrc("AntiSrc"); 169 antisrc.SetXY(240, 0); 170 171 plist.AddToList(&source); 172 plist.AddToList(&antisrc); 165 173 166 174 // … … 187 195 MBlindPixelCalc blind; 188 196 MHillasCalc hcalc; 197 MHillasSrcCalc csrc1("Source", "HillasSource"); 198 MHillasSrcCalc csrc2("AntiSource", "HillasAntiSrc"); 199 200 MFillH hfill("MHHillas", "MHillas"); 201 MFillH sfill("MHStarMap", "MHillas"); 202 203 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource"); 204 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc"); 189 205 190 206 tlist.AddToList(&read); … … 195 211 tlist.AddToList(&blind); 196 212 tlist.AddToList(&hcalc); 197 198 MFillH hfill("MHillas", "MHHillas"); 199 MFillH sfill("MHillas", "MHStarMap"); 213 tlist.AddToList(&csrc1); 214 tlist.AddToList(&csrc2); 200 215 201 216 if (displhillas) 217 { 202 218 tlist.AddToList(&hfill); 219 tlist.AddToList(&hfill2s); 220 tlist.AddToList(&hfill2a); 221 } 203 222 204 223 if (displstarmap) … … 234 253 // 235 254 if (displhillas) 255 { 236 256 plist.FindObject("MHHillas")->DrawClone(); 257 plist.FindObject("HistSource")->DrawClone(); 258 plist.FindObject("HistAntiSrc")->DrawClone(); 259 } 237 260 238 261 if (displstarmap)
Note:
See TracChangeset
for help on using the changeset viewer.