BeamMonMap Namespace Reference

Classes

struct  bmon1
struct  bmon2

Functions

std::map< VldTimeStamp, BeamMonTVMakeBeamMonMap (const char *path)
BeamMonTV FindClosestSpill (const std::map< VldTimeStamp, BeamMonTV > &m, VldTimeStamp vts)
bool IsGoodSpill (BeamMonTV b)
BeamMonTV FillBeamMonTV (struct bmon1 bmn)
BeamMonTV FillBeamMonTV (struct bmon2 bmn)

Function Documentation

BeamMonTV BeamMonMap::FillBeamMonTV ( struct bmon2  bmn  ) 

Definition at line 72 of file BeamMonMap.cxx.

References BeamMonMap::bmon2::beamIntensity, BeamMonTV::bI, BeamMonMap::bmon2::hBeamWidth, BeamMonTV::hbw, BeamMonTV::hornI, BeamMonMap::bmon2::hornPeakCurrent, BeamMonTV::hpos1, BeamMonTV::hpos2, BeamMonMap::bmon2::hPosatTargetBPM, BeamMonMap::bmon2::hPosatTargetPM, BeamMonTV::htan, BeamMonMap::bmon2::nuTarZ, BeamMonTV::nuTarZ, BeamMonMap::bmon2::tanHoriz, BeamMonMap::bmon2::tanVert, BeamMonTV::time, BeamMonTV::timens, BeamMonMap::bmon2::timeStampD, BeamMonMap::bmon2::timeStampSec, BeamMonMap::bmon2::vBeamWidth, BeamMonTV::vbw, BeamMonTV::vpos1, BeamMonTV::vpos2, BeamMonMap::bmon2::vPosatTargetBPM, BeamMonMap::bmon2::vPosatTargetPM, and BeamMonTV::vtan.

00073 {
00074    BeamMonTV b;
00075 //   std::cout<<"Filling beammontv from type 2"<<std::endl;
00076    b.bI=bmn.beamIntensity;
00077    b.hbw=bmn.hBeamWidth;
00078    b.vbw=bmn.vBeamWidth;
00079    b.hpos1=bmn.hPosatTargetPM;
00080    b.vpos1=bmn.vPosatTargetPM;
00081    b.hpos2=bmn.hPosatTargetBPM;
00082    b.vpos2=bmn.vPosatTargetBPM;
00083    b.htan=bmn.tanHoriz;
00084    b.vtan=bmn.tanVert;
00085    b.hornI=bmn.hornPeakCurrent;
00086    b.nuTarZ=bmn.nuTarZ;
00087    b.timens=bmn.timeStampD;
00088    b.time=bmn.timeStampSec;
00089 //   std::cout<<"done"<<std::endl;
00090    return b;
00091 }

BeamMonTV BeamMonMap::FillBeamMonTV ( struct bmon1  bmn  ) 

Definition at line 50 of file BeamMonMap.cxx.

References BeamMonMap::bmon1::beamIntensity, BeamMonTV::bI, BeamMonMap::bmon1::hBeamWidth, BeamMonTV::hbw, BeamMonTV::hornI, BeamMonMap::bmon1::hornPeakCurrent, BeamMonTV::hpos1, BeamMonTV::hpos2, BeamMonMap::bmon1::hPosatTargetBPM, BeamMonMap::bmon1::hPosatTargetPM, BeamMonTV::htan, BeamMonMap::bmon1::nuTarZ, BeamMonTV::nuTarZ, BeamMonMap::bmon1::tanHoriz, BeamMonMap::bmon1::tanVert, BeamMonTV::time, BeamMonTV::timens, BeamMonMap::bmon1::timeStampD, BeamMonMap::bmon1::timeStampSec, BeamMonMap::bmon1::vBeamWidth, BeamMonTV::vbw, BeamMonTV::vpos1, BeamMonTV::vpos2, BeamMonMap::bmon1::vPosatTargetBPM, BeamMonMap::bmon1::vPosatTargetPM, and BeamMonTV::vtan.

Referenced by MakeBeamMonMap().

00051 {
00052    BeamMonTV b;
00053 //   std::cout<<"Filling beammontv from type 1"<<std::endl;
00054    b.bI=bmn.beamIntensity;
00055    b.hbw=bmn.hBeamWidth;
00056    b.vbw=bmn.vBeamWidth;
00057    b.hpos1=bmn.hPosatTargetPM;
00058    b.vpos1=bmn.vPosatTargetPM;
00059    b.hpos2=bmn.hPosatTargetBPM;
00060    b.vpos2=bmn.vPosatTargetBPM;
00061    b.htan=bmn.tanHoriz;
00062    b.vtan=bmn.tanVert;
00063    b.hornI=bmn.hornPeakCurrent;
00064    b.nuTarZ=bmn.nuTarZ;
00065    b.timens=bmn.timeStampD;
00066    b.time=bmn.timeStampSec;
00067 //   std::cout<<"done"<<std::endl;
00068    return b;
00069 }

