BDTarget Class Reference
[BeamDataUtil]

Info about beam at the target and the target itself. More...

#include <BDTarget.h>

Inheritance diagram for BDTarget:
BDProcessor

List of all members.

Public Types

enum  BeamType {
  kUnknown = 0, kLE, kME, kHE,
  kPsME, kPsHE
}

Public Member Functions

 BDTarget ()
virtual ~BDTarget ()
void SetSpill (const RawBeamMonHeaderBlock &rbmhb, const RawBeamMonBlock &rbmb)
 Set the current spill blocks.
BDProfMonGetPM121 ()
BDProfMonGetPMTGT ()
void BpmProjection (std::vector< double > &xp, std::vector< double > &yp, std::vector< double > &xi, std::vector< double > &yi) const
int ProfileProjection (double &x, double &y, double &xrms, double &yrms) const
BeamType TargetIn (bool &is_in, double &z_location, double spilltime=0) const

Private Member Functions

int GetNbatches () const

Private Attributes

const RawBeamDatafBpms [6]
const RawBeamDatafPMs [2]
const RawBeamDatafTgt [3]
BDProfMon fPM121
BDProfMon fPMTGT

Detailed Description

Info about beam at the target and the target itself.

This collects info about the beam at the target and the target itself. It projects the beam via the last two BPMs and profile monitors. It also provides access to info about if the target is in and at what location.

Author:
(last to touch it)
Author
mdier
Version:
Revision
1.13
Date:
Date
2005/11/02 21:53:43

Contact: bv@bnl.gov

Created on: Mon Apr 18 11:25:53 2005

Id
BDTarget.h,v 1.13 2005/11/02 21:53:43 mdier Exp

Definition at line 41 of file BDTarget.h.


Member Enumeration Documentation

Enumerate possible target+horns configuration.

Note:
Implementation note: If extended, it should not be allowed to go beyond 8 types as it is stored in 3 bits of BeamMonSpill's status bits.
Enumerator:
kUnknown 

Unknown beam classification.

kLE 

Nominal Low Energy.

kME 

Nominal (true) Medium Energy.

kHE 

Nominal (true) High Energy.

kPsME 

Nominal (pseudo) Medium Energy.

kPsHE 

Nominal (pseudo) High Energy.

Definition at line 51 of file BDTarget.h.

00051                   {
00052         kUnknown = 0,           
00053         kLE,                    
00054         kME,                    
00055         kHE,                    
00056         kPsME,                  
00057         kPsHE                   
00058     };


Constructor & Destructor Documentation

BDTarget::BDTarget (  ) 

Definition at line 18 of file BDTarget.cxx.

References fBpms, fPMs, and fTgt.

00019     : BDProcessor()
00020 {
00021     for (int ind=0; ind<4; ++ind) fBpms[ind] = 0;
00022     for (int ind=0; ind<2; ++ind) fPMs[ind] = 0;
00023     for (int ind=0; ind<3; ++ind) fTgt[ind] = 0;
00024 }

BDTarget::~BDTarget (  )  [virtual]

Definition at line 26 of file BDTarget.cxx.

00027 {
00028 }


Member Function Documentation

void BDTarget::BpmProjection ( std::vector< double > &  xp,
std::vector< double > &  yp,
std::vector< double > &  xi,
std::vector< double > &  yi 
) const

Fill vectors with projected BPM centers on target (using BPM at 121 and TGT) and intensities (using TGT).

Note:
Position units are Munits, intensities are relative.

Referenced by fill_bdtest(), and BMSpillFiller::Spill().

int BDTarget::GetNbatches (  )  const [private]

Definition at line 109 of file BDTarget.cxx.

References fBpms, RawBeamData::GetDataLength(), and n.

00110 {
00111     // return the shortest physical array length of all BPM positions
00112     // and intensities used.
00113     int n = fBpms[0]->GetDataLength();
00114     for (int ind=1; ind<6; ++ind) {
00115     int n2 = fBpms[ind]->GetDataLength();
00116     if (n2<n) n=n2;
00117     }
00118     return n;
00119 }

BDProfMon& BDTarget::GetPM121 (  )  [inline]

Definition at line 66 of file BDTarget.h.

References fPM121.

00066 { return fPM121; }

BDProfMon& BDTarget::GetPMTGT (  )  [inline]

Definition at line 67 of file BDTarget.h.

References fPMTGT.

00067 { return fPMTGT; }

