NueBeamMonModule Class Reference

Fill in the beam monitor information in the NueAna ntuples. More...

#include <NueBeamMonModule.h>

Inheritance diagram for NueBeamMonModule:
JobCModule

List of all members.

Public Member Functions

 NueBeamMonModule ()
 ~NueBeamMonModule ()
const RegistryDefaultConfig () const
void Config (const Registry &r)
JobCResult Reco (MomNavigator *mom)
void EndJob ()

Private Attributes

BMSpillAna fBMSpillAna
 next two were declared but never implemented .. dangerous!
std::string kPOTTreeName
std::string beamstring
bool firstevent
BeamType::BeamType_t beamtype
int zbeamtype
int lastrun
NuePOTnuepot

Detailed Description

Fill in the beam monitor information in the NueAna ntuples.

Author:
(last to touch it)
Author
rhatcher
Version:
Revision
1.5
Date:
Date
2008/11/19 18:22:51

Contact: mdier@bnl.gov

Created on: Tue Feb 28 14:48:02 2006

Id
NueBeamMonModule.h,v 1.5 2008/11/19 18:22:51 rhatcher Exp

Definition at line 34 of file NueBeamMonModule.h.


Constructor & Destructor Documentation

NueBeamMonModule::NueBeamMonModule (  ) 

Definition at line 36 of file NueBeamMonModule.cxx.

References beamtype, fBMSpillAna, BeamType::kUnknown, nuepot, and BMSpillAna::UseDatabaseCuts().

00037   :fBMSpillAna(),firstevent(true), zbeamtype(0), lastrun(-1)
00038 {
00039   beamtype = BeamType::kUnknown;
00040   nuepot = new NuePOT();
00041   fBMSpillAna.UseDatabaseCuts();
00042 }

NueBeamMonModule::~NueBeamMonModule (  ) 

Definition at line 44 of file NueBeamMonModule.cxx.

References nuepot.

00045 {
00046   if(nuepot){
00047     delete nuepot;
00048     nuepot=0;
00049   }
00050 }


Member Function Documentation

void NueBeamMonModule::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 64 of file NueBeamMonModule.cxx.

References BMSpillAna::Config(), fBMSpillAna, Registry::Get(), and kPOTTreeName.

00065 {
00066     fBMSpillAna.Config(r);
00067     const char* tmps;
00068     if(r.Get("POTTreeFileName",tmps)){kPOTTreeName=tmps;}
00069 //    int imps;
00070 //    if(r.Get("ZarkoBeamType",imps)) {beamtype=imps;}
00071 
00072 }

const Registry & NueBeamMonModule::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 52 of file NueBeamMonModule.cxx.

References Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00053 {
00054     static Registry r;
00055     r.UnLockValues();
00056     r.Set("ZarkoBeamType",0);
00057     r.Set("POTTreeFileName","pottree.root");
00058     r.Set("BeamString", "");
00059     r.LockValues();
00060 
00061     return r;
00062 }

void NueBeamMonModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 217 of file NueBeamMonModule.cxx.

References Msg::kError, Msg::kInfo, kPOTTreeName, MSG, nuepot, and NuePOT::pot.

00217                              {
00218    MSG("NueBeamMon",Msg::kInfo)<<"Number of POT in this job: "<<nuepot->pot<<endl;
00219 
00220    TDirectory *savedir = gDirectory;
00221 
00222    TFile *fpf = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(kPOTTreeName.c_str()));
00223    if(fpf){
00224      fpf->cd();
00225      TTree *pottree = new TTree("pottree","pottree");
00226      pottree->Branch("NuePOT",&nuepot);
00227      pottree->Fill();
00228      pottree->Write();
00229      savedir->cd();
00230    }
00231    else{
00232      MSG("NueBeamMon",Msg::kError)<<"Could not find the file to write the pottree to, there will be no pottree"<<endl;
00233    }
00234 
00235 }

JobCResult NueBeamMonModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 74 of file NueBeamMonModule.cxx.

