/******************************************************************* * * 2015/02/10 Kei Moriya * * Read out tree created by DF1TDCConfig plugin that contains * results of DF1TDCConfig objects. * *******************************************************************/ #include #include int getDF1TDCConfigInfo(std::string infilename = ""){ if(infilename == ""){ cout << "Usage: getDF1TDCConfigInfo.C([infile name])" << endl; abort(); } TFile *infile = new TFile(infilename.c_str()); // Tree and branches TTree *intree = (TTree*)infile->Get("DF1TDCConfig/DF1TDCConfigTree"); Int_t nDF1TDCConfig; const Int_t NMAX = 100; UInt_t rocid[NMAX]; UShort_t refcnt[NMAX]; UShort_t hsdiv[NMAX]; UShort_t refclkdiv[NMAX]; UShort_t binsize[NMAX]; intree->SetBranchAddress("nDF1TDCConfig",&nDF1TDCConfig); intree->SetBranchAddress("rocid",rocid); intree->SetBranchAddress("refcnt",refcnt); intree->SetBranchAddress("hsdiv",hsdiv); intree->SetBranchAddress("refclkdiv",refclkdiv); TFile *outfile = new TFile("out.root","recreate"); TH1F *hnDF1TDCConfig = new TH1F("hnDF1TDCConfig",";hnDF1TDCConfig;",100,-0.5,99.5); TH1F *hrocid = new TH1F("hrocid",";hrocid;",100,-0.5,99.5); TH1F *hrefcnt = new TH1F("hrefcnt",";hrefcnt;",600,-0.5,599.5); TH1F *hhsdiv = new TH1F("hhsdiv",";hhsdiv;",600,-0.5,599.5); TH1F *hrefclkdiv = new TH1F("hrefclkdiv",";hrefclkdiv;",600,-0.5,599.5); for(Int_t n=0;nGetEntries();n++){ intree->GetEntry(n); cout << "---- entry: " << setw(3) << n << " ------" << endl; hnDF1TDCConfig->Fill(nDF1TDCConfig); for(Int_t i=0;iFill(rocid[i]); hrefcnt->Fill(refcnt[i]); hhsdiv->Fill(hsdiv[i]); hrefclkdiv->Fill(refclkdiv[i]); cout << nDF1TDCConfig << "\t" << rocid[i] << "\t" << refcnt[i] << "\t" << hsdiv[i] << "\t" << refclkdiv[i] << endl; if(refclkdiv[i] != 128){ cout << "reflckdiv[" << i << "] was not 128, was " << refclkdiv[i] << "!!!!!!!!!!!!!!!!!!!!!!!" << endl; abort(); } } } // write out results to txt file // remove directory name from input file size_t pos = infilename.find("/"); std::string runname = infilename.substr(pos+1); ofstream OUT; OUT.open("results2.txt", std::ofstream::out | std::ofstream::app); OUT << runname << "\t" << setw(10) << hnDF1TDCConfig->GetMean() << "\t " << setw(10) << hnDF1TDCConfig->GetRMS() << endl; cout << "mean, RMS of DF1TDCConfig = " << hnDF1TDCConfig->GetMean() << ", " << hnDF1TDCConfig->GetRMS() << endl; if(hnDF1TDCConfig->GetRMS()==0 && hnDF1TDCConfig->GetMean() == 0){ cout << "!!! nDF1TDCConfig is always 0" << endl; } if(hrefcnt->GetRMS()==0 && hrefcnt->GetMean() != 0){ cout << "refcnt is always " << hrefcnt->GetMean() << endl; } outfile->Write(); }