int BDTarget::ProfileProjection ( double &  x,
double &  y,
double &  xrms,
double &  yrms 
) const

Project Profile centers and widths to target.

Returns:
an int giving status, 0 if no device data
Note:
Units are Munits.

Definition at line 167 of file BDTarget.cxx.

References check_data(), extrapolate_position(), fPM121, fPMs, fPMTGT, get_dae_time(), BDProfMon::GetGaussFit(), TargetIn(), z_pm121, and z_pmtgt.

Referenced by TargetModule::Fill(), fill_bdtest(), and BMSpillFiller::Spill().

00168 {
00169     if (!check_data(fPMs,2)) return 0;    
00170 
00171     double devtime = get_dae_time(fPMs,2);
00172 
00173     double z_targ=0;
00174     bool is_in = false;
00175     if (! this->TargetIn(is_in,z_targ,devtime) || !is_in) return 0;
00176 
00177     double x121=-999,y121=-999,xrms121=-999,yrms121=-999;
00178     //    fPM121.GetStats(x121,y121,xrms121,yrms121);
00179     fPM121.GetGaussFit(x121,y121,xrms121,yrms121);
00180     
00181     double xtgt=0,ytgt=0,xrmstgt=0,yrmstgt=0;
00182     //    fPMTGT.GetStats(xtgt,ytgt,xrmstgt,yrmstgt);
00183     fPMTGT.GetGaussFit(xtgt,ytgt,xrmstgt,yrmstgt);
00184 
00185     if (fabs(x121) < 11*Munits::mm &&
00186     fabs(xtgt) < 11*Munits::mm &&
00187     fabs(y121) < 11*Munits::mm &&
00188     fabs(ytgt) < 11*Munits::mm) {
00189       x = extrapolate_position(x121,z_pm121,xtgt,z_pmtgt,z_targ);
00190       y = extrapolate_position(y121,z_pm121,ytgt,z_pmtgt,z_targ);
00191     }
00192     
00193     xrms = xrmstgt;
00194     yrms = yrmstgt;
00195 
00196     return 1;
00197 }

void BDTarget::SetSpill ( const RawBeamMonHeaderBlock rbmhb,
const RawBeamMonBlock rbmb 
) [virtual]

Set the current spill blocks.

Implements BDProcessor.

Definition at line 49 of file BDTarget.cxx.

References check_data(), fBpms, fPM121, fPMs, fPMTGT, fTgt, Msg::kDebug, MSG, and BDProfMon::SetData().

Referenced by TargetModule::Fill(), and fill_bdtest().

00051 {
00052 
00053     // Order matters!
00054     const char* bpms[] = { "E:VP121", "E:HP121", "E:VPTGT", "E:HPTGT",
00055                "E:VITGT", "E:HITGT", 0 };
00056     for (int ind=0; bpms[ind]; ++ind) {
00057       fBpms[ind] = rbmb[bpms[ind]];
00058       if (!fBpms[ind]) {
00059         MSG("BDU",Msg::kDebug) << "BPM \"" << bpms[ind] << "\" not found\n";
00060       }
00061     }
00062     
00063     const char* pms[] = { "E:M121DS", "E:MTGTDS", 0 };
00064     for (int ind=0; pms[ind]; ++ind) fPMs[ind] = rbmb[pms[ind]];
00065     if (check_data(fPMs,2)) {
00066     fPM121.SetData(*fPMs[0]);
00067     fPMTGT.SetData(*fPMs[1]);
00068     }
00069     
00070     const char* tgt[] = { "I:NUTARZ", "I:NUTGUV", "I:NUTGDV", 0 };
00071     for (int ind=0; tgt[ind]; ++ind) fTgt[ind] = rbmb[tgt[ind]];
00072 }

BDTarget::BeamType BDTarget::TargetIn ( bool &  is_in,
double &  z_location,
double  spilltime = 0 
) const

Target location.

Fill is_in with true if target is in the beam link, fill z_location with distance from nominal LE. Using a non-zero spilltime will use the average position of the target instead of the readout

Returns:
a BeamType enum giving what type of beam setup is used given z_location
Note:
Units of location are Munits.

Definition at line 199 of file BDTarget.cxx.

References check_data(), fTgt, RawBeamData::GetData(), kLE, kME, kPsHE, kPsME, kUnknown, Munits::meter, and Munits::mil.

