source: fact/tools/rootmacros/PulseTemplates/SaveToCsv.C@ 13604

Last change on this file since 13604 was 13465, checked in by Jens Buss, 13 years ago
initial commit
File size: 2.3 KB
Line 
1//////////////////////////////////////////////////////////////
2//Functions for FPulsetemplate to write template Pulse to csv
3//////////////////////////////////////////////////////////////
4
5#include "SaveToCsv.h"
6#include <TROOT.h>
7#include <TH1F.h>
8#include <TString.h>
9
10TString
11BuildPath(
12 TString path,
13 const char* csv_file_name,
14 int pixel
15 )
16{
17 path += csv_file_name;
18 path += "_";
19
20 if (pixel = -1)
21 path += "AllPixel";
22 else
23 path += pixel;
24 path += ".csv";
25
26 return path;
27}
28
29
30void
31WritePixelTemplateToCsv(
32 TH1* phInputHistogram,
33 TString path,
34 const char* csv_file_name,
35 const char* overlay_method,
36 int pixel,
37 int verbosityLevel
38 )
39{
40 path = BuildPath(path, csv_file_name, pixel); //if want to write ALL pixel= -1
41
42 Int_t nbins = phInputHistogram->GetXaxis()->GetNbins();
43
44 if (verbosityLevel > 0)
45 {
46 cout << "writing point-set to csv file: " ;
47 cout << path << endl;
48 cout << "...opening file" << endl;
49 }
50 if (verbosityLevel > 2) cout << "...number of bins " << nbins << endl;
51
52 ofstream out;
53 out.open( path );
54
55 out << "### point-set of a single photon pulse template" << endl
56 << "### template determined with pulse overlay at: "
57 << overlay_method;
58 if ( pixel = -1 )
59 out << "of all Pixels";
60 else
61 out << endl;
62 out << "### Slice's Amplitude determined by calculating the " << endl
63 << "### value of maximum propability of slice -> Amplitude1 " << endl
64 << "### mean of slice -> Amplitude2 " << endl
65 << "### median of slice -> Amplitude3 " << endl
66 << "### for each slice" << endl
67 << "### Pixel number (CHid): " << pixel << endl
68 << endl
69 << "time [slices],Amplitude1 [mV],Amplitude2 [mV],Amplitude3 [mV]" << endl;
70
71 for (int TimeSlice=1;TimeSlice<=nbins;TimeSlice++)
72 {
73 out << TimeSlice
74 << "," << phInputHistogram->GetBinContent(TimeSlice);
75// << "," << hPixelMean[0]->GetBinContent(TimeSlice);
76// << "," << hPixelMedian[0]->GetBinContent(TimeSlice) << endl;
77 }
78
79 out.close();
80 if (verbosityLevel > 0) cout << "...file closed" << endl;
81}
82
Note: See TracBrowser for help on using the repository browser.