BMSpillAna Class Reference
[BeamDataUtil]

Beam quality cuts and other method to analyze beam data ntuples. More...

#include <BMSpillAna.h>

List of all members.

Public Member Functions

 BMSpillAna ()
virtual ~BMSpillAna ()
const RegistryDefaultConfig () const
void Config (const Registry &r)
const RegistryGetUserCuts () const
 Access the cuts supplied by the user.
void UseDatabaseCuts (Bool_t usedb=true)
 Change if one wants to use the database or not.
void UseCutsSet (Dbi::Task cutset)
 Change the set of cuts to use.
void SetSpill (const BeamMonSpill &spill)
 Set the BeamMonSpill object.
void SetSpill (const NtpBDLiteRecord &ntpbdr, BeamMonSpill &spill)
void SetSnarlTime (const VldTimeStamp &vs_snarl)
void SetTimeDiff (Double_t tdiff)
const BeamMonSpillGetSpill () const
 Return a reference to BeamMonSpill object.
Bool_t SelectSpill ()
 Select a spill within the cut values.
Double_t FractionOnTarget ()
Double_t CalcFracOnTarget (Double_t bpos, Double_t bwid, Double_t tedg, Double_t toff)
void Print (const Option_t *opt="") const
 Print out the cut values.
Int_t FailBits () const
 Bits indicating why SelectSpill() failed.
void PrintFailureReasons (const Option_t *opt="c") const
 Interpret FailBits in user fashion.
std::string FailureReasonsString () const

Private Types

typedef enum BMSpillAna::FailMode FailMode_t
 kTimeDiff = 0x0001
 kTgtX = 0x0002
 kTgtY = 0x0004
 kFitFail = 0x0008
 kSpot1 = 0x0010
 kSpot2 = 0x0020
 kToroid = 0x0040
 kHornCur = 0x0080
 kProfX = 0x0100
 kProfXWid = 0x0200
 kProfY = 0x0400
 kProfYWid = 0x0800
 kOnTgt = 0x1000
 kTgtIn = 0x2000
 kBeamType = 0x4000
 kMask = 0xFFFF
enum  FailMode {
  kTimeDiff = 0x0001, kTgtX = 0x0002, kTgtY = 0x0004, kFitFail = 0x0008,
  kSpot1 = 0x0010, kSpot2 = 0x0020, kToroid = 0x0040, kHornCur = 0x0080,
  kProfX = 0x0100, kProfXWid = 0x0200, kProfY = 0x0400, kProfYWid = 0x0800,
  kOnTgt = 0x1000, kTgtIn = 0x2000, kBeamType = 0x4000, kMask = 0xFFFF
}

Private Member Functions

void ChangeCutValues (const Registry &r)
 Apply changes to the cut values.
void ApplyUserCuts ()

Private Attributes

const BeamMonSpillfSpill
 The pointer to the reference to the BeamMonSpill object.
Registry fUserCuts
Bool_t fUseDBCuts
Dbi::Task fCutsSet
DbiResultPtr< BeamMonCutsfResPtr
Int_t fResID
Double_t fTimeDiff
Double_t fTimeDiffMax
 Below here are all the members that hold the cut values.
Double_t fPosTgtXMin
Double_t fPosTgtXMax
Double_t fPosTgtYMin
 Defaults are min=0.01 and max=2.0.
Double_t fPosTgtYMax
Double_t fWidXMin
Double_t fWidXMax
Double_t fWidYMin
 Defaults are min=0.1 and max=2.0.
Double_t fWidYMax
Int_t fUseSpotSizeCut
Int_t fUseProfMonOut
Double_t fTorIntMin
Double_t fTorIntMax
Double_t fHornCurMin
Double_t fHornCurMax
Int_t fTargetIn
Int_t fBeamType
Double_t fFracOnTargetMin
Double_t fFracOnTargetMax
Int_t fFailBits
 Record of failure modes for previous call to SelectSpill().
Bool_t fCutValuesChanged
 keep track of whether values changed


Detailed Description

Beam quality cuts and other method to analyze beam data ntuples.

A helper class with a number of useful methods, like beam quality cuts, to handle BeamMonSpill or NtpBDLite objects. Behind the scenes, this class uses BeamMonSpill objects, and transforms NtpBDLiteRecord objects accordingly. In this way, one can maintain only one version of the code and also access useful methods in BeamMonSpill.

The default values for the cuts on the beam quantities are not very strict. So don't use them blindly, have a look at them and determine if they satisfy your needs. There is also no cut on the timing difference between the snarl and the spill.

As of February 22, 2007, the default is to use the cut values that are in the database table BEAMMONCUTS. It is possible to switch back and use hardcoded values through the fUseDBCuts switch.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.13
Date:
Date
2015/06/11 21:55:50
Contact: mdier@bnl.gov

Created on: Fri Aug 26 16:29:30 2005

Id
BMSpillAna.h,v 1.13 2015/06/11 21:55:50 rhatcher Exp

Definition at line 51 of file BMSpillAna.h.


Member Typedef Documentation

typedef enum BMSpillAna::FailMode BMSpillAna::FailMode_t [private]


Member Enumeration Documentation

enum BMSpillAna::FailMode [private]

Enumerator:
kTimeDiff 
kTgtX 
kTgtY 
kFitFail 
kSpot1 
kSpot2 
kToroid 
kHornCur 
kProfX 
kProfXWid 
kProfY 
kProfYWid 
kOnTgt 
kTgtIn 
kBeamType 
kMask 

Definition at line 279 of file BMSpillAna.h.