Referenced by fill_bdtest(), ProfileProjection(), and BMSpillFiller::Spill().

00200 {        
00201         /* From Jim Hylen
00202 
00203         Look at I:NUTGUV and I:NUTGDV
00204         If they are around 1531 and 1441, target is "in"
00205         If they are between 8800 and 8900, target is "out"
00206         Unit is .001"
00207     
00208         For I:NUTARZ, LE ~ 0, Semi-ME ~ 39373, Semi-HE ~98408
00209         Calibration appears to have been drifting by a few
00210         tenths of a percent.
00211         */
00212 
00213         // note on units: mils are used here implicitly as this is what
00214         // the raw data is in.  location is returned in Munits
00215 
00216     is_in = false;
00217     location = -9999/Munits::mil;
00218 
00219     if (spilltime==0){
00220         // use the device readout to determine the target position
00221         if (!check_data(fTgt,3)) return kUnknown;
00222         location = fTgt[0]->GetData()[0];
00223         double up = fTgt[1]->GetData()[0];
00224         double down = fTgt[2]->GetData()[0];
00225         
00226         // Check insert.
00227         if (up < 2000 && down < 2000) is_in = true;
00228         
00229     }
00230     else {
00231         // use the measured average over a period of time in order to
00232         // avoid throwing away spills where the target was actually in
00233         // but the device failed to read out 
00234 
00235         // default assume target is in
00236         is_in = true;
00237         // target positions        
00238         // FIXME: this is hardcoded for the time being, it would be
00239         // good if this goes into a database
00240         if      (spilltime <= 1109540100) location = 39465; // 100 cm
00241         else if (spilltime <= 1109899600) location = 98070; // 250 cm
00242         else if (spilltime <= 1110280000) location = 39465; // 100 cm
00243         else if (spilltime <= 1112010000) location = 815.4; //   0 cm
00244         else if (spilltime <= 1112574300) location = 39350; // 100 cm
00245         else if (spilltime <= 1114040000) is_in = false;
00246         else if (spilltime <= 1114062000) location = 39372; // 100 cm
00247         else if (spilltime <= 1114640000) is_in = false;
00248         else if (spilltime <= 1115935000) location = 39363; // 100 cm
00249         else if (spilltime <= 1116615000) location = 98578; // 250 cm
00250         else if (spilltime <= 1149202720) location = 3935;  // 10 cm
00251         else if (spilltime <= 1150047812) location = 57313; // 150 cm
00252         else if (spilltime <= 1155564632) location = 96227; // 250 cm
00253         else location = 3937;                               // 10 cm
00254     }
00255     
00256     location *= Munits::mil;
00257     BeamType bt = kUnknown;
00258     const float dist_cut = 0.35*Munits::meter;
00259     const float le_pos   = 0.0*Munits::meter;
00260     const float pme_pos  = 1.25*Munits::meter;
00261     const float phe_pos  = 2.5*Munits::meter;
00262     if      (fabs(location-le_pos)  < dist_cut) bt = kLE;
00263     else if (fabs(location-pme_pos) < dist_cut) bt = kPsME;
00264     else if (fabs(location-phe_pos) < dist_cut) bt = kPsHE;
00265     else bt = kUnknown;
00266 
00267     // NOvA era ... for now assume target in and true ME configuration
00268     const VldTimeStamp startNOvA(2013,6,1,0/*hr*/,0/*min*/,0/*sec*/,0/*ns*/);
00269     if ( spilltime >= (double)startNOvA ) {
00270       location = 0;
00271       is_in    = true;
00272       bt       = kME;
00273     }
00274 
00275     return bt;
00276 }


Member Data Documentation

const RawBeamData* BDTarget::fBpms[6] [private]

Definition at line 100 of file BDTarget.h.

Referenced by BDTarget(), GetNbatches(), and SetSpill().

Definition at line 101 of file BDTarget.h.

Referenced by GetPM121(), ProfileProjection(), and SetSpill().

const RawBeamData * BDTarget::fPMs[2] [private]

Definition at line 100 of file BDTarget.h.

Referenced by BDTarget(), ProfileProjection(), and SetSpill().

Definition at line 101 of file BDTarget.h.

Referenced by GetPMTGT(), ProfileProjection(), and SetSpill().

const RawBeamData * BDTarget::fTgt[3] [private]

Definition at line 100 of file BDTarget.h.

Referenced by BDTarget(), SetSpill(), and TargetIn().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1