#include "Bdtxt.h"
#include "BmntUtil.h"
#include <TFile.h>
#include <TTree.h>
#include <Validity/VldContext.h>
#include <RawData/RawRecord.h>
#include <RawData/RawBeamMonHeader.h>
#include <RawData/RawBeamMonBlock.h>
#include <RawData/RawDataBlock.h>
#include <RawData/RawBeamData.h>
#include <RawData/RawBeamSwicData.h>
#include <cassert>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <fstream>
#include <cmath>
Go to the source code of this file.
Typedefs | |
typedef map< string, vector < double > > | ScaleMap |
Functions | |
void | init_simple_data (ostream &o) |
void | init_profile_monitor (ostream &o) |
void | init_hadmu_monitor (ostream &o) |
void | dump_simple_data (ostream &o, const RawBeamMonBlock &rbmb) |
void | dump_one_profile (ostream &o, vector< int > &data, int start, const vector< double > &scale) |
void | dump_profile_monitor (ostream &o, const RawBeamMonBlock &rbmb, ScaleMap &profmap) |
void | dump_hadmu_monitor (ostream &o, const RawBeamMonBlock &rbmb, ScaleMap &pedmap) |
void | load_scale_map (const char *file, ScaleMap &sm, int ndev) |
void | bd_text_dump (const char *rootfile, const char *textfile, const char *pedfile, const char *swicfile) |
Dump some stuff from root file to vector text file. | |
Variables | |
const char * | simple_data [] |
const char * | profile_monitor [] |
const char * | hadmu_monitor [] |
const double | MVPERADC = -0.30518 |
void bd_text_dump | ( | const char * | rootfile, | |
const char * | textfile, | |||
const char * | pedfile, | |||
const char * | swicfile | |||
) |
Dump some stuff from root file to vector text file.
Definition at line 314 of file Bdtxt.cxx.
References dump_hadmu_monitor(), dump_profile_monitor(), dump_simple_data(), RawRecord::GetRawBlockIter(), RecMinos::GetVldContext(), init_hadmu_monitor(), init_profile_monitor(), init_simple_data(), and load_scale_map().
00316 { 00317 TFile file(rootfile,"READ"); 00318 TTree* tree = (TTree*)(file.Get("BeamMon")); 00319 RawRecord* record = 0; 00320 00321 ScaleMap pedmap,swicmap; 00322 load_scale_map(pedfile,pedmap,4); 00323 load_scale_map(swicfile,swicmap,10); 00324 00325 ofstream fstr(textfile); 00326 if (!fstr) { 00327 cerr << "Can't open \"" << textfile << "\" for writing\n"; 00328 return; 00329 } 00330 fstr << "# "; 00331 init_simple_data(fstr); 00332 init_profile_monitor(fstr); 00333 init_hadmu_monitor(fstr); 00334 fstr << endl; 00335 00336 for ( Int_t ient = 0; ient < tree -> GetEntries(); ient++ ) { 00337 tree -> SetBranchAddress("RawRecord",&record); 00338 tree->GetEntry(ient); 00339 00340 if (!ient) { 00341 const VldContext* vld = record->GetVldContext(); 00342 cout << "Reading " << rootfile << ":\n" 00343 << *vld << endl; 00344 } 00345 00346 TIter itr = record->GetRawBlockIter(); 00347 const RawDataBlock* rdb = 0; 00348 00349 cerr << "Entry " << ient << endl; 00350 00351 // loop over blocks in record 00352 while ((rdb = dynamic_cast<RawDataBlock*>(itr()))) { 00353 if (! rdb->InheritsFrom("RawBeamMonBlock")) { 00354 //cerr << "Doesn't inherit from RawBeamMonBlock" << endl; 00355 continue; 00356 } 00357 const RawBeamMonBlock* rbmb = 00358 dynamic_cast<const RawBeamMonBlock*>(rdb); 00359 assert(rbmb); 00360 00361 dump_simple_data(fstr,*rbmb); 00362 dump_profile_monitor(fstr,*rbmb,swicmap); 00363 dump_hadmu_monitor(fstr,*rbmb,pedmap); 00364 fstr << endl; 00365 break; 00366 } 00367 00368 if (tree->GetEntries()-ient == 1) { 00369 const VldContext* vld = record->GetVldContext(); 00370 cout << "finishing " << rootfile << ":\n" 00371 << *vld << endl; 00372 } 00373 delete record; record = 0; 00374 } 00375 00376 }
void dump_hadmu_monitor | ( | ostream & | o, | |
const RawBeamMonBlock & | rbmb, | |||
ScaleMap & | pedmap | |||
) |
Definition at line 230 of file Bdtxt.cxx.
References RawBeamData::GetMsecs(), RawBeamData::GetSeconds(), hadmu_monitor, hadron_cell(), hadron_index(), hadron_position(), max, MVPERADC, RawBeamSwicData::UnscaledWireData(), RawBeamSwicData::VmeNanoseconds(), and RawBeamSwicData::VmeSeconds().
Referenced by bd_text_dump().
00232 { 00233 for (int ind=0; hadmu_monitor[ind]; ++ind) { 00234 //cerr << "Getting " << hadmu_monitor[ind] << endl; 00235 const RawBeamData* rbd = rbmb[hadmu_monitor[ind]]; 00236 assert(rbd); 00237 RawBeamSwicData swic(*rbd); 00238 vector<int> data; 00239 swic.UnscaledWireData(data); 00240 00241 o << rbd->GetSeconds() << " " 00242 << rbd->GetMsecs() << " " 00243 << swic.VmeSeconds() << " " 00244 << swic.VmeNanoseconds()/1000 << " "; 00245 00246 const vector<double>& scale = pedmap[hadmu_monitor[ind]]; 00247 double tot=0,max=0; 00248 double Qx=0, Qy=0, X=0, Y=0; 00249 for (int col=1; col <=7; ++col) { 00250 for (int row=1; row <=7; ++row) { 00251 int index = hadron_index(hadron_cell(row,col)); 00252 double val = MVPERADC*data[index]-scale[index]; 00253 tot += val; 00254 if (val>max) max=val; 00255 Qx += val; 00256 Qy += val; 00257 X += val*hadron_position(col); 00258 Y += val*hadron_position(row); 00259 } 00260 } 00261 if (Qx > 0.0) o << X/Qx << " "; 00262 else o << "0.0 "; 00263 if (Qy > 0.0) o << Y/Qy << " "; 00264 else o << "0.0 "; 00265 o << tot << " " << max << " "; 00266 00267 #ifdef DUMP_HADMU_PIXELS 00268 for (int channel=1; channel <= 49; ++channel) { 00269 int index = hadron_index(channel); 00270 double val = MVPERADC*data[index]-scale[index]; 00271 00272 o << val << " "; 00273 } 00274 #endif 00275 00276 } 00277 }
void dump_one_profile | ( | ostream & | o, | |
vector< int > & | data, | |||
int | start, | |||
const vector< double > & | scale | |||
) |
Definition at line 197 of file Bdtxt.cxx.
Referenced by dump_profile_monitor().
00199 { 00200 double qx=0,q=0,q2x2=0,max=0; 00201 for (int ind=start; ind < start+44; ++ind) { 00202 double pos = (ind-(start+22.5))*0.5; 00203 double val = MVPERADC*data[ind] - scale[ind]; 00204 q += val; 00205 if (val>max) max = val; 00206 double tmp = val*pos; 00207 qx += tmp; 00208 q2x2 += tmp*tmp; 00209 } 00210 if (q == 0.0) o << "0.0 0.0 0.0 "; 00211 else o << qx/q << " " << sqrt(q2x2/(q*q)) << " " << q << " "; 00212 00213 }
void dump_profile_monitor | ( | ostream & | o, | |
const RawBeamMonBlock & | rbmb, | |||
ScaleMap & | profmap | |||
) |
Definition at line 214 of file Bdtxt.cxx.
References dump_one_profile(), profile_monitor, and RawBeamSwicData::UnscaledWireData().
Referenced by bd_text_dump().
00216 { 00217 for (int ind=0; profile_monitor[ind]; ++ind) { 00218 //cerr << "Getting " << profile_monitor[ind] << endl; 00219 const RawBeamData* rbd = rbmb[profile_monitor[ind]]; 00220 assert(rbd); 00221 RawBeamSwicData swic(*rbd); 00222 vector<int> data; 00223 swic.UnscaledWireData(data); 00224 const vector<double>& scale = profmap[profile_monitor[ind]]; 00225 dump_one_profile(o,data,2,scale); 00226 dump_one_profile(o,data,50,scale); 00227 } 00228 00229 }
void dump_simple_data | ( | ostream & | o, | |
const RawBeamMonBlock & | rbmb | |||
) |
Definition at line 187 of file Bdtxt.cxx.
References RawBeamData::GetData(), and simple_data.
Referenced by bd_text_dump().
00188 { 00189 for (int ind=0; simple_data[ind]; ++ind) { 00190 const RawBeamData* rbd = rbmb[simple_data[ind]]; 00191 if (!rbd) o << "0.0 "; 00192 else o << rbd->GetData()[0] << " "; 00193 } 00194 00195 }
void init_hadmu_monitor | ( | ostream & | o | ) |
Definition at line 166 of file Bdtxt.cxx.
References Form(), and hadmu_monitor.
Referenced by bd_text_dump().
00167 { 00168 for (int ind=0; hadmu_monitor[ind]; ++ind) { 00169 o << hadmu_monitor[ind] << "_daesec " 00170 << hadmu_monitor[ind] << "_daemsec " 00171 << hadmu_monitor[ind] << "_vmesec " 00172 << hadmu_monitor[ind] << "_vmemsec " 00173 00174 << hadmu_monitor[ind] << "_xmean " 00175 << hadmu_monitor[ind] << "_ymean " 00176 << hadmu_monitor[ind] << "_tot " 00177 << hadmu_monitor[ind] << "_high "; 00178 00179 #ifdef DUMP_HADMU_PIXELS 00180 for (int channel=1; channel <= 49; ++channel) { 00181 o << Form("%s_ch%02d ",hadmu_monitor[ind],channel); 00182 } 00183 #endif 00184 } 00185 }
void init_profile_monitor | ( | ostream & | o | ) |
Definition at line 155 of file Bdtxt.cxx.
References profile_monitor.
Referenced by bd_text_dump().
00156 { 00157 for (int ind=0; profile_monitor[ind]; ++ind) { 00158 o << profile_monitor[ind] << "_xmean " 00159 << profile_monitor[ind] << "_xrms " 00160 << profile_monitor[ind] << "_xtot " 00161 << profile_monitor[ind] << "_ymean " 00162 << profile_monitor[ind] << "_yrms " 00163 << profile_monitor[ind] << "_ytot "; 00164 } 00165 }
void init_simple_data | ( | ostream & | o | ) |
Definition at line 149 of file Bdtxt.cxx.
References simple_data.
Referenced by bd_text_dump().
00150 { 00151 for (int ind=0; simple_data[ind]; ++ind) { 00152 o << simple_data[ind] << " "; 00153 } 00154 }
void load_scale_map | ( | const char * | file, | |
ScaleMap & | sm, | |||
int | ndev | |||
) |
Definition at line 281 of file Bdtxt.cxx.
Referenced by bd_text_dump().
00282 { 00283 ifstream fstr(file); 00284 assert (fstr); 00285 string blah; 00286 vector<string> devs; 00287 00288 fstr >> blah; 00289 for (int ind=0; ind<ndev; ++ind) { 00290 string dev; 00291 fstr >> dev; 00292 devs.push_back(dev); 00293 cerr << dev << " "; 00294 } 00295 cerr << endl; 00296 for (int ch=0; ch<96; ++ch) { 00297 int channel; 00298 fstr >> channel; 00299 for (int dev=0; dev<ndev; ++dev) { 00300 double scale; 00301 fstr >> scale; 00302 string devname = devs[dev]; 00303 //cerr << devname << ": " << scale << endl; 00304 if (!ch) { 00305 vector<double> v; 00306 sm[devname] = v; 00307 } 00308 sm[devname].push_back(scale); 00309 } 00310 } 00311 }
const char* hadmu_monitor[] |
{
"E:HADMDS",
0
}
Definition at line 139 of file Bdtxt.cxx.
Referenced by dump_hadmu_monitor(), and init_hadmu_monitor().
const double MVPERADC = -0.30518 |
Definition at line 196 of file Bdtxt.cxx.
Referenced by dump_hadmu_monitor(), and dump_one_profile().
const char* profile_monitor[] |
{ "E:M101DS", "E:M105DS", "E:M107DS", "E:M108DS", "E:M112DS", "E:M114DS", "E:M115DS", "E:M117DS", "E:M121DS", "E:MTGTDS", 0 }
Definition at line 125 of file Bdtxt.cxx.
Referenced by book_and_fill(), dump_profile_monitor(), fill(), and init_profile_monitor().
const char* simple_data[] |
Definition at line 24 of file Bdtxt.cxx.
Referenced by dump_simple_data(), and init_simple_data().