/********************************************************************\ rootread.cc Reads rawfile created by the CTX DAQ. Run using '.x rootread.cc++(Filename)'. Generate shared library using make, then load library in root with gSystem->Load("RawDataCTX.so") Oliver Grimm \********************************************************************/ #include #include #include #include #include #include #include "../../drsdaq/RawDataCTX.h" void rootread(char* Filename) { #ifdef __CINT__ printf("Error: This script can only be executed via ACliC\n"); return; #endif RawDataCTX *RD = new RawDataCTX(); // Open data file and read run header if (RD->OpenDataFile(Filename, NULL) != CTX_OK) { delete RD; return; } // ...for convenience some abbrevations unsigned int Boards = RD->RHeader->NBoards; unsigned int Channels = RD->RHeader->NChips*RD->RHeader->NChannels; unsigned int Samples = RD->RHeader->Samples; // Allocate histograms and legends TH1F* h = new TH1F [Boards*Channels]; TLegend* Legend = new TLegend [Boards]; // Create a canvas TCanvas* CW = new TCanvas("CW","DRS Waveform",10,10,700,200*Boards); CW->Divide(1, Boards); // Initialise histograms and legends for (unsigned int i=0; iSetTitle(Form("Time slice (%.1f ns/slice)", 1./RD->BStruct[i].NomFreq)); h[i*Channels].GetYaxis()->SetTitle("Amplitude (a.u.)"); Legend[i].SetX1NDC(0.91); Legend[i].SetY1NDC(0.40); Legend[i].SetX2NDC(0.98); Legend[i].SetY2NDC(0.90); Legend[i].SetFillColor(0); Legend[i].SetLineColor(0); Legend[i].SetBorderSize(0); Legend[i].SetTextSize(0.03); Legend[i].SetHeader(Form("Board %d",i)); } // Read and display all events while (RD->ReadEvent(0, stdout) == CTX_OK) { int *TrigPnt = (int *) RD->Data; short *DataPnt = (short *) RD->Data + Boards*RD->RHeader->NChips*sizeof(int); printf("Trigger cells: "); for(unsigned int i=0; iRHeader->NChips; i++) printf("%d ", *(TrigPnt + i)); printf("\n"); for(unsigned int k=0; kBStruct[k].ScaleFactor); } CW->cd(k+1); gPad->SetGrid(); for (unsigned int j=0; j0 ? "same":""); Legend[k].Draw(); CW->Update(); } // Process gui events asynchronously during input TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); timer.TurnOn(); TString input = Getline("Type 'q' to exit, to go on: "); timer.TurnOff(); if (input=="q\n") break; } delete CW; delete[] Legend; delete[] h; delete RD; }