Changeset 2574 for trunk/MagicSoft/Mars/mfilter
- Timestamp:
- 11/28/03 08:08:53 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mfilter
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h
r2521 r2574 24 24 25 25 #pragma link C++ class MFEnergySlope+; 26 #pragma link C++ class MFRandomSplit+; 27 #pragma link C++ class MFAntiFilter+; 26 28 27 29 #endif -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc
r2357 r2574 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 18 ! Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Wolfgang Wittek 11/2003 <mailto:wittek@mppmu.mpg.de> 19 20 ! 20 21 ! Copyright: MAGIC Software Development, 2000-2003 … … 135 136 // would result in redistributing cos(Theta). 136 137 // 138 // If 'fUseOrigDistribution' is set to kTRUE (by SetUseOrigDistribution()) 139 // the original distribution will be used as the nominal distribution; 140 // note that also in this case a dummy nominal distribution has to be 141 // provided in the first argument (the dummy distribution defines the 142 // variable(s) of interest and the binnings) 143 // 144 137 145 MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title) 138 146 : fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL), … … 142 150 fName = name ? (TString)name : gsDefName; 143 151 fTitle = title ? (TString)title : gsDefTitle; 144 } 145 146 // -------------------------------------------------------------------------- 147 // 148 // Destructor. Deletes fHistRes if allocated. 152 153 fUseOrigDistribution = kFALSE; 154 } 155 156 // -------------------------------------------------------------------------- 157 // 158 // 149 159 // 150 160 MFEventSelector2::~MFEventSelector2() 151 161 { 152 if (fHistRes) 153 delete fHistRes; 154 } 155 156 // -------------------------------------------------------------------------- 162 if (fHistRes) 163 delete fHistRes; 164 } 165 166 // -------------------------------------------------------------------------- 167 // 168 // 169 // 170 void MFEventSelector2::SetUseOrigDistribution(Bool_t b) 171 { 172 fUseOrigDistribution = b; 173 174 *fLog << "MFEventSelector2 : use the distribution from the input file as the target distribution" 175 << endl; 176 } 177 178 //--------------------------------------------------------------------------- 157 179 // 158 180 // Recreate a MH3 from fHistNom used as a template. Copy the Binning … … 189 211 190 212 *fLog << "-------------------------" << endl; 191 *fLog << "MFEventSelector2::ReadDistribution; read input file to generate the original distribution" << endl; 213 *fLog << "MFEventSelector2 : Start of eventloop to generate the original distribution" 214 << endl; 192 215 193 216 MEvtLoop run(GetName()); … … 214 237 if (!run.Eventloop()) 215 238 { 216 *fLog << err << dbginf << "Evtloop failed." << endl;239 *fLog << err << dbginf << "Evtloop in MFEventSelector2::ReadDistribution failed." << endl; 217 240 return kFALSE; 218 241 } … … 222 245 *fLog << "MFEventSelector2::ReadDistribution; Original distribution has " 223 246 << fHistOrig->GetHist().GetEntries() << " entries" << endl; 247 *fLog << "MFEventSelector2 : End of eventloop to generate the original distribution" 248 << endl; 224 249 *fLog << "-------------------------" << endl; 225 250 … … 229 254 // -------------------------------------------------------------------------- 230 255 // 231 // After reading the histograms andarrays used for the random event256 // After reading the histograms the arrays used for the random event 232 257 // selction are created. If a MStatusDisplay is set the histograms are 233 258 // displayed there. … … 236 261 { 237 262 TH1 &ho = fHistOrig->GetHist(); 238 TH1 &hn = fHistNom->GetHist(); 239 240 fHistNom->SetTitle("Users Nominal Distribution"); 241 fHistRes->SetTitle("Resulting Distribution"); 263 264 //------------------- 265 // if requested 266 // set the nominal distribution equal to the original distribution 267 268 TH1 *hnp; 269 if (fUseOrigDistribution) 270 hnp = (TH1*)(fHistOrig->GetHist()).Clone(); 271 else 272 hnp = &fHistNom->GetHist(); 273 274 TH1 &hn = *hnp; 275 //-------------------- 242 276 243 277 // normalize to number of counts in primary distribution … … 268 302 if (fNumMax>0) 269 303 { 270 *fLog << "MFEventSelector2::PrepareHistograms; SCALE : fNumMax = " 271 << fNumMax << ", hn.Integral() = " << hn.Integral() 272 << ", fNumMax/hn.Integral() = " << fNumMax/hn.Integral() 273 << endl; 274 275 hn.Scale(fNumMax/hn.Integral()); 304 *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events = " 305 << fNumMax << ", maximum no.of events possible = " 306 << hn.Integral() << endl; 307 308 if (fNumMax > hn.Integral()) 309 { 310 *fLog << "MFEventSelector2::PrepareHistograms; requested no.of events (" 311 << fNumMax << ") is too high" << endl; 312 *fLog << " reduce it to " 313 << hn.Integral() << endl; 314 } 315 316 else 317 hn.Scale(fNumMax/hn.Integral()); 276 318 } 277 319 … … 297 339 fNom[i] = (Long_t)(hn.GetBinContent(i+1)+0.5); 298 340 } 341 342 if (fUseOrigDistribution) 343 delete hnp; 299 344 } 300 345 … … 362 407 InitHistogram(fHistRes); 363 408 409 fHistNom->SetTitle("Users Nominal Distribution"); 364 410 fHistOrig->SetTitle("Primary Distribution"); 411 fHistRes->SetTitle("Resulting Distribution"); 365 412 366 413 // Initialize online display if requested … … 369 416 fHistOrig->Draw(); 370 417 371 // Readprimary distribution418 // Generate primary distribution 372 419 if (!ReadDistribution(*read)) 373 420 return kFALSE; … … 467 514 return kTRUE; 468 515 } 516 517 518 519 520 521 522 523 524 -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h
r2357 r2574 41 41 TCanvas *fCanvas; //! canvas for online display 42 42 43 Bool_t fUseOrigDistribution; 44 43 45 Bool_t fResult; 44 46 Int_t fErrors[2]; … … 57 59 ~MFEventSelector2(); 58 60 61 void SetUseOrigDistribution(Bool_t b=kTRUE); 62 MH3 *GetHistOrig() { return fHistOrig; } 63 59 64 void SetNumMax(Long_t max=-1) { fNumMax = max; } 60 65 Bool_t IsExpressionTrue() const { return fResult; } … … 64 69 65 70 #endif 71 72 73 -
trunk/MagicSoft/Mars/mfilter/Makefile
r2521 r2574 48 48 MFCT1SelStandard.cc \ 49 49 MFCT1SelFinal.cc \ 50 MFEnergySlope.cc 50 MFEnergySlope.cc \ 51 MFRandomSplit.cc \ 52 MFAntiFilter.cc 51 53 52 54 SRCS = $(SRCFILES)
Note:
See TracChangeset
for help on using the changeset viewer.