plots.cxx File Reference

#include <HistMan/HistMan.h>
#include <BeamData/ana/bmnt/ProfMon.h>
#include <BeamData/ana/bmnt/Knot.h>
#include <BeamData/ana/bmnt/Pedestals.h>
#include <BeamData/ana/bmnt/AcnetDevice.h>
#include <TCanvas.h>
#include <TSystem.h>
#include <TTree.h>
#include <TFile.h>
#include <TH1D.h>
#include <TH2D.h>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>

Go to the source code of this file.

Functions

void book_once ()
void fill (Knot &k, ProfMon &, Pedestals &, int)
void fill_profile (ProfMon &pm, int count, TH1D &xh, TH1D &yh, TH2D &xa, TH2D &ya)
void book_and_fill (Knot &k, ProfMon &pm, Pedestals &peds, int count)
void write_plots ()
void make_plots ()
void make_prints ()
void plots ()

Variables

const double MIN_ETOR101 = 0.15
const char * toroids []
const char * profile_monitor []
static int nentries = 0

Function Documentation

void book_and_fill ( Knot k,
ProfMon pm,
Pedestals peds,
int  count 
)

Definition at line 91 of file plots.cxx.

References HistMan::Book(), fill_profile(), Form(), Knot::GetDevice(), Pedestals::GetPeds(), max, ProfMon::MAX_CHANNEL, min, ProfMon::MIN_CHANNEL, profile_monitor, Swic::SetAcnetDevice(), Swic::SetPeds(), ProfMon::WIRE_SPACING, and ProfMon::WirePosition().

Referenced by make_plots().

00092 {
00093     HistMan hm(Form("bv/spill%03d",count));
00094 
00095     double min = ProfMon::WirePosition(ProfMon::MIN_CHANNEL);
00096     double max = ProfMon::WirePosition(ProfMon::MAX_CHANNEL);
00097     min -= ProfMon::WIRE_SPACING;
00098     max -= ProfMon::WIRE_SPACING;
00099     int nbins = ProfMon::MAX_CHANNEL - ProfMon::MIN_CHANNEL + 1;
00100 
00101     int npms = 0;
00102     for (; profile_monitor[npms]; ++npms){};
00103     TH2D* xall =
00104         hm.Book<TH2D>(Form("xallpm_%03d",count),
00105                       Form("All X Profiles for spill %d",count),
00106                       npms,0,npms,nbins,min,max);
00107     TH2D* yall =
00108         hm.Book<TH2D>(Form("yallpm_%03d",count),
00109                       Form("All Y Profiles for spill %d",count),
00110                       npms,0,npms,nbins,min,max);
00111 
00112     for (int ind=0; profile_monitor[ind]; ++ind) {
00113         const AcnetDevice* ad = k.GetDevice(profile_monitor[ind]);
00114         if (!pm.SetPeds(peds.GetPeds(profile_monitor[ind]))) {
00115             cerr << "Failed to set peds for " << profile_monitor[ind]
00116                  << " skipping\n";
00117             continue;
00118         }
00119         int ret = pm.SetAcnetDevice(*ad);
00120         if (! ret) {
00121             cerr << "Failed to set acnet device for spill " << count << endl;
00122             continue;
00123         }
00124 
00125         string pms = profile_monitor[ind];
00126         pms[1]='_';
00127         TH1D* xhist =
00128             hm.Book<TH1D>(Form("%sX_%03d",pms.c_str(),count),
00129                           Form("ProfMon %s X view spill %d",pms.c_str(),count),
00130                           nbins,min,max);
00131         TH1D* yhist =
00132             hm.Book<TH1D>(Form("%sY_%03d",pms.c_str(),count),
00133                           Form("ProfMon %s Y view spill %d",pms.c_str(),count),
00134                           nbins,min,max);
00135 
00136         fill_profile(pm,ind,*xhist,*yhist,*xall,*yall);
00137         ++npms;
00138     }
00139 
00140 }

void book_once (  ) 

Definition at line 53 of file plots.cxx.

References HistMan::Book().

Referenced by make_plots().

00054 {
00055     HistMan hm("bv");
00056     // ...
00057 
00058     hm.Book<TH1D>("max_dae_dt","Maximum difference between 2 DAEs in data block",1200,-60,60);
00059 
00060 }

void fill ( Knot k,
ProfMon ,
Pedestals ,
int   
)

Definition at line 61 of file plots.cxx.

References HistMan::Fill1d(), Knot::GetDevice(), profile_monitor, and AcnetDevice::timestamp.

Referenced by RatioPlot::Draw(), main(), and make_plots().

00062 {
00063     double max_dt = 0;
00064     
00065     for (int ind1=0; profile_monitor[ind1]; ++ind1) {
00066         const AcnetDevice* ad1 = k.GetDevice(profile_monitor[ind1]);
00067         for (int ind2=ind1; profile_monitor[ind2]; ++ind2) {
00068             const AcnetDevice* ad2 = k.GetDevice(profile_monitor[ind2]);
00069             double diff = fabs(ad1->timestamp - ad2->timestamp);
00070             if (diff > max_dt) max_dt = diff;
00071         }
00072     }
00073     HistMan hm("bv");
00074     hm.Fill1d("max_dae_dt",max_dt);
00075     
00076 }

