Changeset 1525 for trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
- Timestamp:
- 09/16/02 10:35:17 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r1498 r1525 101 101 MEvtLoop::MEvtLoop() : fParList(NULL), fProgress(NULL) 102 102 { 103 fName = "Evtloop"; 103 104 } 104 105 … … 300 301 // eventloop setup as a macro. The default name is "evtloop.C". The default 301 302 // extension is .C If the extension is not given, .C is added. 303 // I the last character in the argument is a '+' the file is not closed. 304 // This is usefull if you have an eventloop which runs three times and 305 // you want to write one macro. If the first character is a '+' no 306 // opening is written, eg: 307 // 308 // MEvtLoop evtloop; 309 // // some setup 310 // evtloop.MakeMacro("mymacro+"); 311 // // replace the tasklist the first time 312 // evtloop.MakeMacro("+mymacro+"); 313 // // replace the tasklist the second time 314 // evtloop.MakeMacro("+mymacro"); 302 315 // 303 316 void MEvtLoop::MakeMacro(const char *filename) 304 317 { 305 318 TString name(filename); 319 320 name = name.Strip(TString::kBoth); 321 322 Bool_t open = kTRUE; 323 Bool_t close = kTRUE; 324 if (name[0]=='+') 325 { 326 open = kFALSE; 327 name.Remove(0, 1); 328 name = name.Strip(TString::kBoth); 329 } 330 331 if (name[name.Length()-1]=='+') 332 { 333 close = kFALSE; 334 name.Remove(name.Length()-1, 1); 335 name = name.Strip(TString::kBoth); 336 } 306 337 307 338 if (!name.EndsWith(".C")) 308 339 name += ".C"; 309 340 310 time_t t = time(NULL); 311 312 ofstream fout(name); 313 fout << 314 "/* ======================================================================== *\\" << endl << 315 "!" << endl << 316 "! *" << endl << 317 "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl << 318 "! * Software. It is distributed to you in the hope that it can be a useful" << endl << 319 "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl << 320 "! * It is distributed WITHOUT ANY WARRANTY." << endl << 321 "! *" << endl << 322 "! * Permission to use, copy, modify and distribute this software and its" << endl << 323 "! * documentation for any purpose is hereby granted without fee," << endl << 324 "! * provided that the above copyright notice appear in all copies and" << endl << 325 "! * that both that copyright notice and this permission notice appear" << endl << 326 "! * in supporting documentation. It is provided \"as is\" without express" << endl << 327 "! * or implied warranty." << endl << 328 "! *" << endl << 329 "!" << endl << 330 "!" << endl << 331 "! Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl << 332 "!" << endl << 333 "! Copyright: MAGIC Software Development, 2000-2002" << endl << 334 "!" << endl << 335 "!" << endl << 336 "\\* ======================================================================== */" << endl << endl << 337 "// ------------------------------------------------------------------------" << endl << 338 "//" << endl << 339 "// This macro was automatically created on" << endl<< 340 "// " << ctime(&t) << 341 "// with the MEvtLoop::MakeMacro tool." << endl << 342 "//" << endl << 343 "// ------------------------------------------------------------------------" << endl << endl << 344 "void " << name(0, name.Length()-2) << "()" << endl << 345 "{" << endl; 346 347 SavePrimitive(fout); 341 ofstream fout; 342 343 if (!open) 344 { 345 fout.open(name, ios::app); 346 fout << endl; 347 fout << " // ----------------------------------------------------------------------" << endl; 348 fout << endl; 349 } 350 else 351 { 352 fout.open(name); 353 354 time_t t = time(NULL); 355 fout << 356 "/* ======================================================================== *\\" << endl << 357 "!" << endl << 358 "! *" << endl << 359 "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl << 360 "! * Software. It is distributed to you in the hope that it can be a useful" << endl << 361 "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl << 362 "! * It is distributed WITHOUT ANY WARRANTY." << endl << 363 "! *" << endl << 364 "! * Permission to use, copy, modify and distribute this software and its" << endl << 365 "! * documentation for any purpose is hereby granted without fee," << endl << 366 "! * provided that the above copyright notice appear in all copies and" << endl << 367 "! * that both that copyright notice and this permission notice appear" << endl << 368 "! * in supporting documentation. It is provided \"as is\" without express" << endl << 369 "! * or implied warranty." << endl << 370 "! *" << endl << 371 "!" << endl << 372 "!" << endl << 373 "! Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl << 374 "!" << endl << 375 "! Copyright: MAGIC Software Development, 2000-2002" << endl << 376 "!" << endl << 377 "!" << endl << 378 "\\* ======================================================================== */" << endl << endl << 379 "// ------------------------------------------------------------------------" << endl << 380 "//" << endl << 381 "// This macro was automatically created on" << endl<< 382 "// " << ctime(&t) << 383 "// with the MEvtLoop::MakeMacro tool." << endl << 384 "//" << endl << 385 "// ------------------------------------------------------------------------" << endl << endl << 386 "void " << name(0, name.Length()-2) << "()" << endl << 387 "{" << endl; 388 } 389 390 SavePrimitive(fout, (TString)"" + (open?"open":"") + (close?"close":"")); 391 392 if (!close) 393 return; 348 394 349 395 fout << "}" << endl; … … 358 404 // gui elements to a macro-file. 359 405 // 360 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *) 361 { 406 407 void MEvtLoop::StreamPrimitive(ofstream &out) const 408 { 409 out << " MEvtLoop " << GetUniqueName() << ";" << endl; 410 } 411 412 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt) 413 { 414 TString options = opt; 415 options.ToLower(); 416 362 417 if (HasDuplicateNames("MEvtLoop::SavePrimitive")) 363 418 { … … 370 425 } 371 426 372 gListOfPrimitives = new TList; 427 if (!options.Contains("open")) 428 { 429 if (gListOfPrimitives) 430 { 431 *fLog << err << "MEvtLoop::SavePrimitive - Error: old file not closed." << endl; 432 gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15)); 433 delete gListOfPrimitives; 434 } 435 gListOfPrimitives = new TList; 436 } 373 437 374 438 if (fParList) 375 439 fParList->SavePrimitive(out); 376 440 377 out << " MEvtLoop evtloop;" << endl; 441 MParContainer::SavePrimitive(out); 442 378 443 if (fParList) 379 out << " evtloop.SetParList(&" << fParList->GetUniqueName() << ");" << endl;444 out << " " << GetUniqueName() << ".SetParList(&" << fParList->GetUniqueName() << ");" << endl; 380 445 else 381 446 out << " // fParList empty..." << endl; 382 out << " if (! evtloop.Eventloop())" << endl;447 out << " if (!" << GetUniqueName() << ".Eventloop())" << endl; 383 448 out << " return;" << endl; 449 450 if (!options.Contains("close")) 451 return; 384 452 385 453 gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15)); 386 454 delete gListOfPrimitives; 387 455 gListOfPrimitives = 0; 388 389 // remove all objects with BIT(15) set from gObjectTable390 456 } 391 457
Note:
See TracChangeset
for help on using the changeset viewer.