Changeset 1408
- Timestamp:
- 07/16/02 11:00:32 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1407 r1408 1 1 -*-*- END -*-*- 2 3 2002/07/16: Thomas Bretz 4 5 * mgui/MHexagon.cc: 6 - added a sanity check in DistanceToPrimitive 7 8 * mgui/MCamDisplay.[h,cc]: 9 - added DistanceToPrimitive 10 - declared virtual functions as virtual (easier to read in the Dox) 11 12 * mfileio/MWriteAsciiFile.[h,cc]: 13 - renamed AddContainer and AddRule to AddColumn and AddColumns 14 15 * macros/MagicHillas.C: 16 - adopted to new names of MWriteAsciiFile member functions 17 18 2 19 3 20 2002/07/15: Abelardo Moralejo … … 5 22 * manalysis/MCerPhotCalc2.[h,cc] 6 23 - converted fWeight into a static variable. 24 25 7 26 8 27 2002/07/11: Thomas Bretz -
trunk/MagicSoft/Mars/NEWS
r1401 r1408 38 38 CT1 camera (a pixel 127 doesn't exist and the pixel 126 didn't 39 39 have any neighbour) 40 41 - Calls to MWriteAsciiFile::AddContainer and MWriteAsciiFile::AddRule 42 must be replaced by calles to MWriteAsciiFile::AddColumn and 43 MWriteAsciiFile::AddColumns. Be carefull, the arguments have slightly 44 changed. 40 45 41 46 -
trunk/MagicSoft/Mars/macros/MagicHillas.C
r1395 r1408 113 113 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc"); 114 114 115 MWriteRootFile write("hillas.root"); 116 write.AddContainer("MHillas", "Hillas"); 117 write.AddContainer("HillasSource", "Hillas"); 118 write.AddContainer("HillasAntiSrc", "Hillas"); 119 write.AddContainer("MHStarMap"); 120 write.AddContainer("MMcEvt","Hillas"); 115 /* 116 MWriteRootFile write("hillas.root"); 117 write.AddContainer("MHillas", "Hillas"); 118 write.AddContainer("HillasSource", "Hillas"); 119 write.AddContainer("HillasAntiSrc", "Hillas"); 120 write.AddContainer("MMcEvt", "Hillas"); 121 write.AddContainer("MHStarMap"); 121 122 122 123 /*124 123 MWriteAsciiFile write("hillas.txt"); 125 write.AddCo ntainer("MHillas", "fLength");126 write.AddCo ntainer("MHillas", "fConc");127 write.AddCo ntainer("MHillas");124 write.AddColumn("MHillas.fLength*MGeomCam.fConvMm2Deg"); 125 write.AddColumn("MHillas", "fConc"); 126 write.AddColumns("MHillas"); 128 127 */ 129 128 … … 141 140 tlist.AddToList(&hfill2s); 142 141 tlist.AddToList(&hfill2a); 143 tlist.AddToList(&write);144 142 145 143 // … … 159 157 // 160 158 // After the analysis is finished we can display the histograms 161 // 159 162 160 plist.FindObject("MHHillas")->DrawClone(); 163 161 plist.FindObject("HistSource")->DrawClone(); -
trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
r1381 r1408 95 95 96 96 if (contname) 97 AddCo ntainer(contname);97 AddColumns(contname); 98 98 } 99 99 … … 115 115 116 116 if (cont) 117 AddCo ntainer(cont);117 AddColumns(cont); 118 118 } 119 119 … … 140 140 // -------------------------------------------------------------------------- 141 141 // 142 // Tries to get all containers from the ParList which were given by name 143 // adds them to the list of pointers to the container which should be 144 // written to the ascii file. 145 // 146 Bool_t MWriteAsciiFile::GetContainer(MParList *plist) 147 { 148 TObject *obj=NULL; 149 150 TIter Next(&fList); 151 while ((obj=Next())) 152 { 153 // 154 // MData is the highest class in the inheritance tree 155 // 156 if (obj->InheritsFrom(MData::Class())) 157 { 158 if (!((MData*)obj)->PreProcess(plist)) 159 return kFALSE; 160 continue; 161 } 162 163 // 164 // MParContainer is the next class in the inheritance tree 165 // 166 if (obj->InheritsFrom(MParContainer::Class())) 167 continue; 168 169 // 170 // It is neither a MData nor a MParContainer, it must be a TNamed 171 // 172 TObject *o = plist->FindObject(obj->GetName()); 173 if (!o) 174 return kFALSE; 175 176 fList[fList.IndexOf(obj)] = o; 177 } 178 return kTRUE; 179 } 180 181 // -------------------------------------------------------------------------- 182 // 183 // Check if the containers are ready for writing. If so write them. 184 // The containers are written in one line, one after each other. 185 // If not all containers are written (because of the IsReadyToSave-flag) 186 // a warning message is print. 187 // 188 void MWriteAsciiFile::CheckAndWrite() const 189 { 190 Bool_t written = kFALSE; 191 192 MParContainer *obj = NULL; 193 194 Int_t num = fList.GetEntries(); 195 196 TIter Next(&fList); 197 while ((obj=(MParContainer*)Next())) 198 { 199 if (!obj->IsReadyToSave()) 200 continue; 201 202 if (!obj->AsciiWrite(*fOut)) 203 continue; 204 205 written = kTRUE; 206 207 num--; 208 } 209 210 if (!written) 211 return; 212 213 *fOut << endl; 214 215 if (num!=0) 216 *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl; 217 } 218 219 // -------------------------------------------------------------------------- 220 // 142 221 // Add a rule to be written as a column to the ascii file. 143 222 // For more information about rules see MDataChain. 144 223 // 145 void MWriteAsciiFile::AddRule(const char *rule) 224 // eg: MWriteAsciiFile::AddColumn("log10(MHillas.fEnergy)/2") 225 // 226 void MWriteAsciiFile::AddColumn(const TString rule) 146 227 { 147 228 MDataChain *chain = new MDataChain(rule); … … 151 232 // -------------------------------------------------------------------------- 152 233 // 153 // Add another container (by pointer) to be written to the ascii file. 154 // The container will be output one after each other in one line. 155 // If you want to write only one data member of the container 156 // specify the name of the data member (eg. fAlpha) Make sure, 157 // that a "GetteMethod" for this data type exists (strip the f and 158 // replace it by Get) 159 // If you specify a single data member you can add a scale-factor which 160 // is (in case of the data member being a floating point value) multiplied 161 // with the data member value. This is usefull if you are want to 162 // change the scale (unit) of a data member for writing (eg. 163 // writing degrees for the hillas parameters instead of the internally 164 // used millimeters) 165 // 166 void MWriteAsciiFile::AddContainer(MParContainer *cont, const TString member, Double_t scale) 167 { 168 if (member.IsNull()) 169 { 170 fList.Add(cont); 171 return; 172 } 173 234 // Add another column to be written to the ascii file. The columns will be 235 // output one after each other in one line. 236 // Specify the name of the data member to be written (eg fWidth) and 237 // a possible scale factor (eg. to transform millimeters to degrees) 238 // 239 // eg: 240 // MMcEvt evt; 241 // MWriteAsciiFile::AddColumn(&evt, "fImpact", 0.01); 242 // 243 void MWriteAsciiFile::AddColumn(MParContainer *cont, const TString member, Double_t scale) 244 { 174 245 MData *data = new MDataMember(cont, member); 175 246 … … 193 264 // Add another container (by name) to be written to the ascii file. 194 265 // The container will be output one after each other in one line. 195 // If you want to write only one data member of the container 196 // specify the name of the data member (eg. fAlpha) Make sure, 197 // that a "GetteMethod" for this data type exists (strip the f and 198 // replace it by Get) 199 // If you specify a single data member you can add a scale-factor which 200 // is (in case of the data member being a floating point value) multiplied 201 // with the data member value. This is usefull if you are want to 202 // change the scale (unit) of a data member for writing (eg. 203 // writing degrees for the hillas parameters instead of the internally 204 // used millimeters) 205 // 206 void MWriteAsciiFile::AddContainer(const TString cont, const TString member, Double_t scale) 207 { 208 if (member.IsNull()) 209 { 210 TNamed *name = new TNamed(cont, cont); 211 fList.Add(name); 212 fAutoDel.Add(name); 213 return; 214 } 215 216 MData *data = new MDataMember(Form("%s.%s", (const char*)cont, (const char*)member)); 217 if (scale!=1) 218 { 219 MDataList *list = new MDataList('*'); 220 MDataValue *val = new MDataValue(scale); 221 222 list->SetOwner(); 223 list->AddToList(data); 224 list->AddToList(val); 225 226 data = list; 227 } 228 fList.Add(data); 229 fAutoDel.Add(data); 230 } 231 232 // -------------------------------------------------------------------------- 233 // 234 // Tries to get all containers from the ParList which were given by name 235 // adds them to the list of pointers to the container which should be 236 // written to the ascii file. 237 // 238 Bool_t MWriteAsciiFile::GetContainer(MParList *plist) 239 { 240 TObject *obj=NULL; 241 242 TIter Next(&fList); 243 while ((obj=Next())) 244 { 245 // 246 // MData is the highest class in the inheritance tree 247 // 248 if (obj->InheritsFrom(MData::Class())) 249 { 250 if (!((MData*)obj)->PreProcess(plist)) 251 return kFALSE; 252 continue; 253 } 254 255 // 256 // MParContainer is the next class in the inheritance tree 257 // 258 if (obj->InheritsFrom(MParContainer::Class())) 259 continue; 260 261 // 262 // It is neither a MData nor a MParContainer, it must be a TNamed 263 // 264 TObject *o = plist->FindObject(obj->GetName()); 265 if (!o) 266 return kFALSE; 267 268 fList[fList.IndexOf(obj)] = o; 269 } 270 return kTRUE; 271 } 272 273 // -------------------------------------------------------------------------- 274 // 275 // Check if the containers are ready for writing. If so write them. 276 // The containers are written in one line, one after each other. 277 // If not all containers are written (because of the IsReadyToSave-flag) 278 // a warning message is print. 279 // 280 void MWriteAsciiFile::CheckAndWrite() const 281 { 282 Bool_t written = kFALSE; 283 284 MParContainer *obj = NULL; 285 286 Int_t num = fList.GetEntries(); 287 288 TIter Next(&fList); 289 while ((obj=(MParContainer*)Next())) 290 { 291 if (!obj->IsReadyToSave()) 292 continue; 293 294 if (!obj->AsciiWrite(*fOut)) 295 continue; 296 297 written = kTRUE; 298 299 num--; 300 } 301 302 if (!written) 303 return; 304 305 *fOut << endl; 306 307 if (num!=0) 308 *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl; 309 } 310 266 // The output will be done either by MParContainer::AsciiWrite or 267 // by the corresponding overloaded function. 268 // 269 // eg: MWriteAsciiFile::AddColumns("MMcEvt") 270 // 271 void MWriteAsciiFile::AddColumns(const TString cont) 272 { 273 TNamed *name = new TNamed(cont, cont); 274 fList.Add(name); 275 fAutoDel.Add(name); 276 } 277 278 // -------------------------------------------------------------------------- 279 // 280 // Add another container (by pointer) to be written to the ascii file. 281 // The container will be output one after each other in one line. 282 // The output will be done either by MParContainer::AsciiWrite or 283 // by the corresponding overloaded function. 284 // 285 // eg: 286 // MMcEvt evt; 287 // MWriteAsciiFile::AddColumns(&evt); 288 // 289 void MWriteAsciiFile::AddColumns(MParContainer *cont) 290 { 291 fList.Add(cont); 292 } -
trunk/MagicSoft/Mars/mfileio/MWriteAsciiFile.h
r1381 r1408 35 35 ~MWriteAsciiFile(); 36 36 37 void AddCo ntainer(const TString cname, const TString member="", Double_t scale=1);38 void AddCo ntainer(MParContainer *cont, const TString member="", Double_t scale=1);39 40 void Add Rule(const char *rule);37 void AddColumn(const TString rule); 38 void AddColumn(MParContainer *cont, const TString member="", Double_t scale=1); 39 void AddColumns(const TString name); 40 void AddColumns(MParContainer *cont); 41 41 42 42 ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
Note:
See TracChangeset
for help on using the changeset viewer.