Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PedStudy Class Reference

#include <PedStudy.h>

List of all members.

Public Types

typedef std::map< std::string,
Hists
HistMap

Public Member Functions

void GetFiles (const char *directories[])
void Book ()
void Fill ()
void OneFile (int count, std::string file, std::string dir)
void OneRecord (int count, const RawBeamMonBlock &block)
 PedStudy (const char *directories[])
 ~PedStudy ()
PedViewerView ()
 View the plots.
void WriteOut (const char *filename)
 Write out the histograms to soem root file.

Public Attributes

HistMap fHist
std::map< std::string, std::string > fFileMap


Member Typedef Documentation

typedef std::map<std::string,Hists> PedStudy::HistMap
 

Definition at line 22 of file PedStudy.h.


Constructor & Destructor Documentation

PedStudy::PedStudy const char *  directories[]  ) 
 

Create a PedStudy with list of directories holding B*_*.mbeam.root files to use as input.

Definition at line 25 of file PedStudy.cxx.

References Book(), Fill(), and GetFiles().

00026 {
00027     cerr << "PedStudy\n";
00028 
00029     this->GetFiles(directories);
00030     this->Book();
00031     this->Fill();
00032 }

PedStudy::~PedStudy  )  [inline]
 

Definition at line 37 of file PedStudy.h.

00037 {}


Member Function Documentation

void PedStudy::Book  ) 
 

Definition at line 53 of file PedStudy.cxx.

References HistMan::Book(), fFileMap, fHist, BDDevices::SwicDevices(), and swics.

Referenced by PedStudy().

00054 {
00055     int nfiles = fFileMap.size();
00056     HistMan hm("pedstudy");
00057     vector<string> swics = BDDevices::SwicDevices();
00058     for (size_t ind=0; ind<swics.size(); ++ind) {
00059         fHist[swics[ind]].all =
00060             hm.Book<TH2I>(swics[ind].substr(2).c_str(),
00061                           swics[ind].c_str(),
00062                           nfiles,0,nfiles,
00063                           96,0,96,"all");
00064     }
00065 }

void PedStudy::Fill  ) 
 

Definition at line 67 of file PedStudy.cxx.

References count, done(), fFileMap, files, MSG, and OneFile().

Referenced by PedStudy().

00068 {
00069     map<string,string>::iterator it, done = fFileMap.end();
00070     list<string> files;
00071     for (it=fFileMap.begin(); it != done; ++it) files.push_back(it->first);
00072     files.sort();
00073     list<string>::iterator lit, ldone = files.end();
00074 
00075     int count = 0;
00076     for (lit = files.begin(); lit != ldone; ++lit) {
00077         string file = *lit;
00078         string dir = fFileMap[file];
00079 
00080         MSG("BD",Msg::kInfo) << dir << "/" << file << endl;
00081         this->OneFile(count,file,dir);
00082         ++count;
00083     }
00084 }

void PedStudy::GetFiles const char *  directories[]  ) 
 

Definition at line 34 of file PedStudy.cxx.

References fFileMap, gSystem(), and MSG.

Referenced by PedStudy().

00035 {
00036     for (int ind=0; directories[ind]; ++ind) {
00037         void* dir = gSystem->OpenDirectory(directories[ind]);
00038         if (!dir) {
00039             MSG("BD",Msg::kWarning)
00040                 << "Skipping empty directory: " << directories[ind] << endl;
00041             continue;
00042         }
00043 
00044         const char* cptr=0;
00045         while ( (cptr = gSystem->GetDirEntry(dir)) ) {
00046             string file = cptr;
00047             if (string::npos == file.find(".mbeam.root")) continue;
00048             fFileMap[file] = directories[ind];
00049         }
00050     }
00051 }

void PedStudy::OneFile int  count,
std::string  file,
std::string  dir
 

Definition at line 86 of file PedStudy.cxx.

References HistMan::Book(), count, done(), fHist, RawRecord::GetRawBlockIter(), BDSwicPeds::IsPedSpill(), OneRecord(), and RawBeamMonBlock::TclkTriggerEvent().