References BeamMon::batchint, BeamMon::batchposx, BeamMon::batchposy, NuePOT::beamtype, beamtype, BeamMon::bI, NueRecord::bmon, BeamMon::bmst_vts, BeamMonSpill::BpmAtTarget(), BeamMon::dt_bmst, BeamMon::dt_stnd, fBMSpillAna, BeamMonSpill::fBpmInt, BeamMonSpill::fHornCur, firstevent, BeamMonSpill::fProfWidX, BeamMonSpill::fProfWidY, MomNavigator::FragmentIter(), BeamMonSpill::fTargBpmX, BeamMonSpill::fTargBpmY, BeamMonSpill::fTargProfX, BeamMonSpill::fTargProfY, BeamMonSpill::fTor101, BeamMonSpill::fTortgt, BeamMonSpill::fTr101d, BeamMonSpill::fTrtgtd, JobCModule::Get(), NueHeader::GetBeamType(), VldContext::GetDetector(), VldTimeStamp::GetEOT(), NueHeader::GetEventNo(), RecRecordImp< T >::GetHeader(), MCInfo::GetMCPoT(), BeamMon::GetPot(), NueHeader::GetRelease(), NueHeader::GetRun(), VldTimeStamp::GetSeconds(), VldContext::GetSimFlag(), NueHeader::GetSnarl(), SpillTimeFinder::GetTimeOfNearestSpill(), VldContext::GetTimeStamp(), SpillTimeFinder::GetTimeToNearestSpill(), RecHeader::GetVldContext(), BeamMon::goodBeamMon, BeamMon::goodDataQual, BeamMon::hbw, BeamMon::hornI, BeamMon::hpos1, BeamMon::hpos2, SpillTimeFinder::Instance(), RunStatus::IsOK(), CoilTools::IsReverse(), SimFlag::kData, Msg::kDebug, Msg::kError, Detector::kFar, Detector::kNear, JobCResult::kPassed, Msg::kWarning, lastrun, BDSpillAccessor::LoadSpill(), MSG, NuePOT::nruns, NuePOT::nsnarls, nuepot, NueStandard::PassesPOTStandards(), NuePOT::pot, NuePOT::pot_nocut, BeamMon::Reset(), BMSpillAna::SelectSpill(), BMSpillAna::SetSnarlTime(), BMSpillAna::SetSpill(), BeamMonSpill::SpillTime(), BeamMon::stnd_vts, BeamMon::tor101, BeamMon::tortgt, BeamType::ToZarko(), BeamMon::tr101d, BeamMon::trtgtd, BeamMon::vbw, BeamMon::vpos1, BeamMon::vpos2, and zbeamtype.