00279                           {
00280       kTimeDiff = 0x0001,
00281       kTgtX     = 0x0002,
00282       kTgtY     = 0x0004,
00283       kFitFail  = 0x0008,
00284       kSpot1    = 0x0010,
00285       kSpot2    = 0x0020,
00286       kToroid   = 0x0040,
00287       kHornCur  = 0x0080,
00288       kProfX    = 0x0100,
00289       kProfXWid = 0x0200,
00290       kProfY    = 0x0400,
00291       kProfYWid = 0x0800,
00292       kOnTgt    = 0x1000,
00293       kTgtIn    = 0x2000,
00294       kBeamType = 0x4000,
00295       kMask     = 0xFFFF
00296     } FailMode_t;


Constructor & Destructor Documentation

BMSpillAna::BMSpillAna (  ) 

Definition at line 16 of file BMSpillAna.cxx.

References ChangeCutValues().

00017     :fSpill(0),fUserCuts(),fUseDBCuts(true),fCutsSet(0),fResPtr(),
00018      fResID(-1),fTimeDiff(-99999),fFailBits(0), fCutValuesChanged(1)
00019 {
00020     this->ChangeCutValues(this->DefaultConfig());
00021 }

BMSpillAna::~BMSpillAna (  )  [virtual]

Definition at line 24 of file BMSpillAna.cxx.

00025 {}


Member Function Documentation

void BMSpillAna::ApplyUserCuts (  )  [private]

Definition at line 110 of file BMSpillAna.cxx.

References ChangeCutValues(), and fUserCuts.

Referenced by SelectSpill().

00111 {
00112     this->ChangeCutValues(fUserCuts);
00113 }

Double_t BMSpillAna::CalcFracOnTarget ( Double_t  bpos,
Double_t  bwid,
Double_t  tedg,
Double_t  toff 
)

Calculates the fraction of the integral of a gaussian with mean bpos and width bwid between -tpos-toff and +tpos-toff

Definition at line 366 of file BMSpillAna.cxx.

Referenced by FractionOnTarget().

00367 {
00368     Double_t powl = tedg+bpos-toff;
00369     powl /= bwid;
00370     powl /= TMath::Sqrt(2.0);
00371     Double_t powu = tedg-bpos+toff;
00372     powu /= bwid;
00373     powu /= TMath::Sqrt(2.0);
00374     Double_t frac = TMath::Erf(powl)/2 +  TMath::Erf(powu)/2; 
00375     return frac;
00376 }

void BMSpillAna::ChangeCutValues ( const Registry r  )  [private]

Apply changes to the cut values.

Definition at line 74 of file BMSpillAna.cxx.

References fBeamType, fCutValuesChanged, fFracOnTargetMax, fFracOnTargetMin, fHornCurMax, fHornCurMin, fPosTgtXMax, fPosTgtXMin, fPosTgtYMax, fPosTgtYMin, fTargetIn, fTimeDiffMax, fTorIntMax, fTorIntMin, fUseProfMonOut, fUseSpotSizeCut, fWidXMax, fWidXMin, fWidYMax, fWidYMin, Registry::Get(), and Registry::Size().

Referenced by ApplyUserCuts(), BMSpillAna(), Config(), and SelectSpill().

00075 {
00076     fCutValuesChanged = 1;
00077     if (r.Size()>0){
00078         r.Get("TimeDiffMax",fTimeDiffMax);
00079         
00080         r.Get("PosTgtXMin",fPosTgtXMin);
00081         r.Get("PosTgtXMax",fPosTgtXMax);
00082         
00083         r.Get("PosTgtYMin",fPosTgtYMin);
00084         r.Get("PosTgtYMax",fPosTgtYMax);
00085         
00086         r.Get("WidXMin",fWidXMin);
00087         r.Get("WidXMax",fWidXMax);
00088         
00089         r.Get("WidYMin",fWidYMin);
00090         r.Get("WidYMax",fWidYMax);
00091 
00092         r.Get("UseSpotSizeCut",fUseSpotSizeCut);
00093         
00094         r.Get("UseProfMonOut",fUseProfMonOut);
00095         
00096         r.Get("TorIntMin",fTorIntMin);
00097         r.Get("TorIntMax",fTorIntMax);
00098         
00099         r.Get("HornCurMin",fHornCurMin);
00100         r.Get("HornCurMax",fHornCurMax);
00101         
00102         r.Get("TargetIn",fTargetIn);
00103         r.Get("BeamType",fBeamType);
00104         
00105         r.Get("FracOnTargetMin",fFracOnTargetMin);
00106         r.Get("FracOnTargetMax",fFracOnTargetMax);
00107     }        
00108 }

void BMSpillAna::Config ( const Registry r  ) 

Definition at line 68 of file BMSpillAna.cxx.

References ChangeCutValues(), and fUserCuts.

Referenced by NueBeamMonModule::Config(), MeuCuts::GetBDSelectSpillInfo(), NuBeam::IsGoodSpillAndFillPot(), NtpTools::PassBeamCuts(), and StndBmsSpin::Scan().

00069 {
00070     fUserCuts=r;
00071     this->ChangeCutValues(r);
00072 }

const Registry & BMSpillAna::DefaultConfig (  )  const

Definition at line 28 of file BMSpillAna.cxx.

References Munits::ampere, Registry::LockValues(), Munits::mm, Munits::s, Registry::Set(), Registry::Size(), and Registry::UnLockValues().

