Changeset 954 for trunk/MagicSoft/Mars/mmain
- Timestamp:
- 09/28/01 10:51:06 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mmain
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmain/MAnalysis.cc
r953 r954 165 165 // ====================================================================== 166 166 167 #include "MLog.h"168 167 #include "MParList.h" 169 168 #include "MTaskList.h" … … 179 178 #include "MEvtLoop.h" 180 179 #include "MHillas.h" 181 #include <iostream.h> 180 182 181 void MAnalysis::CalculateHillas() const 183 182 { … … 212 211 MTaskList tlist; 213 212 plist.AddToList(&tlist); 214 215 213 216 214 // -
trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
r947 r954 26 26 #include "MMonteCarlo.h" 27 27 28 #include <stdlib.h> 29 #include <iostream.h> 30 31 #include <TGLabel.h> // TGLabel 28 32 #include <TGButton.h> // TGTextButton 33 #include <TGTextEntry.h> // TGTextEntry 34 #include <TGButtonGroup.h> // TGVButtonGroup 29 35 30 36 ClassImp(MMonteCarlo) 31 37 32 38 enum { 33 M_BUTTON_ACTION 39 M_BUTTON_COLAREA, 40 M_BUTTON_RATE, 41 M_BUTTON_THRESHOLD 34 42 }; 43 44 void MMonteCarlo::AddButtons() 45 { 46 TGTextButton *carea = new TGTextButton(fTop1, "Collection Area", M_BUTTON_COLAREA); 47 TGTextButton *trate = new TGTextButton(fTop1, "Trigger Rate", M_BUTTON_RATE); 48 TGTextButton *thold = new TGTextButton(fTop1, "Threshold", M_BUTTON_THRESHOLD); 49 50 fList->Add(carea); 51 fList->Add(trate); 52 fList->Add(thold); 53 54 carea->Associate(this); 55 trate->Associate(this); 56 thold->Associate(this); 57 58 TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 5, 5, 10, 10); 59 fList->Add(laybut); 60 61 fTop1->AddFrame(carea, laybut); 62 fTop1->AddFrame(trate, laybut); 63 fTop1->AddFrame(thold, laybut); 64 } 65 66 void MMonteCarlo::AddSetupTab() 67 { 68 // 69 // Create Setup Tab 70 // 71 TGCompositeFrame *frame = CreateNewTab("Setup"); 72 73 // 74 // Create a button group (it alignes the buttons and make 75 // them automatic radio buttons) 76 // 77 TGVButtonGroup *group = new TGVButtonGroup(frame); 78 fList->Add(group); 79 80 // 81 // Create three (auto) radio buttons in the button group 82 // 83 fRadioButton1 = new TGRadioButton(group, "Use unnumbered trigger condition olny."); 84 fRadioButton2 = new TGRadioButton(group, "Use only one trigger condition (specify number below)."); 85 fRadioButton3 = new TGRadioButton(group, "Use a number of trigger conditions (1..n)."); 86 87 fList->Add(fRadioButton1); 88 fList->Add(fRadioButton2); 89 fList->Add(fRadioButton3); 90 91 // 92 // Add the button group (all buttons) as first line 93 // 94 frame->AddFrame(group); 95 96 // 97 // Create entry fields and labels for line 3 and 4 98 // 99 100 /* 101 * --> use with root >=3.02 <-- 102 * 103 104 TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative); 105 TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative); 106 107 */ 108 109 // 110 // Align the lines: 111 // - top, left 112 // - padding: top=20, bottom=0, left=20, right=0 113 // 114 TGLayoutHints *layline = new TGLayoutHints(kLHintsNormal, 20, 0, 20); 115 fList->Add(layline); 116 117 118 // 119 // Create a frame for line 3 and 4 to be able 120 // to align entry field and label in one line 121 // 122 TGHorizontalFrame *f = new TGHorizontalFrame(frame, 0, 0); 123 fNumEntry = new TGTextEntry(f, "****"); 124 fNumEntry->SetText("1"); 125 fList->Add(fNumEntry); 126 127 // --- doesn't work like expected --- fNumEntry1->SetAlignment(kTextRight); 128 // --- doesn't work like expected --- fNumEntry2->SetAlignment(kTextRight); 129 130 TGLabel *l = new TGLabel(f, "Trigger Condition Setup."); 131 l->SetTextJustify(kTextLeft); 132 fList->Add(l); 133 134 // 135 // Align the text of the label centered, left in the row 136 // with a left padding of 10 137 // 138 TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10); //, 10); //, 5, 5); 139 fList->Add(laylabel); 140 141 // 142 // Add one entry field and the corresponding label to each line 143 // 144 f->AddFrame(fNumEntry); 145 f->AddFrame(l, laylabel); 146 147 // 148 // Add line 3 and 4 to tab 149 // 150 frame->AddFrame(f, layline); 151 } 35 152 36 153 MMonteCarlo::MMonteCarlo(const TGWindow *main, const TGWindow *p, … … 38 155 : MBrowser(main, p, w, h) 39 156 { 40 TGTextButton *action = new TGTextButton(fTop1, "ACTION", M_BUTTON_ACTION); 41 fList->Add(action); 42 action->Associate(this); 43 44 TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5); 45 fList->Add(laybut); 46 47 fTop1->AddFrame(action, laybut); 157 AddButtons(); 158 AddSetupTab(); 48 159 49 160 MapSubwindows(); … … 58 169 59 170 // ====================================================================== 171 #include <TObjArray.h> 172 173 #include "MParList.h" 174 #include "MTaskList.h" 175 #include "MEvtLoop.h" 176 177 #include "MReadTree.h" 178 179 #include "MHMcRate.h" 180 #include "MHMcEnergy.h" 181 182 #include "MMcTriggerRateCalc.h" 183 #include "MMcThresholdCalc.h" 184 #include "MMcCollectionAreaCalc.h" 185 186 Int_t MMonteCarlo::GetDim() const 187 { 188 Int_t dim = atoi(fNumEntry->GetText()); 189 190 if (dim<0) 191 { 192 dim=0; 193 fNumEntry->SetText("0"); 194 } 195 196 if (fRadioButton1->GetState()) 197 dim = 0; 198 199 if (fRadioButton2->GetState()) 200 dim = -dim; 201 202 return dim; 203 } 204 205 void MMonteCarlo::CalculateCollectionArea() const 206 { 207 // 208 // first we have to create our empty lists 209 // 210 MParList plist; 211 212 MTaskList tlist; 213 plist.AddToList(&tlist); 214 215 // 216 // Setup out tasks: 217 // - First we have to read the events 218 // - Then we can fill the efficiency histograms 219 // 220 MReadTree reader("Events", fInputFile); 221 tlist.AddToList(&reader); 222 223 MMcCollectionAreaCalc effi; 224 tlist.AddToList(&effi); 225 226 // 227 // set up the loop for the processing 228 // 229 MEvtLoop magic; 230 magic.SetParList(&plist); 231 232 // 233 // Start to loop over all events 234 // 235 if (!magic.Eventloop()) 236 return; 237 238 // 239 // Now the histogram we wanted to get out of the data is 240 // filled and can be displayd 241 // 242 plist.FindObject("MHMcCollectionArea")->DrawClone(); 243 } 244 245 void MMonteCarlo::CalculateTriggerRate() const 246 { 247 // This macro has two input parameter: 248 // dim : = 0 -> root file with 1 trigger condition. 249 // > 0 -> number of trigger condition to be analised 250 // in multi conditon file. 251 // < 0 -> selects the -dim trigger condition. 252 // 253 // first we have to create our empty lists 254 // 255 const Int_t dim = GetDim(); 256 257 MParList plist; 258 MTaskList tlist; 259 260 // 261 // Setup the parameter list. 262 // - we do not need to create any other container. All of them 263 // are created automatically without loss - we don't have to 264 // access them- 265 // 266 // - we need to create MHMcRate only. The other containers 267 // are created automatically without loss - we don't have to 268 // access them- 269 // - MHMcRate must be created by us because we need the pointer 270 // to it and if it would get created automatically it would also be 271 // deleted automatically 272 // - Actually, depending on using a single trigger option MonteCarlo 273 // file or a multyple trigger option, a MHMcRate or an array of 274 // MHMcRate are needed. 275 // 276 plist.AddToList(&tlist); 277 278 // 279 // You don't have to add the MHMcRate container here by hand. 280 // But if you want to print or display these containers later on 281 // it is necessary (Rem: No printing or displaying is done in this 282 // macro yet) 283 // 284 TObjArray hists(MParList::CreateObjList("MHMcRate", dim)); 285 hists.SetOwner(); 286 287 // 288 // Check if the list really contains the right number of histograms 289 // 290 if (hists.GetEntriesFast() != dim) 291 return; 292 293 // 294 // Add the histograms to the paramater list. 295 // 296 plist.AddToList(&hists); 297 298 // 299 // Setup out tasks: 300 // - First we have to read the events 301 // - Then we can calculate rates, for what the number of 302 // triggered showers from a empty reflector file for the 303 // analised trigger conditions should be set (BgR[]) 304 // 305 MReadTree reader("Events", fInputFile); 306 tlist.AddToList(&reader); 307 308 Float_t BgR[10]={660,4,0,0,0,0,0,0,0,0}; 309 310 MMcTriggerRateCalc crate(dim, 14, BgR, 100000, 2.75, 10.91e-2); 311 tlist.AddToList(&crate); 312 313 // 314 // set up the loop for the processing 315 // 316 MEvtLoop magic; 317 magic.SetParList(&plist); 318 319 // 320 // Start to loop over all events 321 // 322 if (!magic.Eventloop()) 323 return; 324 325 TIter Next(&hists); 326 MHMcRate *rate=NULL; 327 while ((rate=(MHMcRate*)Next())) 328 rate->Print(); 329 } 330 331 void MMonteCarlo::CalculateThreshold() const 332 { 333 const Int_t dim = GetDim(); 334 335 // 336 // This macro fill the container MHMcEnergies using the task 337 // MMcThresholdCalc and shows the results. 338 // 339 MParList plist; 340 341 MTaskList tlist; 342 plist.AddToList(&tlist); 343 344 // 345 // Setup the parameter list 346 // - You need create the container MHMcEnergies. 347 // + You need to put the number of trigger conditions when 348 // you declarete the MHMcEnergies 349 // + If you don't put any dimension to MHMcEnergies it works 350 // taking only the trigger information from MMcTrig 351 // 352 353 // 354 // Create numtriggerconditions histograms of type MHMcEnergy 355 // and store the histograms in an TObjArray 356 // 357 TObjArray hists(MParList::CreateObjList("MHMcEnergy", dim)); 358 hists.SetOwner(); 359 360 // 361 // Check if the list really contains the right number of histograms 362 // 363 if (hists.GetEntriesFast() != dim) 364 return; 365 366 // 367 // Add the histograms to the paramater list. 368 // 369 plist.AddToList(&hists); 370 371 // 372 // Setup the task list 373 // - You need the read and the MMcThresholdCalc tasks 374 // - You have to fill the histograms for the Energy threshold 375 // + You need to put the number of trigger conditions when 376 // you declarete the MMcThresholdCalc 377 // + If you don't put any dimension to MMcThresholdCalc it works 378 // like one dimension MMcThresholdCalc 379 // 380 MReadTree read("Events", fInputFile); 381 MMcThresholdCalc calc(dim); 382 383 tlist.AddToList(&read); 384 tlist.AddToList(&calc); 385 386 MEvtLoop evtloop; 387 evtloop.SetParList(&plist); 388 389 // 390 // Begin the loop (if the loop wasn't succesfull 391 // don't try to draw the results 392 // 393 if (!evtloop.Eventloop()) 394 return; 395 396 // 397 // Now you can display the results 398 // 399 TIter Next(&hists); 400 MHMcRate *hist=NULL; 401 while ((hist=(MHMcRate*)Next())) 402 hist->DrawClone(); 403 } 404 405 // ====================================================================== 60 406 61 407 Bool_t MMonteCarlo::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) 62 { 63 if (GET_MSG(msg) == kC_COMMAND && 64 GET_SUBMSG(msg) == kCM_BUTTON && 65 parm1 == M_BUTTON_ACTION) 66 { 67 DisplInfo("Put Intelligence here!"); 68 return kTRUE; 69 } 408 { 409 if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON) 410 switch (parm1) 411 { 412 case M_BUTTON_COLAREA: 413 CalculateCollectionArea(); 414 return kTRUE; 415 416 case M_BUTTON_RATE: 417 CalculateTriggerRate(); 418 return kTRUE; 419 420 case M_BUTTON_THRESHOLD: 421 CalculateThreshold(); 422 return kTRUE; 423 } 70 424 71 425 return MBrowser::ProcessMessage(msg, parm1, parm2); -
trunk/MagicSoft/Mars/mmain/MMonteCarlo.h
r947 r954 10 10 #endif 11 11 12 class TGTextEntry; 13 class TGRadioButton; 14 12 15 class MMonteCarlo : public MBrowser 13 { 16 { 17 private: 18 TGRadioButton *fRadioButton1; 19 TGRadioButton *fRadioButton2; 20 TGRadioButton *fRadioButton3; 21 22 TGTextEntry *fNumEntry; 23 24 Int_t GetDim() const; 25 26 void CalculateCollectionArea() const; 27 void CalculateTriggerRate() const; 28 void CalculateThreshold() const; 29 30 void AddButtons(); 31 void AddSetupTab(); 32 14 33 public: 15 34 MMonteCarlo(const TGWindow *main=NULL, const TGWindow *p=NULL, -
trunk/MagicSoft/Mars/mmain/Makefile
r949 r954 23 23 # 24 24 INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp \ 25 -I../mgui -I../mhist 25 -I../mgui -I../mhist -I../mmontecarlo 26 26 27 27 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.