29static const uint32_t
NPED = 4;
67 "FADC Mode %d Pulse Integral Data Slot %u; Channel Number; FADC Units (Channels)",
mode, islot), 16, -0.5, 15.5,
71 "FADC Mode %d Pulse Time Data Slot %u; Channel Number; FADC Units (Channels)",
mode, islot), 16, -0.5, 15.5,
75 "FADC Mode %d Pulse Pedestal Data Slot %u; Channel Number; FADC Units (Channels)",
mode, islot), 16, -0.5, 15.5,
79 "FADC Mode %d Pulse Peak Data Slot %u; Channel Number; FADC Units (Channels)",
mode, islot), 16, -0.5, 15.5,
91 "FADC Mode %d Pulse Integral Data Slot %u Channel %u; FADC Units (Channels); Counts / 10 Channels",
mode, islot,
92 chan), 4096, 0, 40095);
96 "FADC Mode %d Pulse Time Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel",
mode, islot,
chan),
100 "FADC Mode %d Pulse Pedestal Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel",
mode, islot,
101 chan), 4096, 0, 4095);
104 "FADC Mode %d Pulse Peak Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel",
mode, islot,
chan),
110 for( uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++ )
112 Form(
"samples_npeak_%u", ipeak + 1));
117 Form(
"c_psamp_slot_%u_chan_%u", islot,
chan), 800, 800);
119 for( uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++ ) {
121 Form(
"c_psamp_npeak_%u_slot_%u_chan_%u", ipeak + 1, islot,
chan),
134 for( uint32_t raw_index = 0; raw_index <
NUMRAWEVENTS; raw_index++ ) {
140 for( uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++ ) {
142 Form(
"raw_samples_npeak_%u", ipeak + 1)));
147 hfile->
cd(
Form(
"/mode_%d_data/slot_%u/chan_%u/raw_samples_npeak_%u",
mode, islot,
chan, ipeak + 1));
148 for( uint32_t raw_index = 0; raw_index <
NUMRAWEVENTS; raw_index++ ) {
152 Form(
"g_psamp_npeak_%u_event_%u", ipeak + 1, raw_index));
169 Int_t crateNumber = 0;
175 if (fileLocation ==
"") {
176 cout <<
"\nEnter the location of the raw CODA file (raw or cache): ";
178 if (fileLocation !=
"raw" && fileLocation !=
"cache") {
179 cerr <<
"...Invalid entry\n";
183 if (runNumber == 0) {
184 cout <<
"\nEnter a Run Number (-1 to exit): ";
186 if (runNumber <= 0) {
187 cerr <<
"...Invalid entry\n" << endl;
192 cout <<
"\nEnter Number of Events to Analyze (-1 = All): ";
194 if (maxEvent <= 0 && maxEvent != -1) {
195 cerr <<
"...Invalid entry\n" << endl;
199 cout <<
"\nAll Events in Run " << runNumber <<
" Will be Analyzed" << endl;
201 if (spectrometer ==
"") {
202 cout <<
"\nEnter the Spectrometer Name (hms or shms): ";
204 if (spectrometer !=
"hms" && spectrometer !=
"shms") {
205 cerr <<
"...Invalid entry\n";
209 if (crateNumber == 0) {
210 cout <<
"\nEnter the Crate Number to be Analyzed: ";
212 if (crateNumber <= 0) {
213 cerr <<
"...Invalid entry\n";
219 if (fileLocation ==
"raw")
220 runFile = fileLocation+
"/";
221 if (fileLocation ==
"cache")
222 runFile = fileLocation+
"/";
223 if (spectrometer ==
"hms")
224 runFile +=
Form(
"hms_all_%05d.dat", runNumber);
225 if (spectrometer ==
"shms")
226 runFile +=
Form(
"shms_all_%05d.dat", runNumber);
227 rootFile =
Form(
"ROOTfiles/raw_fadc_%d.root", runNumber);
240 auto *debugfile =
new ofstream;
246 cerr <<
"ERROR: Cannot open CODA data" << endl;
247 cerr <<
"Perhaps you mistyped it" << endl;
248 cerr <<
"... exiting." << endl;
256 evdata->SetDebugFile(debugfile);
259 TROOT fadcana(
"tstfadcroot",
"Hall C analysis");
260 hfile =
new TFile(
"fadc_data.root",
"RECREATE",
"fadc module data");
263 uint32_t iievent = (maxEvent == -1) ? 1 : maxEvent;
265 for(uint32_t ievent = 0; ievent < iievent; ievent++) {
269 status = evdata->LoadEvent(datafile.
getEvBuffer());
270 if( status != CodaDecoder::HED_OK && status != CodaDecoder::HED_WARN ) {
271 cerr <<
"ERROR " << status <<
" while decoding event " << ievent
272 <<
". Exiting." << endl;
277 if (evdata->GetNumRaw(crateNumber, islot) != 0) {
279 dynamic_cast <Fadc250Module*
> (evdata->GetModule(crateNumber, islot));
280 if (fadc !=
nullptr) {
286 if (debugfile) *debugfile <<
"Channel " <<
chan <<
" is in FADC Mode " << fadc_mode << endl;
287 Bool_t raw_mode = ((fadc_mode == 1) || (fadc_mode == 8) || (fadc_mode == 10));
290 UInt_t num_fadc_events = fadc->GetNumFadcEvents(
chan);
292 UInt_t num_fadc_samples = 0;
294 num_fadc_samples = fadc->GetNumFadcSamples(
chan, ievent);
296 if (num_fadc_events > 0) {
299 for (
UInt_t jevent = 0; jevent < num_fadc_events; jevent++) {
302 if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0)
303 *debugfile <<
"FADC EMULATED PI DATA = " << fadc->GetEmulatedPulseIntegralData(
chan) << endl;
304 if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
306 *debugfile <<
"FADC PI DATA = " << fadc->GetPulseIntegralData(
chan, jevent) << endl;
307 *debugfile <<
"FADC PT DATA = " << fadc->GetPulseTimeData(
chan, jevent) << endl;
308 *debugfile <<
"FADC PPED DATA = " << fadc->GetPulsePedestalData(
chan, jevent) /
NPED << endl;
309 *debugfile <<
"FADC PPEAK DATA = " << fadc->GetPulsePeakData(
chan, jevent) << endl;
313 if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0)
315 else if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
316 if (fadc_mode != 8) {
325 if (fadc_mode != 8) {
335 if (raw_mode && num_fadc_samples > 0) {
337 if (debugfile) *debugfile <<
"NUM FADC SAMPLES = " << num_fadc_samples << endl;
340 for (uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++) {
341 if (uint32_t (num_fadc_events) == ipeak+1)
347 static_cast<Int_t>(sample_num), sample_num + 1,
353 for (uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++) {
354 if (num_fadc_events == ipeak+1) {
358 static_cast<Int_t>(sample_num), sample_num + 1,
372 if (debugfile) *debugfile <<
"FADC MODULE NOT FOUND!!!" << endl;
375 }
else if( status != EOF ) {
376 cerr <<
"ERROR " << status <<
" while reading CODA event " << ievent
377 <<
". Twonk." << endl;
380 if (ievent % 1000 == 0 && ievent != 0)
381 cout << ievent <<
" events have been processed" << endl;
382 if (maxEvent == -1) iievent++;
383 if (status == EOF)
break;
388 for(uint32_t islot = 3; islot <
NUMSLOTS; islot++) {
390 for( uint32_t raw_index = 0; raw_index <
NUMRAWEVENTS; raw_index++) {
393 Color_t rand_int = 1 + rand->Integer(9);
415 for (uint32_t ipeak = 0; ipeak <
NPEAK; ipeak++) {
416 for( uint32_t raw_index = 0; raw_index <
NUMRAWEVENTS; raw_index++) {
419 Color_t rand_int = 1 + rand->Integer(9);
452 printf (
"The analysis took %.1f seconds \n", ((
float) t) / CLOCKS_PER_SEC);
453 printf (
"The analysis event rate is %.1f Hz \n", (iievent - 1) / (((
float) t) / CLOCKS_PER_SEC));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char mode
char * Form(const char *fmt,...)
virtual Int_t GetFadcMode() const
virtual Int_t getCodaVersion()
virtual Int_t codaOpen(const char *filename, Int_t mode=1)
virtual Int_t codaClose()
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
TVirtualPad * cd(Int_t subpadnumber=0) override
T * Get(const char *namecycle)
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
virtual TObject * Get(const char *namecycle)
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override
void Close(Option_t *option="") override
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
void SetTitle(const char *title="") override
virtual Int_t Fill(const char *name, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual void Add(TGraph *graph, Option_t *chopt="")
void Draw(Option_t *chopt="") override
virtual void SetTitle(const char *title="")
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual void SetDrawOption(Option_t *option="")
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
double sum_of_elements(const LASymMatrix &)
TH1I * h_pped[NUMSLOTS][NADCCHAN]
TH2I * h2_ppeak[NUMSLOTS]
TMultiGraph * mg_psamp[NUMSLOTS][NADCCHAN]
TGraph * g_psamp_event[NUMSLOTS][NADCCHAN][NUMRAWEVENTS]
TH2I * h2_ptime[NUMSLOTS]
UInt_t SumVectorElements(const vector< uint32_t > &data_vector)
static const uint32_t NPED
TH1I * h_ppeak[NUMSLOTS][NADCCHAN]
TGraph * g_psamp_npeak_event[NUMSLOTS][NADCCHAN][NPEAK][NUMRAWEVENTS]
uint32_t raw_samp_npeak_index[NUMSLOTS][NADCCHAN][NPEAK]
static const uint32_t NPEAK
TH1I * h_ptime[NUMSLOTS][NADCCHAN]
TCanvas * c_psamp_npeak[NUMSLOTS][NADCCHAN][NPEAK]
uint32_t raw_samp_index[NUMSLOTS][NADCCHAN]
TDirectory * chan_dir[NADCCHAN]
void GeneratePlots(Int_t mode, uint32_t islot, uint32_t chan)
TDirectory * slot_dir[NUMSLOTS]
static const uint32_t NUMSLOTS
TH1I * h_pinteg[NUMSLOTS][NADCCHAN]
TDirectory * raw_samples_dir[NADCCHAN]
TCanvas * c_psamp[NUMSLOTS][NADCCHAN]
static const uint32_t NADCCHAN
TH2I * h2_pinteg[NUMSLOTS]
TDirectory * raw_samples_npeak_dir[NADCCHAN][NPEAK]
static const uint32_t SLOTMIN
TMultiGraph * mg_psamp_npeak[NUMSLOTS][NADCCHAN][NPEAK]
vector< uint32_t > raw_samples_npeak_vector[NUMSLOTS][NADCCHAN][NPEAK]
static int fadc_mode_const
static const uint32_t NUMRAWEVENTS
vector< uint32_t > raw_samples_vector[NUMSLOTS][NADCCHAN]