Changeset 3081 for trunk/MagicSoft/Mars/mhbase/MH.cc
- Timestamp:
- 02/10/04 16:10:52 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r2858 r3081 1081 1081 return NULL; 1082 1082 } 1083 1084 TH1I* MH::ProjectArray(const TArrayF *array, Int_t nbins, const char* name, const char* title) 1085 { 1086 1087 const Int_t size = array->GetSize(); 1088 TH1I *h1=0; 1089 1090 //check if histogram with identical name exist 1091 TObject *h1obj = gROOT->FindObject(name); 1092 if (h1obj && h1obj->InheritsFrom("TH1I")) { 1093 h1 = (TH1I*)h1obj; 1094 h1->Reset(); 1095 } 1096 1097 Double_t max = 0.; 1098 Double_t min = 0.; 1099 Int_t newbins = 0; 1100 1101 // first loop over array to find the maximum: 1102 for (Int_t i=0; i<size;i++) 1103 if (array->At(i) > max) 1104 max = array->At(i); 1105 1106 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1107 1108 if (!h1) 1109 { 1110 h1 = new TH1I(name, title, newbins, min, max); 1111 h1->SetXTitle(""); 1112 h1->SetYTitle("Counts"); 1113 h1->SetDirectory(NULL); 1114 } 1115 1116 // Second loop to fill the histogram 1117 for (Int_t i=0;i<size;i++) 1118 h1->Fill(array->At(i)); 1119 1120 h1->SetEntries(size); 1121 1122 return h1; 1123 } 1124 1125 TH1I* MH::ProjectArray(const TArrayD *array, Int_t nbins, const char* name, const char* title) 1126 { 1127 1128 const Int_t size = array->GetSize(); 1129 1130 TH1I *h1=0; 1131 1132 //check if histogram with identical name exist 1133 TObject *h1obj = gROOT->FindObject(name); 1134 if (h1obj && h1obj->InheritsFrom("TH1I")) { 1135 h1 = (TH1I*)h1obj; 1136 h1->Reset(); 1137 } 1138 1139 Double_t max = 0.; 1140 Double_t min = 0.; 1141 Int_t newbins = 0; 1142 1143 // first loop over array to find the maximum: 1144 for (Int_t i=0; i<size;i++) 1145 if (array->At(i) > max) 1146 max = array->At(i); 1147 1148 FindGoodLimits( nbins, newbins, min, max, kFALSE); 1149 1150 if (!h1) 1151 { 1152 h1 = new TH1I(name, title, newbins, min, max); 1153 h1->SetXTitle(""); 1154 h1->SetYTitle("Counts"); 1155 h1->SetDirectory(NULL); 1156 } 1157 1158 // Second loop to fill the histogram 1159 for (Int_t i=0;i<size;i++) 1160 h1->Fill(array->At(i)); 1161 1162 h1->SetEntries(size); 1163 1164 return h1; 1165 } 1166
Note:
See TracChangeset
for help on using the changeset viewer.