00029 {
00030     static Registry r;
00031     if (r.Size() == 0) {
00032         r.UnLockValues();
00033         r.Set("TimeDiffMax", 1.0*Munits::s);
00034 
00035         r.Set("PosTgtXMin",-2.0*Munits::mm);
00036         r.Set("PosTgtXMax",-0.01*Munits::mm);
00037 
00038         r.Set("PosTgtYMin",0.01*Munits::mm);
00039         r.Set("PosTgtYMax",2.0*Munits::mm);
00040 
00041         r.Set("WidXMin",0.1*Munits::mm);
00042         r.Set("WidXMax",1.5*Munits::mm);
00043 
00044         r.Set("WidYMin",0.1*Munits::mm);
00045         r.Set("WidYMax",2.0*Munits::mm);
00046 
00047         r.Set("UseSpotSizeCut",0);
00048         
00049         r.Set("UseProfMonOut",1);
00050 
00051         r.Set("TorIntMin",0.50);
00052         r.Set("TorIntMax",50.0);
00053 
00054         r.Set("HornCurMin",-2.0e5*Munits::ampere);
00055         r.Set("HornCurMax",-1.55e5*Munits::ampere);
00056 
00057         r.Set("TargetIn",1);
00058         r.Set("BeamType",-1);
00059 
00060         r.Set("FracOnTargetMin",0.0);
00061         r.Set("FracOnTargetMax",1.0);
00062 
00063         r.LockValues();
00064     }
00065     return r;
00066 }

Int_t BMSpillAna::FailBits (  )  const [inline]

Bits indicating why SelectSpill() failed.

Definition at line 126 of file BMSpillAna.h.

References fFailBits.

00126 { return fFailBits; }

std::string BMSpillAna::FailureReasonsString (  )  const

Definition at line 425 of file BMSpillAna.cxx.

References fFailBits, kBeamType, kFitFail, kHornCur, kOnTgt, kProfX, kProfXWid, kProfY, kProfYWid, kSpot1, kSpot2, kTgtIn, kTgtX, kTgtY, kTimeDiff, and kToroid.

Referenced by PrintFailureReasons().

00426 {
00427   std::ostringstream os;
00428   if ( fFailBits & kTimeDiff ) os <<" TimeDiff";
00429   if ( fFailBits & kTgtX     ) os <<" TgtX";
00430   if ( fFailBits & kTgtY     ) os <<" TgtY";
00431   if ( fFailBits & kFitFail  ) os <<" FitFail";
00432   if ( fFailBits & kSpot1    ) os <<" Spot1";
00433   if ( fFailBits & kSpot2    ) os <<" Spot2";
00434   if ( fFailBits & kToroid   ) os <<" Toroid";
00435   if ( fFailBits & kHornCur  ) os <<" HornCur";
00436   if ( fFailBits & kProfX    ) os <<" ProfX";
00437   if ( fFailBits & kProfXWid ) os <<" ProfXWid";
00438   if ( fFailBits & kProfY    ) os <<" ProfY";
00439   if ( fFailBits & kProfYWid ) os <<" ProfYWid";
00440   if ( fFailBits & kOnTgt    ) os <<" OnTgt";
00441   if ( fFailBits & kTgtIn    ) os <<" TgtIn";
00442   if ( fFailBits & kBeamType ) os <<" BeamType";
00443   return os.str();
00444 }

Double_t BMSpillAna::FractionOnTarget (  ) 

Calcualte the fraction of beam on target using the BPM position at the target and the beam with from the profile monitors. It is actually the product of the fraction in the horizontal and vertical direction. For the latter, the part of the target that is hidden behind the baffle is not taken as part of the target (i.e. assume a target of +-5.5mm in vertical and +-3.2mm in horizontal, values from sections 4.2.2 and 4.2.3 of the NuMI Technical Design Handbook)

note **** This method can only be used when the widths assume a gaussian distribution (e.g. obtained from fitting to the profile monitors). At the moment, only the rms of the beam profiles are in the database and the result from this method has no meaning.

Definition at line 308 of file BMSpillAna.cxx.

References BeamMonSpill::BpmAtTarget(), CalcFracOnTarget(), BeamMonSpill::fProfWidX, BeamMonSpill::fProfWidY, fSpill, VldTimeStamp::GetSec(), Munits::mm, and BeamMonSpill::SpillTime().

Referenced by SelectSpill().

00309 {
00310     Double_t frac = -1;
00311 //
00312     Double_t bposx = 0;
00313     Double_t bwidx = 0;
00314 //
00315     Double_t bposy = 0;
00316     Double_t bwidy = 0;
00317     
00318     // Get the position at target 
00319     fSpill->BpmAtTarget(bposx,bposy,bwidx,bwidy);
00320     
00321     // Set the values of the widths to prof mon fits
00322     bwidx = fSpill->fProfWidX; 
00323     bwidy = fSpill->fProfWidY; 
00324 
00325     // information of profile monitors not available or fits failed
00326     if (bwidx<=0 || bwidy<=0) return frac;
00327 
00328     // large values also indicate fit failure
00329 
00330     if (bwidx>5*Munits::mm || bwidy>05*Munits::mm) return frac;
00331 
00332 
00333     Double_t tedgx = -9999;
00334     Double_t toffx = -9999;
00335     Double_t tedgy = -9999;
00336     Double_t toffy = -9999;
00337 
00338     const VldTimeStamp startNOvA(2013,6,1,0/*hr*/,0/*min*/,0/*sec*/,0/*ns*/);
00339 
00340     Double_t spilltime = fSpill->SpillTime().GetSec();
00341 
00342 
00343     if (spilltime >= (double)startNOvA) {
00344 
00345       // Nova era target coordinates
00346       tedgx = 3.7*Munits::mm;
00347       toffx = 1.0*Munits::mm;
00348       tedgy = 3.7*Munits::mm;
00349       toffy = 1.0*Munits::mm;
00350     }
00351     else  {
00352       // MINOS era target coordinates:
00353       tedgx = 3.2*Munits::mm;
00354       toffx = -1.2*Munits::mm;
00355       tedgy = 5.5*Munits::mm;
00356       toffy = 0.9*Munits::mm;
00357     }
00358 
00359 
00360     frac = CalcFracOnTarget(bposx,bwidx,tedgx,toffx);
00361     frac *= CalcFracOnTarget(bposy,bwidy,tedgy,toffy);
00362     
00363     return frac;    
00364 }