BeamMonTV BeamMonMap::FindClosestSpill ( const std::map< VldTimeStamp, BeamMonTV > &  m,
VldTimeStamp  vts 
)

Definition at line 158 of file BeamMonMap.cxx.

References BeamMonTV::closestspill.

00159 {
00160    if(m.size()==0){
00161       BeamMonTV b;
00162       return b;
00163    }
00164 
00165    std::map<VldTimeStamp, BeamMonTV>::const_iterator lb = m.lower_bound(vts);
00166    if(lb==m.begin()){ return lb->second; }
00167    std::map<VldTimeStamp, BeamMonTV>::const_iterator prev=lb;
00168    prev--;
00169    if(lb==m.end()){ return prev->second; }
00170 
00171    double early = fabs(vts-prev->first);
00172    double late = fabs(lb->first-vts);
00173 
00174 //   std::cout<<"early "<<early<<" late "<<late<<std::endl;
00175 
00176    if(early<late){
00177      BeamMonTV bmtv = prev->second;
00178      bmtv.closestspill=early;
00179      return bmtv;
00180    }
00181    BeamMonTV bmtv2 = lb->second;
00182    bmtv2.closestspill=late;
00183    return bmtv2;
00184 }

bool BeamMonMap::IsGoodSpill ( BeamMonTV  b  ) 

Definition at line 186 of file BeamMonMap.cxx.

References BeamMonTV::bI, BeamMonTV::closestspill, BeamMonTV::hbw, BeamMonTV::hpos2, BeamMonTV::vbw, and BeamMonTV::vpos2.

00187 {
00188 
00189    if(b.bI>0.1&&
00190       b.hbw<2&&b.vbw<2&&
00191       b.hpos2<-1.5&&b.hpos2>-2.0&&
00192       b.vpos2>.2&&b.hpos2<1.8&&b.closestspill<2){
00193       return true;
00194    }
00195    return false;
00196 }

std::map< VldTimeStamp, BeamMonTV > BeamMonMap::MakeBeamMonMap ( const char *  path  ) 

Definition at line 94 of file BeamMonMap.cxx.

References BeamMonMap::bmon2::beamIntensity, BeamMonMap::bmon1::beamIntensity, FillBeamMonTV(), fname, Munits::m, n, BeamMonMap::bmon2::timeStampSec, and BeamMonMap::bmon1::timeStampSec.

00095 {
00096 
00097    std::map<VldTimeStamp, BeamMonTV> m;
00098    if(path==NULL){
00099       std::cout<<"Didn't specify a path for beam mon files, wont get em in your tree"<<std::endl;
00100       return m;
00101    }
00102    std::cout<<"opening dir "<<path<<std::endl;
00103 
00104    DIR *dfd;
00105    dirent *dp;
00106    if(!(dfd =  opendir(path))){
00107       std::cout<<" path "<<path<<" "<<dfd<<std::endl;
00108       return m;
00109    }
00110 
00111    std::vector<std::string> names;
00112    while((dp=readdir(dfd))!=NULL){
00113       if(strstr(dp->d_name,"beamsummary_")!=NULL){
00114          names.push_back((std::string)(dp->d_name));
00115       }
00116    }
00117 
00118    std::cout<<"Found "<<names.size()<<" names "<<std::endl;
00119    for(unsigned int i=0;i<names.size();i++){
00120       //figure out what version of bmon ntuple we've got
00121       std::string n=names[i].substr(names[i].find_last_of("_")+1,
00122                                names[i].find_last_of(".")-names[i].find_last_of("_")-1);
00123 //      std::cout<<"n is "<<n<<std::endl;
00124 
00125       //open tree file
00126       std::string fname = path+names[i];
00127       TFile f(fname.c_str());
00128       TTree *b = (TTree *)(f.Get("btree"));
00129       if(atoi(n.c_str())<=7){
00130          struct bmon1 bs;
00131          b->SetBranchAddress("Beaminfo",&bs.beamIntensity);
00132 //       std::cout<<"In first type"<<std::endl;
00133          //loop over tree
00134          for(int z=0;z<b->GetEntries();z++){
00135             b->GetEntry(z);
00136             BeamMonTV bmtv = FillBeamMonTV(bs);
00137             VldTimeStamp vts(bs.timeStampSec,0);
00138             m[vts]=bmtv;
00139          }
00140       }
00141       else{
00142 //       std::cout<<"In second type"<<std::endl;
00143          struct bmon2 bs;
00144          b->SetBranchAddress("Beaminfo",&bs.beamIntensity);
00145          //loop over tree
00146          for(int z=0;z<b->GetEntries();z++){
00147             b->GetEntry(z);
00148             BeamMonTV bmtv = FillBeamMonTV(bs);
00149             VldTimeStamp vts(bs.timeStampSec,0);
00150             m[vts]=bmtv;
00151          }
00152       }
00153       f.Close();
00154    }
00155    return m;
00156 }


Generated on 24 Jul 2018 for loon by  doxygen 1.6.1