00075 {
00076 
00077     // Instantiate a BDSpillAccessor object, necessary to access the
00078     // BeamMonSpill database.
00079     BDSpillAccessor& sa = BDSpillAccessor::Get();
00080 
00081     // Same to access SpillTimeND table 
00082     SpillTimeFinder &stf = SpillTimeFinder::Instance();    
00083 
00084     // Get the nue records from mom -- basically copied from the
00085     // Trimmer class
00086     TObject *obj=0;
00087     vector<NueRecord *> records;
00088 
00089     int nnuerec=0;
00090     bool contains_mc=false;
00091     TIter objiter = mom->FragmentIter();
00092     while(( obj=objiter.Next() )){
00093         NueRecord *nr = dynamic_cast<NueRecord *>(obj);
00094 
00095         if (!nr){
00096             MSG("NueBeamMon",Msg::kDebug)<<"Didn't find a NueRecord in MOM"<<endl;
00097             continue;
00098         }        
00099        MSG("NueBeamMon",Msg::kDebug)<<"Found a NueRecord in MOM"
00100                                       <<" Snarl "<<nr->GetHeader().GetSnarl()
00101                                       <<" Event "<<nr->GetHeader().GetEventNo()<<endl;      
00102         
00103         VldContext evt_vldc = nr->GetHeader().GetVldContext();
00104         ReleaseType::Release_t rel = nr->GetHeader().GetRelease();
00105         beamtype = nr->GetHeader().GetBeamType();
00106 
00107         if(firstevent){
00108           firstevent=false;
00109           nuepot->beamtype=beamtype;
00110           zbeamtype = BeamType::ToZarko(beamtype);
00111         }
00112 
00113         if(nr->GetHeader().GetRun()!=lastrun){
00114           nuepot->nruns++;
00115           lastrun = nr->GetHeader().GetRun();
00116           if(evt_vldc.GetSimFlag() != SimFlag::kData &&
00117                evt_vldc.GetDetector()==Detector::kFar){
00118                double temp = MCInfo::GetMCPoT(Detector::kFar, beamtype, rel);
00119                nuepot->pot += temp;
00120                nuepot->pot_nocut += temp; 
00121           }
00122         }
00123         if(nnuerec==0){
00124           nuepot->nsnarls++;
00125         }
00126                                                                                 
00127         // Only fill if this is data
00128         if (evt_vldc.GetSimFlag() != SimFlag::kData){
00129             contains_mc=true;
00130             if(nnuerec==0&&evt_vldc.GetDetector()==Detector::kNear){
00131               nuepot->pot+=MCInfo::GetMCPoT(Detector::kNear, beamtype, rel);
00132             }
00133             nnuerec++;
00134             continue;
00135         }
00136 
00137         // Get the closest spill out of the database
00138         const BeamMonSpill* bms = sa.LoadSpill(evt_vldc.GetTimeStamp());
00139         VldTimeStamp bms_vts;
00140         if (!bms) {
00141             MSG("NueBeamMon",Msg::kError) << "No BeamMonSpill found for " << evt_vldc << endl;
00142             bms_vts = VldTimeStamp::GetEOT();
00143         }
00144         else {
00145             bms_vts = bms->SpillTime();
00146         }
00147 
00148         fBMSpillAna.SetSpill(*bms);
00149         // Get the time of the event, the value in the header is
00150         // accurate enough for this purpose
00151         fBMSpillAna.SetSnarlTime(evt_vldc.GetTimeStamp());
00152 
00153         // First reset the values of the BeamMon branch
00154         nr->bmon.Reset();
00155         // Fill in the variables
00156         if (fBMSpillAna.SelectSpill())
00157             nr->bmon.goodBeamMon=1;
00158         else
00159             nr->bmon.goodBeamMon=0;
00160 
00161         nr->bmon.tortgt = bms->fTortgt;
00162         nr->bmon.trtgtd = bms->fTrtgtd;
00163         nr->bmon.tor101 = bms->fTor101;
00164         nr->bmon.tr101d = bms->fTr101d;
00165 
00166 //        cout<<fBMSpillAna.SelectSpill()<<"  "<<"   "<<bms->BeamType()<<endl;
00167         nr->bmon.bI = nr->bmon.GetPot();
00168         
00169         double xbpm,ybpm,xrms,yrms;
00170         bms->BpmAtTarget(xbpm,ybpm,xrms,yrms);
00171         nr->bmon.hpos2 = xbpm;
00172         nr->bmon.vpos2 = ybpm;
00173 
00174         for (Int_t i=0;i<6;++i){
00175             nr->bmon.batchposx[i]=bms->fTargBpmX[i];
00176             nr->bmon.batchposy[i]=bms->fTargBpmY[i];
00177             nr->bmon.batchint[i]=bms->fBpmInt[i];
00178         }
00179 
00180         nr->bmon.hpos1 = bms->fTargProfX;
00181         nr->bmon.vpos1 = bms->fTargProfY;
00182         
00183         nr->bmon.hbw = bms->fProfWidX;
00184         nr->bmon.vbw = bms->fProfWidY;
00185 
00186         nr->bmon.hornI = bms->fHornCur;
00187 
00188         nr->bmon.bmst_vts = bms->SpillTime();
00189         
00190         VldTimeStamp vtsdif = nr->bmon.bmst_vts-evt_vldc.GetTimeStamp();
00191         nr->bmon.dt_bmst=vtsdif.GetSeconds();
00192 
00193         nr->bmon.stnd_vts=stf.GetTimeOfNearestSpill(evt_vldc);
00194         nr->bmon.dt_stnd=stf.GetTimeToNearestSpill(evt_vldc);
00195 
00196         // count the pots for the good spills, only take the value
00197         // from the first event in the snarl
00198         bool goodCoil = CoilTools::IsOK(evt_vldc) && !CoilTools::IsReverse(evt_vldc);    
00199         goodCoil = goodCoil || (evt_vldc.GetDetector()==Detector::kFar);
00200 
00201         nr->bmon.goodDataQual = (int) NueStandard::PassesPOTStandards(nr);  
00202         // includes the goodBeamMon, SpillType, CoilCuts and FarDet special cuts 
00203 
00204         if (nnuerec==0 && nr->bmon.goodDataQual == 1){
00205 //            fTotPot+=nr->bmon.bI;
00206             nuepot->pot+=nr->bmon.bI;
00207         }
00208         if(nnuerec==0) nuepot->pot_nocut +=nr->bmon.bI;        
00209         ++nnuerec;
00210     }
00211     if (!contains_mc && nnuerec==0)
00212         MSG("NueBeamMon",Msg::kWarning)<<"No NueRecord found in MOM"<<endl;
00213     
00214     return JobCResult::kPassed;
00215 }


Member Data Documentation

std::string NueBeamMonModule::beamstring [private]

Definition at line 60 of file NueBeamMonModule.h.

Definition at line 62 of file NueBeamMonModule.h.

Referenced by NueBeamMonModule(), and Reco().

next two were declared but never implemented .. dangerous!

Definition at line 55 of file NueBeamMonModule.h.

Referenced by Config(), NueBeamMonModule(), and Reco().

Definition at line 61 of file NueBeamMonModule.h.

Referenced by Reco().

std::string NueBeamMonModule::kPOTTreeName [private]

Definition at line 59 of file NueBeamMonModule.h.

Referenced by Config(), and EndJob().

Definition at line 64 of file NueBeamMonModule.h.

Referenced by Reco().

Definition at line 65 of file NueBeamMonModule.h.

Referenced by EndJob(), NueBeamMonModule(), Reco(), and ~NueBeamMonModule().

Definition at line 63 of file NueBeamMonModule.h.

Referenced by Reco().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1