Changeset 5692
- Timestamp:
- 01/03/05 12:02:16 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Makefile
r5065 r5692 58 58 mimage \ 59 59 mmontecarlo \ 60 mhft \ 60 61 mmc \ 61 62 mraw \ -
trunk/MagicSoft/Mars/NEWS
r5691 r5692 20 20 MGeomCamMagic to a enhanced geometry MGeomCamMagicXT having only 21 21 small pixels 22 23 - added possibility to write data to memory (TTree) using MReadTree 24 25 - added possibility to read a TTree stored only in memory by MReadTree 22 26 23 27 -
trunk/MagicSoft/Mars/mbase/MLog.cc
r5551 r5692 18 18 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 116 116 using namespace std; 117 117 118 #undef DEBUG 119 //#define DEBUG 120 121 118 122 // root 3.02: 119 123 // check for TObjectWarning, TObject::Info, gErrorIgnoreLevel … … 216 220 DeallocateFile(); 217 221 222 #ifdef DEBUG 223 TIter Next(fPlugins); 224 TObject *o=0; 225 while ((o=Next())) 226 { 227 cout << "Delete: " << o->GetName() << std::flush; 228 cout << " [" << o->ClassName() << "]" << endl; 229 delete o; 230 } 231 232 cout << "Delete: fPlugins " << fPlugins << "..." << std::flush; 233 #endif 234 218 235 delete fPlugins; 236 #ifdef DEBUG 237 cout << "done." << endl; 238 #endif 239 219 240 #ifdef _REENTRANT 220 241 delete fMuxStream; -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r5557 r5692 18 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 109 109 { 110 110 #ifdef DEBUG 111 if (fName.IsNull() || fName==(TString)"MTime") 112 return; 113 111 114 *fLog << all << "Deleting " << GetDescriptor() << endl; 115 if (TestBit(kMustCleanup) && gROOT && gROOT->MustClean()) 116 { 117 *fLog << "Recursive Remove..." << flush; 118 if (TestBit(kCanDelete)) 119 *fLog << "kCanDelete..." << flush; 120 TIter Next(gROOT->GetListOfCleanups()); 121 TObject *o=0; 122 while ((o=Next())) 123 *fLog << dbg << o->GetName() << " [" << o->ClassName() << "]" << endl; 124 *fLog << dbg << "Removing..." << flush; 125 gROOT->GetListOfCleanups()->RecursiveRemove(this); 126 *fLog << "Removed." << endl; 127 } 112 128 #endif 113 129 } -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r5030 r5692 879 879 880 880 } 881 882 // -------------------------------------------------------------------------- 883 // 884 // Find an object with the same name in the list and replace it with 885 // the new one. If the kIsOwner flag is set and the object was not 886 // created automatically, the object is deleted. 887 // 888 Bool_t MTaskList::Replace(MTask *task) 889 { 890 // 891 // check if the object (you want to add) exists 892 // 893 if (!task) 894 return kFALSE; 895 896 if (task==this) 897 { 898 *fLog << warn << "WARNING - You cannot add a tasklist to itself. This" << endl; 899 *fLog << " would create infinite recursions...ignored." << endl; 900 return kFALSE; 901 902 } 903 904 MTask *obj = (MTask*)FindObject(task->GetName()); 905 if (!obj) 906 { 907 *fLog << warn << "No object with the same name '"; 908 *fLog << task->GetName() << "' in list... adding." << endl; 909 return AddToList(task); 910 } 911 912 if (task==obj) 913 return kTRUE; 914 915 *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << obj->GetStreamId() << "... " << flush; 916 task->SetStreamId(obj->GetStreamId()); 917 task->SetBit(kMustCleanup); 918 fTasks->AddAfter((TObject*)obj, task); 919 *fLog << "Done." << endl; 920 921 RemoveFromList(obj); 922 923 if (TestBit(kIsOwner)) 924 delete obj; 925 926 //*fLog << inf << "MTask '" << task->GetName() << "' found and replaced..." << endl; 927 928 return kTRUE; 929 } -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r4828 r5692 49 49 void SetSerialNumber(Byte_t num); 50 50 51 Bool_t Replace(MTask *obj); 51 52 Bool_t RemoveFromList(MTask *task); 52 53 -
trunk/MagicSoft/Mars/mdata/MDataArray.cc
r5100 r5692 18 18 ! Author(s): Thomas Bretz 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 86 86 // -------------------------------------------------------------------------- 87 87 // 88 // Try to find a MData which has the same rule (GetRule()). 89 // Be carefull: This may already fail if the rule is A*B and you are 90 // searching for B*A - FIXME: A more intelligent comaparton (based on 91 // IsEqual()) should be developed. 92 // 93 // Returns the index in the array, -1 if rule was not found. 94 // 95 Int_t MDataArray::FindRule(const char *rule) const 96 { 97 const MDataChain data(rule); 98 if (!data.IsValid()) 99 return -1; 100 101 const TString r(data.GetRule()); 102 103 TIter Next(&fList); 104 const MData *d = NULL; 105 while ((d=(MData*)Next())) 106 if (d->GetRule()==r) 107 return fList.IndexOf(d); 108 109 return -1; 110 } 111 112 // -------------------------------------------------------------------------- 113 // 88 114 // Return the i-th entry 89 115 // … … 131 157 Int_t n=0; 132 158 133 TIter Next(&fList); 134 MData *data = NULL; 135 while ((data=(MData*)Next())) 136 { 137 *fLog << all << " " << fName << "[" << setw(3) << n++ << "] = " << flush; 159 const Int_t w = 1+(Int_t)TMath::Log10(fList.GetEntries()); 160 161 TIter Next(&fList); 162 MData *data = NULL; 163 while ((data=(MData*)Next())) 164 { 165 *fLog << all << " " << fName << "[" << setw(w) << n++ << "] = " << flush; 138 166 data->Print(); 139 167 *fLog << endl; -
trunk/MagicSoft/Mars/mdata/MDataArray.h
r3572 r5692 32 32 void AddEntry(MData *data); 33 33 34 Int_t FindRule(const char *rule) const; 35 34 36 MData &operator[](Int_t i) const; 35 37 Double_t operator()(Int_t i) const; -
trunk/MagicSoft/Mars/mdata/MDataChain.cc
r3788 r5692 18 18 ! Author(s): Thomas Bretz 04/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 211 211 return; 212 212 213 *fLog << inf << " Trying to resolverule... " << flush;213 *fLog << inf << "Parsing rule... " << flush; 214 214 if (!(fMember=ParseString(rule, 1))) 215 215 { -
trunk/MagicSoft/Mars/mfbase/MF.cc
r5300 r5692 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 01/2002 <mailto:tbretz@ uni-sw.gwdg.de>19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 218 ! Author(s): Thomas Bretz 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 122 122 fTitle = title ? title : gsDefTitle.Data(); 123 123 124 *fLog << inf << " Trying to resolvefilter rule... " << flush;124 *fLog << inf << "Parsing filter rule... " << flush; 125 125 if (!(fF=ParseString(text, 1))) 126 126 { -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r5160 r5692 18 18 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 24 24 25 25 ///////////////////////////////////////////////////////////////////////////// 26 // // 27 // MReadTree // 28 // // 29 // This tasks opens all branches in a specified tree and creates the // 30 // corresponding parameter containers if not already existing in the // 31 // parameter list. // 32 // // 33 // The Process function reads one events from the tree. To go through the // 34 // events of one tree make sure that the event number is increased from // 35 // outside. It makes also possible to go back by decreasing the number. // 36 // // 37 // If you don't want to start reading the first event you have to call // 38 // MReadTree::SetEventNum after instantiating your MReadTree-object. // 39 // // 40 // To make reading much faster (up to a factor of 10 to 20) you can // 41 // ensure that only the data you are really processing is enabled by // 42 // calling MReadTree::UseLeaf. // 43 // // 44 // If the chain switches from one file to another file all // 45 // TObject::Notify() functions are called of TObject objects which were // 46 // added to the Notifier list view MReadTree::AddNotify. If MReadTree // 47 // is the owner (viw MReadTree::SetOwner) all this objects are deleted // 48 // by the destructor of MReadTree // 49 // // 26 // 27 // MReadTree 28 // 29 // This tasks opens all branches in a specified tree and creates the 30 // corresponding parameter containers if not already existing in the 31 // parameter list. 32 // 33 // The Process function reads one events from the tree. To go through the 34 // events of one tree make sure that the event number is increased from 35 // outside. It makes also possible to go back by decreasing the number. 36 // 37 // If you don't want to start reading the first event you have to call 38 // MReadTree::SetEventNum after instantiating your MReadTree-object. 39 // 40 // To make reading much faster (up to a factor of 10 to 20) you can 41 // ensure that only the data you are really processing is enabled by 42 // calling MReadTree::UseLeaf. 43 // 44 // If the chain switches from one file to another file all 45 // TObject::Notify() functions are called of TObject objects which were 46 // added to the Notifier list view MReadTree::AddNotify. If MReadTree 47 // is the owner (viw MReadTree::SetOwner) all this objects are deleted 48 // by the destructor of MReadTree 49 // 50 // 51 // ToDo: 52 // ----- 53 // - Auto Scheme and Branch choosing doesn't work for memory trees 54 // 50 55 ///////////////////////////////////////////////////////////////////////////// 51 56 #include "MReadTree.h" … … 73 78 // -------------------------------------------------------------------------- 74 79 // 75 // Default constructor. Don't use it. 76 // 77 MReadTree::MReadTree() 80 // Default constructor. Use this constructor (ONLY) if you want to 81 // access a memory tree (a TTree not stored in a file) created by 82 // MWriteRootFile or manually. 83 // 84 MReadTree::MReadTree(TTree *tree) 78 85 : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE) 79 86 { … … 81 88 fTitle = "Task to loop over all events in one single tree"; 82 89 83 fVetoList = NULL; 84 fNotify = NULL; 90 fVetoList = new TList; 91 fVetoList->SetOwner(); 92 93 fNotify = new TList; 85 94 86 95 fChain = NULL; 96 97 fTree = tree; 98 SetBit(kChainWasChanged); 99 100 if (fTree) 101 fAutoEnable = kFALSE; 102 /* 103 if (!fTree) 104 return; 105 106 TIter Next(fTree->GetListOfBranches()); 107 TBranch *b=0; 108 while ((b=(TBranch*)Next())) 109 b->ResetAddress(); 110 */ 87 111 } 88 112 … … 114 138 // 115 139 fChain = new MChain(tname); 140 fTree = fChain; 116 141 117 142 // root 3.02: … … 122 147 if (fname) 123 148 AddFile(fname); 124 // if (fChain->Add(fname)>0)125 // SetBit(kChainWasChanged);126 149 } 127 150 … … 137 160 // creates a memory leak! 138 161 // 139 TIter Next(fChain->GetStatus()); 140 141 TChainElement *element = NULL; 142 while ((element=(TChainElement*)Next())) 143 if (element->GetBaddress()) 144 delete (MParContainer**)element->GetBaddress(); 145 146 // 147 // Delete the chain and the veto list 148 // 162 if (fChain) // FIXME: MEMORY LEAK for fTree!=0 163 { 164 TIter Next(fChain->GetStatus()); 165 166 TChainElement *element = NULL; 167 while ((element=(TChainElement*)Next())) 168 if (element->GetBaddress()) 169 delete (MParContainer**)element->GetBaddress(); 170 171 // 172 // Delete the chain and the veto list 173 // 149 174 #if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00) 150 if (fChain->GetFile())151 delete fChain->GetFile();175 if (fChain->GetFile()) 176 delete fChain->GetFile(); 152 177 #endif 153 delete fChain; 178 delete fChain; 179 } 180 181 /* This is AND MUST be done in PostProcess. See there for more details 182 else 183 { 184 TIter Next(fTree->GetListOfBranches()); 185 186 TBranch *element = NULL; 187 while ((element=(TBranch*)Next())) 188 if (element->GetAddress()) 189 delete (MParContainer**)element->GetAddress(); 190 } 191 */ 154 192 155 193 delete fNotify; … … 179 217 Bool_t MReadTree::CheckBranchSize() 180 218 { 181 TArrayI entries(fChain->GetStatus()->GetSize()); 219 //if (!fChain) // >FIXME: fTree!=0 220 // return kTRUE; 221 222 TArrayI entries(fChain ? fChain->GetStatus()->GetSize() : fTree->GetListOfBranches()->GetSize()); 182 223 Int_t num=0; 183 224 184 225 // Loop over all branches which have a corresponding container 185 TIter Next(fChain->GetStatus()); 186 187 TChainElement *element = NULL; 188 while ((element=(TChainElement*)Next())) 189 { 190 // Get branch name and find pointer to corresponding branch 191 const TString name = element->GetName(); 192 const TBranch *b = fChain->FindBranch(name); 193 194 // Skip element without corresponding branches (like "*") 195 if (!b) 196 continue; 197 198 entries[num++] = (Int_t)b->GetEntries(); 226 /* 227 if (fChain) 228 { 229 TIter Next(fChain->GetStatus()); 230 231 TChainElement *element = NULL; 232 while ((element=(TChainElement*)Next())) 233 { 234 // Get branch name and find pointer to corresponding branch 235 const TString name = element->GetName(); 236 const TBranch *b = fChain->FindBranch(name); 237 238 // Skip element without corresponding branches (like "*") 239 if (!b) 240 continue; 241 242 entries[num++] = (Int_t)b->GetEntries(); 243 } 244 } 245 else */ 246 { 247 TIter Next(fTree->GetListOfBranches()); 248 249 TBranch *element = NULL; 250 while ((element=(TBranch*)Next())) 251 entries[num++] = (Int_t)element->GetEntries(); 199 252 } 200 253 … … 209 262 *fLog << " Due to several circumstances (such at a bug in MReadTree or wrong" << endl; 210 263 *fLog << " usage of the file UPDATE mode) you may have produced a file in which" << endl; 211 *fLog << " at least two branches in the same tree (" << f Chain->GetName() << ") have different" << endl;264 *fLog << " at least two branches in the same tree (" << fTree->GetName() << ") have different" << endl; 212 265 *fLog << " number of entries. Sorry, but this file (" << GetFileName() << ")" << endl; 213 266 *fLog << " is unusable." << endl; … … 278 331 Int_t MReadTree::AddFile(const char *fname, Int_t entries) 279 332 { 333 if (!fChain) 334 { 335 *fLog << err << "MReadTree::AddFile - ERROR: You cannot add a file, because MReadTree" << endl; 336 *fLog << " handles a memory based tree or its default" << endl; 337 *fLog << " constructor was called." << endl; 338 return 0; 339 } 340 280 341 #if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01) 281 342 // … … 353 414 Int_t MReadTree::AddFiles(const MReadTree &read) 354 415 { 416 if (!fChain) 417 { 418 *fLog << err << "MReadTree::AddFiles - ERROR: You cannot add a file, because MReadTree" << endl; 419 *fLog << " handles a memory based tree or its default" << endl; 420 *fLog << " constructor was called." << endl; 421 return 0; 422 } 423 355 424 const Int_t rc = fChain->Add(read.fChain); 356 425 … … 376 445 void MReadTree::SortFiles() 377 446 { 378 fChain->GetListOfFiles()->Sort(); 447 if (fChain) 448 fChain->GetListOfFiles()->Sort(); 379 449 } 380 450 … … 392 462 393 463 *fLog << inf << GetDescriptor() << ": Branch choosing enabled (only enabled branches are read)." << endl; 394 f Chain->SetBranchStatus("*", kFALSE);464 fTree->SetBranchStatus("*", kFALSE); // *CHANGED-fChain-to-fTree* 395 465 fBranchChoosing = kTRUE; 396 466 } … … 405 475 void MReadTree::EnableBranch(const char *name) 406 476 { 477 if (!fChain) 478 { 479 *fLog << warn << "MReadTree::EnableBranch - WARNING: EnableBranch doesn't work with memory based trees... ignored." << endl; 480 return; 481 } 482 407 483 if (fChain->GetListOfFiles()->GetEntries()==0) 408 484 { … … 424 500 void MReadTree::SetBranchStatus(const char *name, Bool_t status) 425 501 { 426 f Chain->SetBranchStatus(name, status);502 fTree->SetBranchStatus(name, status); // *CHANGED-fChain-to-fTree* 427 503 428 504 *fLog << inf << (status ? "Enabled" : "Disabled"); … … 449 525 bn.Remove(bn.Length()-1); 450 526 451 if (f Chain->GetBranch(bn))527 if (fTree->GetBranch(bn)) // *CHANGED-fChain-to-fTree* 452 528 SetBranchStatus(name, status); 453 529 … … 461 537 return; 462 538 463 if (f Chain->GetBranch(dot+1))539 if (fTree->GetBranch(dot+1)) // *CHANGED-fChain-to-fTree* 464 540 SetBranchStatus(dot+1, status); 465 541 } … … 575 651 if (TestBit(kChainWasChanged)) 576 652 { 577 *fLog << inf << "Scanning chain " << fChain->GetName() << "... " << flush; 578 fNumEntries = (UInt_t)fChain->GetEntries(); 653 // *CHANGED-fChain-to-fTree* 654 *fLog << inf << "Scanning chain " << fTree->GetName() << "... " << flush; 655 fNumEntries = (UInt_t)fTree->GetEntries(); 579 656 *fLog << fNumEntries << " events found." << endl; 580 657 ResetBit(kChainWasChanged); … … 624 701 // tasks are not preprocessed. 625 702 // 626 f Chain->SetNotify(NULL);703 fTree->SetNotify(NULL); //*CHANGED-fChain-to-fTree* 627 704 628 705 // … … 633 710 // it crashes. ResetTree makes sure, that the tree number is -1 634 711 // 635 fChain->ResetTree(); 712 if (fChain) // *CHANGED-fChain-to-fTree* 713 fChain->ResetTree(); 636 714 // Maybe this would be enough, but the above might be safer... 637 715 //if (fChain->GetTreeNumber()==0) … … 641 719 // check for files and for the tree! 642 720 // 643 if ( !fChain->GetFile())721 if (fChain && !fChain->GetFile()) // *CHANGED-fChain-to-fTree* 644 722 { 645 723 *fLog << err << GetDescriptor() << ": No file or no tree with name " << fChain->GetName() << " in file." << endl; … … 665 743 // create the Iterator to loop over all branches 666 744 // 667 TIter Next(f Chain->GetListOfBranches());745 TIter Next(fTree->GetListOfBranches()); // *CHANGED-fChain-to-fTree* 668 746 TBranch *branch=NULL; 669 747 … … 728 806 // If we created one already, delete it. 729 807 // 730 TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname); 731 if (element) 732 delete (MParContainer**)element->GetBaddress(); 808 // *CHANGED-fChain-to-fTree* 809 if (fChain) 810 { 811 TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname); 812 if (element) 813 delete (MParContainer**)element->GetBaddress(); 814 } 815 /* This can't be done here for memory trees - see 816 PostProcess for more details. 817 else 818 { 819 TBranch *branch = (TBranch*)fTree->GetBranch(bname); 820 if (branch) 821 { 822 *fLog << bname << " " << (void*)branch->GetAddress() << " " << pcont << endl; 823 delete (MParContainer**)branch->GetAddress(); 824 } 825 } 826 */ 733 827 734 828 // … … 736 830 // the actual branch should be stored - enable branch. 737 831 // 738 f Chain->SetBranchAddress(bname, pcont);832 fTree->SetBranchAddress(bname, pcont); // *CHANGED-fChain-to-fTree* 739 833 740 834 *fLog << inf << "Master branch address '" << bname << "' ["; … … 762 856 // PreProcess-function. 763 857 // 764 fChain->ResetTree(); 765 fChain->SetNotify(this); 766 767 return GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE; 858 if (fChain) 859 fChain->ResetTree(); // *CHANGED-fChain-to-fTree* 860 861 fTree->SetNotify(this); // *CHANGED-fChain-to-fTree* 862 863 const Int_t rc = GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE; 864 if (rc!=kTRUE || fChain) 865 return rc; 866 867 return Notify(); 768 868 } 769 869 … … 775 875 void MReadTree::SetReadyToSave(Bool_t flag) 776 876 { 877 if (!fChain) 878 return; 879 777 880 TIter Next(fChain->GetStatus()); 778 881 … … 870 973 } 871 974 872 const Bool_t rc = f Chain->GetEntry(fNumEntry++) != 0;975 const Bool_t rc = fTree->GetEntry(fNumEntry++) != 0; // *CHANGED-fChain-to-fTree* 873 976 874 977 if (fTaskList) 875 fTaskList->SetStreamId(f Chain->GetName());978 fTaskList->SetStreamId(fTree->GetName()); // *CHANGED-fChain-to-fTree* 876 979 877 980 if (rc) … … 887 990 Int_t MReadTree::PostProcess() 888 991 { 992 // In the case of a memory tree I don't know how we can 993 // make a decision in PreProcess between a self allocated 994 // memory address or a pending address set long before. 995 // So we delete the stuff in PostProcess and not the destructor 996 // (which might seg faullt if PreProcess has never been called) 997 if (!fChain) 998 { 999 TIter Next(fTree->GetListOfBranches()); 1000 TBranch *b=0; 1001 while ((b=(TBranch*)Next())) 1002 { 1003 if (b->GetAddress()) 1004 { 1005 delete b->GetAddress(); 1006 b->ResetAddress(); 1007 } 1008 } 1009 } 1010 889 1011 return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE; 890 1012 } … … 896 1018 Bool_t MReadTree::GetEvent() 897 1019 { 898 Bool_t rc = f Chain->GetEntry(fNumEntry) != 0;1020 Bool_t rc = fTree->GetEntry(fNumEntry) != 0; // *CHANGED-fChain-to-fTree* 899 1021 900 1022 if (rc) … … 981 1103 TString MReadTree::GetFileName() const 982 1104 { 983 const TFile *file = fChain ->GetFile();1105 const TFile *file = fChain ? fChain->GetFile() : fTree->GetCurrentFile(); 984 1106 985 1107 if (!file) … … 997 1119 Int_t MReadTree::GetFileIndex() const 998 1120 { 999 return fChain ->GetTreeNumber();1121 return fChain ? fChain->GetTreeNumber() : 0; 1000 1122 /* 1001 1123 const TString filename = fChain->GetFile()->GetName(); -
trunk/MagicSoft/Mars/mfileio/MReadTree.h
r5160 r5692 8 8 class MChain; 9 9 class TBranch; 10 class TTree; 10 11 class MTaskList; 11 12 … … 15 16 16 17 private: 17 MChain *fChain; // Pointer to tree 18 MChain *fChain; // Pointer to tree==fTree (only if fTree inherits from MChain) 19 TTree *fTree; // Pointer to tree 18 20 19 21 UInt_t fNumEntry; // Number of actual entry in chain … … 23 25 Bool_t fAutoEnable; // Flag for auto enabeling scheme 24 26 25 TList *fVetoList; // List of Branches which are not allowed to get enabled26 TList *fNotify; // List of TObjects to notify when switching files27 TList *fVetoList; //-> List of Branches which are not allowed to get enabled 28 TList *fNotify; //-> List of TObjects to notify when switching files 27 29 28 30 MTaskList *fTaskList; // Tasklist to set StreamId … … 47 49 48 50 public: 49 MReadTree( );51 MReadTree(TTree *tree=0); 50 52 MReadTree(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL); 51 53 ~MReadTree(); -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r4826 r5692 18 18 ! Author(s): Thomas Bretz, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2005 21 21 ! 22 22 ! … … 37 37 // ReInit()) For more details se the corresponding constructor. 38 38 // 39 // Memory based trees 40 // ------------------ 41 // It is possible to store the data into memory (TTrees) instead of 42 // writing the data into a file. To do this either call the default 43 // constructor or specify 'memory' as option in the constructor. 44 // 45 // Afterwards the tree can be found using gROOT->FindObject("treename") 46 // 47 // Currently(!) the tree is not deleted at all! Please make sure to 48 // delete it if it is not used anymore - otherwise you could wast a LOT 49 // of memory. Please consider that this behaviour might change in the 50 // future. 51 // 52 // Such trees are usefull if you want to use more basic root-tools 53 // like TMultiLayerPerceptron or TEventList. 54 // 55 // If you want to process such memory based Trees using Mars make sure, 56 // that you don't need data from the RunHeader tree because you can 57 // only use MReadTree but not MReadMarsFile with such a tree. 58 // 39 59 ///////////////////////////////////////////////////////////////////////////// 40 60 #include "MWriteRootFile.h" … … 72 92 73 93 // 74 // Believing the root user guide, TTree instance dare owned by the94 // Believing the root user guide, TTree instances are owned by the 75 95 // directory (file) in which they are. This means we don't have to 76 96 // care about their destruction. … … 87 107 { 88 108 Init(); 89 90 //91 // Set the Arrays the owner of its entries. This means, that the92 // destructor of the arrays will delete all its entries.93 //94 fBranches.SetOwner();95 109 } 96 110 … … 133 147 // 134 148 MWriteRootFile::MWriteRootFile(const char *fname, 135 const Option_t *opt ,149 const Option_t *option, 136 150 const char *ftitle, 137 151 const Int_t comp, 138 152 const char *name, 139 const char *title) 153 const char *title) : fOut(NULL) 140 154 { 141 155 Init(name, title); 156 157 TString opt(option); 158 opt.ToLower(); 159 160 // 161 // Check if we are writing to memory 162 // 163 if (opt.Contains("memory")) 164 { 165 fSplitRule = fname; 166 return; 167 } 142 168 143 169 // … … 172 198 Print(); 173 199 174 // 175 // If the file is still open (no error) write the keys. This is necessary 176 // for appearance of the all trees and branches. 177 // 178 if (IsFileOpen()) 179 fOut->Write(); 180 181 // 182 // Delete the file. This'll also close the file (if open) 183 // 184 delete fOut; 185 fOut = 0; 200 if (fOut) 201 { 202 // 203 // If the file is still open (no error) write the keys. This is necessary 204 // for appearance of the all trees and branches. 205 // 206 if (IsFileOpen()) 207 fOut->Write(); 208 209 // 210 // Delete the file. This'll also close the file (if open) 211 // 212 delete fOut; 213 fOut = 0; 214 } 186 215 187 216 // … … 257 286 void MWriteRootFile::AddContainer(const char *cname, const char *tname, Bool_t must) 258 287 { 288 if (!fOut && !tname) 289 tname = fSplitRule; 290 259 291 TIter Next(&fBranches); 260 292 TObject *o=0; … … 262 294 if (TString(o->GetName())==TString(tname) && TString(o->GetTitle())==TString(cname)) 263 295 { 296 *fLog << warn; 264 297 *fLog << "WARNING - Container '" << cname << "' in Tree '" << tname << "' already scheduled... ignored." << endl; 265 298 return; … … 290 323 Bool_t must) 291 324 { 325 if (!fOut && !tname) 326 tname = fSplitRule; 327 292 328 TIter Next(&fBranches); 293 329 TObject *o=0; … … 296 332 static_cast<MRootFileBranch*>(o)->GetContainer()==cont) 297 333 { 334 *fLog << warn; 298 335 *fLog << "WARNING - Container " << cont << " in Tree '" << tname << "' already scheduled... ignored." << endl; 299 336 return; … … 378 415 379 416 // 380 // Check if the tree is already existing (part of the file) 381 // 382 TTree *tree = (TTree*)fOut->Get(tname); 417 // Check if the tree is already existing (part of the file or memory) 418 // 419 TTree *tree = fOut ? (TTree*)fOut->Get(tname) : dynamic_cast<TTree*>(gROOT->FindObject(tname)); 420 if (!fOut && tree) 421 { 422 if (tree->GetCurrentFile()) 423 { 424 *fLog << err; 425 *fLog << "ERROR - You are trying to write data into a memory stored root tree," << endl; 426 *fLog << " because you either called the default constructor or have" << endl; 427 *fLog << " instantiated MWriteRootFile using the write option 'memory'." << endl; 428 *fLog << " This tree '" << tname << "' is already existing in" << endl; 429 *fLog << " memory (gROOT->FindObject) and is already belonging to a" << endl; 430 *fLog << " file (" << tree->GetCurrentFile()->GetName() << ")." << endl; 431 *fLog << " This can - for example - happen if you are reading from a" << endl; 432 *fLog << " tree with the same name. The easiest solution in this case" << endl; 433 *fLog << " is to change the name of the tree you want to write to." << endl; 434 *fLog << endl; 435 return kFALSE; 436 } 437 *fLog << inf << "Tree '" << tname << "' found already in Memory... using." << endl; 438 } 439 383 440 if (!tree) 384 441 { … … 389 446 // 390 447 TDirectory *save = gDirectory; 391 fOut->cd(); 392 393 tree = new TTree(tname, ttitle); 448 if (fOut) 449 fOut->cd(); 450 else 451 gROOT->cd(); 452 453 tree = new TTree(tname, ttitle, fOut ? 99 : 1); 394 454 fTrees.AddLast(tree); 395 455 … … 567 627 568 628 // 629 // If we are writing into memory we don't split into seperate files 630 // 631 if (!fOut) 632 return kTRUE; 633 634 // 569 635 // For more information see TTree:ChangeFile() 570 636 // … … 774 840 // -------------------------------------------------------------------------- 775 841 // 776 // return open state of the root file. 842 // return open state of the root file. If the file is 'memory' kTRUE is 843 // returned. 777 844 // 778 845 Bool_t MWriteRootFile::IsFileOpen() const 779 846 { 847 if (!fOut) 848 return kTRUE; 849 780 850 const char *n = fOut->GetName(); 781 851 return n==0 || *n==0 ? kTRUE : fOut->IsOpen(); … … 784 854 // -------------------------------------------------------------------------- 785 855 // 786 // return name of the root-file 856 // return name of the root-file. If the file is "memory" "<memory>" is 857 // returned. 787 858 // 788 859 const char *MWriteRootFile::GetFileName() const 789 860 { 861 if (!fOut) 862 return "<memory>"; 863 790 864 const char *n = fOut->GetName(); 791 865 return n==0 || *n==0 ? "<dummy>" : n; … … 794 868 // -------------------------------------------------------------------------- 795 869 // 796 // cd into file. See TFile::cd() 870 // cd into file. See TFile::cd(). If the file is "memory" kTRUE is returned. 797 871 // 798 872 Bool_t MWriteRootFile::cd(const char *path) 799 873 { 800 return fOut ->cd(path);874 return fOut ? fOut->cd(path) : kTRUE; 801 875 } 802 876 … … 809 883 void MWriteRootFile::StreamPrimitive(ofstream &out) const 810 884 { 811 out << " MWriteRootFile " << GetUniqueName() << "(\""; 812 out << fOut->GetName() << "\", \""; 813 out << fOut->GetOption() << "\", \""; 814 out << fOut->GetTitle() << "\", "; 815 out << fOut->GetCompressionLevel(); 816 817 if (fName!=gsDefName || fTitle!=gsDefTitle) 818 { 819 out << ", \"" << fName << "\""; 820 if (fTitle!=gsDefTitle) 821 out << ", \"" << fTitle << "\""; 822 } 823 out << ");" << endl; 824 885 out << " MWriteRootFile " << GetUniqueName(); 886 if (fOut) 887 { 888 out << "(\""; 889 out << fOut->GetName() << "\", \""; 890 out << fOut->GetOption() << "\", \""; 891 out << fOut->GetTitle() << "\", "; 892 out << fOut->GetCompressionLevel(); 893 out << ")"; 894 } 895 out << ";" << endl; 896 897 if (fName!=gsDefName) 898 out << " " << GetUniqueName() << ".SetName(\"" << fName << "\");" << endl; 899 if (fTitle!=gsDefTitle) 900 out << " " << GetUniqueName() << ".SetTitle(\"" << fTitle << "\");" << endl; 825 901 826 902 MRootFileBranch *entry; -
trunk/MagicSoft/Mars/mhbase/MBinning.h
r5143 r5692 38 38 MBinning(const char *name=NULL, const char *title=NULL); 39 39 MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name=0, const char *opt="", const char *title=NULL); 40 MBinning(const MBinning &bins) { SetEdges(bins); } 41 42 void Copy(TObject &named) const 43 { 44 MBinning &bins = (MBinning&)named; 45 bins.SetEdges(*this); 46 } 40 47 41 48 void SetEdges(const TArrayD &arr) 42 49 { 43 50 fEdges = arr; 44 fType = kIsUserArray;51 fType = kIsUserArray; 45 52 } 46 53 47 54 void SetEdges(const TAxis &axe); 48 void SetEdges(const MBinning &bins) { SetEdges( fEdges); }55 void SetEdges(const MBinning &bins) { SetEdges(bins.fEdges); fType = bins.fType; } 49 56 void SetEdges(const TH1 &h, const Char_t axis='x'); 50 57 void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up); -
trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
r5100 r5692 160 160 } 161 161 162 const Int_t idx = fData->FindRule(rule); 163 if (idx>=0) 164 return idx; 165 162 166 fData->AddEntry(rule); 163 167 return fData->GetNumEntries()-1; -
trunk/MagicSoft/Mars/mhbase/MHMatrix.h
r4646 r5692 115 115 void ReduceRows(UInt_t num); 116 116 117 ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events117 ClassDef(MHMatrix, 1) // Multidimensional Matrix (TMatrix) to store events 118 118 }; 119 119 -
trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
r5114 r5692 41 41 #include <TF1.h> 42 42 #include <TH1.h> 43 #include <TH3.h> 44 45 #include <TRandom.h> 43 46 44 47 #include <TLatex.h> … … 51 54 52 55 using namespace std; 56 57 void MAlphaFitter::Clear(Option_t *o) 58 { 59 fSignificance=0; 60 fEventsExcess=0; 61 fEventsSignal=0; 62 fEventsBackground=0; 63 64 fChiSqSignal=0; 65 fChiSqBg=0; 66 fIntegralMax=0; 67 68 fCoefficients.Reset(); 69 } 53 70 54 71 // -------------------------------------------------------------------------- … … 84 101 Bool_t MAlphaFitter::Fit(TH1D &h, Bool_t paint) 85 102 { 103 Clear(); 104 if (h.GetEntries()==0) 105 return kFALSE; 106 86 107 Double_t sigmax=fSigMax; 87 108 Double_t bgmin =fBgMin; … … 175 196 //fSignificance = MMath::SignificanceLiMaSigned(s, b); 176 197 177 178 198 const Int_t bin = h.GetXaxis()->FindFixBin(fSigInt*0.999); 179 199 … … 190 210 } 191 211 212 Bool_t MAlphaFitter::Fit(TH1D &hon, TH1D &hof, Bool_t paint) 213 { 214 /* 215 Clear(); 216 if (hon.GetEntries()==0) 217 return kFALSE; 218 */ 219 220 TH1D h(hon); 221 h.Add(&hof, -1); 222 223 MAlphaFitter fit(*this); 224 fit.SetPolynomOrder(1); 225 226 if (!fit.Fit(h, paint)) 227 return kFALSE; 228 229 fChiSqSignal = fit.GetChiSqSignal(); 230 fChiSqBg = fit.GetChiSqBg(); 231 fCoefficients = fit.GetCoefficients(); 232 233 const Int_t bin = hon.GetXaxis()->FindFixBin(fSigInt*0.999); 234 235 fIntegralMax = hon.GetBinLowEdge(bin+1); 236 fEventsBackground = hof.Integral(0, bin); 237 fEventsSignal = hon.Integral(0, bin); 238 fEventsExcess = fEventsSignal-fEventsBackground; 239 fSignificance = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground); 240 241 if (fEventsExcess<0) 242 fEventsExcess=0; 243 /* 244 TF1 func("", "gaus(0)+pol0(3)", 0., 90.); 245 246 const Double_t A = fEventsSignal/bin; 247 const Double_t dA = TMath::Abs(A); 248 func.SetParLimits(0, -dA*4, dA*4); 249 func.SetParLimits(2, 0, 90); 250 func.SetParLimits(3, -dA, dA); 251 252 func.SetParameter(0, A); 253 func.FixParameter(1, 0); 254 func.SetParameter(2, fSigMax*0.75); 255 func.SetParameter(3, 0); 256 257 // options : N do not store the function, do not draw 258 // I use integral of function in bin rather than value at bin center 259 // R use the range specified in the function range 260 // Q quiet mode 261 TH1D h(hon); 262 h.Add(&hof, -1); 263 h.Fit(&func, "NQI", "", 0, 90); 264 265 fChiSqSignal = func.GetChisquare()/func.GetNDF(); 266 267 const Int_t bin1 = h.GetXaxis()->FindFixBin(func.GetParameter(2)*2); 268 269 fChiSqBg = 0; 270 for (int i=bin1; i<=h.GetNbinsX(); i++) 271 { 272 const Float_t val = h.GetBinContent(i); 273 fChiSqBg = val*val; 274 } 275 if (fChiSqBg>0) 276 fChiSqBg /= h.GetNbinsX()+1-bin1; 277 278 fCoefficients.Set(func.GetNpar(), func.GetParameters()); 279 280 // ------------------------------------ 281 if (paint) 282 { 283 func.SetLineColor(kBlue); 284 func.SetLineWidth(2); 285 func.Paint("same"); 286 } 287 // ------------------------------------ 288 */ 289 return kTRUE; 290 } 291 192 292 void MAlphaFitter::PaintResult(Float_t x, Float_t y, Float_t size) const 193 293 { 194 TLatex text(x, y, Form("\\sigma_{Li/Ma}=%.1f \\omega=%.1f\\circ E=%d (\\alpha<%.1f\\circ) (\\chi_{b}^{2} =%.1f \\chi_{s}^{2}=%.1f)",294 TLatex text(x, y, Form("\\sigma_{Li/Ma}=%.1f \\omega=%.1f\\circ E=%d (\\alpha<%.1f\\circ) (\\chi_{b}^{2}/ndf=%.1f \\chi_{s}^{2}/ndf=%.1f c_{0}=%.1f)", 195 295 fSignificance, GetGausSigma(), 196 296 (int)fEventsExcess, fIntegralMax, 197 fChiSqBg, fChiSqSignal ));297 fChiSqBg, fChiSqSignal, fCoefficients[3])); 198 298 199 299 text.SetBit(TLatex::kTextNDC); … … 210 310 f.fBgMin = fBgMin; 211 311 f.fBgMax = fBgMax; 312 f.fScaleMin = fScaleMin; 313 f.fScaleMax = fScaleMax; 212 314 f.fPolynomOrder = fPolynomOrder; 315 f.fScaleMode = fScaleMode; 316 f.fScaleUser = fScaleUser; 213 317 f.fCoefficients.Set(fCoefficients.GetSize()); 214 318 f.fCoefficients.Reset(); … … 227 331 *fLog << " ...signal to " << fSigMax << " (integrate into bin at " << fSigInt << ")" << endl; 228 332 *fLog << " ...polynom order " << fPolynomOrder << endl; 229 } 333 *fLog << " ...scale mode: "; 334 switch (fScaleMode) 335 { 336 case kNone: *fLog << "none."; break; 337 case kEntries: *fLog << "entries."; break; 338 case kIntegral: *fLog << "integral."; break; 339 case kOffRegion: *fLog << "off region."; break; 340 case kLeastSquare: *fLog << "least square."; break; 341 case kUserScale: *fLog << "user def (" << fScaleUser << ")"; break; 342 } 343 *fLog << endl; 344 345 if (TString(o).Contains("result")) 346 { 347 *fLog << "Result:" << endl; 348 *fLog << " - Significance " << fSignificance << endl; 349 *fLog << " - Excess Events " << fEventsExcess << endl; 350 *fLog << " - Signal Events " << fEventsSignal << endl; 351 *fLog << " - Background Events " << fEventsBackground << endl; 352 *fLog << " - Chi^2/ndf (Signal) " << fChiSqSignal << endl; 353 *fLog << " - Chi^2/ndf (Background) " << fChiSqBg << endl; 354 *fLog << " - Signal integrated " << fIntegralMax << "°" << endl; 355 } 356 } 357 358 Bool_t MAlphaFitter::FitEnergy(const TH3D &hon, UInt_t bin, Bool_t paint) 359 { 360 const TString name(Form("TempAlphaEnergy%06d", gRandom->Integer(1000000))); 361 TH1D *h = hon.ProjectionZ(name, -1, 9999, bin, bin, "E"); 362 h->SetDirectory(0); 363 364 const Bool_t rc = Fit(*h, paint); 365 delete h; 366 return rc; 367 } 368 369 Bool_t MAlphaFitter::FitTheta(const TH3D &hon, UInt_t bin, Bool_t paint) 370 { 371 const TString name(Form("TempAlphaTheta%06d", gRandom->Integer(1000000))); 372 TH1D *h = hon.ProjectionZ(name, bin, bin, -1, 9999, "E"); 373 h->SetDirectory(0); 374 375 const Bool_t rc = Fit(*h, paint); 376 delete h; 377 return rc; 378 } 379 380 Bool_t MAlphaFitter::FitAlpha(const TH3D &hon, Bool_t paint) 381 { 382 const TString name(Form("TempAlpha%06d", gRandom->Integer(1000000))); 383 TH1D *h = hon.ProjectionZ(name, -1, 9999, -1, 9999, "E"); 384 h->SetDirectory(0); 385 386 const Bool_t rc = Fit(*h, paint); 387 delete h; 388 return rc; 389 } 390 391 Bool_t MAlphaFitter::FitEnergy(const TH3D &hon, const TH3D &hof, UInt_t bin, Bool_t paint) 392 { 393 const TString name1(Form("TempAlpha%06d_on", gRandom->Integer(1000000))); 394 const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000))); 395 TH1D *h1 = hon.ProjectionZ(name1, -1, 9999, bin, bin, "E"); 396 TH1D *h0 = hof.ProjectionZ(name0, -1, 9999, bin, bin, "E"); 397 h1->SetDirectory(0); 398 h0->SetDirectory(0); 399 400 Scale(*h0, *h1); 401 402 const Bool_t rc = Fit(*h1, *h0, paint); 403 404 delete h0; 405 delete h1; 406 407 return rc; 408 } 409 410 Bool_t MAlphaFitter::FitTheta(const TH3D &hon, const TH3D &hof, UInt_t bin, Bool_t paint) 411 { 412 const TString name1(Form("TempAlpha%06d_on", gRandom->Integer(1000000))); 413 const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000))); 414 415 TH1D *h1 = hon.ProjectionZ(name1, bin, bin, -1, 9999, "E"); 416 TH1D *h0 = hof.ProjectionZ(name0, bin, bin, -1, 9999, "E"); 417 h1->SetDirectory(0); 418 h0->SetDirectory(0); 419 420 Scale(*h0, *h1); 421 422 const Bool_t rc = Fit(*h1, *h0, paint); 423 424 delete h0; 425 delete h1; 426 427 return rc; 428 } 429 430 Bool_t MAlphaFitter::FitAlpha(const TH3D &hon, const TH3D &hof, Bool_t paint) 431 { 432 const TString name1(Form("TempAlpha%06d_on", gRandom->Integer(1000000))); 433 const TString name0(Form("TempAlpha%06d_off", gRandom->Integer(1000000))); 434 435 TH1D *h1 = hon.ProjectionZ(name1, -1, 9999, -1, 9999, "E"); 436 TH1D *h0 = hof.ProjectionZ(name0, -1, 9999, -1, 9999, "E"); 437 h1->SetDirectory(0); 438 h0->SetDirectory(0); 439 440 Scale(*h0, *h1); 441 442 const Bool_t rc = Fit(*h1, *h0, paint); 443 444 delete h0; 445 delete h1; 446 447 return rc; 448 } 449 450 void MAlphaFitter::Scale(TH1D &of, const TH1D &on) const 451 { 452 Float_t scaleon = 1; 453 Float_t scaleof = 1; 454 switch (fScaleMode) 455 { 456 case kNone: 457 return; 458 459 case kEntries: 460 scaleon = on.GetEntries(); 461 scaleof = of.GetEntries(); 462 break; 463 464 case kIntegral: 465 scaleon = on.Integral(); 466 scaleof = of.Integral(); 467 break; 468 469 case kOffRegion: 470 { 471 const Int_t min = on.GetXaxis()->FindFixBin(fScaleMin); 472 const Int_t max = on.GetXaxis()->FindFixBin(fScaleMax); 473 scaleon = on.Integral(min, max); 474 scaleof = of.Integral(min, max); 475 } 476 break; 477 478 case kUserScale: 479 scaleon = fScaleUser; 480 break; 481 482 default: 483 return; 484 } 485 486 if (scaleof!=0) 487 of.Scale(scaleon/scaleof); 488 } -
trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
r5114 r5692 15 15 16 16 class TH1D; 17 class TH3D; 17 18 18 19 class MAlphaFitter : public MParContainer 19 20 { 21 public: 22 enum ScaleMode_t { 23 kNone, 24 kEntries, 25 kIntegral, 26 kOffRegion, 27 kLeastSquare, 28 kUserScale 29 }; 20 30 private: 21 31 Float_t fSigInt; … … 23 33 Float_t fBgMin; 24 34 Float_t fBgMax; 35 Float_t fScaleMin; 36 Float_t fScaleMax; 25 37 Int_t fPolynomOrder; 26 38 … … 38 50 TF1 *fFunc; 39 51 52 ScaleMode_t fScaleMode; 53 Double_t fScaleUser; 54 40 55 public: 41 56 // Implementing the function yourself is only about 5% faster 42 MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15), fSigMax(75), fBgMin(45), fBgMax(85), f PolynomOrder(2), fCoefficients(3+fPolynomOrder+1), fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90))57 MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15), fSigMax(75), fBgMin(45), fBgMax(85), fScaleMin(40), fScaleMax(80), fPolynomOrder(2), fCoefficients(3+fPolynomOrder+1), fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90)), fScaleMode(kEntries), fScaleUser(1) 43 58 { 44 59 fName = name ? name : "MAlphaFitter"; … … 58 73 } 59 74 60 void Print(Option_t *o=0) const; 75 void Clear(Option_t *o=""); 76 void Print(Option_t *o="") const; 61 77 void Copy(TObject &o) const; 62 78 /* … … 67 83 */ 68 84 85 void SetScaleUser(Float_t scale) { fScaleUser = scale; fScaleMode=kUserScale; } 86 void SetScaleMode(ScaleMode_t mode) { fScaleMode = mode; } 69 87 void SetSignalIntegralMax(Float_t s) { fSigInt = s; } 70 88 void SetSignalFitMax(Float_t s) { fSigMax = s; } 71 89 void SetBackgroundFitMin(Float_t s) { fBgMin = s; } 72 90 void SetBackgroundFitMax(Float_t s) { fBgMax = s; } 91 void SetScaleMin(Float_t s) { fScaleMin = s; } 92 void SetScaleMax(Float_t s) { fScaleMax = s; } 73 93 void SetPolynomOrder(Int_t s) { fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s)); 74 94 gROOT->GetListOfFunctions()->Remove(fFunc); … … 93 113 94 114 Bool_t Fit(TH1D &h, Bool_t paint=kFALSE); 115 Bool_t Fit(TH1D &on, TH1D &off, Bool_t paint=kFALSE); 116 Bool_t Fit(TH1D &on, TH1D *off, Bool_t paint=kFALSE) 117 { 118 return off ? Fit(on, *off, paint) : Fit(on, paint); 119 } 120 121 Bool_t FitAlpha(const TH3D &h, Bool_t paint=kFALSE); 122 Bool_t FitEnergy(const TH3D &h, UInt_t bin, Bool_t paint=kFALSE); 123 Bool_t FitTheta(const TH3D &h, UInt_t bin, Bool_t paint=kFALSE); 124 125 Bool_t FitAlpha(const TH3D &on, const TH3D &off, Bool_t paint=kFALSE); 126 Bool_t FitEnergy(const TH3D &on, const TH3D &off, UInt_t bin, Bool_t paint=kFALSE); 127 Bool_t FitTheta(const TH3D &on, const TH3D &off, UInt_t bin, Bool_t paint=kFALSE); 128 129 Bool_t FitAlpha(const TH3D &on, const TH3D *off, Bool_t paint=kFALSE) 130 { 131 return off ? FitAlpha(on, *off, paint) : FitAlpha(on, paint); 132 } 133 Bool_t FitEnergy(const TH3D &on, const TH3D *off, UInt_t bin, Bool_t paint=kFALSE) 134 { 135 return off ? FitEnergy(on, *off, bin, paint) : FitEnergy(on, bin, paint); 136 } 137 Bool_t FitTheta(const TH3D &on, const TH3D *off, UInt_t bin, Bool_t paint=kFALSE) 138 { 139 return off ? FitTheta(on, *off, bin, paint) : FitTheta(on, bin, paint); 140 } 141 142 void Scale(TH1D &off, const TH1D &on) const; 95 143 96 144 ClassDef(MAlphaFitter, 1) -
trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
r5300 r5692 75 75 // 76 76 MHAlpha::MHAlpha(const char *name, const char *title) 77 : fResult(0), /*fExcess(0),*/ fEnergy(0), fPointPos(0), fTimeEffOn(0), 78 fTime(0), fNameProjAlpha(Form("Alpha_%p", this)), fMatrix(0) 77 : fOffData(0), fResult(0), /*fExcess(0),*/ fEnergy(0), fHillas(0), 78 fPointPos(0), fTimeEffOn(0), fTime(0), 79 fSkipHistTime(kFALSE), fSkipHistTheta(kFALSE), fSkipHistEnergy(kFALSE), 80 //fEnergyMin(-1), fEnergyMax(-1), fSizeMin(-1), fSizeMax(-1), 81 fMatrix(0) 79 82 { 80 83 // … … 100 103 101 104 102 fHEnergy.SetName("Energy");103 fHEnergy.SetTitle(" N_{exc} vs. E_{est} ");104 fHEnergy.SetXTitle("E_{est} [GeV]");105 //fHEnergy.SetName("Energy"); 106 //fHEnergy.SetTitle(" N_{exc} vs. E_{est} "); 107 //fHEnergy.SetXTitle("E_{est} [GeV]"); 105 108 fHEnergy.SetYTitle("N_{exc}"); 106 109 fHEnergy.SetDirectory(NULL); … … 184 187 for (int i=1; i<=n; i++) 185 188 { 186 TH1D *h = fHAlpha.ProjectionZ("Alpha_EE", -1, 9999, i, i, i==1?"E":""); 187 if (fit.Fit(*h)) 189 if (fit.FitEnergy(fHAlpha, fOffData, i)) 188 190 { 189 191 fHEnergy.SetBinContent(i, fit.GetEventsExcess()); 190 192 fHEnergy.SetBinError(i, fit.GetEventsExcess()*0.2); 191 193 } 192 delete h;193 194 } 194 195 } … … 203 204 for (int i=1; i<=n; i++) 204 205 { 205 TH1D *h = fHAlpha.ProjectionZ("Alpha_EE", i, i, -1, 9999, i==1?"E":""); 206 if (fit.Fit(*h)) 206 if (fit.FitTheta(fHAlpha, fOffData, i)) 207 207 { 208 208 fHTheta.SetBinContent(i, fit.GetEventsExcess()); 209 209 fHTheta.SetBinError(i, fit.GetEventsExcess()*0.2); 210 210 } 211 delete h;212 211 } 213 212 } … … 219 218 fHTheta.Reset(); 220 219 220 if (fName!=(TString)"MHAlphaOff") 221 { 222 MHAlpha *hoff = (MHAlpha*)pl->FindObject("MHAlphaOff"); 223 if (!hoff) 224 *fLog << inf << "No MHAlphaOff [MHAlpha] found... using current data only!" << endl; 225 else 226 { 227 *fLog << inf << "MHAlphaOff [MHAlpha] found... using on-off mode!" << endl; 228 SetOffData(*hoff); 229 } 230 } 231 232 fHillas = 0; 233 /* 234 if (fSizeMin>=0 || fSizeMax>=0) 235 { 236 fHillas = (MHillas*)pl->FindObject("MHillas"); 237 if (!fHillas) 238 { 239 *fLog << warn << "Size cut set, but MHillas not found... abort." << endl; 240 return kFALSE; 241 } 242 } 243 */ 221 244 fEnergy = (MEnergyEst*)pl->FindObject("MEnergyEst"); 222 245 if (!fEnergy) 223 *fLog << warn << "MEnergyEst not found... ignored." << endl; 246 { /* 247 if (fEnergyMin>=0 || fEnergyMax>=0) 248 { 249 *fLog << warn << "Energy cut set, but MEnergyEst not found... abort." << endl; 250 return kFALSE; 251 } */ 252 253 *fLog << warn << "MEnergyEst not found... " << flush; 254 255 if (!fHillas) 256 fHillas = (MHillas*)pl->FindObject("MHillas"); 257 if (fHillas) 258 *fLog << "using SIZE instead!" << endl; 259 else 260 *fLog << "ignored." << endl; 261 262 fHEnergy.SetName("Size"); 263 fHEnergy.SetTitle(" N_{exc} vs. Size "); 264 fHEnergy.SetXTitle("Size [\\gamma]"); 265 } 266 else 267 { 268 fHEnergy.SetName("Energy"); 269 fHEnergy.SetTitle(" N_{exc} vs. E_{est} "); 270 fHEnergy.SetXTitle("E_{est} [GeV]"); 271 } 224 272 225 273 fPointPos = (MPointingPos*)pl->FindObject("MPointingPos"); … … 230 278 if (!fTimeEffOn) 231 279 *fLog << warn << "MTimeEffectiveOnTime [MTime] not found... ignored." << endl; 280 else 281 *fTimeEffOn = MTime(); // FIXME: How to do it different? 232 282 233 283 fTime = (MTime*)pl->FindObject("MTime"); … … 246 296 247 297 MBinning binst, binse, binsa; 248 binst.SetEdges(fHAlpha, 'x'); 249 binse.SetEdges(fHAlpha, 'y'); 250 binsa.SetEdges(fHAlpha, 'z'); 251 252 MBinning *bins = (MBinning*)pl->FindObject("BinningTheta", "MBinning"); 253 if (fPointPos && bins) 254 binst.SetEdges(*bins); 255 if (!fPointPos) 256 binst.SetEdges(1, 0, 90); 257 258 bins = (MBinning*)pl->FindObject("BinningEnergyEst", "MBinning"); 259 if (fEnergy && bins) 260 binse.SetEdges(*bins); 261 if (!fEnergy) 262 binse.SetEdges(1, 10, 100000); 263 264 bins = (MBinning*)pl->FindObject("BinningAlpha", "MBinning"); 265 if (bins) 266 binsa.SetEdges(*bins); 298 binst.SetEdges(fOffData ? *fOffData : fHAlpha, 'x'); 299 binse.SetEdges(fOffData ? *fOffData : fHAlpha, 'y'); 300 binsa.SetEdges(fOffData ? *fOffData : fHAlpha, 'z'); 301 302 if (!fOffData) 303 { 304 MBinning *bins = (MBinning*)pl->FindObject("BinningTheta", "MBinning"); 305 if (fPointPos && bins) 306 binst.SetEdges(*bins); 307 if (!fPointPos) 308 binst.SetEdges(1, 0, 60); 309 310 bins = (MBinning*)pl->FindObject("BinningEnergyEst", "MBinning"); 311 if ((fEnergy||fHillas) && bins) 312 binse.SetEdges(*bins); 313 if (!fEnergy && !fHillas) 314 binse.SetEdges(1, 10, 100000); 315 316 bins = (MBinning*)pl->FindObject("BinningAlpha", "MBinning"); 317 if (bins) 318 binsa.SetEdges(*bins); 319 } 267 320 268 321 binse.Apply(fHEnergy); … … 321 374 } 322 375 376 // Check new 'last time' 377 MTime *time = final ? fTime : fTimeEffOn; 378 379 if (time->GetAxisTime()<=fHTime.GetXaxis()->GetXmax()) 380 { 381 *fLog << warn << "WARNING - New time-stamp " << *time << " lower" << endl; 382 *fLog << "than upper edge of histogram... skipped." << endl; 383 *fLog << "This should not happen. Maybe you started you eventloop with" << endl; 384 *fLog << "an already initialized time stamp MTimeEffectiveOnTime?" << endl; 385 rebin++; 386 return; 387 } 388 389 // Fit time histogram 323 390 MAlphaFitter fit(fFit); 324 if (!fit.Fit(fHAlphaTime)) 391 392 TH1D *h = fOffData ? fOffData->ProjectionZ("ProjTimeTemp", -1, 9999, -1, 9999, "E") : 0; 393 const Bool_t rc = fit.Fit(fHAlphaTime, h); 394 if (h) 395 delete h; 396 397 if (!rc) 325 398 return; 326 399 … … 334 407 // Prepare Histogram 335 408 // 336 337 MTime *time = final ? fTime : fTimeEffOn;338 409 if (final) 339 410 time->Plus1ns(); … … 363 434 { 364 435 Double_t alpha, energy, theta; 436 Double_t size=-1; 365 437 366 438 if (fMatrix) 367 439 { 368 440 alpha = (*fMatrix)[fMap[0]]; 369 energy = 1000; 370 theta = 0; 441 energy = fMap[1]<0 ? -1 : (*fMatrix)[fMap[1]]; 442 size = fMap[2]<0 ? -1 : (*fMatrix)[fMap[2]]; 443 //<0 ? 1000 : (*fMatrix)[fMap[1]]; 444 theta = 0; 445 446 if (energy<0) 447 energy=size; 448 if (size<0) 449 size=energy; 450 451 if (energy<0 && size<0) 452 energy = size = 1000; 371 453 } 372 454 else … … 380 462 381 463 alpha = hil->GetAlpha(); 382 energy = fEnergy ? fEnergy->GetEnergy() : 1000; 464 if (fHillas) 465 size = fHillas->GetSize(); 466 energy = fEnergy ? fEnergy->GetEnergy() : (fHillas?fHillas->GetSize():1000); 383 467 theta = fPointPos ? fPointPos->GetZd() : 0; 384 468 } 385 469 470 // enhance histogram if necessary 386 471 UpdateAlphaTime(); 387 472 473 // Fill histograms 388 474 fHAlpha.Fill(theta, energy, TMath::Abs(alpha), w); 389 fHAlphaTime.Fill(TMath::Abs(alpha), w); 475 476 // Check cuts 477 /* 478 if ( (fEnergyMin>=0 && energy<fEnergyMin) || 479 (fEnergyMax>=0 && energy>fEnergyMax) || 480 (fSizeMin>=0 && size <fSizeMin) || 481 (fSizeMax>=0 && size >fSizeMin) ) 482 return kTRUE; 483 */ 484 485 if (!fSkipHistTime) 486 fHAlphaTime.Fill(TMath::Abs(alpha), w); 390 487 391 488 return kTRUE; … … 441 538 442 539 padsave->cd(1); 443 fHAlpha.ProjectionZ(fNameProjAlpha); 540 TH1D *hon = fHAlpha.ProjectionZ("ProjAlpha"); 541 if (fOffData) 542 { 543 TH1D *hoff = fOffData->ProjectionZ("ProjAlphaOff"); 544 fFit.Scale(*hoff, *hon); 545 546 hon->SetMaximum(); 547 hon->SetMaximum(TMath::Max(hon->GetMaximum(), hoff->GetMaximum())*1.05); 548 549 if ((h0=(TH1D*)gPad->FindObject("ProjAlphaOnOff"))) 550 { 551 h0->Reset(); 552 h0->Add(hoff, hon, -1); 553 const Float_t min = h0->GetMinimum()*1.05; 554 hon->SetMinimum(min<0 ? min : 0); 555 } 556 } 444 557 FitEnergyBins(); 445 558 FitThetaBins(); … … 447 560 448 561 if (o==(TString)"alpha") 449 if ((h0 = (TH1D*)gPad->FindObject( fNameProjAlpha)))562 if ((h0 = (TH1D*)gPad->FindObject("ProjAlpha"))) 450 563 { 451 564 // Do not store the 'final' result in fFit 452 565 MAlphaFitter fit(fFit); 453 fit.Fit(*h0, kTRUE); 566 TH1D *hoff = (TH1D*)gPad->FindObject("ProjAlphaOff"); 567 fit.Fit(*h0, hoff, kTRUE); 454 568 fit.PaintResult(); 455 569 } … … 459 573 460 574 if (o==(TString)"theta") 575 { 576 TH1 *h = (TH1*)gPad->FindObject("Alpha_x"); 577 if (h) 578 { 579 TH1D *h2 = (TH1D*)fHAlpha.Project3D("dum_x"); 580 h2->SetDirectory(0); 581 h2->Scale(fHTheta.Integral()/h2->Integral()); 582 h->Reset(); 583 h->Add(h2); 584 delete h2; 585 } 461 586 PaintText(fHTheta.Integral(), 0); 587 } 462 588 463 589 if (o==(TString)"energy") 464 590 { 591 TH1 *h = (TH1*)gPad->FindObject("Alpha_y"); 592 if (h) 593 { 594 TH1D *h2 = (TH1D*)fHAlpha.Project3D("dum_y"); 595 h2->SetDirectory(0); 596 h2->Scale(fHEnergy.Integral()/h2->Integral()); 597 h->Reset(); 598 h->Add(h2); 599 delete h2; 600 } 601 465 602 if (fHEnergy.GetMaximum()>1) 466 603 { … … 469 606 } 470 607 FitEnergySpec(kTRUE); 471 472 608 } 473 609 … … 494 630 pad->cd(1); 495 631 gPad->SetBorderMode(0); 496 h = fHAlpha.ProjectionZ(fNameProjAlpha, -1, 9999, -1, 9999, "E"); 632 633 h = fHAlpha.ProjectionZ("ProjAlpha", -1, 9999, -1, 9999, "E"); 497 634 h->SetBit(TH1::kNoTitle); 635 h->SetStats(kTRUE); 498 636 h->SetXTitle("\\alpha [\\circ]"); 499 637 h->SetYTitle("Counts"); … … 501 639 h->SetMarkerStyle(kFullDotMedium); 502 640 h->SetBit(kCanDelete); 503 h->Draw(); 641 h->Draw(""); 642 643 if (fOffData) 644 { 645 h->SetMarkerColor(kGreen); 646 647 h = fOffData->ProjectionZ("ProjAlphaOff", -1, 9999, -1, 9999, "E"); 648 h->SetBit(TH1::kNoTitle|TH1::kNoStats); 649 h->SetXTitle("\\alpha [\\circ]"); 650 h->SetYTitle("Counts"); 651 h->SetDirectory(NULL); 652 h->SetMarkerStyle(kFullDotMedium); 653 h->SetBit(kCanDelete); 654 h->SetMarkerColor(kRed); 655 h->Draw("same"); 656 657 h = (TH1D*)h->Clone("ProjAlphaOnOff"); 658 h->SetBit(TH1::kNoTitle); 659 h->SetXTitle("\\alpha [\\circ]"); 660 h->SetYTitle("Counts"); 661 h->SetDirectory(NULL); 662 h->SetMarkerStyle(kFullDotMedium); 663 h->SetBit(kCanDelete); 664 h->SetMarkerColor(kBlue); 665 h->Draw("same"); 666 667 TLine lin; 668 lin.SetLineStyle(kDashed); 669 lin.DrawLine(0, 0, 90, 0); 670 } 671 504 672 // After the Alpha-projection has been drawn. Fit the histogram 505 673 // and paint the result into this pad … … 511 679 gPad->SetBorderMode(0); 512 680 fHEnergy.Draw(); 681 513 682 AppendPad("energy"); 683 684 h = (TH1D*)fHAlpha.Project3D("y"); 685 h->SetBit(TH1::kNoTitle|TH1::kNoStats); 686 h->SetXTitle("E [GeV]"); 687 h->SetYTitle("Counts"); 688 h->SetDirectory(NULL); 689 h->SetMarkerStyle(kFullDotMedium); 690 h->SetBit(kCanDelete); 691 h->SetMarkerColor(kCyan); 692 h->SetLineColor(kCyan); 693 h->Draw("Psame"); 514 694 } 515 695 else … … 531 711 gPad->SetBorderMode(0); 532 712 fHTheta.Draw(); 713 533 714 AppendPad("theta"); 715 716 h = (TH1D*)fHAlpha.Project3D("x"); 717 h->SetBit(TH1::kNoTitle|TH1::kNoStats); 718 h->SetXTitle("\\theta [\\circ]"); 719 h->SetYTitle("Counts"); 720 h->SetDirectory(NULL); 721 h->SetMarkerStyle(kFullDotMedium); 722 h->SetBit(kCanDelete); 723 h->SetMarkerColor(kCyan); 724 h->SetLineColor(kCyan); 725 h->Draw("Psame"); 534 726 } 535 727 else 536 728 delete pad->GetPad(4); 537 538 } 729 } 730 731 void MHAlpha::DrawAll() 732 { 733 // FIXME: Do in Paint if special option given! 734 TCanvas *c = new TCanvas; 735 Int_t n = fHAlpha.GetNbinsY(); 736 Int_t nc = (Int_t)(TMath::Sqrt((Float_t)n-1)+1); 737 c->Divide(nc, nc, 0, 0); 738 739 // Do not store the 'final' result in fFit 740 MAlphaFitter fit(fFit); 741 742 for (int i=1; i<=fHAlpha.GetNbinsY(); i++) 743 { 744 c->cd(i); 745 746 TH1D *hon = fHAlpha.ProjectionZ("ProjAlpha", -1, 9999, i, i, "E"); 747 hon->SetBit(TH1::kNoTitle); 748 hon->SetStats(kTRUE); 749 hon->SetXTitle("\\alpha [\\circ]"); 750 hon->SetYTitle("Counts"); 751 hon->SetDirectory(NULL); 752 hon->SetMarkerStyle(kFullDotMedium); 753 hon->SetBit(kCanDelete); 754 hon->Draw(""); 755 756 TH1D *hof = 0; 757 758 if (fOffData) 759 { 760 hon->SetMarkerColor(kGreen); 761 762 hof = fOffData->ProjectionZ("ProjAlphaOff", -1, 9999, i, i, "E"); 763 hof->SetBit(TH1::kNoTitle|TH1::kNoStats); 764 hof->SetXTitle("\\alpha [\\circ]"); 765 hof->SetYTitle("Counts"); 766 hof->SetDirectory(NULL); 767 hof->SetMarkerStyle(kFullDotMedium); 768 hof->SetBit(kCanDelete); 769 hof->SetMarkerColor(kRed); 770 hof->Draw("same"); 771 772 fit.Scale(*hof, *hon); 773 774 hon->SetMaximum(); 775 hon->SetMaximum(TMath::Max(hon->GetMaximum(), hof->GetMaximum())*1.05); 776 777 TH1D *diff = new TH1D(*hon); 778 diff->Add(hof, -1); 779 diff->SetBit(TH1::kNoTitle); 780 diff->SetXTitle("\\alpha [\\circ]"); 781 diff->SetYTitle("Counts"); 782 diff->SetDirectory(NULL); 783 diff->SetMarkerStyle(kFullDotMedium); 784 diff->SetBit(kCanDelete); 785 diff->SetMarkerColor(kBlue); 786 diff->Draw("same"); 787 788 TLine lin; 789 lin.SetLineStyle(kDashed); 790 lin.DrawLine(0, 0, 90, 0); 791 792 const Float_t min = diff->GetMinimum()*1.05; 793 hon->SetMinimum(min<0 ? min : 0); 794 } 795 796 if (hof ? fit.Fit(*hon, *hof) : fit.Fit(*hon)) 797 *fLog << dbg << "Bin " << i << ": sigma=" << fit.GetSignificance() << " omega=" << fit.GetGausSigma() << " events=" << fit.GetEventsExcess() << endl; 798 /* 799 if (fit.FitEnergy(fHAlpha, fOffData, i, kTRUE)) 800 { 801 fHEnergy.SetBinContent(i, fit.GetEventsExcess()); 802 fHEnergy.SetBinError(i, fit.GetEventsExcess()*0.2); 803 }*/ 804 } 805 806 } 807 539 808 540 809 Bool_t MHAlpha::Finalize() 541 810 { 542 // Store the final result in fFit 543 TH1D *h = fHAlpha.ProjectionZ("AlphaExc_px", -1, 9999, -1, 9999, "E"); 544 h->SetDirectory(0); 545 fFit.Print(); 546 Bool_t rc = fFit.Fit(*h); 547 delete h; 548 if (!rc) 811 //TH1D *h = fHAlpha.ProjectionZ("AlphaExc_px", -1, 9999, -1, 9999, "E"); 812 //h->SetDirectory(0); 813 //Bool_t rc = fFit.Fit(*h); 814 //delete h; 815 if (!fFit.FitAlpha(fHAlpha, fOffData)) 549 816 { 550 817 *fLog << warn << "Histogram empty." << endl; … … 552 819 } 553 820 821 // Store the final result in fFit 822 fFit.Print("result"); 823 554 824 if (fResult) 555 825 fResult->SetVal(fFit.GetSignificance()); 556 826 557 FitEnergyBins(); 558 FitThetaBins(); 559 UpdateAlphaTime(kTRUE); 560 MH::RemoveFirstBin(fHTime); 827 if (!fSkipHistEnergy) 828 { 829 *fLog << inf << "Processing energy bins..." << endl; 830 FitEnergyBins(); 831 } 832 if (!fSkipHistTheta) 833 { 834 *fLog << inf << "Processing theta bins..." << endl; 835 FitThetaBins(); 836 } 837 if (!fSkipHistTime) 838 { 839 *fLog << inf << "Processing time bins..." << endl; 840 UpdateAlphaTime(kTRUE); 841 MH::RemoveFirstBin(fHTime); 842 } 561 843 562 844 return kTRUE; … … 572 854 // will take the values from the matrix instead of the containers. 573 855 // 574 void MHAlpha::InitMapping(MHMatrix *mat) 856 // It takes fSkipHist* into account! 857 // 858 void MHAlpha::InitMapping(MHMatrix *mat, Int_t type) 575 859 { 576 860 if (fMatrix) … … 580 864 581 865 fMap[0] = fMatrix->AddColumn("MHillasSrc.fAlpha"); 582 //fMap[1] = fMatrix->AddColumn("MEnergyEst.fEnergy"); 866 fMap[1] = -1; 867 fMap[2] = -1; 868 fMap[3] = -1; 869 fMap[4] = -1; 870 871 if (!fSkipHistEnergy) 872 if (type==0) 873 { 874 fMap[1] = fMatrix->AddColumn("MEnergyEst.fEnergy"); 875 fMap[2] = -1; 876 } 877 else 878 { 879 fMap[1] = -1; 880 fMap[2] = fMatrix->AddColumn("MHillas.fSize"); 881 } 882 883 if (!fSkipHistTheta) 884 fMap[3] = fMatrix->AddColumn("MPointingPos.fZd"); 885 886 // if (!fSkipHistTime) 887 // fMap[4] = fMatrix->AddColumn("MTime.GetAxisTime"); 583 888 } 584 889 -
trunk/MagicSoft/Mars/mhflux/MHAlpha.h
r5100 r5692 21 21 class MParameterD; 22 22 class MEnergyEst; 23 class MHillas; 23 24 class MHMatrix; 24 25 class MPointingPos; … … 84 85 { 85 86 private: 87 const TH3D *fOffData; 88 86 89 MAlphaFitter fFit; // SEEMS THAT STREAMER HAS SOME PROBLEMS... MAYBE IF FUNC IS USED AT THE SAME TIME FOR FITS (PAINT) 87 90 … … 94 97 MParameterD *fResult; //! 95 98 MEnergyEst *fEnergy; //! 99 MHillas *fHillas; //! 96 100 MPointingPos *fPointPos; //! 97 101 … … 100 104 MTime fLastTime; //! Last fTimeEffOn 101 105 102 const TString fNameProjAlpha; //! This should make sure, that gROOT doen't confuse the projection with something else 106 //Float_t fEnergyMin; 107 //Float_t fEnergyMax; 108 //Float_t fSizeMin; 109 //Float_t fSizeMax; 110 111 Bool_t fSkipHistTime; 112 Bool_t fSkipHistTheta; 113 Bool_t fSkipHistEnergy; 114 115 //const TString fNameProjAlpha; //! This should make sure, that gROOT doen't confuse the projection with something else 103 116 104 117 MHMatrix *fMatrix; //! 105 Int_t fMap[ 2]; //!118 Int_t fMap[5]; //! 106 119 107 120 void FitEnergySpec(Bool_t paint=kFALSE); … … 115 128 void PaintText(Double_t val, Double_t error) const; 116 129 130 Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; } 131 117 132 public: 118 133 MHAlpha(const char *name=NULL, const char *title=NULL); … … 125 140 const MAlphaFitter &GetAlphaFitter() const { return fFit; } 126 141 142 void SetOffData(const MHAlpha &h) 143 { 144 fOffData = &h.fHAlpha; 145 } 146 /* 147 void SetSizeCuts(Float_t min, Float_t max) { fSizeMin=min; fSizeMax=max; } 148 void SetSizeMin(Float_t min) { fSizeMin=min; } 149 void SetSizeMax(Float_t max) { fSizeMax=max; } 150 void SetEnergyCuts(Float_t min, Float_t max) { fEnergyMin=min; fEnergyMax=max; } 151 void SetEnergyMin(Float_t min) { fEnergyMin=min; } 152 void SetEnergyMax(Float_t max) { fEnergyMax=max; } 153 154 void SetCuts(const MHAlpha &h) { 155 fSizeMin = h.fSizeMin; fEnergyMin = h.fEnergyMin; 156 fSizeMax = h.fSizeMax; fEnergyMax = h.fEnergyMax; 157 } 158 */ 159 160 void SkipHistTime(Bool_t b=kTRUE) { fSkipHistTime=b; } 161 void SkipHistTheta(Bool_t b=kTRUE) { fSkipHistTheta=b; } 162 void SkipHistEnergy(Bool_t b=kTRUE) { fSkipHistEnergy=b; } 163 127 164 void Paint(Option_t *opt=""); 128 165 void Draw(Option_t *option=""); 129 166 130 void InitMapping(MHMatrix *mat); 167 void DrawAll(); //*MENU* 168 169 void InitMapping(MHMatrix *mat, Int_t type=0); 131 170 void StopMapping(); 132 171 -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r5316 r5692 145 145 d += fNight.GetStringFmt("%Y_%m_%d"); 146 146 } 147 else 148 gSystem->ExpandPathName(d); 147 149 148 150 for (int i=0; i<arr.GetSize(); i++) … … 174 176 { 175 177 fName = fname; 176 fTitle = Form("Sequence contained in file %s", fName.Data()); 177 178 TEnv env(fname); 178 179 const char *expname = gSystem->ExpandPathName(fname); 180 181 fTitle = Form("Sequence contained in file %s", expname); 182 183 TEnv env(expname); 184 delete [] expname; 179 185 180 186 TString str;
Note:
See TracChangeset
for help on using the changeset viewer.