void fill_profile ( ProfMon pm,
int  count,
TH1D &  xh,
TH1D &  yh,
TH2D &  xa,
TH2D &  ya 
)

Definition at line 78 of file plots.cxx.

References Swic::GetVoltage(), ProfMon::MAX_CHANNEL, ProfMon::MIN_CHANNEL, ProfMon::WirePosition(), ProfMon::Xindex(), and ProfMon::Yindex().

Referenced by book_and_fill().

00080 {
00081     for (int ch=pm.MIN_CHANNEL; ch<=pm.MAX_CHANNEL; ++ch) {
00082         xh.Fill(pm.WirePosition(ch),pm.GetVoltage(pm.Xindex(ch)));
00083         xa.Fill(count,pm.WirePosition(ch),pm.GetVoltage(pm.Xindex(ch)));
00084         yh.Fill(pm.WirePosition(ch),pm.GetVoltage(pm.Yindex(ch)));
00085         ya.Fill(count,pm.WirePosition(ch),pm.GetVoltage(pm.Yindex(ch)));
00086 
00087     }
00088 }

void make_plots (  ) 

Definition at line 152 of file plots.cxx.

References book_and_fill(), book_once(), count, AcnetDevice::data, fill(), Knot::GetDevice(), Knot::GetEntry(), Knot::GetSize(), Pedestals::LoadPedFile(), MIN_ETOR101, AcnetDevice::ndata, nentries, and Swic::SetScale().

Referenced by plots().

00153 {
00154     //TFile f("first-data.tree.root");
00155     TFile f("second.bmnt.root");
00156     TTree* bd = dynamic_cast<TTree*>(f.FindObjectAny("bd"));
00157     assert(bd);
00158     Knot k(*bd);
00159 
00160     book_once();
00161 
00162     Pedestals peds;
00163     peds.LoadPedFile("peds.txt");
00164 
00165     nentries = k.GetSize();
00166     int count = 0;
00167     for (int entry=0; entry<nentries; ++entry) {
00168         cerr << entry << " ";
00169         k.GetEntry(entry);
00170 
00171         const AcnetDevice* ad = k.GetDevice("E:TOR101");
00172         if (ad->ndata == 0) {
00173             cerr << "No E:TOR101!\n";
00174             continue;
00175         }
00176         double cut = fabs(ad->data[0]);
00177         if (cut < MIN_ETOR101) continue;
00178         ++count;
00179 
00180         ProfMon pm;
00181         pm.SetScale(cut/MIN_ETOR101);
00182         book_and_fill(k,pm,peds,count);
00183         fill(k,pm,peds,count);
00184     }
00185     //write();
00186 }

void make_prints (  ) 

Definition at line 188 of file plots.cxx.

References Draw(), Form(), HistMan::Get(), and nentries.

Referenced by plots().

00188                    {
00189     TCanvas c("c","BeamData Plots",850,1100);
00190 
00191     c.Print("bdplots.ps[");
00192 
00193     HistMan hm("bv");
00194     hm.Get<TH1D>("max_dae_dt")->Draw();
00195     c.Print("bdplots.ps");
00196     
00197 #if 0
00198     for (int ind=1; ind <= nentries; ++ind) {
00199         HistMan hm(Form("bv/spill%03d",ind));
00200         TH2D* hx = hm.Get<TH2D>(Form("xallpm_%03d",ind));
00201         TH2D* hy = hm.Get<TH2D>(Form("yallpm_%03d",ind));
00202 
00203         if (!hx || !hy) {
00204             cerr << "Failed to get hists for spill " << ind << endl;
00205             continue;
00206         }
00207 
00208         c.Clear();
00209         c.Divide(1,2);
00210         c.cd(1);
00211         hx->Draw("colz");
00212         c.cd(2);
00213         hy->Draw("colz");
00214 
00215         c.Print("bdplots.ps");
00216     }
00217 #endif
00218 
00219     c.Print("bdplots.ps]");
00220     
00221 }

void plots (  ) 
void write_plots (  ) 

Definition at line 142 of file plots.cxx.

References HistMan::WriteOut().

Referenced by plots().

00143 {
00144     HistMan hm("bv");
00145     TFile file("plots.root","RECREATE");
00146     hm.WriteOut(file);
00147     file.Close();
00148 }


Variable Documentation

const double MIN_ETOR101 = 0.15

Definition at line 29 of file plots.cxx.

Referenced by make_plots().

int nentries = 0 [static]
const char* profile_monitor[]
Initial value:
 {
    "E:M101DS",
    "E:M105DS",
    "E:M107DS",
    "E:M108DS",
    "E:M112DS",
    "E:M114DS",
    "E:M115DS",
    "E:M117DS",
    "E:M121DS",
    "E:MTGTDS",
    0
}

Definition at line 39 of file plots.cxx.

const char* toroids[]
Initial value:
 {
    "E:TOR101",
    "E:TORTGT",
    0
}

Definition at line 33 of file plots.cxx.

Referenced by BDCheckDB::BDCheckDB(), BDCheckDB::CheckSpill(), BeamMonDbuModule::FillPipeline(), BDSwicPeds::IsPedSpill(), and BDDevices::Toroids().


Generated on 14 Feb 2019 for loon by  doxygen 1.6.1