- Timestamp:
- 10/29/01 11:15:53 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Makefile.rules
r991 r1003 5 5 6 6 $(LIB): $(OBJS) $(HEADERS) $(CINT)Cint.o 7 @echo " - Building Library lib$(LIB) ..."7 @echo " - Building Library lib$(LIB)" 8 8 $(AR) $(LIB) *.o 9 9 10 10 $(CINT)Cint.cc: $(HEADERS) 11 @echo " - Generating dictionary $(CINT)Cint.cc ..."11 @echo " - Generating dictionary $(CINT)Cint.cc" 12 12 13 13 $(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \ … … 15 15 16 16 .cxx.o: 17 @echo " - Compiling 17 @echo " - Compiling" $< 18 18 $(CXX) $(CXXFLAGS) -c $< -o $@ 19 19 20 20 .cc.o: 21 @echo " - Compiling 21 @echo " - Compiling" $< 22 22 $(CXX) $(CXXFLAGS) -c $< -o $@ 23 23 24 24 .c.o: 25 @echo " - Compiling 25 @echo " - Compiling" $< 26 26 $(CC) $(CFLAGS) -c $< -o $@ 27 27 # -
trunk/MagicSoft/Mars/macros/rootlogon.C
r948 r1003 33 33 cout << "error." << endl; 34 34 else 35 { 36 MParContainer::Class()->IgnoreTObjectStreamer(); 35 37 cout << "done." << endl; 38 } 36 39 37 40 cout << endl; -
trunk/MagicSoft/Mars/manalysis/MCT1ReadAscii.cc
r959 r1003 43 43 #include <fstream.h> 44 44 45 #include <T ArrayC.h>45 #include <TList.h> 46 46 47 47 #include "MLog.h" … … 65 65 : fIn(NULL) 66 66 { 67 *fName = name ? name : "MCT1ReadAscii";68 *fTitle = title ? title : "Task to loop over events in CT1 ascii file";67 fName = name ? name : "MCT1ReadAscii"; 68 fTitle = title ? title : "Task to loop over events in CT1 ascii file"; 69 69 70 70 // 71 71 // remember file name for opening the file in the preprocessor 72 72 // 73 fFileNames = new TArrayC; 73 fFileNames = new TList; 74 fFileNames->SetOwner(); 75 74 76 if (fname) 75 77 AddFile(fname); … … 93 95 void MCT1ReadAscii::AddFile(const char *txt) 94 96 { 95 const int sz = fFileNames->GetSize(); 96 const int tsz = strlen(txt)+1; 97 98 fFileNames->Set(sz+tsz); 99 100 memcpy(fFileNames->GetArray()+sz, txt, tsz); 97 TNamed *name = new TNamed(txt, ""); 98 fFileNames->AddLast(name); 101 99 } 102 100 … … 114 112 fIn = NULL; 115 113 116 const int arrsz = fFileNames->GetSize(); 117 118 if (arrsz<1) 114 // 115 // Check for the existance of a next file to read 116 // 117 TNamed *file = (TNamed*)fFileNames->First(); 118 if (!file) 119 119 return kFALSE; 120 120 … … 122 122 // open the file which is the first one in the chain 123 123 // 124 const char *name = f FileNames->GetArray();124 const char *name = file->GetName(); 125 125 126 126 fIn = new ifstream(name); 127 if (!(*fIn)) 128 { 127 128 const Bool_t noexist = !(*fIn); 129 130 if (noexist) 129 131 *fLog << dbginf << "Cannot open file '" << name << "'" << endl; 130 return kFALSE; 131 } 132 133 // 134 // remove the first entry from the chain 135 // 136 *fLog << "Open file: '" << name << "'" << endl; 137 138 // 139 // create the new char array containing the filenames to process 140 // 141 const int sz = strlen(name)+1; 142 143 char *dummy = new char[arrsz-sz]; 144 memcpy(dummy, name+sz, arrsz-sz); 145 146 // 147 // dummy will be deleted by the destructor of fFileNames 148 // 149 fFileNames->Adopt(arrsz-sz, dummy); 150 151 return kTRUE; 152 132 else 133 *fLog << "Open file: '" << name << "'" << endl; 134 135 // 136 // Remove this file from the list of pending files 137 // 138 fFileNames->Remove(file); 139 140 return !noexist; 153 141 } 154 142 -
trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
r857 r1003 58 58 MCerPhotCalc::MCerPhotCalc(const char *name, const char *title) 59 59 { 60 *fName = name ? name : "MCerPhotCalc";61 *fTitle = title ? title : "Task to calculate Cerenkov photons from raw data";60 fName = name ? name : "MCerPhotCalc"; 61 fTitle = title ? title : "Task to calculate Cerenkov photons from raw data"; 62 62 } 63 63 -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r991 r1003 45 45 { 46 46 47 *fName = name ? name : "MCerPhotEvt";48 *fTitle = title ? title : "(Number of Photon)-Event Information";47 fName = name ? name : "MCerPhotEvt"; 48 fTitle = title ? title : "(Number of Photon)-Event Information"; 49 49 50 50 fPixels = new TClonesArray ("MCerPhotPix", 577) ; -
trunk/MagicSoft/Mars/manalysis/MHillas.cc
r991 r1003 60 60 MHillas::MHillas(const char *name, const char *title) : fEllipse(NULL) 61 61 { 62 *fName = name ? name : "MHillas";63 *fTitle = title ? title : "Storage container for Hillas parameter of one event";62 fName = name ? name : "MHillas"; 63 fTitle = title ? title : "Storage container for Hillas parameter of one event"; 64 64 65 65 Reset(); -
trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc
r857 r1003 56 56 MHillasCalc::MHillasCalc(const char *name, const char *title) 57 57 { 58 *fName = name ? name : "MHillasCalc";59 *fTitle = title ? title : "Task to calculate Hillas parameters";58 fName = name ? name : "MHillasCalc"; 59 fTitle = title ? title : "Task to calculate Hillas parameters"; 60 60 } 61 61 -
trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
r977 r1003 66 66 : fCleanLvl1(lvl1), fCleanLvl2(lvl2) 67 67 { 68 *fName = name ? name : "MImgCleanStd";69 *fTitle = title ? title : "Task which does a standard image cleaning";68 fName = name ? name : "MImgCleanStd"; 69 fTitle = title ? title : "Task which does a standard image cleaning"; 70 70 71 71 *fLog << "Cleaning initialized. Using noise level " << lvl1 << " and " << lvl2 << endl; -
trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
r993 r1003 49 49 MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title) 50 50 { 51 *fName = name ? name : "MMcPedestalCopy";52 *fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";51 fName = name ? name : "MMcPedestalCopy"; 52 fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container"; 53 53 } 54 54 -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r857 r1003 53 53 MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title) 54 54 { 55 *fName = name ? name : "MPedCalcPedRun";56 *fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";55 fName = name ? name : "MPedCalcPedRun"; 56 fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data"; 57 57 } 58 58 -
trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
r857 r1003 42 42 MPedestalCam::MPedestalCam(const char *name, const char *title) 43 43 { 44 *fName = name ? name : "MPedestalCam";45 *fTitle = title ? title : "Storage container for all Pedestal Information in the camera";44 fName = name ? name : "MPedestalCam"; 45 fTitle = title ? title : "Storage container for all Pedestal Information in the camera"; 46 46 47 47 fArray = new TClonesArray("MPedestalPix", 577); -
trunk/MagicSoft/Mars/mbase/MArray.h
r654 r1003 12 12 #ifndef MAGIC_H 13 13 #include "MAGIC.h" 14 #endif15 16 #ifndef ROOT_TObject17 #include <TObject.h>18 14 #endif 19 15 -
trunk/MagicSoft/Mars/mbase/MArrayB.h
r654 r1003 15 15 16 16 #include <string.h> 17 18 17 19 18 class MArrayB : public MArray -
trunk/MagicSoft/Mars/mbase/MClone.cc
r991 r1003 66 66 void MClone::Init(const char *name, const char *title) 67 67 { 68 *fName = name ? name : "MClone";69 *fTitle = title ? title : "Task to clone a parameter container for later usage";68 fName = name ? name : "MClone"; 69 fTitle = title ? title : "Task to clone a parameter container for later usage"; 70 70 71 71 fClone = NULL; -
trunk/MagicSoft/Mars/mbase/MInputStreamID.cc
r752 r1003 44 44 MInputStreamID::MInputStreamID(const char *name, const char *title) 45 45 { 46 *fName = name ? name : ClassName();47 *fTitle = title;46 fName = name ? name : ClassName(); 47 fTitle = title; 48 48 49 fStreamId = new char[4];50 strcpy(fStreamId, "All");49 fStreamId = "All"; //new char[4]; 50 //strcpy(fStreamId, "All"); 51 51 } 52 52 -
trunk/MagicSoft/Mars/mbase/MInputStreamID.h
r458 r1003 19 19 { 20 20 private: 21 char *fStreamId;//! which type of task should be processed?21 TString fStreamId; //! which type of task should be processed? 22 22 23 23 public: 24 24 MInputStreamID(const char *name=NULL, const char *title=NULL); 25 25 26 const char *GetStreamId() 26 const TString &GetStreamId() const { return fStreamId; } 27 void SetStreamId(const char *t) { fStreamId = t; } 28 29 Bool_t operator==(MInputStreamID &id) const 27 30 { 28 return (const char *)fStreamId; 29 } 30 void SetStreamId(const char *t) 31 { 32 delete fStreamId; 33 fStreamId = new char[strlen(t)+1]; 34 strcpy(fStreamId, t); 31 return fStreamId == id.fStreamId; 35 32 } 36 33 37 ClassDef(MInputStreamID, 1) //Assigns an ID to tasks or a task list 34 Bool_t operator!=(MInputStreamID &id) const 35 { 36 return fStreamId != id.fStreamId; 37 } 38 39 ClassDef(MInputStreamID, 0) //Assigns an Id to tasks or a task list 38 40 }; 39 41 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r986 r1003 51 51 MParContainer::MParContainer(const MParContainer &named) 52 52 { 53 *fName = *(named.fName);54 *fTitle = *(named.fTitle);53 fName = named.fName; 54 fTitle = named.fTitle; 55 55 56 56 fLog = named.fLog; … … 70 70 TObject::operator=(rhs); 71 71 72 *fName = *(rhs.fName);73 *fTitle = *(rhs.fTitle);72 fName = rhs.fName; 73 fTitle = rhs.fTitle; 74 74 75 75 fLog = rhs.fLog; … … 81 81 // -------------------------------------------------------------------------- 82 82 // 83 // Make a clone of an object using the Streamer facility. 84 // If newname is specified, this will be the name of the new object 85 // 86 TObject *MParContainer::Clone(const char *newname) const 87 { 88 89 MParContainer *named = (MParContainer*)TObject::Clone(newname); 90 if (newname && strlen(newname)) named->SetName(newname); 91 return named; 92 } 93 94 // -------------------------------------------------------------------------- 95 // 83 96 // Compare two MParContainer objects. Returns 0 when equal, -1 when this is 84 97 // smaller and +1 when bigger (like strcmp). 85 98 // 86 Int_t MParContainer::Compare( TObject *obj)99 Int_t MParContainer::Compare(const TObject *obj) const 87 100 { 88 101 if (this == obj) return 0; 89 return fName ->CompareTo(obj->GetName());102 return fName.CompareTo(obj->GetName()); 90 103 } 91 104 … … 100 113 TObject::Copy(obj); 101 114 102 *cont.fName = *fName;103 *cont.fTitle = *fTitle;115 cont.fName = fName; 116 cont.fTitle = fTitle; 104 117 105 118 cont.fLog = fLog; … … 113 126 void MParContainer::FillBuffer(char *&buffer) 114 127 { 115 fName ->FillBuffer(buffer);116 fTitle ->FillBuffer(buffer);128 fName.FillBuffer(buffer); 129 fTitle.FillBuffer(buffer); 117 130 } 118 131 … … 121 134 // List MParContainer name and title. 122 135 // 123 void MParContainer::ls(Option_t *) 136 void MParContainer::ls(Option_t *) const 124 137 { 125 138 TROOT::IndentLevel(); … … 147 160 void MParContainer::SetName(const char *name) 148 161 { 149 *fName = name;162 fName = name; 150 163 if (gPad && TestBit(kMustCleanup)) gPad->Modified(); 151 164 } … … 158 171 void MParContainer::SetObject(const char *name, const char *title) 159 172 { 160 *fName = name;161 *fTitle = title;173 fName = name; 174 fTitle = title; 162 175 if (gPad && TestBit(kMustCleanup)) gPad->Modified(); 163 176 } … … 169 182 void MParContainer::SetTitle(const char *title) 170 183 { 171 *fTitle = title;184 fTitle = title; 172 185 if (gPad && TestBit(kMustCleanup)) gPad->Modified(); 173 186 } … … 179 192 Int_t MParContainer::Sizeof() const 180 193 { 181 Int_t nbytes = fName ->Sizeof() + fTitle->Sizeof();194 Int_t nbytes = fName.Sizeof() + fTitle.Sizeof(); 182 195 return nbytes; 183 196 } -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r986 r1003 22 22 class ofstream; 23 23 class ifstream; 24 24 /* 25 25 class MParContainer : public TObject 26 26 { … … 32 32 fTitle = new TString; 33 33 (*fTitle) = title; 34 35 cout << " <***> " << flush; 34 36 } 35 37 … … 53 55 //delete fName; delete fTitle; 54 56 } 55 virtual Int_t Compare(TObject *obj); 57 virtual TObject *Clone(const char *newname) const; 58 virtual Int_t Compare(const TObject *obj) const; 56 59 virtual void Copy(TObject &named); 57 60 virtual void FillBuffer(char *&buffer); … … 63 66 virtual void SetObject(const char *name, const char *title); 64 67 virtual void SetTitle(const char *title=""); // *MENU* 65 virtual void ls(Option_t *option="") ;68 virtual void ls(Option_t *option="") const; 66 69 virtual void Print(Option_t *option="") const; 67 70 virtual Int_t Sizeof() const; … … 77 80 ClassDef(MParContainer, 1) //The basis for all parameter containers 78 81 }; 82 */ 79 83 84 class MParContainer : public TObject 85 { 86 protected: 87 TString fName; // parameter container identifier (name) 88 TString fTitle; // parameter container title 89 90 MLog *fLog; // The general log facility for this object, initialized with the global object 91 92 private: 93 Bool_t fReadyToSave; // should be set to true if the contents of the container is changed somehow 94 95 public: 96 MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) { } 97 MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) { } 98 MParContainer(const MParContainer &named); 99 MParContainer& operator=(const MParContainer& rhs); 100 101 void SetLogStream(MLog *lg) { fLog = lg; } 102 103 virtual TObject *Clone(const char *newname="") const; 104 virtual Int_t Compare(const TObject *obj) const; 105 virtual void Copy(TObject &named); 106 virtual void FillBuffer(char *&buffer); 107 virtual const char *GetName() const { return fName.Data(); } 108 virtual const char *GetTitle() const { return fTitle.Data(); } 109 virtual ULong_t Hash() { return fName.Hash(); } 110 virtual Bool_t IsSortable() const { return kTRUE; } 111 virtual void SetName(const char *name); // *MENU* 112 virtual void SetObject(const char *name, const char *title); 113 virtual void SetTitle(const char *title=""); // *MENU* 114 virtual void ls(Option_t *option="") const; 115 virtual void Print(Option_t *option="") const; 116 virtual Int_t Sizeof() const; 117 118 virtual void Reset() { } 119 120 virtual Bool_t IsReadyToSave() { return fReadyToSave; } 121 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } 122 123 virtual void AsciiRead(ifstream &fin); 124 virtual void AsciiWrite(ofstream &fout) const; 125 126 ClassDef(MParContainer, 0) //The basis for all parameter containers 127 }; 128 129 /* 130 class MParContainer : public TNamed 131 { 132 protected: 133 MLog *fLog; //! The general log facility for this object, initialized with the global object 134 135 private: 136 Bool_t fReadyToSave; //! should be set to true if the contents of the container is changed somehow 137 138 public: 139 MParContainer(const char *name="", const char *title="") : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { } 140 MParContainer(const TString &name, const TString &title) : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { } 141 142 void SetLogStream(MLog *lg) { fLog = lg; } 143 144 virtual void Reset() { } 145 146 virtual Bool_t IsReadyToSave() { return fReadyToSave; } 147 virtual void SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; } 148 149 virtual void AsciiRead(ifstream &fin); 150 virtual void AsciiWrite(ofstream &fout) const; 151 152 ClassDef(MParContainer, 0) //The basis for all parameter containers 153 }; 154 */ 80 155 #endif 81 156 -
trunk/MagicSoft/Mars/mbase/MParList.cc
r986 r1003 43 43 #include <TNamed.h> 44 44 #include <TClass.h> 45 #include <TO bjArray.h>45 #include <TOrdCollection.h> 46 46 47 47 #include "MLog.h" … … 57 57 MParList::MParList(const char *name, const char *title) 58 58 { 59 *fName = name ? name : "MParList";60 *fTitle = title ? title : "A list of Parameter Containers";59 fName = name ? name : "MParList"; 60 fTitle = title ? title : "A list of Parameter Containers"; 61 61 62 62 // … … 64 64 // that the destructor of the list deletes all it's objects 65 65 // 66 fAutodelete.SetOwner(); 66 fContainer = new TOrdCollection; 67 fAutodelete = new TOrdCollection; 68 69 fAutodelete->SetOwner(); 67 70 } 68 71 … … 76 79 MParList::MParList(MParList &ts) 77 80 { 78 fContainer .AddAll(&ts.fContainer);81 fContainer->AddAll(ts.fContainer); 79 82 } 80 83 … … 87 90 { 88 91 if (TestBit(kIsOwner)) 89 fContainer.SetOwner(); 92 fContainer->SetOwner(); 93 94 delete fContainer; 95 delete fAutodelete; 90 96 } 91 97 … … 107 113 void MParList::SetLogStream(MLog *log) 108 114 { 109 TIter Next( &fContainer);115 TIter Next(fContainer); 110 116 111 117 MParContainer *cont=NULL; … … 143 149 // Check if the new container is already existing in the list 144 150 // 145 const TObject *objn = fContainer .FindObject(name);146 const TObject *objt = fContainer .FindObject(cont);151 const TObject *objn = fContainer->FindObject(name); 152 const TObject *objt = fContainer->FindObject(cont); 147 153 148 154 if (objn || objt) … … 172 178 if (where) 173 179 { 174 if (!fContainer .FindObject(where))180 if (!fContainer->FindObject(where)) 175 181 { 176 182 *fLog << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl; … … 181 187 *fLog << "Adding " << name << " to " << GetName() << "... " << flush; 182 188 183 fContainer .Add(cont);189 fContainer->Add(cont); 184 190 *fLog << "Done." << endl; 185 191 … … 204 210 while ((cont=(MParContainer*)Next())) 205 211 { 206 // 212 AddToList(cont); 213 /* // 207 214 // Get Name of new container 208 215 // … … 212 219 // Check if the new container is already existing in the list 213 220 // 214 const TObject *objn = fContainer .FindObject(name);215 const TObject *objt = fContainer .FindObject(cont);221 const TObject *objn = fContainer->FindObject(name); 222 const TObject *objt = fContainer->FindObject(cont); 216 223 217 224 if (objn || objt) … … 237 244 *fLog << "Adding " << name << " to " << GetName() << "... " << flush; 238 245 239 fContainer .Add(cont);240 241 *fLog << "Done." << endl; 246 fContainer->Add(cont); 247 248 *fLog << "Done." << endl;*/ 242 249 } 243 250 } … … 250 257 TObject *MParList::FindObject(const char *name) const 251 258 { 252 return fContainer .FindObject(name);259 return fContainer->FindObject(name); 253 260 } 254 261 … … 259 266 TObject *MParList::FindObject(TObject *obj) const 260 267 { 261 return fContainer .FindObject(obj);268 return fContainer->FindObject(obj); 262 269 } 263 270 … … 358 365 // if object is not existing in the list try to create one 359 366 // 360 *fLog << dbginf << "Object '" << oname << "' [" << cname << "] not found... creating." << endl;367 *fLog << "Object '" << oname << "' [" << cname << "] not yet in " << GetName() << "... creating." << endl; 361 368 362 369 // … … 393 400 // object is deleted together with the list 394 401 // 395 fAutodelete .Add(pcont);402 fAutodelete->Add(pcont); 396 403 397 404 // … … 419 426 void MParList::SetReadyToSave(Bool_t flag) 420 427 { 421 TIter Next( &fContainer);428 TIter Next(fContainer); 422 429 423 430 MParContainer *cont=NULL; … … 438 445 void MParList::Reset() 439 446 { 440 TIter Next( &fContainer);447 TIter Next(fContainer); 441 448 442 449 MParContainer *cont=NULL; -
trunk/MagicSoft/Mars/mbase/MParList.h
r986 r1003 14 14 #endif 15 15 16 #ifndef ROOT_TO rdCollection17 #include "TOrdCollection.h"16 #ifndef ROOT_TObjArray 17 #include <TObjArray.h> 18 18 #endif 19 19 #ifndef MPARCONTAINER_H … … 21 21 #endif 22 22 23 #include <TObjArray.h> 23 class TOrdCollection; 24 24 25 25 class MLog; … … 28 28 { 29 29 private: 30 TOrdCollection fContainer; // Collection of Parameter and Data Containers31 TOrdCollection fAutodelete; // All what this list contains is deleted in the destructor30 TOrdCollection *fContainer; // Collection of Parameter and Data Containers 31 TOrdCollection *fAutodelete; // All what this list contains is deleted in the destructor 32 32 33 33 static TString GetClassName(const char *classname); -
trunk/MagicSoft/Mars/mbase/MPrint.cc
r991 r1003 54 54 void MPrint::Init(const char *name, const char *title) 55 55 { 56 *fName = name ? name : "MPrint";57 *fTitle = title ? title : "Task to print a parameter container";56 fName = name ? name : "MPrint"; 57 fTitle = title ? title : "Task to print a parameter container"; 58 58 59 59 fObject = NULL; -
trunk/MagicSoft/Mars/mbase/MReadTree.cc
r991 r1003 53 53 #include <fstream.h> 54 54 55 #include <TFile.h>56 55 #include <TChain.h> 57 #include <TArrayC.h>58 #include <TObjArray.h>59 56 #include <TChainElement.h> 57 #include <TOrdCollection.h> 60 58 61 59 #include "MLog.h" … … 64 62 #include "MTime.h" 65 63 #include "MParList.h" 64 #include "MTaskList.h" 66 65 67 66 ClassImp(MReadTree); … … 77 76 MReadTree::MReadTree(const char *tname, const char *fname, 78 77 const char *name, const char *title) 79 : fNumEntry(0), fLeafEnabled(kFALSE) 80 { 81 *fName = name ? name : "MReadTree"; 82 *fTitle = title ? title : "Task to loop over all events in one single tree"; 83 84 fVetoList = new TArrayC; 78 : fNumEntry(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE) 79 { 80 fName = name ? name : "MReadTree"; 81 fTitle = title ? title : "Task to loop over all events in one single tree"; 82 83 fVetoList = new TOrdCollection; 84 fVetoList->SetOwner(); 85 85 86 86 // … … 138 138 } 139 139 140 // -------------------------------------------------------------------------- 141 // 142 // The first time this function is called all leafes/branches are disabled 143 // and the given branch/leaf is enabled. By enabling only the branches you 140 void MReadTree::EnableBranchChoosing() 141 { 142 if (fBranchChoosing) 143 return; 144 145 *fLog << "Branch choosing method enabled (only enabled branches are read)." << endl; 146 fChain->SetBranchStatus("*", kFALSE); 147 fBranchChoosing = kTRUE; 148 } 149 150 // -------------------------------------------------------------------------- 151 // 152 // The first time this function is called all branches are disabled. 153 // The given branch is enabled. By enabling only the branches you 144 154 // are processing you can speed up your calculation many times (up to 145 155 // a factor of 10 or 20) 146 156 // 147 void MReadTree::UseLeaf(const char *name) 148 { 149 if (!fLeafEnabled) 150 { 151 *fLog << "Leaf choosing method enabled (only enabled leaves are read)." << endl; 152 fChain->SetBranchStatus("*", kFALSE); 153 fLeafEnabled = kTRUE; 154 } 155 157 void MReadTree::EnableBranch(const char *name) 158 { 159 EnableBranchChoosing(); 156 160 fChain->SetBranchStatus(name, kTRUE); 161 } 162 163 // -------------------------------------------------------------------------- 164 // 165 // This is the implementation of the Auto Enabling Scheme. 166 // For more information see MTask::AddBranchToList. 167 // This function loops over all tasks in the tasklist and enables 168 // all branches which are requested by the tasks. 169 // 170 // To enable 'unknown' branches which are not in the Branchlist of 171 // the tasks you can call EnableBranch 172 // 173 void MReadTree::EnableBranches(MParList *plist) 174 { 175 // 176 // if auto enabling is off reject the request 177 // 178 if (!fAutoEnable) 179 return; 180 181 // 182 // check whether branch choosing must be switched on 183 // 184 EnableBranchChoosing(); 185 186 // 187 // request the tasklist from the parameter list. 188 // FIXME: Tasklist can have a different name 189 // 190 const MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList"); 191 if (!tlist) 192 { 193 *fLog << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl; 194 return; 195 } 196 197 // 198 // Loo over all tasks in the task list. 199 // 200 MTask *task; 201 TIter NextTask(tlist->GetList()); 202 while ((task=(MTask*)NextTask())) 203 { 204 // 205 // Loop over all branches of this task 206 // 207 TNamed *branch; 208 TIter NextBranch(task->GetListOfBranches()); 209 while ((branch=(TNamed*)NextBranch())) 210 { 211 // 212 // Get branch name to enable and enable the branch 213 // 214 const char *name = branch->GetName(); 215 216 *fLog << "Enabeling '" << name << "'." << endl; 217 218 fChain->SetBranchStatus(name, kTRUE); 219 } 220 } 157 221 } 158 222 … … 208 272 // Check if enabeling the branch is allowed 209 273 // 210 if ( HasVeto(name))274 if (fVetoList->FindObject(name)) 211 275 { 212 276 *fLog << "Branch " << name << " has veto... skipped." << endl; … … 242 306 fChain->SetBranchAddress(name, pcont); 243 307 244 *fLog << "Branch " << name << " enabledfor reading." << endl;308 *fLog << "Branch " << name << " setup for reading." << endl; 245 309 246 310 num++; 247 311 } 248 312 249 *fLog << "MReadTree will read " << num << " branches." << endl; 313 *fLog << "MReadTree setup " << num << " branches." << endl; 314 315 EnableBranches(pList); 250 316 251 317 return kTRUE; … … 261 327 Bool_t MReadTree::Process() 262 328 { 263 return fChain->GetEntry(fNumEntry++) == 0 ? kFALSE : kTRUE;329 return fChain->GetEntry(fNumEntry++) != 0; 264 330 } 265 331 … … 270 336 Bool_t MReadTree::GetEvent() 271 337 { 272 return fChain->GetEntry(fNumEntry) == 0 ? kFALSE : kTRUE;338 return fChain->GetEntry(fNumEntry) != 0; 273 339 } 274 340 … … 338 404 // -------------------------------------------------------------------------- 339 405 // 340 // This function checks if the Branch Name is part of the Veto List. 341 // This means, that the preprocess doesn't enable the branch. 342 // 343 Bool_t MReadTree::HasVeto(const char *name) const 344 { 345 const size_t nlen = strlen(name)+1; 346 347 char *pos = fVetoList->GetArray(); 348 size_t len = fVetoList->GetSize(); 349 350 // 351 // now we compare the 'strings' in the list word by word 352 // (string or word in this context means a zero terminated 353 // array of chars 354 // 355 356 for (;;) 357 { 358 // 359 // Search for the first byte of the name 360 // 361 char *c = (char*)memchr(pos, name[0], len); 362 363 // 364 // if we don't find the first byte, the list cannot contain 'name' 365 // 366 if (!c) 367 return kFALSE; 368 369 // 370 // calculate and check how many bytes remains in the list 371 // 372 len -= c-pos; 373 374 // 375 // if there are not enough bytes to match the query we are done 376 // 377 if (len<nlen) 378 return kFALSE; 379 380 // 381 // check if the next 'nlen' byte (including the trailing '\0' 382 // are matching 383 // 384 if (!memcmp(c, name, nlen)) 385 return kTRUE; 386 387 // 388 // we didn't find the string, goto the next 'string' 389 // 390 pos = (char*)memchr(c, '\0', len); 391 392 // 393 // check if there is a 'next' string really 394 // 395 if (!pos) 396 return kFALSE; 397 398 // 399 // calculate the remaining length 400 // 401 len -= pos-c; 402 403 // 404 // if there are not enough bytes to match the query we are done 405 // 406 if (len<nlen) 407 return kFALSE; 408 } 409 } 410 411 412 // -------------------------------------------------------------------------- 413 // 414 // If you don't want that a branch is enabled within the PreProcess you 415 // can set a veto for enabeling the branch. (This means also the 416 // corresponding object won't be created automatically) 417 // 418 // This functionality is for experienced users which don't want to 419 // read in branches which are not processed in the program (for 420 // speed reasons) 406 // If you don't want that an object is created for this branch 407 // and/or the branch address is set in the Preprocessing of 408 // MReadTree use VetoBranch. This saves mainly memory space. 421 409 // 422 410 void MReadTree::VetoBranch(const char *name) 423 411 { 424 // 425 // Add this file as the last entry of the list 426 // (including the trailing '\0') 427 // 428 const int sz = fVetoList->GetSize(); 429 const int tsz = strlen(name)+1; 430 431 fVetoList->Set(sz+tsz); 432 433 memcpy(fVetoList->GetArray()+sz, name, tsz); 434 } 412 TNamed *branch = new TNamed(name, ""); 413 fVetoList->Add(branch); 414 } -
trunk/MagicSoft/Mars/mbase/MReadTree.h
r965 r1003 6 6 #endif 7 7 8 class TFile;9 8 class TChain; 10 class TArrayC;11 9 12 10 class MReadTree : public MTask 13 11 { 14 12 private: 15 TFile *fFile; // Pointer to file 16 TChain *fChain; // Pointer to tree 13 TChain *fChain; // Pointer to tree 17 14 18 TArrayC *fVetoList; // List of Branches which are not allowed to get enabled 15 UInt_t fNumEntry; // Number of actual entry 16 UInt_t fNumEntries; // Number of Events in Tree 19 17 20 UInt_t fNumEntry; // Number of actual entry21 UInt_t fNumEntries; // Number of Events in Tree18 Bool_t fBranchChoosing; // Flag for branch choosing method 19 Bool_t fAutoEnable; // Flag for auto enabeling scheme 22 20 23 Bool_t fLeafEnabled; // Flag whether UseLeaf is called the first time or not21 TOrdCollection *fVetoList; // List of Branches which are not allowed to get enabled 24 22 25 Bool_t HasVeto(const char *name) const; 23 void EnableBranches(MParList *plist); 24 void EnableBranchChoosing(); 26 25 27 26 public: … … 32 31 Bool_t Process(); 33 32 34 Int_t AddFile(const char *fname);35 void VetoBranch(const char *name);33 Int_t AddFile(const char *fname); 34 void VetoBranch(const char *name); 36 35 37 void UseLeaf(const char *name);36 void EnableBranch(const char *name); 38 37 39 38 Bool_t GetEvent(); … … 46 45 UInt_t GetEntries() const { return fNumEntries; } 47 46 47 void DisableAutoScheme() { fAutoEnable = kFALSE; } 48 48 49 ClassDef(MReadTree, 0) // Reads one tree 49 50 }; -
trunk/MagicSoft/Mars/mbase/MTask.cc
r988 r1003 67 67 #include "MTask.h" 68 68 69 #include <TOrdCollection.h> 70 69 71 #include "MLog.h" 70 72 #include "MLogManip.h" … … 75 77 76 78 MTask::MTask(const char *name, const char *title) 77 : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions() 78 { 79 *fName = name ? name : "MTask"; 80 *fTitle = title ? title : "Base class for all tasks (dummy task)."; 79 : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions(0) 80 { 81 fName = name ? name : "MTask"; 82 fTitle = title ? title : "Base class for all tasks (dummy task)."; 83 84 fListOfBranches = new TOrdCollection; 85 fListOfBranches->SetOwner(); 86 } 87 88 MTask::~MTask() 89 { 90 delete fListOfBranches; 91 } 92 93 // -------------------------------------------------------------------------- 94 // 95 // This adds a branch to the list for the auto enabeling schmeme. 96 // This makes it possible for MReadTree to decide which branches 97 // are really needed for the eventloop. Only the necessary branches 98 // are read from disk which speeds up the calculation enormously. 99 // 100 // You can use TRegExp expressions like "*.fEnergy", but the 101 // recommended method is to call this function for exactly all 102 // branches you want to have, eg: 103 // AddToBranchList("MMcTrig;1.fNumFirstLevel"); 104 // AddToBranchList("MMcTrig;2.fNumFirstLevel"); 105 // 106 // We agreed on the convetion, that all branches are stored with 107 // a trailing dot '.' so that always the Master Branch name 108 // (eg. MMcTrig) is part of the branch name. 109 // 110 // Remark: The common place to call AddToBranchList is the 111 // constructor of the derived classes (tasks) 112 // 113 void MTask::AddToBranchList(const char *b) 114 { 115 TNamed *name = new TNamed(b, ""); 116 fListOfBranches->Add(name); 117 } 118 119 // -------------------------------------------------------------------------- 120 // 121 // Copy constructor. 122 // 123 MTask::MTask(MTask &t) 124 { 125 fFilter = t.fFilter; 126 fListOfBranches->AddAll(t.fListOfBranches); 81 127 } 82 128 -
trunk/MagicSoft/Mars/mbase/MTask.h
r988 r1003 14 14 #endif 15 15 16 class TOrdCollection; 17 16 18 class MFilter; 17 19 class MParList; … … 20 22 { 21 23 private: 22 const MFilter *fFilter;24 TOrdCollection *fListOfBranches; // List of Branch names for auto enabeling scheme 23 25 24 Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList) 25 UInt_t fNumExecutions; // Number of Excutions 26 const MFilter *fFilter; // Filter for conditional task execution 27 28 Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList) 29 UInt_t fNumExecutions; // Number of Excutions 26 30 27 31 virtual Bool_t PreProcess(MParList *pList); … … 29 33 virtual Bool_t PostProcess(); 30 34 35 protected: 36 void AddToBranchList(const char *b); 37 void AddToBranchList(const TString &str) 38 { 39 AddToBranchList((const char*)str); 40 } 41 31 42 public: 32 43 MTask(const char *name=NULL, const char *title=NULL); 33 virtual ~MTask() 34 { 35 } 44 MTask(MTask &t); 45 virtual ~MTask(); 36 46 37 47 void SetFilter(const MFilter *filter) { fFilter=filter; } … … 42 52 Bool_t CallPostProcess(); 43 53 54 const TOrdCollection *GetListOfBranches() const { return fListOfBranches; } 55 44 56 ClassDef(MTask, 0) //Abstract base class for a task 45 57 }; -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r988 r1003 47 47 #include "MTaskList.h" 48 48 49 #include <TOrdCollection.h> 50 49 51 #include "MLog.h" 50 52 #include "MLogManip.h" … … 63 65 MTaskList::MTaskList(const char *name, const char *title) 64 66 { 65 *fName = name ? name : "MTaskList"; 66 *fTitle = title ? title : "A list for tasks to be executed"; 67 fName = name ? name : "MTaskList"; 68 fTitle = title ? title : "A list for tasks to be executed"; 69 70 fTasks = new TOrdCollection; 67 71 } 68 72 … … 75 79 MTaskList::MTaskList(MTaskList &ts) 76 80 { 77 fTasks .AddAll(&ts.fTasks);81 fTasks->AddAll(ts.fTasks); 78 82 } 79 83 … … 86 90 { 87 91 if (TestBit(kIsOwner)) 88 fTasks.SetOwner(); 92 fTasks->SetOwner(); 93 94 delete fTasks; 89 95 } 90 96 … … 110 116 // create the Iterator over the tasklist 111 117 // 112 TIter Next( &fTasks);118 TIter Next(fTasks); 113 119 114 120 MTask *task=NULL; … … 147 153 // Check if the new task is already existing in the list 148 154 // 149 const TObject *objn = fTasks .FindObject(name);150 const TObject *objt = fTasks .FindObject(task);155 const TObject *objn = fTasks->FindObject(name); 156 const TObject *objt = fTasks->FindObject(task); 151 157 152 158 if (objn || objt) … … 165 171 // Otherwise add it to the list, but print a warning message 166 172 // 167 *fLog << dbginf << "Warning: Task with the same name'" << task->GetName();173 *fLog << dbginf << "Warning: Task '" << task->GetName(); 168 174 *fLog << "' already existing in '" << GetName() << "'." << endl; 169 175 *fLog << "You may not be able to get a pointer to this task by name." << endl; … … 172 178 if (where) 173 179 { 174 if (!fTasks .FindObject(where))180 if (!fTasks->FindObject(where)) 175 181 { 176 182 *fLog << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl; … … 182 188 183 189 task->SetStreamId(type); 184 fTasks .Add(task);190 fTasks->Add(task); 185 191 186 192 *fLog << "Done." << endl; … … 196 202 TObject *MTaskList::FindObject(const char *name) const 197 203 { 198 return fTasks .FindObject(name);204 return fTasks->FindObject(name); 199 205 } 200 206 … … 205 211 TObject *MTaskList::FindObject(TObject *obj) const 206 212 { 207 return fTasks .FindObject(obj);213 return fTasks->FindObject(obj); 208 214 } 209 215 … … 221 227 // create the Iterator over the tasklist 222 228 // 223 TIter Next( &fTasks);229 TIter Next(fTasks); 224 230 225 231 MTask *task=NULL; … … 260 266 // create the Iterator for the TaskList 261 267 // 262 TIter Next( &fTasks);268 TIter Next(fTasks); 263 269 MTask *task=NULL; 264 270 … … 271 277 // if the task has the wrong stream id skip it. 272 278 // 273 if ( strcmp(GetStreamId(), task->GetStreamId()) &&274 strcmp(task->GetStreamId(), "All"))279 if (GetStreamId() != task->GetStreamId() && 280 task->GetStreamId() != "All") 275 281 continue; 276 282 … … 331 337 // create the Iterator for the TaskList 332 338 // 333 TIter Next( &fTasks);339 TIter Next(fTasks); 334 340 335 341 MTask *task=NULL; … … 377 383 // create the Iterator for the TaskList 378 384 // 379 TIter Next( &fTasks);385 TIter Next(fTasks); 380 386 381 387 MTask *task=NULL; … … 396 402 *fLog << "TaskList: " << GetName() << " <" << GetTitle() << ">" << endl; 397 403 398 fTasks .Print();404 fTasks->Print(); 399 405 400 406 *fLog << endl; -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r988 r1003 10 10 /////////////////////////////////////////////////////////////////////// 11 11 12 #ifndef ROOT_TOrdCollection13 #include <TOrdCollection.h>14 #endif15 12 #ifndef MTASK_H 16 13 #include "MTask.h" … … 24 21 { 25 22 private: 26 TOrdCollection fTasks; // Container for the ordered list of different tasks27 MParList *fParList;23 TOrdCollection *fTasks; // Container for the ordered list of different tasks 24 MParList *fParList; 28 25 29 26 UInt_t *fCntContinue; … … 53 50 void SetOwner(Bool_t enable=kTRUE); 54 51 52 const TOrdCollection *GetList() const { return fTasks; } 53 55 54 ClassDef(MTaskList, 0) //collection of tasks to be performed in the eventloop 56 55 }; -
trunk/MagicSoft/Mars/mbase/MTime.h
r986 r1003 24 24 MTime(const char *name=NULL, const char *title=NULL) 25 25 { 26 *fName = name ? name : ClassName();27 *fTitle = title;26 fName = name ? name : ClassName(); 27 fTitle = title; 28 28 29 SetTime(0, 0);29 SetTime(0, 0); 30 30 } 31 31 -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r858 r1003 59 59 : fOut(NULL), fContainer(NULL) 60 60 { 61 *fName = name ? name : "MWriteAsciiFile";62 *fTitle = title ? title : "Task to write one container to an ascii file";61 fName = name ? name : "MWriteAsciiFile"; 62 fTitle = title ? title : "Task to write one container to an ascii file"; 63 63 64 64 fNameFile = filename; … … 77 77 : fOut(NULL), fContainer(cont) 78 78 { 79 *fName = name ? name : "MWriteAsciiFile";80 *fTitle = title ? title : "Task to write one container to an ascii file";79 fName = name ? name : "MWriteAsciiFile"; 80 fTitle = title ? title : "Task to write one container to an ascii file"; 81 81 82 82 fNameFile = filename; -
trunk/MagicSoft/Mars/mbase/MWriteRootFile.cc
r995 r1003 46 46 ClassImp(MWriteRootFile); 47 47 48 #define k SaveNowBIT(1)48 #define kFillTree BIT(1) 49 49 50 50 // -------------------------------------------------------------------------- … … 62 62 const char *title) 63 63 { 64 *fName = name ? name : "MWriteRootFile";65 *fTitle = title ? title : "Task which writes a root-output file";64 fName = name ? name : "MWriteRootFile"; 65 fTitle = title ? title : "Task which writes a root-output file"; 66 66 67 67 // … … 113 113 114 114 TTree *t; 115 T ObjArrayIter Next(&fTrees);115 TIter Next(&fTrees); 116 116 while ((t=(TTree*)Next())) 117 117 cout << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl; … … 177 177 // loop over all branches which are 'marked' as branches to get written. 178 178 // 179 T ObjArrayIter Next(&fBranches);179 TIter Next(&fBranches); 180 180 while ((entry=(MRootFileBranch*)Next())) 181 181 { … … 244 244 // 245 245 TObject *obj; 246 T ObjArrayIter NextTree(&fTrees);246 TIter NextTree(&fTrees); 247 247 while ((obj=NextTree())) 248 248 { … … 270 270 // The containers should be written in Splitlevel=1 271 271 // 272 branch = tree->Branch(cname, cont->ClassName(), entry->GetAddress() , 32000, 1);272 branch = tree->Branch(cname, cont->ClassName(), entry->GetAddress()); 273 273 274 274 *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl; … … 302 302 // Loop over all branch entries 303 303 // 304 T ObjArrayIter NextBranch(&fBranches);304 TIter NextBranch(&fBranches); 305 305 while ((obj=NextBranch())) 306 306 { … … 317 317 // the corresponding tree entry. 318 318 // 319 b->GetTree()->SetBit(k SaveNow);319 b->GetTree()->SetBit(kFillTree); 320 320 } 321 321 … … 323 323 // Loop over all tree entries 324 324 // 325 T ObjArrayIter NextTree(&fTrees);325 TIter NextTree(&fTrees); 326 326 while ((obj=NextTree())) 327 327 { … … 331 331 // Check the write flag of the tree 332 332 // 333 if (!t->TestBit(k SaveNow))333 if (!t->TestBit(kFillTree)) 334 334 continue; 335 335 … … 340 340 // 341 341 t->Fill(); 342 t->ResetBit(k SaveNow);342 t->ResetBit(kFillTree); 343 343 } 344 344 } -
trunk/MagicSoft/Mars/mgui/MGeomCam.cc
r986 r1003 52 52 : fNumPixels(npix) 53 53 { 54 *fName = name ? name : "MGeomCam";55 *fTitle = title ? title : "Storage container for a camera geometry";54 fName = name ? name : "MGeomCam"; 55 fTitle = title ? title : "Storage container for a camera geometry"; 56 56 57 57 fPixels = new TObjArray(npix); -
trunk/MagicSoft/Mars/mhist/MH.cc
r888 r1003 40 40 #include "MH.h" 41 41 42 #include <TCanvas.h> 43 42 44 ClassImp(MH); 43 45 … … 52 54 // set the name and title of this object 53 55 // 54 *fName = name ? name : "MH" ;55 *fTitle = title ? title : "Base class for Mars histograms" ;56 fName = name ? name : "MH" ; 57 fTitle = title ? title : "Base class for Mars histograms" ; 56 58 } 57 59 60 TCanvas *MH::MakeDefCanvas(const char *name, const char *title, 61 const UInt_t w, const UInt_t h) 62 { 63 const TList *list = (TList*)gROOT->GetListOfCanvases(); 64 65 const char *def = name ? name : gROOT->GetDefCanvasName(); 66 67 TCanvas *c; 68 if (list->FindObject(def)) 69 { 70 const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1)); 71 c = new TCanvas(n, title, w, h); 72 delete [] n; 73 } 74 else 75 c = new TCanvas(def, title, w, h); 76 77 return c; 78 } 79 80 TCanvas *MH::MakeDefCanvas(const TObject *obj, 81 const UInt_t w, const UInt_t h) 82 { 83 return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h); 84 }
Note:
See TracChangeset
for help on using the changeset viewer.