const BeamMonSpill & BMSpillAna::GetSpill (  )  const [inline]

Return a reference to BeamMonSpill object.

Definition at line 309 of file BMSpillAna.h.

References fSpill.

Referenced by NuBeam::IsGoodSpillAndFillPot().

00310 {return *fSpill;}

const Registry & BMSpillAna::GetUserCuts (  )  const [inline]

Access the cuts supplied by the user.

Definition at line 306 of file BMSpillAna.h.

References fUserCuts.

00307 {return fUserCuts;}

void BMSpillAna::Print ( const Option_t *  opt = ""  )  const

Print out the cut values.

Definition at line 378 of file BMSpillAna.cxx.

References Munits::ampere, fBeamType, fFracOnTargetMax, fFracOnTargetMin, fHornCurMax, fHornCurMin, fPosTgtXMax, fPosTgtXMin, fPosTgtYMax, fPosTgtYMin, fTargetIn, fTimeDiffMax, fTorIntMax, fTorIntMin, fUseProfMonOut, fWidXMax, fWidXMin, fWidYMax, fWidYMin, and Munits::mm.

Referenced by NuAnalysis::ExtractConfig(), NuBeam::IsGoodSpillAndFillPot(), PrintFailureReasons(), and SelectSpill().

00379 {
00380     cout << endl << "Beam Monitoring Cut Values:" << endl;
00381     cout         << "===========================" << endl;
00382 
00383     printf(" > Maximum time diffrence (s):         %5.3f\n",fTimeDiffMax);
00384     printf(" > Spill intensity (1e12 pot):     [%5.2f,%5.2f]\n",
00385            fTorIntMin, fTorIntMax);
00386     printf(" > Horn Current (kA):             [%+5.1f,%+5.1f]\n",
00387            fHornCurMin/Munits::ampere/1e3, fHornCurMax/Munits::ampere/1e3);
00388     printf(" > Target in/out:                      %3d\n",fTargetIn);
00389     printf(" > fBeamType:                          %3d\n",fBeamType);    
00390     printf(" > Horizontal beam position (mm): [%+5.3f,%+5.3f]\n",
00391            fPosTgtXMin/Munits::mm, fPosTgtXMax/Munits::mm);
00392     printf(" > Vertical beam position (mm):   [%+5.3f,%+5.3f]\n",
00393            fPosTgtYMin/Munits::mm, fPosTgtYMax/Munits::mm);
00394     printf(" > Horizontal beam width a (mm):  [%+5.3f,%+5.3f]\n",
00395            fWidXMin/Munits::mm, fWidXMax/Munits::mm);
00396     printf(" > Vertical beam width a (mm):    [%+5.3f,%+5.3f]\n",
00397            fWidYMin/Munits::mm, fWidYMax/Munits::mm);
00398     printf(" > Use spill when prof mon out:        %3d\n",fUseProfMonOut);
00399     printf(" > Beam fraction on target:       [%5.3f,%5.3f]\n",
00400            fFracOnTargetMin, fFracOnTargetMax);
00401 
00402 }

void BMSpillAna::PrintFailureReasons ( const Option_t *  opt = "c"  )  const

Interpret FailBits in user fashion.

Definition at line 404 of file BMSpillAna.cxx.

References FailureReasonsString(), fCutValuesChanged, fFailBits, and Print().

00405 {
00406   if ( fFailBits == 0 ) return;  // nothing to report
00407 
00408   // print cut values if option 'C' or 'c'
00409   // if 'c' only print each time they change
00410   std::string optstr(opt);
00411   bool print_once   = ( optstr.find("c") != std::string::npos );
00412   bool print_always = ( optstr.find("C") != std::string::npos );
00413   if ( print_once || print_always ) {
00414     // print the cuts
00415     if ( fCutValuesChanged || print_always ) Print();
00416     fCutValuesChanged = false;
00417   }
00418 
00419   std::cout << "BMSpillAna: SelectSpill failed due to "
00420             << "0x" << std::setfill('0') << std::hex << std::setw(8)
00421             << fFailBits << std::dec << std::setfill(' ') << std::endl;
00422   std::cout << "  " << FailureReasonsString() << std::endl;
00423 }

Bool_t BMSpillAna::SelectSpill (  ) 

Select a spill within the cut values.

Definition at line 164 of file BMSpillAna.cxx.

