Changeset 3153 for trunk/MagicSoft/Mars/mhbase
- Timestamp:
- 02/15/04 13:54:08 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhbase/MH.cc
r3152 r3153 1116 1116 if (!h1) 1117 1117 { 1118 h1 = new TH1I(name, title, nbins, min, max); 1119 h1->SetXTitle(""); 1120 h1->SetYTitle("Counts"); 1121 h1->SetDirectory(gROOT); 1122 } 1123 1124 // Second loop to fill the histogram 1125 for (Int_t i=0;i<size;i++) 1126 h1->Fill(array[i]); 1127 1128 return h1; 1129 } 1130 1131 // -------------------------------------------------------------------------- 1132 // 1133 // M.Gaug added this withouz Documentation 1134 // 1135 TH1I* MH::ProjectArray(const TArrayD &array, Int_t nbins, const char* name, const char* title) 1136 { 1137 const Int_t size = array.GetSize(); 1138 TH1I *h1=0; 1139 1140 //check if histogram with identical name exist 1141 TObject *h1obj = gROOT->FindObject(name); 1142 if (h1obj && h1obj->InheritsFrom("TH1I")) 1143 { 1144 h1 = (TH1I*)h1obj; 1145 h1->Reset(); 1146 } 1147 1148 Double_t min = size>0 ? array[0] : 0; 1149 Double_t max = size>0 ? array[0] : 1; 1150 1151 // first loop over array to find the min and max 1152 for (Int_t i=1; i<size;i++) 1153 { 1154 max = TMath::Max(array[i], max); 1155 min = TMath::Min(array[i], min); 1156 } 1157 1158 Int_t newbins = 0; 1159 FindGoodLimits(nbins, newbins, min, max, kFALSE); 1160 1161 if (!h1) 1162 { 1118 1163 h1 = new TH1I(name, title, newbins, min, max); 1119 1164 h1->SetXTitle(""); … … 1129 1174 } 1130 1175 1131 // --------------------------------------------------------------------------1132 //1133 // M.Gaug added this withouz Documentation1134 //1135 TH1I* MH::ProjectArray(const TArrayD &array, Int_t nbins, const char* name, const char* title)1136 {1137 const Int_t size = array.GetSize();1138 TH1I *h1=0;1139 1140 //check if histogram with identical name exist1141 TObject *h1obj = gROOT->FindObject(name);1142 if (h1obj && h1obj->InheritsFrom("TH1I"))1143 {1144 h1 = (TH1I*)h1obj;1145 h1->Reset();1146 }1147 1148 Double_t min = size>0 ? array[0] : 0;1149 Double_t max = size>0 ? array[0] : 1;1150 1151 // first loop over array to find the min and max1152 for (Int_t i=1; i<size;i++)1153 {1154 max = TMath::Max(array[i], max);1155 min = TMath::Min(array[i], min);1156 }1157 1158 Int_t newbins = 0;1159 FindGoodLimits(nbins, newbins, min, max, kFALSE);1160 1161 if (!h1)1162 {1163 h1 = new TH1I(name, title, newbins, min, max);1164 h1->SetXTitle("");1165 h1->SetYTitle("Counts");1166 h1->SetDirectory(gROOT);1167 }1168 1169 // Second loop to fill the histogram1170 for (Int_t i=0;i<size;i++)1171 h1->Fill(array[i]);1172 1173 return h1;1174 }1175
Note:
See TracChangeset
for help on using the changeset viewer.