Changeset 14534 for fact/tools/rootmacros/PulseTemplates
- Timestamp:
- 10/26/12 09:23:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/csv.C
r14480 r14534 17 17 mSuffix = suffix; 18 18 mVerbLevel = verbLevel; 19 mSeparator = ";"; 19 20 20 21 BuildPath(); … … 39 40 if (!mSuffix.IsNull()){ 40 41 41 if (mSuffix = -1)42 if (mSuffix.Contains("-1")) 42 43 mSuffix = "AllPixel"; 43 44 44 mSuffix. Append("_");45 mSuffix.Prepend("_"); 45 46 mPath.Append(mSuffix); 46 47 } … … 55 56 56 57 bool 57 Csv::WriteP ixelToCsv(58 Csv::WritePointSetToCsv( 58 59 Pixel* pixel, 59 60 TString overlayMethod, … … 67 68 } 68 69 69 WritePoint setExplain();70 71 WritePointSet ToCsv(70 WritePointSetHeader(); 71 72 WritePointSet( 72 73 pixel, 73 74 overlayMethod, … … 88 89 TH1F* Median_histo = NULL; 89 90 TH1F* Mean_histo = NULL; 91 int overlayPos = 0; 90 92 91 93 if (overlayMethod.Contains("Maximum")) … … 94 96 Median_histo = pixel->hPixelMedian[order]; 95 97 Mean_histo = pixel->hPixelMean[order]; 98 overlayPos = 1; 96 99 } 97 100 else if (overlayMethod.Contains("Edge")) … … 100 103 Median_histo = pixel->hPixelMedian[order]; 101 104 Mean_histo = pixel->hPixelMean[order]; 105 overlayPos = 2; 102 106 } 103 107 else 104 108 { 105 109 cout << endl << "Unknown Overlay Method-->aborting" << endl; 106 return 1;110 return ; 107 111 } 108 112 … … 117 121 if (mVerbLevel > 2) cout << "...number of bins " << nbins << endl; 118 122 123 //fill coulums 124 for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++) 125 { 126 mCsvFile << TimeSlice << mSeparator ; 127 mCsvFile << pixel->mChid << mSeparator ; 128 mCsvFile << order << mSeparator ; 129 mCsvFile << overlayPos << mSeparator ; 130 mCsvFile.precision(8); 131 mCsvFile << Max_histo->GetBinContent(TimeSlice) << mSeparator; 132 mCsvFile << Mean_histo->GetBinContent(TimeSlice) << mSeparator; 133 mCsvFile << Median_histo->GetBinContent(TimeSlice) << endl; 134 mCsvFile.precision(mPrecision); 135 } 136 137 return ; 138 } 139 140 void 141 Csv::WritePointSetHeader() 142 { 143 mCsvFile << "### point-set of a single photon pulse template" 144 << endl 145 << "### Slice's Amplitude determined by calculating the " 146 << endl 147 << "### value of maximum propability of slice -> AmplitudeMax " 148 << endl 149 << "### mean of slice -> AmplitudeMean " 150 << endl 151 << "### median of slice -> AmplitudeMedian " 152 << endl 153 << "### for each slice" 154 << endl 155 << "### " 156 << endl 157 << "### OverlayMethods (1) at Maximum, (2) at rising Edge" << endl; 158 119 159 //name coulums header 120 mCsvFile << "pixel [CHid]" << ","; 121 mCsvFile << "OverlayPosition" << ","; 122 mCsvFile << "AmplitudeMax [mV]" << ","; 123 mCsvFile << "AmplitudeMean [mV]" << ","; 160 mCsvFile << "TimeSlice [a.u.]" << mSeparator; 161 mCsvFile << "pixel [CHid]" << mSeparator; 162 mCsvFile << "Pulseorder [PhE]" << mSeparator; 163 mCsvFile << "OverlayPosition" << mSeparator; 164 mCsvFile << "AmplitudeMax [mV]" << mSeparator; 165 mCsvFile << "AmplitudeMean [mV]" << mSeparator; 124 166 mCsvFile << "AmplitudeMedian [mV]"; 125 167 mCsvFile << endl; 126 127 //fill coulums 128 for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++) 129 { 130 mCsvFile << pixel->mChid << "," ; 131 mCsvFile << overlayMethod << "," ; 132 mCsvFile << TimeSlice << "," ; 133 mCsvFile << Max_histo->GetBinContent(TimeSlice) << ","; 134 mCsvFile << Mean_histo->GetBinContent(TimeSlice) << ","; 135 mCsvFile << Median_histo->GetBinContent(TimeSlice) << endl; 136 } 137 return 0; 138 } 139 140 void 141 Csv::WritePointSetExplain() 142 { 143 mCsvFile << "### point-set of a single photon pulse template" 144 << endl; 145 << "### Slice's Amplitude determined by calculating the " 146 << endl 147 << "### value of maximum propability of slice -> AmplitudeMax " 148 << endl 149 << "### mean of slice -> AmplitudeMean " 150 << endl 151 << "### median of slice -> AmplitudeMedian " 152 << endl 153 << "### for each slice" 154 << endl 155 << "### " << endl; 156 } 157 168 } 169 170 void 171 Csv::WritePulseAttributesHeader() 172 { 173 //name coulums header 174 mCsvFile << "pixel [CHid]" << mSeparator; 175 mCsvFile << "OverlayPosition" << mSeparator; 176 mCsvFile << "ModelName" << mSeparator ; 177 mCsvFile << "Bsl" << mSeparator; 178 mCsvFile << "BslErr" << mSeparator; 179 mCsvFile << "Height" << mSeparator ; 180 mCsvFile << "HeightErr" << mSeparator ; 181 mCsvFile << "T0" << mSeparator ; 182 mCsvFile << "T0Err" << mSeparator ; 183 mCsvFile << "T1" << mSeparator ; 184 mCsvFile << "T1Err" << mSeparator ; 185 mCsvFile << "Tau1" << mSeparator ; 186 mCsvFile << "Tau1Err" << mSeparator ; 187 mCsvFile << "Tau2" << mSeparator ; 188 mCsvFile << "Tau2Err" << mSeparator ; 189 mCsvFile << "Integral" << mSeparator ; 190 mCsvFile << "IntegralErr" << mSeparator ; 191 mCsvFile << "Amplitude" << mSeparator ; 192 mCsvFile << "AmplitudeErr" << mSeparator ; 193 mCsvFile << "Phe" << mSeparator ; 194 mCsvFile << "PheErr" << mSeparator ; 195 mCsvFile << "Order" << mSeparator ; 196 mCsvFile << "Type" << mSeparator ; 197 mCsvFile << "FitProb" << mSeparator ; 198 mCsvFile << "FitNCalls" << mSeparator ; 199 mCsvFile << "FitNdf" << mSeparator ; 200 mCsvFile << "Chi2" ; 201 mCsvFile << endl; 202 } 158 203 void 159 204 Csv::WritePulseAttributes( 160 205 Pixel* pixel, 161 206 Pulse* pulse, 162 TString overlayMethod 207 TString overlayMethod, 208 int order 163 209 ) 164 210 { 165 //name coulums header 166 mCsvFile << "pixel [CHid]" << ","; 167 mCsvFile << "OverlayPosition" << ","; 168 mCsvFile << "ModelName" << "," ; 169 mCsvFile << "Bsl" << ","; 170 mCsvFile << "Height" << "," ; 171 mCsvFile << "T0" << "," ; 172 mCsvFile << "T1" << "," ; 173 mCsvFile << "Tau1" << "," ; 174 mCsvFile << "Tau2" << "," ; 175 mCsvFile << "Integral" << "," ; 176 mCsvFile << "Amplitude" << "," ; 177 mCsvFile << "PhE" << "," ; 178 mCsvFile << "Type" << "," ; 179 mCsvFile << "FitProb" << "," ; 180 mCsvFile << "FitNCalls" << "," ; 181 mCsvFile << "FitNdf" << "," ; 182 mCsvFile << "Chi2" ; 211 //fill coulums 212 mCsvFile << pixel->mChid << mSeparator ; 213 mCsvFile << overlayMethod << mSeparator ; 214 mCsvFile << pulse->GetName() << mSeparator ; 215 mCsvFile.precision(12); 216 mCsvFile << pulse->GetBsl() << mSeparator ; 217 mCsvFile << pulse->GetBslErr() << mSeparator ; 218 mCsvFile << pulse->GetHeight() << mSeparator ; 219 mCsvFile << pulse->GetHeightErr() << mSeparator ; 220 mCsvFile.precision(12); 221 mCsvFile << pulse->GetT0() << mSeparator ; 222 mCsvFile << pulse->GetT0Err() << mSeparator ; 223 mCsvFile << pulse->GetT1() << mSeparator ; 224 mCsvFile << pulse->GetT1Err() << mSeparator ; 225 mCsvFile << pulse->GetTau1() << mSeparator ; 226 mCsvFile << pulse->GetTau1Err() << mSeparator ; 227 mCsvFile << pulse->GetTau2() << mSeparator ; 228 mCsvFile << pulse->GetTau2Err() << mSeparator ; 229 mCsvFile.precision(8); 230 mCsvFile << pulse->GetIntegral() << mSeparator ; 231 mCsvFile << pulse->GetAmplitude() << mSeparator ; 232 mCsvFile.precision(2); 233 mCsvFile << pulse->GetPhE() << mSeparator ; 234 mCsvFile << pulse->GetPhEErr() << mSeparator ; 235 mCsvFile << order << mSeparator ; 236 mCsvFile << pulse->GetType() << mSeparator ; 237 mCsvFile << pulse->GetFitProb() << mSeparator ; 238 mCsvFile.precision(12); 239 mCsvFile << pulse->GetFitNCalls() << mSeparator ; 240 mCsvFile << pulse->GetFitNdf() << mSeparator ; 241 mCsvFile << pulse->GetChi2() << mSeparator ; 183 242 mCsvFile << endl; 184 185 //fill coulums 186 for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++) 187 { 188 mCsvFile << pixel->mChid << "," ; 189 mCsvFile << overlayMethod << "," ; 190 mCsvFile << pulse->GetName() << "," ; 191 mCsvFile << pulse->GetBsl() << "," ; 192 mCsvFile << pulse->GetHeight() << "," ; 193 mCsvFile << pulse->GetT0() << "," ; 194 mCsvFile << pulse->GetT1() << "," ; 195 mCsvFile << pulse->GetTau1() << "," ; 196 mCsvFile << pulse->GetTau2() << "," ; 197 mCsvFile << pulse->GetIntegral() << "," ; 198 mCsvFile << pulse->GetAmplitude() << "," ; 199 mCsvFile << pulse->GetPhE() << "," ; 200 mCsvFile << pulse->GetType() << "," ; 201 mCsvFile << pulse->GetFitProb() << "," ; 202 mCsvFile << pulse->GetFitNCalls() << "," ; 203 mCsvFile << pulse->GetFitNdf() << "," ; 204 mCsvFile << pulse->GetChi2() << "," ; 205 mCsvFile << endl; 206 } 243 mCsvFile.precision(mPrecision); 207 244 } 208 245 … … 211 248 if (mVerbLevel > 2) cout << "...opening csv file" << endl; 212 249 mCsvFile.open( mPath ); 250 mPrecision = mCsvFile.precision(); 213 251 } 214 252 … … 223 261 // =========================================================================== 224 262 225 void 263 TString 226 264 Csv::GetFilename(){ 227 265 return mFilename; 228 266 } 229 267 230 void 268 TString 231 269 Csv::GetPath(){ 232 270 return mPath;
Note:
See TracChangeset
for help on using the changeset viewer.