References ApplyUserCuts(), BeamMonSpill::BeamType(), BeamMonSpill::BpmAtTarget(), ChangeCutValues(), fBeamType, fCutsSet, fFailBits, fFracOnTargetMax, fFracOnTargetMin, BeamMonSpill::fHornCur, fHornCurMax, BeamMonCuts::FillRegistry(), fPosTgtXMax, fPosTgtYMax, BeamMonSpill::fProfWidX, BeamMonSpill::fProfWidY, FractionOnTarget(), fResID, fResPtr, fSpill, fTargetIn, fTimeDiff, fTimeDiffMax, fTorIntMax, fTorIntMin, BeamMonSpill::fTrtgtd, fUseDBCuts, fUseProfMonOut, fUseSpotSizeCut, fWidXMax, fWidXMin, fWidYMax, fWidYMin, MsgStream::GetLogLevel(), DbiResultPtr< T >::GetResultID(), DbiResultPtr< T >::GetRow(), BeamMonSpill::GetStatusBits(), MsgService::GetStream(), MsgService::Instance(), kBeamType, SimFlag::kData, Msg::kDebug, kFitFail, kHornCur, Detector::kNear, kOnTgt, kProfX, kProfXWid, kProfY, kProfYWid, kSpot1, kSpot2, kTgtIn, kTgtX, kTgtY, kTimeDiff, kToroid, Msg::kWarning, MAXMSG, Munits::mm, MSG, DbiResultPtr< T >::NewQuery(), Print(), and BeamMonSpill::SpillTime().

Referenced by ParticleBeamMonAna::ana(), MadTVAnalysis::CreatePAN(), MadPIDAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), MadAnalysis::CreatePAN(), NuExtraction::ExtractBeamInfoDB(), NuAnalysis::ExtractConfig(), ANtpInfoObjectFillerBeam::FillBeamInformation(), NtpMaker::FillSpillInfo(), MeuCuts::GetBDSelectSpillInfo(), NuBeam::IsGoodSpillAndFillPot(), NtpTools::PassBeamCuts(), DataQualityInterface::ProcessBeamStatus(), DataUtil::QueryBeamDB(), NueBeamMonModule::Reco(), and StndBmsSpin::Scan().

00165 {
00166     fFailBits = 0;
00167     if (fTimeDiff==-99999) {
00168         MSG("BMSpillAna", Msg::kWarning) <<
00169             "Time difference seems not to be set correctly" << endl;
00170         fFailBits |= kTimeDiff;
00171     }
00172     
00173     // If using the database, check whether the cuts need to be
00174     // updated
00175         
00176     if (fUseDBCuts){
00177         MAXMSG("BMSpillAna", Msg::kDebug,5) <<
00178             "Using database cuts" << endl;
00179 
00180 
00181         VldContext vc(Detector::kNear,SimFlag::kData,fSpill->SpillTime());
00182         Int_t nrows = fResPtr.NewQuery(vc,fCutsSet);
00183         if (nrows==0){
00184             MAXMSG("BMSpillAna",Msg::kWarning,20)
00185                 << "No cuts found in database. This should not happen!"
00186                 << endl;
00187         }
00188         else {
00189             if (nrows>1) {
00190                 MAXMSG("BMSpillAna",Msg::kWarning,20)
00191                     << "More than one row found for VldContext " 
00192                     << vc << endl
00193                     << "   --> Will only use first row! " << endl;
00194             }
00195             
00196             MAXMSG("BMSpillAna", Msg::kDebug,5) <<
00197                 "Rows found in BEAMMONCUTS table" << endl;
00198             // If the cuts are still the same (i.e. the data in the
00199             // DbiResultPointer is the same, do nothing, just keep the
00200             // current cut values, else change the cut values and
00201             // apply user cuts
00202 
00203             Int_t newid = fResPtr.GetResultID();
00204             if (newid != fResID){
00205                 MSG("BMSpillAna", Msg::kDebug) <<
00206                     "Cuts need to be updated for spill at " << fSpill->SpillTime()  << endl;
00207                 fResID = newid;
00208                 const BeamMonCuts* bmc = fResPtr.GetRow(0);
00209                 Registry newreg;
00210                 bmc->FillRegistry(&newreg);
00211                 this->ChangeCutValues(newreg);
00212 
00213                 Int_t loglevel = MsgService::Instance()->GetStream("BMSpillAna")->GetLogLevel();
00214                 if (loglevel == Msg::kDebug){
00215                     cout << "Database cuts" << endl;
00216                     this->Print();
00217                 }
00218 
00219                 this->ApplyUserCuts();
00220                 if (loglevel == Msg::kDebug){
00221                     cout << "After user cuts" << endl;
00222                     this->Print();
00223                 }
00224             }
00225         }        
00226     }
00227 
00228     if (fabs(fTimeDiff)>fTimeDiffMax) return false;
00229     
00230     Double_t xmean=0;
00231     Double_t ymean=0;
00232     Double_t xrms=0;
00233     Double_t yrms=0;
00234     fSpill->BpmAtTarget(xmean,ymean,xrms,yrms);
00235     if (xmean < fPosTgtXMin || xmean > fPosTgtXMax) fFailBits |= kTgtX;
00236     if (ymean < fPosTgtYMin || ymean > fPosTgtYMax) fFailBits |= kTgtY;
00237 
00238 
00239     // Never select fit failures
00240     if ( fSpill->fProfWidX < -0.1*Munits::mm ||
00241          fSpill->fProfWidY < -0.1*Munits::mm    ) fFailBits |= kFitFail;
00242     //
00243     if (fUseSpotSizeCut){
00244         // The widths should never be negative, unless it's due to a
00245         // fit failure, but these are already excluded above. The
00246         // values will be zero if the profile monitor is out.
00247         Double_t spot_size=0;
00248         if (fSpill->fProfWidX>0 && fSpill->fProfWidY>0)
00249             spot_size = fSpill->fProfWidX*fSpill->fProfWidY;
00250 
00251         // put this defualt to a small negative value, so that the
00252         // pribility exists to select the spill if the profile monitor
00253         // is out, i.e. widths are zero.
00254         Double_t spot_size_min = -0.01*Munits::mm*Munits::mm;
00255         if (fWidXMin>0 && fWidYMin>0)
00256             spot_size_min = fWidXMin*fWidYMin;
00257 
00258         // Assume people are smart enough not to put negative values
00259         // for the upper limit on the beam widths. If they do, they
00260         // will loose all spills...
00261         Double_t spot_size_max = fWidXMax*fWidYMax;
00262 
00263         if (!(fUseProfMonOut) && spot_size < spot_size_min ) fFailBits |= kSpot1;
00264         else if (spot_size > spot_size_max) fFailBits |= kSpot2;
00265 
00266     }
00267     else {       
00268         if (!(fUseProfMonOut) && fSpill->fProfWidX < fWidXMin) fFailBits |= kProfX;
00269         else if (fSpill->fProfWidX > fWidXMax) fFailBits |= kProfXWid;
00270         
00271         if (!(fUseProfMonOut) && fSpill->fProfWidY < fWidYMin) fFailBits |= kProfY;
00272         else if (fSpill->fProfWidY > fWidYMax) fFailBits |= kProfYWid;
00273     }
00274 
00275 
00276     //changed to Trtgtd from Tortgt on 20080814
00277     if (fSpill->fTrtgtd < fTorIntMin || fSpill->fTrtgtd > fTorIntMax){
00278         fFailBits |= kToroid;
00279     }
00280     
00281     // FIXME: values in the database are in kAmps, not in
00282     // Munits. This will get fixed eventually, but for now, there
00283     // need to be an explicit factor of 1e3.
00284     if (fSpill->fHornCur*1e3 < fHornCurMin || fSpill->fHornCur*1e3 > fHornCurMax){
00285         fFailBits |= kHornCur;
00286     }
00287 
00288     //added  fTargetIn < 0 || on 20080814
00289     if ( fTargetIn < 0 || (fTargetIn >= 0 && (Bool_t)fSpill->GetStatusBits().target_in != (Bool_t)fTargetIn) ){ 
00290         fFailBits |= kTgtIn;
00291     }
00292 
00293     if (fBeamType >=0 && (fSpill->BeamType() != fBeamType)){
00294         fFailBits |= kBeamType;
00295     }
00296 
00297     if (fFracOnTargetMin > 0 &&  this->FractionOnTarget() < fFracOnTargetMin) {
00298         fFailBits |= kOnTgt;
00299     }
00300     if (fFracOnTargetMax < 1 &&  this->FractionOnTarget() > fFracOnTargetMax) {
00301         fFailBits |= kOnTgt;
00302     }
00303     
00304     return (fFailBits == 0);
00305 }

