Changeset 2744 for trunk/MagicSoft/Mars/mtools
- Timestamp:
- 12/22/03 20:35:39 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mtools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtools/MChisqEval.cc
r2208 r2744 32 32 33 33 #include "MDataChain.h" 34 #include "MParameters.h" // MParameterD 35 36 #include "MParList.h" 34 37 35 38 ClassImp(MChisqEval); … … 120 123 return kFALSE; 121 124 125 fResult = (MParameterD*)plist->FindCreateObj("MParameterD", "MFitResult"); 126 if (!fResult) 127 return kFALSE; 128 122 129 return kTRUE; 123 130 } … … 138 145 { 139 146 fChisq /= GetNumExecutions(); 147 148 fResult->SetVal(fChisq); 149 140 150 return kTRUE; 141 151 } -
trunk/MagicSoft/Mars/mtools/MChisqEval.h
r2208 r2744 7 7 8 8 class MData; 9 class MParameterD; 9 10 10 11 class MChisqEval : public MTask … … 14 15 static const TString gsDefTitle; 15 16 16 Double_t fChisq; //! Evaluated chi square 17 Double_t fChisq; //! Evaluated chi square 18 MParameterD *fResult; //! Storage for result 17 19 18 20 MData *fData0; // Data Member one (monte carlo data or chisq function) -
trunk/MagicSoft/Mars/mtools/MTFillMatrix.cc
r2711 r2744 35 35 // reference histogram. 36 36 // 37 // If no reference histogram is available the number of events are 38 // randomly choosen from the sample with a probability which fits 39 // the total destination number of events. 37 40 // 38 41 // Here is an example of how to choose 1000 events somehow distributed in … … 49 52 // read.DisableAutoScheme(); // make sure everything is read 50 53 // 51 // MTFillMatrix fill( ref);// setup MTFillMatrix54 // MTFillMatrix fill(&ref); // setup MTFillMatrix 52 55 // fill.SetNumDestEvents1(1000); // setup number of events to select 53 56 // fill.SetDestMatrix1(&matrix1); // setup destination matrix … … 91 94 #include "MContinue.h" 92 95 #include "MFilterList.h" 93 #include "MF RandomSplit.h"96 #include "MFEventSelector.h" 94 97 #include "MFEventSelector2.h" 95 98 … … 151 154 // at MFEventSelector2 which is used to select the events. 152 155 // 153 // FIXME: Make a copy of ref. 154 // 155 MTFillMatrix::MTFillMatrix(const MH3 &ref) 156 : fReference(ref), fReader(0), fDestMatrix1(0), 157 fDestMatrix2(0), fNumDestEvents1(0), fNumDestEvents2(0), 158 fWriteFile1(0), fWriteFile2(0) 156 // If no MH3 *ref is given the events are randomly selected from the 157 // total sample - this may result in samples which don't have exactly 158 // the predefined size, but it is much faster. 159 // 160 MTFillMatrix::MTFillMatrix(const MH3 *ref) 161 : fReference(0), fReader(0), fDestMatrix1(0), fDestMatrix2(0), 162 fNumDestEvents1(0), fNumDestEvents2(0), fWriteFile1(0), fWriteFile2(0) 159 163 { 160 164 fName = "MFillMatrix"; 161 165 fTitle = "Tool to fill MHMatrix from file"; 166 167 if (ref) 168 fReference = (MH3*)ref->Clone(); 169 } 170 171 MTFillMatrix::~MTFillMatrix() 172 { 173 if (fReference) 174 delete fReference; 162 175 } 163 176 … … 178 191 *fLog << "Fill " << fDestMatrix1->GetDescriptor() << " with " << fNumDestEvents1 << endl; 179 192 *fLog << "Fill " << fDestMatrix2->GetDescriptor() << " with " << fNumDestEvents2 << endl; 180 181 if (fReference .GetHist().GetEntries()>0)182 *fLog << "from " << fReference .GetDescriptor();193 *fLog << "Distribution choosen "; 194 if (fReference && fReference->GetHist().GetEntries()>0) 195 *fLog << "from " << fReference->GetDescriptor(); 183 196 else 184 197 *fLog << "randomly"; … … 195 208 // A selector to select a given number of events from a sample 196 209 // 197 MFEventSelector2 selector(fReference); 198 selector.SetNumMax(fNumDestEvents1+fNumDestEvents2); 199 selector.SetInverted(); 210 // FIXME: Merge MFEventSelector and MFEventSelector2 211 MFilter *selector=0; 212 if (fReference) 213 { 214 // Case of a reference/nominal distribution 215 // The events must be read before selection 216 MFEventSelector2 *sel = new MFEventSelector2(*fReference); 217 sel->SetNumMax(fNumDestEvents1+fNumDestEvents2); 218 sel->SetInverted(); 219 220 selector = sel; 221 } 222 else 223 { 224 // Case of a random distribution 225 // The events can be selected before reading 226 MFEventSelector *sel = new MFEventSelector; 227 sel->SetNumSelectEvts(fNumDestEvents1+fNumDestEvents2); 228 fReader->SetSelector(sel); 229 230 selector = sel; 231 } 200 232 201 233 // … … 203 235 // selected by the 'selector' 204 236 // 205 MContinue cont( &selector);237 MContinue cont(selector); 206 238 207 239 // … … 209 241 // 210 242 const Double_t prob = (Double_t)fNumDestEvents1/(fNumDestEvents1+fNumDestEvents2); 211 MFRandomSplit split(prob); 243 MFEventSelector split; 244 split.SetSelectionRatio(prob); 212 245 213 246 // … … 227 260 228 261 // entries in MTaskList 229 tlist.AddToList(fReader); // Read events 230 tlist.AddToList(&cont); // select a sample of events 231 tlist.AddToList(&invsplit); // process invsplit (which implicitly processes split) 262 tlist.AddToList(fReader); // Read events 263 if (fReference) 264 tlist.AddToList(&cont); // select a sample of events 265 tlist.AddToList(&invsplit); // process invsplit (which implicitly processes split) 232 266 if (fDestMatrix1 && fNumDestEvents1>0) 233 tlist.AddToList(&fill1); // fill matrix 1267 tlist.AddToList(&fill1); // fill matrix 1 234 268 if (fDestMatrix2 && fNumDestEvents2>0) 235 tlist.AddToList(&fill2); // fill matrix 2269 tlist.AddToList(&fill2); // fill matrix 2 236 270 if (fWriteFile1) 237 271 { … … 252 286 evtloop.SetDisplay(fDisplay); 253 287 evtloop.SetLogStream(fLog); 254 if (!evtloop.Eventloop()) 288 289 const Bool_t rc = evtloop.Eventloop(); 290 291 // Print execution statistics of the tasklist 292 if (rc) 293 tlist.PrintStatistics(); 294 295 delete selector; 296 297 if (!rc) 255 298 { 256 299 *fLog << err << GetDescriptor() << ": Failed." << endl; 257 300 return kFALSE; 258 301 } 259 260 // Print execution statistics of the tasklist261 tlist.PrintStatistics();262 302 263 303 // Check the result of filling... -
trunk/MagicSoft/Mars/mtools/MTFillMatrix.h
r2712 r2744 13 13 { 14 14 private: 15 MH3 15 MH3 *fReference; 16 16 MRead *fReader; 17 17 MHMatrix *fDestMatrix1; … … 26 26 27 27 public: 28 MTFillMatrix(const MH3 &ref); 28 MTFillMatrix(const MH3 *ref=NULL); 29 ~MTFillMatrix(); 29 30 30 31 void SetDestMatrix1(MHMatrix *matrix, UInt_t num=0)
Note:
See TracChangeset
for help on using the changeset viewer.