#include <TObject.h>Go to the source code of this file.
Classes | |
| class | BDTestData |
| Simple class holding different proton counts. More... | |
Functions | |
| void | convert_raw_to_bdtest (const char *raw_file, const char *output_file) |
| Convert one raw file to a BDTestData tree file. | |
| void | generate_bdtd_plots (const char *input_directory, const char *output_file="") |
| bool | fill_bdtest (BDTestData &td, const RawBeamMonBlock &block, const RawBeamMonHeaderBlock &head) |
|
||||||||||||
|
Convert one raw file to a BDTestData tree file.
Definition at line 117 of file BDTestData.cxx. References fill_bdtest(), RawRecord::GetRawBlockIter(), infile, and outfile. 00118 {
00119 TFile infile(raw_file,"READ");
00120 TTree* intree=(TTree*)(infile.Get("BeamMon"));
00121
00122 TFile outfile(output_file,"RECREATE");
00123 TTree* outtree = new TTree("bdtest", "Beam Monitoring Data");
00124 BDTestData* bdtd = new BDTestData;
00125 outtree->Branch("pot","BDTestData",&bdtd);
00126
00127 RawRecord* record = 0;
00128 int nentries = intree->GetEntries();
00129 for ( Int_t ient = 0; ient < nentries; ient++ ) {
00130 intree -> SetBranchAddress("RawRecord",&record);
00131 intree->GetEntry(ient);
00132
00133 const RawBeamMonBlock* rbmb = 0;
00134 const RawBeamMonHeaderBlock* rbmhb = 0;
00135 TObject *obj = 0;
00136 TIter itr = record->GetRawBlockIter();
00137 while ((obj = itr())) {
00138 const RawBeamMonBlock* b = dynamic_cast<const RawBeamMonBlock*>(obj);
00139 if (b) rbmb = b;
00140 const RawBeamMonHeaderBlock* h = dynamic_cast<const RawBeamMonHeaderBlock*>(obj);
00141 if (h) rbmhb = h;
00142 }
00143
00144 if (!(rbmb && rbmhb)) continue;
00145
00146 if (fill_bdtest(*bdtd,*rbmb,*rbmhb))
00147 outtree->Fill();
00148 }
00149
00150 outfile.cd();
00151 outtree->Write();
00152 outfile.Close();
00153
00154 infile.Close();
00155 }
|
|
||||||||||||||||
|
Definition at line 54 of file BDTestData.cxx. References BDTarget::BpmProjection(), BDTestData::earliest, RawBeamData::GetData(), RawBeamData::GetDataLength(), SpillTimeFinder::GetTimeOfNearestSpill(), BDEarliest::GetTimestamps(), RawBeamMonHeaderBlock::GetVldContext(), BDTestData::hitgt, BDTestData::horni, SpillTimeFinder::Instance(), BDTestData::nbunch, BDTarget::ProfileProjection(), BDTestData::Reset(), set_toroid(), BDTarget::SetSpill(), BDEarliest::SetSpill(), BDTestData::spilltimend, BDTarget::TargetIn(), RawBeamMonBlock::TclkTriggerEvent(), BDTestData::tgtdist, BDTestData::tor101, BDTestData::tortgt, BDTestData::tr101d, BDTestData::trtgtd, BDTestData::vitgt, BDTestData::xsigma, BDTestData::xtgt, BDTestData::ysigma, and BDTestData::ytgt. Referenced by convert_raw_to_bdtest(), and BDTestDataModuleImp::Fill(). 00056 {
00057 td.Reset();
00058
00059 const int trig_event = block.TclkTriggerEvent();
00060 if (trig_event != 0xa9) return false;
00061
00062 // time stamp
00063 BDEarliest earliest;
00064 earliest.SetSpill(head,block);
00065 double dae=0, vme=0;
00066 earliest.GetTimestamps(dae,vme);
00067 if (vme) td.earliest = vme;
00068 else td.earliest = dae;
00069
00070 // toroids
00071 set_toroid("E:TORTGT",td.tortgt,block);
00072 set_toroid("E:TRTGTD",td.trtgtd,block);
00073 set_toroid("E:TOR101",td.tor101,block);
00074 set_toroid("E:TR101D",td.tr101d,block);
00075
00076 BDTarget targ;
00077 targ.SetSpill(head,block);
00078 vector<double> xp,yp,xi,yi;
00079 targ.BpmProjection(xp,yp,xi,yi);
00080 td.nbunch = xp.size();
00081 for (int ind=0; ind<td.nbunch && ind<8; ++ind) {
00082 td.hitgt[ind] = static_cast<float>(xi[ind]);
00083 td.vitgt[ind] = static_cast<float>(yi[ind]);
00084 td.xtgt[ind] = static_cast<float>(xp[ind]);
00085 td.ytgt[ind] = static_cast<float>(yp[ind]);
00086 }
00087 double xm=0, ym=0, xsig=0, ysig=0;
00088
00089 targ.ProfileProjection(xm,ym,xsig,ysig);
00090 td.xsigma = xsig;
00091 td.ysigma = ysig;
00092 bool is_in=false;
00093 double z_loc = 0;
00094 BDTarget::BeamType beam_type = targ.TargetIn(is_in,z_loc);
00095 if (beam_type == BDTarget::kUnknown || !is_in) {
00096 cerr << "Unknown target location: is_in="<<is_in<<" at " << z_loc << endl;
00097 }
00098 if (!is_in)
00099 td.tgtdist = -1e6;
00100 else td.tgtdist = z_loc;
00101
00102 // horn
00103 const char* dev[] = {"E:NSLINA","E:NSLINB","E:NSLINC","E:NSLIND",0};
00104 float horni = 0;
00105 for (int ind=0; dev[ind]; ++ind) {
00106 const RawBeamData* d = block[dev[ind]];
00107 if (d && d->GetDataLength()) horni += d->GetData()[0];
00108 }
00109 td.horni = horni;
00110
00111 td.spilltimend =
00112 SpillTimeFinder::Instance().GetTimeOfNearestSpill(head.GetVldContext());
00113
00114 return true;
00115 }
|
|
||||||||||||
|
Definition at line 503 of file BDTestData.cxx. References done(), BDTDPlotter::fill(), gSystem(), outfile, and BDTDPlotter::write(). 00504 {
00505 void* dir = gSystem->OpenDirectory(input_directory);
00506 if (!dir) {
00507 cerr << "Failed to open directory \"" << input_directory << "\"\n";
00508 return;
00509 }
00510
00511 BDTDPlotter* plotter = new BDTDPlotter; // leak it!
00512
00513 list<string> file_names;
00514 const char* cptr=0;
00515 while ( (cptr = gSystem->GetDirEntry(dir)) ) if (cptr) file_names.push_back(cptr);
00516 if (!file_names.size()) return;
00517 file_names.sort();
00518 list<string>::iterator it, done = file_names.end();
00519 for (it=file_names.begin(); it != done; ++it) {
00520 string file = *it;
00521 if (string::npos == file.find(".bdtd.root")) {
00522 cerr << "Skipping unmatched file \"" << file << "\"\n";
00523 continue;
00524 }
00525
00526 string path = input_directory;
00527 path += "/" + file;
00528 cerr << "Processing " << path << endl;
00529 TFile tfile(path.c_str(),"READ");
00530 TTree* tree = (TTree*)(tfile.Get("bdtest"));
00531 BDTestData* bd_test_data = 0;
00532 int ninds = tree->GetEntries();
00533 for (int ind=0; ind<ninds; ++ind) {
00534 tree->SetBranchAddress("pot",&bd_test_data);
00535 tree->GetEntry(ind);
00536
00537 plotter->fill(*bd_test_data);
00538 }
00539 tfile.Close();
00540 }
00541
00542 plotter->write(outfile);
00543 }
|
1.3.9.1