void BMSpillAna::SetSnarlTime ( const VldTimeStamp vs_snarl  ) 

Give the snarl trigger time, to calculate the time difference wrt the beam monitoring data. This can be used alternative to SetTimeDiff below. This need to be called when using BeamMonSpill objects (i.e. no BDLite ntuples). Be aware that you will need to call this method AFTER you set the spill object, and this needs to be set.

Definition at line 155 of file BMSpillAna.cxx.

References fSpill, Msg::kError, MSG, SetTimeDiff(), and BeamMonSpill::SpillTime().

Referenced by ParticleBeamMonAna::ana(), MadPIDAnalysis::CreatePAN(), and NueBeamMonModule::Reco().

00156 {
00157     if (fSpill==0){
00158         MSG("BMSpillAna", Msg::kError)<< "Set the spill object before setting this time" << endl;
00159         return;
00160     }
00161     this->SetTimeDiff(vs_snarl-fSpill->SpillTime());
00162 }

void BMSpillAna::SetSpill ( const NtpBDLiteRecord ntpbdr,
BeamMonSpill spill 
)

Set the NtpBDLiteRecord object. The user should create and pass in a non const BeamMonSpill object by him/herself. This is to facilitate memory management.

Definition at line 125 of file BMSpillAna.cxx.

References NtpBDLiteRecord::bpmint, NtpBDLiteRecord::bposx, NtpBDLiteRecord::bposy, NtpBDLiteRecord::bwidx, NtpBDLiteRecord::bwidy, BeamMonSpill::fBpmInt, BeamMonSpill::fDaeTime, BeamMonSpill::fHadInt, BeamMonSpill::fHornCur, BeamMonSpill::fMuInt1, BeamMonSpill::fMuInt2, BeamMonSpill::fMuInt3, BeamMonSpill::fProfWidX, BeamMonSpill::fProfWidY, fSpill, BeamMonSpill::fTargBpmX, BeamMonSpill::fTargBpmY, BeamMonSpill::fTor101, BeamMonSpill::fTortgt, BeamMonSpill::fTr101d, BeamMonSpill::fTrtgtd, BeamMonSpill::fVmeTime, BeamDataLiteHeader::GetEarliestTimeStamp(), RecRecordImp< T >::GetHeader(), BeamDataLiteHeader::GetStatus(), BeamDataLiteHeader::GetTimeDiffStreamSpill(), NtpBDLiteRecord::hadint, NtpBDLiteRecord::horncur, NtpBDLiteRecord::muint1, NtpBDLiteRecord::muint2, NtpBDLiteRecord::muint3, BeamMonSpill::SetStatusBits(), SetTimeDiff(), NtpBDLiteRecord::tor101, NtpBDLiteRecord::tortgt, NtpBDLiteRecord::tr101d, and NtpBDLiteRecord::trtgtd.