Referenced by Fill().

00087 {
00088     HistMan hm("pedstudy");
00089 
00090     HistMap::iterator it, done=fHist.end();
00091     for (it=fHist.begin(); it != done; ++it) {
00092         string name = it->first.substr(2);
00093         string hmdir = name + "/" + filename;
00094         TProfile* hist = hm.Book<TProfile>(name.c_str(),hmdir.c_str(),
00095                                            96,0,96,hmdir.c_str());
00096         fHist[it->first].perfile.push_back(hist);
00097     }
00098 
00099     string rootfile = dirname + "/" + filename;
00100     TFile file(rootfile.c_str(),"READ");
00101     TTree* tree = (TTree*)(file.Get("BeamMon"));
00102     RawRecord* record = 0;
00103     for ( Int_t ient = 0; ient < tree -> GetEntries(); ient++ ) {
00104         tree -> SetBranchAddress("RawRecord",&record);
00105         tree->GetEntry(ient);
00106         TIter itr = record->GetRawBlockIter();
00107 
00108         const RawBeamMonBlock* rbmb = 0;;
00109         const RawBeamMonHeaderBlock* rbmhb = 0;
00110 
00111         // check all blocks
00112         RawDataBlock* rdb = 0;
00113         while ((rdb = dynamic_cast<RawDataBlock*>(itr()))) {
00114             if (rdb->InheritsFrom("RawBeamMonBlock"))
00115                 rbmb = dynamic_cast<const RawBeamMonBlock*>(rdb);
00116             if (rdb->InheritsFrom("RawBeamMonHeaderBlock"))
00117                 rbmhb = dynamic_cast<const RawBeamMonHeaderBlock*>(rdb);
00118         }
00119 
00120         if (!(rbmb && rbmhb)) continue;
00121 
00122         if (rbmb->TclkTriggerEvent() != 0xa9) continue;
00123         if (! BDSwicPeds::IsPedSpill(*rbmb)) continue;
00124 
00125         this->OneRecord(count,*rbmb);
00126     }
00127     delete record; record = 0;
00128 }

void PedStudy::OneRecord int  count,
const RawBeamMonBlock block
 

Definition at line 130 of file PedStudy.cxx.

References count, done(), fHist, RawBeamSwicData::SetData(), and RawBeamSwicData::UnscaledWireData().

Referenced by OneFile().

00131 {
00132     map<string,Hists>::iterator it, done = fHist.end();
00133     RawBeamSwicData swic;
00134     for (it = fHist.begin(); it != done; ++it) {
00135         const RawBeamData* rbd = block[it->first];
00136         if (!rbd) continue;
00137         swic.SetData(*rbd);
00138 
00139         vector<int> wire;
00140         swic.UnscaledWireData(wire);
00141         for (size_t ind=0; ind<wire.size(); ++ind) {
00142             it->second.all->Fill(count,ind,wire[ind]);
00143             it->second.perfile.back()->Fill(ind,wire[ind]);
00144 
00145         }
00146     }
00147 }

PedViewer * PedStudy::View  ) 
 

View the plots.

Definition at line 157 of file PedStudy.cxx.

00158 {
00159     return new PedViewer(*this);
00160 }

void PedStudy::WriteOut const char *  filename  ) 
 

Write out the histograms to soem root file.

Definition at line 151 of file PedStudy.cxx.

References HistMan::WriteOut().

00152 {
00153     HistMan hm("");
00154     hm.WriteOut(filename);
00155 }


Member Data Documentation

std::map<std::string,std::string> PedStudy::fFileMap
 

Definition at line 25 of file PedStudy.h.

Referenced by Book(), Fill(), and GetFiles().

HistMap PedStudy::fHist
 

Definition at line 24 of file PedStudy.h.

Referenced by Book(), PedViewer::Next(), OneFile(), OneRecord(), PedViewer::PedViewer(), and PedViewer::Prev().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:00 2010 for loon by  doxygen 1.3.9.1