#include "TObject.h" // define the Scope class and make it inherit from TObject so that we can write // Scope to a ROOT file class Scope : public TObject { private: Int_t nentries; Double_t voltages[1024]; TBranch *b_voltagesI; TBranch *b_voltagesQ; TBranch *b_timestamps; public: Double_t NoisePower, RMSVoltage; void Print() const; void Read(); void GetNoisePower(); void Scope::Print() const { printf("Scope says hi\n");} void Scope::GetNoisePower(){ this->Read(); nentries = (Int_t)b_voltagesI->GetEntries(); printf("nentries is %d\n", nentries); // This works fine. b_voltagesI->SetAddress(voltages); // This does not work. TH1F *hvoltages = new TH1F("hvoltages", ("Scope Voltages;Volts;Counts"), 100, -0.5, 0.5); for (Int_t i=0;iGetEntry(i); // fill the histogram with the voltages for (Int_t j=0; j<1024; j++) hvoltages->Fill(voltages[j]); } //hvoltages->DrawCopy(); RMSVoltage = hvoltages->GetRMS(); delete hvoltages; // Noise power is RMS of histogram. In dBm/Hz: // With 4 MHz LPF at output, voltage gain of 5X, 1.e3 for W->mW: //NoisePower = 10.*log10(voltage_RMS*voltage_RMS*1.e3/25./50./4.e6); // Without LPF at output, 32 MHz BPF, voltage gain of 5X1.e3 for W->mW: NoisePower = 10.*log10(RMSVoltage*RMSVoltage*1.e3/25./50./32.8e6); printf("noise power at scope is %f dBm/Hz \n", NoisePower); } void Scope::Read(){ TFile *f = 0; TTree *T = 0; //int run(const char *fname = "Feb24-12-57-28_16bit.root") //int run(const char *fname = "Apr01-12-29-54_16bit.root") //int run(const char *fname = "Apr05-12-35-22_16bit.root") //int run(const char *fname = "Apr05-01-21-38_16bit.root") //int run(const char *fname = "Apr05-01-42-33_16bit.root") const char *fname = "Apr05-02-24-08_16bit.root"; // f_N = 100 MHz. no LPF. if (!(fname && *fname)) printf("oops\n"); // just a precaution if (T) {delete T; T = 0;} // make sure you delete it, if it already exists if (f) {delete f; f = 0;} // make sure you close the file, if it is opened //f = new TFile("Feb15-12-16-20_16bit.root", "READ"); f = new TFile(fname, "READ"); if (!f) return; // just a precaution T = (TTree *)f->FindObjectAny("T"); if (!T) printf("double oops\n"); // just a precaution b_voltagesI = T->GetBranch("voltages_chan1"); b_voltagesQ = T->GetBranch("voltages_chan2"); b_timestamps = T->GetBranch("timestamps"); #if 1 /* 0 or 1 */ if (T) {delete T; T = 0;} // make sure you delete it, if it already exists if (f) {delete f; f = 0;} // make sure you close the file, if it is opened #endif /* 0 or 1 */ } // Define the class for the cint dictionary ClassDef (Scope,1) }; // Call the ClassImp macro to give the ABC class RTTI and full I/O capabilities. #if !defined(__CINT__) ClassImp(Scope); #endif