- Timestamp:
- 08/20/04 11:25:36 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4688 r4694 20 20 -*-*- END OF LINE -*-*- 21 21 22 2004/08/20: Thomas Bretz 23 24 * macros/sql/filldotrbk.C: 25 - removed obsolete output 26 27 * macros/sql/filldotrun.C: 28 - removed obsolete output 29 - updated to support ExcludedFDA-table 30 31 * mbase/MParList.[h,cc]: 32 - added FindTask-member function 33 34 * mcalib/MHCalibrationChargeBlindCam.cc: 35 - fixed a 'comparison between signed and unsigned' 36 37 * mfileio/MRead.h: 38 - added GetFileName() 39 - removed const-qualifier from CheckAndWrite 40 41 * mfileio/MReadMarsFile.cc: 42 - changed some logiing output 43 44 * mfileio/MWriteAsciiFile.[h,cc], mfileio/MWriteFile.[h,cc]: 45 - removed const-qualifier from CheckAndWrite 46 47 * mfileio/MWriteRootFile.[h,cc]: 48 - simplified the constructor by adding Init() function 49 - added ReInit function to support file splitting 50 - added file splitting support (GetNewFileName, ChangeFile) 51 - added new constructor for file splitting 52 - made gsDef* a static member 53 - slight changed to PreProcess to support file-splitting 54 - if file-spliiting is enabled return always kTRUE in IsFileOpen 55 - added many new outputs in case of possible problems 56 57 * mraw/MRawFileRead.[h,cc]: 58 - changed return type of GetFileName() 59 60 * mraw/MRawFileWrite.[h,cc]: 61 - removed obsolete pParList data member 62 - by default write all events to the 'Events' tree 63 64 * msql/MSQLServer.[h,cc]: 65 - enhanced Query function 66 67 68 22 69 2004/08/19: Marcos Lopez 23 70 … … 26 73 the calibration file name, ignore the case, to deal with colors 27 74 written in capital letters. 75 28 76 29 77 -
trunk/MagicSoft/Mars/NEWS
r4601 r4694 14 14 - Added a new task (MTaskEnv) which can be used in setup files to switch 15 15 between different tasks (for example to choose a signal extractor) 16 17 - Implemented automatic file splitting in MWriteRootFile 16 18 17 19 -
trunk/MagicSoft/Mars/macros/sql/filldotrbk.C
r4680 r4694 193 193 TSQLResult *res = serv.Query(query); 194 194 if (!res) 195 {196 cout << "ERROR: " << query << endl << endl;197 195 return 0; 198 }199 196 200 197 delete res; -
trunk/MagicSoft/Mars/macros/sql/filldotrun.C
r4680 r4694 107 107 TSQLResult *res = serv.Query(query); 108 108 if (!res) 109 { 110 cout << "ERROR - Query: " << query << endl; 111 return -1; 112 } 109 return -1; 113 110 114 111 TSQLRow *row=res->Next(); … … 134 131 res=serv.Query(query); 135 132 if (!res) 136 { 137 cout << "ERROR - Query: " << query << endl; 138 return -1; 139 } 133 return -1; 134 140 135 delete res; 141 136 … … 157 152 if (!fin) 158 153 { 159 cout << "Could not open file " << f name << endl;154 cout << "Could not open file " << filename << endl; 160 155 return -1; 161 156 } … … 379 374 if (!TMath::IsNaN(l2uprate) && TMath::Finite(l2uprate)) 380 375 query += Form("fL2RateUnpresc=%d, ", TMath::Nint(l2uprate)); 381 query += "fMagicNumberKEY=1 ";376 query += "fMagicNumberKEY=1, fExcludedFDAKEY=1"; 382 377 383 378 //cout << query << endl; … … 393 388 TSQLResult *res = serv.Query(query); 394 389 if (!res) 395 {396 cout << query << " - FAILED!" << endl;397 390 return -1; 398 }399 391 400 392 delete res; … … 406 398 407 399 // This tool will work from Period017 (2004_05_17) on... 408 void filldotrun(const char *path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE)400 int filldotrun(const TString path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE) 409 401 { 410 402 MSQLServer serv("mysql://hercules:d99swMT!@localhost"); … … 423 415 if (path.EndsWith(".run")) 424 416 { 417 cout << path(TRegexp("CC_.*.run", kFALSE)) << flush; 418 Int_t n = insert(serv, dummy, path); 419 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl; 420 421 return n<0 ? 0 : 1; 422 } 423 424 MDirIter Next(path, "CC_*.run", -1); 425 while (1) 426 { 427 TString name = Next(); 428 if (name.IsNull()) 429 break; 430 425 431 cout << name(TRegexp("CC_.*.run", kFALSE)) << flush; 426 432 Int_t n = insert(serv, dummy, name); 427 433 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl; 428 434 429 return n<0 ? 0 : 1;430 }431 432 MDirIter Next(path, "CC_*.run", -1);433 while (1)434 {435 TString name = Next();436 if (name.IsNull())437 break;438 439 cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;440 Int_t n = insert(serv, dummy, name);441 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;442 443 435 if (n<0) 444 436 return 0; -
trunk/MagicSoft/Mars/mbase/MParList.cc
r4601 r4694 368 368 // -------------------------------------------------------------------------- 369 369 // 370 // Searches for the tasklist tlist (default: MTaskList) and returns 371 // a task with the given name found in this list. If one of both isn't 372 // found NULL is returned 373 // 374 MTask *MParList::FindTask(const char *name, const char *tlist) const 375 { 376 TObject *l = FindObject(tlist, "MTaskList"); 377 return (MTask*)(l ? l->FindObject(name) : NULL); 378 } 379 380 // -------------------------------------------------------------------------- 381 // 370 382 // returns the ClassName without anything which is behind that last ';' in 371 383 // string. -
trunk/MagicSoft/Mars/mbase/MParList.h
r4601 r4694 21 21 22 22 class MLog; 23 class MTask; 23 24 24 25 class MParList : public MParContainer … … 57 58 TObject *FindObject(const char *name, const char *classname) const; 58 59 TObject *FindObject(const TObject *obj, const char *classname) const; 60 61 MTask *FindTask(const char *name, const char *tlist="MTaskList") const; 59 62 60 63 MParContainer *FindCreateObj(const char *classname, const char *objname=NULL); -
trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeBlindCam.cc
r4669 r4694 179 179 { 180 180 181 const Int_t nblindpixels = fSignal->GetNumBlindPixels();181 const UInt_t nblindpixels = fSignal->GetNumBlindPixels(); 182 182 183 183 Int_t runnr = 0; … … 195 195 if (fCam->GetNumBlindPixels() != nblindpixels) 196 196 { 197 *fLog << err << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl; 198 *fLog << err << "Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels() 199 << "Size of MExtractedSignalBlindPixel: " << nblindpixels << endl; 197 *fLog << err; 198 *fLog << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl; 199 *fLog << " Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels() << endl; 200 *fLog << " Size of MExtractedSignalBlindPixel: " << nblindpixels << endl; 200 201 return kFALSE; 201 202 } … … 210 211 fBlindPixelsArray->Expand(nblindpixels); 211 212 212 for ( Int_t i=0; i<nblindpixels; i++)213 for (UInt_t i=0; i<nblindpixels; i++) 213 214 { 214 215 (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix; … … 230 231 } 231 232 232 for ( Int_t i=0; i<nblindpixels; i++)233 for (UInt_t i=0; i<nblindpixels; i++) 233 234 { 234 235 TH1F *h = (*this)[i].GetHGausHist(); -
trunk/MagicSoft/Mars/mfileio/MRead.h
r4601 r4694 17 17 MRead() : fSelector(NULL) {} 18 18 19 virtual UInt_t GetEntries() = 0; 20 virtual Bool_t Rewind(); 19 virtual UInt_t GetEntries() = 0; 20 virtual TString GetFileName() const = 0; 21 virtual Bool_t Rewind(); 21 22 22 23 void SetSelector(MFilter *f) { fSelector = f; } -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
r3682 r4694 191 191 if (!tlist) 192 192 { 193 *fLog << err << dbginf << "ERROR - TaskList not found in Parameter List." << endl;193 *fLog << err << dbginf << "ERROR - MTaskList not found in Parameter List." << endl; 194 194 return kFALSE; 195 195 } -
trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
r3336 r4694 188 188 // a warning message is print. 189 189 // 190 Bool_t MWriteAsciiFile::CheckAndWrite() const190 Bool_t MWriteAsciiFile::CheckAndWrite() 191 191 { 192 192 Bool_t written = kFALSE; -
trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h
r3336 r4694 21 21 TObjArray fAutoDel; //! List of object to be deleted in the destructor 22 22 23 virtual Bool_t CheckAndWrite() const;23 virtual Bool_t CheckAndWrite(); 24 24 virtual Bool_t IsFileOpen() const; 25 25 virtual Bool_t GetContainer(MParList *pList); -
trunk/MagicSoft/Mars/mfileio/MWriteFile.h
r3336 r4694 8 8 class MWriteFile : public MTask 9 9 { 10 protected: 11 Bool_t ReInit(MParList *pList); 12 10 13 private: 11 14 Int_t PreProcess(MParList *pList); 12 15 Int_t Process(); 13 16 Int_t PostProcess(); 14 Bool_t ReInit(MParList *pList);15 17 16 18 virtual Bool_t IsFileOpen() const = 0; 17 virtual Bool_t CheckAndWrite() const= 0;19 virtual Bool_t CheckAndWrite() = 0; 18 20 virtual Bool_t GetContainer(MParList *pList) = 0; 19 21 virtual const char *GetFileName() const = 0; -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r3710 r4694 18 18 ! Author(s): Thomas Bretz, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2004 21 21 ! 22 22 ! … … 24 24 25 25 ///////////////////////////////////////////////////////////////////////////// 26 // // 27 // MWriteRootFile // 28 // // 29 // This is a writer to store several containers to a root file. // 30 // The containers are added with AddContainer. // 31 // To understand how it works, see base class MWriteFile // 32 // // 33 // Warning: Checkout the Warning in MTaskList. // 34 // // 26 // 27 // MWriteRootFile 28 // 29 // This is a writer to store several containers to a root file. 30 // The containers are added with AddContainer. 31 // To understand how it works, see base class MWriteFile 32 // 33 // Warning: Look at the Warning in MTaskList. 34 // 35 // There is a special mode of operation which opens a new file for each new 36 // file read by the reading task (opening the new file is initiated by 37 // ReInit()) For more details se the corresponding constructor. 38 // 35 39 ///////////////////////////////////////////////////////////////////////////// 36 40 #include "MWriteRootFile.h" … … 40 44 #include <TFile.h> 41 45 #include <TTree.h> 46 #include <TRegexp.h> 42 47 43 48 #include "MLog.h" 44 49 #include "MLogManip.h" 45 50 51 #include "MRead.h" 46 52 #include "MParList.h" 47 53 … … 51 57 using namespace std; 52 58 53 static const TString gsDefName = "MWriteRootFile"; 54 static const TString gsDefTitle = "Task which writes a root-output file"; 59 const TString MWriteRootFile::gsDefName = "MWriteRootFile"; 60 const TString MWriteRootFile::gsDefTitle = "Task which writes a root-output file"; 61 62 void MWriteRootFile::Init(const char *name, const char *title) 63 { 64 fName = name ? name : gsDefName.Data(); 65 fTitle = title ? title : gsDefTitle.Data(); 66 67 // 68 // Set the Arrays the owner of its entries. This means, that the 69 // destructor of the arrays will delete all its entries. 70 // 71 fBranches.SetOwner(); 72 73 // 74 // Believing the root user guide, TTree instanced are owned by the 75 // directory (file) in which they are. This means we don't have to 76 // care about their destruction. 77 // 78 //fTrees.SetOwner(); 79 } 55 80 56 81 // -------------------------------------------------------------------------- … … 61 86 MWriteRootFile::MWriteRootFile() : fOut(NULL) 62 87 { 63 fName = gsDefName; 64 fTitle = gsDefTitle; 65 88 Init(); 89 90 // 91 // Set the Arrays the owner of its entries. This means, that the 92 // destructor of the arrays will delete all its entries. 93 // 66 94 fBranches.SetOwner(); 95 } 96 97 // -------------------------------------------------------------------------- 98 // 99 // Use this constructor to run in a special mode. 100 // 101 // In this mode for each input file a new output file is written. This 102 // happens in ReInit. 103 // 104 // comp: Compression Level (see TFile, TBranch) 105 // rule: Rule to create output file name (see GetNewFileName()) 106 // overwrite: Allow newly created file to overwrite old files ("RECREATE") 107 // ftitle: File title stored in the file (see TFile) 108 // name, title: Name and title of this object 109 // 110 MWriteRootFile::MWriteRootFile(const Int_t comp, 111 const char *rule, 112 const Bool_t overwrite, 113 const char *ftitle, 114 const char *name, 115 const char *title) : fSplitRule(rule) 116 { 117 Init(name, title); 118 119 // 120 // Open a TFile in dummy mode! This is necessary to be able to create 121 // the trees and branches, which are then (in ReInit) moved to 122 // a valid file. (Stupid workaround - but does a good job) 123 // 124 fOut = new TFile("/dev/null", overwrite?"RECREATE":"NEW", ftitle, comp); 67 125 } 68 126 … … 81 139 const char *title) 82 140 { 83 fName = name ? name : gsDefName.Data(); 84 fTitle = title ? title : gsDefTitle.Data(); 85 86 // 87 // Set the Arrays the owner of its entries. This means, that the 88 // destructor of the arrays will delete all its entries. 89 // 90 fBranches.SetOwner(); 91 92 // 93 // Believing the root user guide, TTree instanced are owned by the 94 // directory (file) in which they are. This means we don't have to 95 // care about their destruction. 96 // 97 //fTrees.SetOwner(); 141 Init(name, title); 142 143 // 144 // If no name is given we open the TFile in some kind of dummy mode... 145 // 146 if (!fname) 147 { 148 fOut = new TFile("/dev/null", "READ", ftitle, comp); 149 return; 150 } 98 151 99 152 TString str(fname); … … 112 165 // properly. 113 166 // 114 MWriteRootFile::~MWriteRootFile()167 void MWriteRootFile::Close() 115 168 { 116 169 // … … 130 183 // 131 184 delete fOut; 185 fOut = 0; 132 186 133 187 // … … 139 193 140 194 *fLog << inf << "Output File closed and object deleted." << endl; 195 } 196 197 // -------------------------------------------------------------------------- 198 // 199 // call Close() 200 // 201 MWriteRootFile::~MWriteRootFile() 202 { 203 Close(); 141 204 } 142 205 … … 350 413 *fLog << inf << "Branch '" << cname << "' already existing... updating." << endl; 351 414 branch->SetAddress(entry->GetAddress()); 415 416 if (!fSplitRule.IsNull()) 417 { 418 *fLog << warn << endl; 419 *fLog << "WARNING: You are updating an existing branch. For this" << endl; 420 *fLog << " case file-splitting mode is not allowed... disabled!" << endl; 421 *fLog << endl; 422 fSplitRule = ""; 423 } 352 424 } 353 425 else … … 365 437 366 438 branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress()); 439 367 440 // 368 441 // If the branch couldn't be created we have a problem. … … 376 449 377 450 *fLog << "done." << endl; 451 452 if (!tree->TestBit(kIsNewTree) && !fSplitRule.IsNull()) 453 { 454 *fLog << warn << endl; 455 *fLog << "WARNING: You have created a new branch in an existing tree." << endl; 456 *fLog << " For this case file-splitting mode is not allowed... disabled!" << endl; 457 *fLog << endl; 458 fSplitRule= ""; 459 } 378 460 } 379 461 … … 384 466 entry->SetBranch(branch); 385 467 } 468 386 469 return kTRUE; 387 470 } … … 401 484 // has the write flag, all containers in this tree are filled! 402 485 // 403 Bool_t MWriteRootFile::CheckAndWrite() const486 Bool_t MWriteRootFile::CheckAndWrite() 404 487 { 405 488 TObject *obj; … … 438 521 // Loop over all tree entries 439 522 // 440 TIter NextTree(&fTrees); 441 while ((obj=NextTree())) 442 { 443 TTree *t = (TTree*)obj; 523 const Int_t n = fTrees.GetEntriesFast(); 524 525 for (int idx=0; idx<n; idx++) 526 { 527 TTree *t = (TTree*)fTrees[idx]; 444 528 445 529 // … … 455 539 // 456 540 t->ResetBit(kFillTree); 541 457 542 if (!t->Fill()) 458 543 { … … 461 546 } 462 547 } 548 549 // 550 // For more information see TTree:ChangeFile() 551 // 552 TTree *t0 = (TTree*)fTrees[0]; 553 if (!t0 || fOut==t0->GetCurrentFile()) 554 return kTRUE; 555 556 *fLog << warn << endl; 557 *fLog << "WARNING - MWriteRootFile: Root's TTree/TFile has opened a new file" << endl; 558 *fLog << " automatically. You can change this behaviour using TTree::SetMaxTreeSize." << endl; 559 *fLog << " You won't be able to read splitted files correctly with MReadMarsFile if" << endl; 560 *fLog << " they have more than one entry in 'RunHeaders' or you try to read more than" << endl; 561 *fLog << " one of such sequences at once." << endl; 562 *fLog << endl; 563 463 564 return kTRUE; 464 565 } … … 466 567 // -------------------------------------------------------------------------- 467 568 // 569 // Open a new file with the ame fname. Move all trees and branches from the 570 // old file to the new file. 571 // 572 Bool_t MWriteRootFile::ChangeFile(const char *fname) 573 { 574 // 575 // The following code is more or less a copy of TTree::ChangeFile 576 // 577 const Int_t compr = fOut->GetCompressionLevel(); 578 const TString title = fOut->GetTitle(); 579 580 *fLog << inf << "MWriteRootFile - Open new file " << fname << " (Title=" << title << ", Compression=" << compr << ")" << endl; 581 582 // Open new file with old setup 583 TFile *newfile = TFile::Open(fname, "RECREATE", title, compr); 584 if (!newfile) 585 { 586 *fLog << err << "ERROR - Cannot open new file " << fname << endl; 587 return kFALSE; 588 } 589 590 // Print statistics of old file 591 const TString n = GetFileName(); 592 if (!n.IsNull() && n!=TString("/dev/null")) 593 Print(); 594 595 if (fOut->IsOpen()) 596 fOut->Write(); 597 598 // Move all trees from the old file to the new file 599 TObject *obj=0; 600 while ((obj = fOut->GetList()->First())) 601 { 602 // Remove obj from old file (otherwise deleting 603 // the old file will delete the objs) 604 fOut->GetList()->Remove(obj); 605 606 // If this is not a tree do nothing. 607 if (!obj->InheritsFrom("TTree")) 608 continue; 609 610 // process all trees in the old file 611 TTree *t = (TTree*)obj; 612 613 // reset and move to new file (this is done implicitly for all branches) 614 t->Reset(); 615 t->SetDirectory(newfile); 616 } 617 618 // Close/delete the old file (keys already written above) 619 delete fOut; 620 621 // Replace current with new file 622 fOut = newfile; 623 624 // Change current directory to new file 625 gFile = fOut; 626 627 return kTRUE; 628 } 629 630 // -------------------------------------------------------------------------- 631 // 632 // A rule looks like: 633 // "outputpath{s/source/destination}" 634 // 635 // outpath: the output path into which the files are written 636 // {s/source/destination} a substitution rule for the filename 637 // while source can be a regular expression everything which matches this 638 // regular expression (see TRegexp) will be replaced by destination. 639 // Warning: The algorithm is recursive you may create endless loops! 640 // 641 // Example: 642 // inputfile: /data/MAGIC/Period016/rootdata/20040621_23210_D_Mkn421_E.root 643 // rule: /outpath/{s/_D_/_Y_} 644 // outfile: /outpath/20040621_23210_Y_Mkn421_E.root 645 // 646 // If you need more difficult rules please send me an eMail... 647 // 648 TString MWriteRootFile::GetNewFileName(const char *inname) const 649 { 650 // Remove the path from the filename 651 TString fname(inname); 652 if (fname.Last('/')>=0) 653 fname.Remove(0, fname.Last('/')+1); 654 655 // Make a copy of the rule 656 TString rule(fSplitRule); 657 658 // [characte class], ^ do not, [^{}] do not match { and }, [^{}]+ match at least not one { or } 659 const TRegexp subst0("{s/[^{}/]+/[^{}/]+}"); 660 661 TString path; 662 Bool_t first = kTRUE; 663 664 Ssiz_t idx=0; 665 while (1) 666 { 667 // Find a substitution exprsssion 668 Ssiz_t len = 0; 669 idx = subst0.Index(rule, &len); 670 if (idx<0) 671 break; 672 673 // If the first substitution expression is found in the rule 674 // determin the path from everything before 675 if (first) 676 { 677 path=rule(0, idx); 678 first = kFALSE; 679 } 680 681 // Extract a substitution expression 682 TString expr = rule(idx, len); 683 rule.Remove(idx, len); 684 685 expr.Remove(0,3); 686 expr.Remove(expr.Length()-1); 687 688 // In all cases this is well defined (see Regexp) 689 const Ssiz_t pos = expr.First('/'); 690 691 // Split substitution rule into source and destination 692 const TString src = expr(0, pos); 693 const TString dest = expr(pos+1, expr.Length()); 694 695 // Replace source by destination 696 const TRegexp regexp(src); 697 while (1) 698 { 699 TString sub = fname(idx+dest.Length()); 700 idx = regexp.Index(fname, &len); 701 if (idx<0) 702 break; 703 704 fname.Replace(idx, len, dest); 705 } 706 } 707 708 // Check if we have a trailing '/' 709 if (!path.IsNull() && path[path.Length()-1]!='/') 710 path.Append("/"); 711 712 // Create full qualified pathname 713 path += fname; 714 return path; 715 } 716 717 // -------------------------------------------------------------------------- 718 // 719 // ReInit. If file splitting is not allowed call MWriteFile::ReInit. 720 // 721 // In other cases get MRead from the TaskList (splitting is switched of if 722 // this is impossible). 723 // 724 // Convert the input- into a new output file-name. 725 // 726 // Open a new file, change all trees to the new file (calling ChangeFile()), 727 // and close the old one. 728 // 729 // Call MWriteFile::ReInit() 730 // 731 Bool_t MWriteRootFile::ReInit(MParList *pList) 732 { 733 if (fSplitRule.IsNull()) 734 return MWriteFile::ReInit(pList); 735 736 MRead *read = (MRead*)pList->FindTask("MRead"); 737 if (!read) 738 { 739 *fLog << warn; 740 *fLog << "WARNING: No Task 'MRead' found in the tasklist. This task is" << endl; 741 *fLog << " necessary to get the filename. Without a filename file" << endl; 742 *fLog << " file splitting is not allowed... disabled!" << endl; 743 *fLog << endl; 744 fSplitRule = ""; 745 return kTRUE; 746 } 747 748 const TString fname = GetNewFileName(read->GetFileName()); 749 if (!ChangeFile(fname)) 750 return kFALSE; 751 752 return MWriteFile::ReInit(pList); 753 } 754 755 // -------------------------------------------------------------------------- 756 // 468 757 // return open state of the root file. 469 758 // 470 759 Bool_t MWriteRootFile::IsFileOpen() const 471 760 { 472 return fOut->IsOpen(); 761 const char *n = fOut->GetName(); 762 return n==0 || *n==0 ? kTRUE : fOut->IsOpen(); 473 763 } 474 764 … … 479 769 const char *MWriteRootFile::GetFileName() const 480 770 { 481 return fOut->GetName(); 771 const char *n = fOut->GetName(); 772 return n==0 || *n==0 ? "<dummy>" : n; 482 773 } 483 774 -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
r3336 r4694 7 7 #ifndef ROOT_TObjArray 8 8 #include <TObjArray.h> 9 #endif 10 #ifndef ROOT_TArrayL 11 #include <TArrayL.h> 9 12 #endif 10 13 … … 68 71 { 69 72 private: 70 TFile *fOut; 73 static const TString gsDefName; 74 static const TString gsDefTitle; 71 75 72 TObjArray fBranches; 73 TObjArray fTrees; //! 76 TFile *fOut; // Current file 74 77 75 //UInt_t fNumEvents; //! Number of events written in a run 78 TObjArray fBranches; // List of Branch setup (MRootFileBranch) 79 TObjArray fTrees; //! List of trees 76 80 77 Bool_t CheckAndWrite() const; 78 Bool_t IsFileOpen() const; 79 Bool_t GetContainer(MParList *pList); 80 const char *GetFileName() const; 81 82 void StreamPrimitive(ofstream &out) const; 83 //Bool_t ReInit(MParList *pList); 81 TString fSplitRule; // file splitting allowed if rule existing (done in ReInit) 84 82 85 83 enum { 86 84 kFillTree = BIT(14), 85 // Be carefull these bits are already in use! 87 86 // TBranch::kAutoDelete = BIT(15) 88 87 // TBranchElement::kDeleteObject = BIT(16) … … 90 89 }; 91 90 91 // File handling 92 void Close(); 93 TString GetNewFileName(const char *fname) const; 94 Bool_t ChangeFile(const char *fname); 95 96 // MWrite 97 Bool_t CheckAndWrite(); 98 Bool_t IsFileOpen() const; 99 Bool_t GetContainer(MParList *pList); 100 const char *GetFileName() const; 101 102 // MTask 103 Bool_t ReInit(MParList *pList); 104 void StreamPrimitive(ofstream &out) const; 105 106 // Constructor 107 void Init(const char *name=0, const char *title=0); 108 92 109 public: 93 110 MWriteRootFile(); 111 MWriteRootFile(const Int_t comp, 112 const char *rule, 113 const Bool_t overwrite=kTRUE, 114 const char *ftitle="Untitled", 115 const char *name=NULL, 116 const char *title=NULL); 94 117 MWriteRootFile(const char *fname, 95 118 const Option_t *opt="RECREATE", 96 119 const char *ftitle="Untitled", 97 const Int_t comp= 9,120 const Int_t comp=2, 98 121 const char *name=NULL, 99 122 const char *title=NULL); 100 123 ~MWriteRootFile(); 101 124 102 103 125 void AddContainer(const char *cname, const char *tname=NULL, Bool_t must=kTRUE); 104 126 void AddContainer(MParContainer *cont, const char *tname=NULL, Bool_t must=kTRUE); 105 106 127 107 128 void Print(Option_t *t=NULL) const; -
trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
r4577 r4694 109 109 fFileNames->SetOwner(); 110 110 111 if (fname!=NULL)112 AddFile(fname);111 if (fname!=NULL) 112 AddFile(fname); 113 113 } 114 114 … … 230 230 // Return file name of current file. 231 231 // 232 constTString MRawFileRead::GetFileName() const232 TString MRawFileRead::GetFileName() const 233 233 { 234 234 const TObject *file = fFileNames->At(fNumFile-1); -
trunk/MagicSoft/Mars/mraw/MRawFileRead.h
r4601 r4694 34 34 void SetInterleave(UInt_t i) { fInterleave = i; } 35 35 36 constTString GetFileName() const;36 TString GetFileName() const; 37 37 38 38 Int_t AddFile(const char *fname, Int_t entries=-1); -
trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc
r4370 r4694 65 65 const char *ftitle, 66 66 const Int_t comp, 67 const char *name, const char *title) 67 const char *name, const char *title) : fSplit(kFALSE) 68 68 { 69 69 fName = name ? name : "MRawFileWrite"; … … 82 82 MRawFileWrite::~MRawFileWrite() 83 83 { 84 if (fOut != fTData->GetCurrentFile()) 85 { 86 *fLog << warn << endl; 87 *fLog << "WARNING - MWriteRootFile: Root's TTree/TFile has opened a new file" << endl; 88 *fLog << " automatically. You can change this behaviour using TTree::SetMaxTreeSize." << endl; 89 *fLog << " You won't be able to read splitted files correctly with MReadMarsFile if" << endl; 90 *fLog << " they have more than one entry in 'RunHeaders' or you try to read more than" << endl; 91 *fLog << " one of such sequences at once." << endl; 92 *fLog << endl; 93 } 94 95 // 96 // For more information see TTree:ChangeFile() 97 // 98 fOut = fTData->GetCurrentFile(); 99 84 100 // 85 101 // delete instance, this also does a fOut->Close() … … 125 141 126 142 // 127 // remember the pointer to the parameter list fur further usage128 //129 pParList = pList;130 131 //132 143 // check if MEvtHeader exists in the Parameter list already. 133 144 // if not create one and add them to the list … … 180 191 // create data trees for the three types of data 181 192 // 182 fTData = new TTree("Events", "Normal Triggered Events");183 fTPedestal = new TTree("Pedestals", "Pedestal Triggered Events");184 fTCalibration = new TTree("Calibration", "Calibration Triggered Events");193 fTData = new TTree("Events", "Normal Triggered Events"); 194 fTPedestal = fSplit ? new TTree("Pedestals", "Pedestal Triggered Events") : fTData; 195 fTCalibration = fSplit ? new TTree("Calibration", "Calibration Triggered Events") : fTData; 185 196 186 197 // … … 207 218 // FIXME: Can we calculate a good buffer size out of the event size? 208 219 // using splitlevel=0 sppeds up writing by a factor of 5-10% 209 fTData ->Branch("MTime.", "MTime", &fTime, 32000); 220 fTData->Branch("MTime.", "MTime", &fTime, 32000); 221 fTData->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 222 fTData->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000); 223 fTData->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000); 224 if (!fSplit) 225 return kTRUE; 226 210 227 fTPedestal ->Branch("MTime.", "MTime", &fTime, 32000); 211 228 fTCalibration->Branch("MTime.", "MTime", &fTime, 32000); 212 fTData ->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000);213 229 fTPedestal ->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 214 230 fTCalibration->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 215 fTData ->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000);216 231 fTPedestal ->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000); 217 232 fTCalibration->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000); 218 //fTree->Branch("MRawCrateArray", fRawCrateArray->GetArray(), 32000, 1);219 fTData ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);220 233 fTPedestal ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000); 221 234 fTCalibration->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000); -
trunk/MagicSoft/Mars/mraw/MRawFileWrite.h
r4370 r4694 19 19 { 20 20 private: 21 MParList *pParList;22 23 21 MTime *fTime; 24 22 MRawRunHeader *fRawRunHeader; … … 35 33 TFile *fOut; //! 36 34 35 Bool_t fSplit; 36 37 37 Int_t PreProcess(MParList *pList); 38 38 Bool_t ReInit(MParList *pList); … … 47 47 ~MRawFileWrite(); 48 48 49 void EnableSplit(Bool_t b=kTRUE) { fSplit=b; } 50 49 51 ClassDef(MRawFileWrite, 0) // Task to write the raw data containers to a root file 50 52 }; -
trunk/MagicSoft/Mars/msql/MSQLServer.cc
r4577 r4694 410 410 } 411 411 412 // -------------------------------------------------------------------------- 413 // 414 // Send a SQL query to the SQl server. 415 // 416 // If MSQLServer is no server (column, row, ...) NULL is returned and an 417 // error message is send to stdout. 418 // 419 // If the query failed for some reason an error message is send to stdout 420 // and NULL is returned. 421 // 422 // If everything works fine a TSQLResult is returned. Make sure that you 423 // delete it! 424 // 412 425 TSQLResult *MSQLServer::Query(const char *sql) /*FOLD00*/ 413 426 { 414 return fType==kIsServer ? fServ->Query(sql) : NULL; 427 if (fType!=kIsServer) 428 { 429 cout << "ERROR: MSQLServer::Query - this is not a server!" << endl; 430 return NULL; 431 } 432 433 TSQLResult *res = fServ->Query(sql); 434 if (!res) 435 { 436 cout << "ERROR: MSQLServer::Query - Query failed: " << sql << endl; 437 return NULL; 438 } 439 440 return res; 415 441 } 416 442
Note:
See TracChangeset
for help on using the changeset viewer.