00126 {
00127     fSpill = &spill;
00128 
00129     this->SetTimeDiff(ntpbdr.GetHeader().GetTimeDiffStreamSpill());
00130     
00131     spill.fDaeTime = ntpbdr.GetHeader().GetEarliestTimeStamp();
00132     spill.fVmeTime = ntpbdr.GetHeader().GetEarliestTimeStamp();
00133     spill.fTor101  = ntpbdr.tor101;
00134     spill.fTr101d  = ntpbdr.tr101d;
00135     spill.fTortgt  = ntpbdr.tortgt;
00136     spill.fTrtgtd  = ntpbdr.trtgtd;
00137     spill.fHornCur = ntpbdr.horncur;
00138     for (int i=0;i<6;++i){
00139         spill.fTargBpmX[i] = ntpbdr.bposx[i];
00140         spill.fTargBpmY[i] = ntpbdr.bposy[i];
00141         spill.fBpmInt[i]   = ntpbdr.bpmint[i];
00142     }
00143     spill.fProfWidX = ntpbdr.bwidx;
00144     spill.fProfWidY = ntpbdr.bwidy;
00145     spill.fHadInt = ntpbdr.hadint;
00146     spill.fMuInt1 = ntpbdr.muint1;
00147     spill.fMuInt2 = ntpbdr.muint2;
00148     spill.fMuInt3 = ntpbdr.muint3;
00149     union {int integer; BeamMonSpill::StatusBits bits; } status;
00150     status.integer = ntpbdr.GetHeader().GetStatus();
00151     spill.SetStatusBits(status.bits);
00152 
00153 }

void BMSpillAna::SetSpill ( const BeamMonSpill spill  ) 

Set the BeamMonSpill object.

Definition at line 116 of file BMSpillAna.cxx.

References fSpill, and SetTimeDiff().

Referenced by ParticleBeamMonAna::ana(), MadTVAnalysis::CreatePAN(), MadPIDAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), MadAnalysis::CreatePAN(), NuExtraction::ExtractBeamInfoDB(), NuAnalysis::ExtractConfig(), ANtpInfoObjectFillerBeam::FillBeamInformation(), NtpMaker::FillSpillInfo(), MeuCuts::GetBDSelectSpillInfo(), NuBeam::IsGoodSpillAndFillPot(), NtpTools::PassBeamCuts(), DataQualityInterface::ProcessBeamStatus(), DataUtil::QueryBeamDB(), NueBeamMonModule::Reco(), and StndBmsSpin::Scan().

00117 {
00118     fSpill = &spill;
00119     // Reset the time difference every time to make sure that the user
00120     // updates it.
00121     this->SetTimeDiff(-99999);
00122 
00123 }

void BMSpillAna::SetTimeDiff ( Double_t  tdiff  )  [inline]

Set the time difference between the data stream and the beam monitoring data, needed when not using the ntuples. Be aware that you will need to call this method AFTER you set the spill object.

Definition at line 312 of file BMSpillAna.h.

References fTimeDiff.

Referenced by MadTVAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), MadAnalysis::CreatePAN(), NuExtraction::ExtractBeamInfoDB(), ANtpInfoObjectFillerBeam::FillBeamInformation(), NtpMaker::FillSpillInfo(), DataQualityInterface::ProcessBeamStatus(), DataUtil::QueryBeamDB(), StndBmsSpin::Scan(), SetSnarlTime(), and SetSpill().

00313 {fTimeDiff = tdiff;}

void BMSpillAna::UseCutsSet ( Dbi::Task  cutset  )  [inline]

Change the set of cuts to use.

Definition at line 303 of file BMSpillAna.h.

References fCutsSet.

00304 {fCutsSet = cutset;}

void BMSpillAna::UseDatabaseCuts ( Bool_t  usedb = true  )  [inline]

Change if one wants to use the database or not.

Definition at line 300 of file BMSpillAna.h.

References fUseDBCuts.

Referenced by ANtpInfoObjectFillerBeam::ANtpInfoObjectFillerBeam(), MadTVAnalysis::CreatePAN(), MadPIDAnalysis::CreatePAN(), NuExtraction::ExtractBeamInfoDB(), NuAnalysis::ExtractConfig(), NtpMaker::FillSpillInfo(), NuBeam::IsGoodSpillAndFillPot(), NueBeamMonModule::NueBeamMonModule(), DataQualityInterface::ProcessBeamStatus(), and DataUtil::QueryBeamDB().

00301 {fUseDBCuts = usedb;}


Member Data Documentation

Int_t BMSpillAna::fBeamType [private]

Select specific beam type determined from the position of the target position and horn current. The conventions of Conventions/BeamType.h are followed. Note that the value is stored as an int, so let's hope no one will change the order of the enumeration.... Use the value "-1" to select all target positions. Default is -1

Definition at line 261 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Dbi::Task BMSpillAna::fCutsSet [private]

The database can hold different set of cuts used for different purposes. This variables determines which set of cuts to use: 0: Analysis cuts (default) 1-?: Beam study cuts

Definition at line 154 of file BMSpillAna.h.

Referenced by SelectSpill(), and UseCutsSet().

Bool_t BMSpillAna::fCutValuesChanged [mutable, private]

keep track of whether values changed

Definition at line 277 of file BMSpillAna.h.

Referenced by ChangeCutValues(), and PrintFailureReasons().

Int_t BMSpillAna::fFailBits [private]

Record of failure modes for previous call to SelectSpill().

Definition at line 274 of file BMSpillAna.h.

Referenced by FailBits(), FailureReasonsString(), PrintFailureReasons(), and SelectSpill().

Double_t BMSpillAna::fFracOnTargetMax [private]

