Changeset 4991 for trunk/MagicSoft/Mars/mhbase/MH.cc
- Timestamp:
- 09/14/04 12:13:07 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r4966 r4991 1271 1271 const char* name, const char* title) 1272 1272 { 1273 const Int_t size = array.GetSize(); 1274 1275 TH1I *h1=0; 1276 1277 //check if histogram with identical name exist 1278 TObject *h1obj = gROOT->FindObject(name); 1279 if (h1obj && h1obj->InheritsFrom("TH1I")) 1280 { 1281 h1 = (TH1I*)h1obj; 1282 h1->Reset(); 1283 } 1284 1285 Double_t min = size>0 ? array[0] : 0; 1286 Double_t max = size>0 ? array[0] : 1; 1287 1288 // first loop over array to find the min and max 1289 for (Int_t i=1; i<size;i++) 1290 { 1291 max = TMath::Max((Double_t)array[i], max); 1292 min = TMath::Min((Double_t)array[i], min); 1293 } 1294 1295 Int_t newbins = 0; 1296 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1297 1298 if (!h1) 1299 { 1300 h1 = new TH1I(name, title, nbins, min, max); 1301 h1->SetXTitle(""); 1302 h1->SetYTitle("Counts"); 1303 h1->SetDirectory(gROOT); 1304 } 1305 1306 // Second loop to fill the histogram 1307 for (Int_t i=0;i<size;i++) 1308 h1->Fill(array[i]); 1309 1310 return h1; 1273 const TArrayF arr(array.GetSize(), array.GetArray()); 1274 return ProjectArray(array, nbins, name, title); 1311 1275 } 1312 1276 … … 1317 1281 TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title) 1318 1282 { 1319 const Int_t size = array.GetSize(); 1320 TH1I *h1=0; 1321 1322 //check if histogram with identical name exist 1323 TObject *h1obj = gROOT->FindObject(name); 1324 if (h1obj && h1obj->InheritsFrom("TH1I")) 1325 { 1326 h1 = (TH1I*)h1obj; 1327 h1->Reset(); 1328 } 1329 1330 Double_t min = size>0 ? array[0] : 0; 1331 Double_t max = size>0 ? array[0] : 1; 1332 1333 // first loop over array to find the min and max 1334 for (Int_t i=1; i<size;i++) 1335 { 1336 max = TMath::Max(array[i], max); 1337 min = TMath::Min(array[i], min); 1338 } 1339 1340 Int_t newbins = 0; 1341 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1342 1343 if (!h1) 1344 { 1345 h1 = new TH1I(name, title, newbins, min, max); 1346 h1->SetXTitle(""); 1347 h1->SetYTitle("Counts"); 1348 h1->SetDirectory(gROOT); 1349 } 1350 1351 // Second loop to fill the histogram 1352 for (Int_t i=0;i<size;i++) 1353 h1->Fill(array[i]); 1354 1355 return h1; 1356 } 1357 1283 const TArrayD arr(array.GetSize(), array.GetArray()); 1284 return ProjectArray(array, nbins, name, title); 1285 } 1286 1287 // -------------------------------------------------------------------------- 1288 // 1289 // See MTask::PrintSkipped 1290 // 1291 void MH::PrintSkipped(UInt_t n, const char *str) 1292 { 1293 *fLog << " " << setw(7) << n << " ("; 1294 *fLog << setw(3) << (int)(100.*n/GetNumExecutions()); 1295 *fLog << "%) Evts skipped: " << str << endl; 1296 }
Note:
See TracChangeset
for help on using the changeset viewer.