Changeset 14952
- Timestamp:
- 02/24/13 11:07:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/Sample.C
r14951 r14952 198 198 Sample::BootstrapTH1(TH1* inputHisto, TH1* outHisto) 199 199 { 200 //reset outHisto in case it is reused 200 201 outHisto->Reset(); 201 202 202 //compute the medianfor 1-d histogram h1203 //compute number of bins for 1-d histogram h1 203 204 int nbins = inputHisto->GetXaxis()->GetNbins(); 204 205 … … 206 207 //we need to get the binning 207 208 208 // entries of TH1209 //vector to contain entries of TH1 209 210 vector<double> entries; 210 211 211 212 //quantity of entries in bin 212 int quantity = 0; 213 double value = 0; 213 int quantity = 0; //number of entries in a bin 214 double value = 0; //value of a bin 215 216 //Loop over bins to fill entries vektor 214 217 for (int i=0;i<nbins;i++) 215 218 { 216 219 value = inputHisto->GetBinLowEdge(i); 217 220 quantity = inputHisto->GetBinContent(i); 221 //Loop over bin quantities 218 222 for (int j = 0; j < quantity; j++) 219 223 { 224 // fill entries vektor with value of a bin 225 // as many times as the bin has entries 220 226 entries.push_back(value); 221 227 } … … 230 236 vector<int> entryID (sampleSize,0); 231 237 232 //calculate a list with random EntryIDs and fill it into entryID 238 //calculate a list with random int numbers between 0 ad sampleSize 239 // and fill it into entryID vector 233 240 BootstrapSample(&entryID, 0, sampleSize, sampleSize ); 234 241 … … 237 244 for ( unsigned int i = 0 ; i < entryID.size(); i++ ) 238 245 { 246 //fill values pulled from entries vektor into outHisto 239 247 outHisto->Fill( 240 248 entries.at( entryID.at(i) ) … … 243 251 } 244 252 253 //return the nummber of filled entries 245 254 return counter + 1; 246 255 }
Note:
See TracChangeset
for help on using the changeset viewer.