Definition at line 271 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fFracOnTargetMin [private]

Fraction of the beam on target, calculated using BMSpillAna::GetFracOnTarget. The default does not make a selection on this value, i.e. min=0 and max=1 This also makes an assumption of the knowledge of the horizontal and vertical target position. These values might have changed throughout the run.

Definition at line 270 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fHornCurMax [private]

Definition at line 245 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fHornCurMin [private]

Cuts on the horn current. Units are Munits::ampere Defaults are min=-2.0e5 and max=-1.55e5

Definition at line 244 of file BMSpillAna.h.

Referenced by ChangeCutValues(), and Print().

Double_t BMSpillAna::fPosTgtXMax [private]

Definition at line 181 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fPosTgtXMin [private]

Cuts on the beam position at the target projected from the intensity weighted average of all the batch positions measured by the BPMs. Be aware that the target center is not necessarily at (0,0) in this coordinate system. This offset is hard-coded for the time being! Hopefully this can be changed sometime in the future. Units are in Munits::mm. Defaults are min=-2.0 and max=-0.01

Definition at line 180 of file BMSpillAna.h.

Referenced by ChangeCutValues(), and Print().

Double_t BMSpillAna::fPosTgtYMax [private]

Definition at line 184 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fPosTgtYMin [private]

Defaults are min=0.01 and max=2.0.

Definition at line 183 of file BMSpillAna.h.

Referenced by ChangeCutValues(), and Print().

Int_t BMSpillAna::fResID [private]

Definition at line 157 of file BMSpillAna.h.

Referenced by SelectSpill().

DbiResultPtr<BeamMonCuts> BMSpillAna::fResPtr [private]

Definition at line 156 of file BMSpillAna.h.

Referenced by SelectSpill().

const BeamMonSpill* BMSpillAna::fSpill [private]

The pointer to the reference to the BeamMonSpill object.

Definition at line 140 of file BMSpillAna.h.

Referenced by FractionOnTarget(), GetSpill(), SelectSpill(), SetSnarlTime(), and SetSpill().

Int_t BMSpillAna::fTargetIn [private]

Target in? <0: i don't care =0: target out >0: target in Default is 1

Definition at line 252 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fTimeDiff [private]

Time difference between the data stream one is looking at and the beam monitoring time. This will be automatically set when using the beam data ntuples, but has to be set manually when using BeamMonSpill objects. Note that this variable always gets reset after setting the spill when not using the ntuples.

Definition at line 164 of file BMSpillAna.h.

Referenced by SelectSpill(), and SetTimeDiff().

Double_t BMSpillAna::fTimeDiffMax [private]

Below here are all the members that hold the cut values.

The maximum absolute time difference allowed. default is 1 second

Definition at line 170 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fTorIntMax [private]

Definition at line 239 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fTorIntMin [private]

The beam intensity as read out by TORTGT. Units are in 1e12 protons on target Defaults are min=0.5 and max=50

Definition at line 238 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Bool_t BMSpillAna::fUseDBCuts [private]

Choose wether to use the database or not, current default is to use the database.

Definition at line 148 of file BMSpillAna.h.

Referenced by SelectSpill(), and UseDatabaseCuts().

Int_t BMSpillAna::fUseProfMonOut [private]

Select beam when profile monitors are out. Default is true, one can also use a small negative values for the minimum widths cuts (e.g. -0.1mm)

Definition at line 233 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Registry BMSpillAna::fUserCuts [private]

Hold the user defined cut values as a Registry. Will be used to override the default values

Definition at line 144 of file BMSpillAna.h.

Referenced by ApplyUserCuts(), Config(), and GetUserCuts().

Int_t BMSpillAna::fUseSpotSizeCut [private]

If this value is non-zero, cut on the spot size instead of individual widths. This is introduced predominantly do deal with the cable swaps of the readout of x and y during the period Summer/Fall 2007. When using the old method of hard coded cuts, the default method will be to cut on the individual widths. In the database, most likely the individual cuts can be maintained for the first year of running, while the cut on beam spot size will be used for data thereafter.

Definition at line 228 of file BMSpillAna.h.

Referenced by ChangeCutValues(), and SelectSpill().

Double_t BMSpillAna::fWidXMax [private]

Definition at line 213 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fWidXMin [private]

Cuts on the beam widths as measured by the last profile monitor before the target. Be aware that the SWIC devices are not always read out, so there might be perfectly good beam be thrown away Units are in Munits::mm.

For reco version R1.18.0, the rms of the beam profile is in the database. These are in general larger than the widths of a gaussian fit. The default cuts on the rms are determined from the recommended values on the widths above, using data from May 19, 2005 to July 19, 2005. Defaults for rms in x are min=0.1 and max=2.0 Defaults for rms in y are min=0.1 and max=5.0

During the repopulating of the database in November, the widths of the profile monitors where obtained from a Gaussian fit. In the rare case of a fit failure, the database gets filled with -999.

These values will also be used to determine the cut value on the beam spot size. The minimum cut values on the widths in x and y should be set such that S_min=pi*fWidXMin*fWidYMin and likewise for the maximum cut value

Defaults are min=0.1 and max=1.5

Definition at line 212 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fWidYMax [private]

Definition at line 216 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().

Double_t BMSpillAna::fWidYMin [private]

Defaults are min=0.1 and max=2.0.

Definition at line 215 of file BMSpillAna.h.

Referenced by ChangeCutValues(), Print(), and SelectSpill().


The documentation for this class was generated from the following files:
Generated on Wed Jul 1 22:52:35 2015 for loon by  doxygen 1.4.7