Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BeamMonAna.cxx

Go to the documentation of this file.
00001 #include "StandardNtuple/NtpStRecord.h"
00002 #include "CandNtupleSR/NtpSRRecord.h"
00003 #include "CandNtupleSR/NtpSREvent.h"
00004 #include "CandNtupleSR/NtpSRTrack.h"
00005 #include "CandNtupleSR/NtpSRStrip.h"
00006 #include "Conventions/SimFlag.h"
00007 #include "Conventions/Munits.h"
00008 #include "MessageService/MsgService.h"
00009 #include "BeamData/ana/Summary/BeamSummary.h"
00010 #include "NueAna/BeamMonAna.h"
00011 #include "NueAna/BeamMon.h"
00012 #include <SpillTiming/SpillTimeFinder.h>
00013 
00014 #include <BeamDataUtil/BeamMonSpill.h>
00015 #include <BeamDataUtil/BDSpillAccessor.h>
00016 
00017 CVSID("$ID:");
00018 
00019 
00020 BeamMonAna::BeamMonAna(BeamMon &bmon):
00021   fBmon(bmon),
00022   bs(0)
00023 {}
00024 
00025 BeamMonAna::~BeamMonAna()
00026 {}
00027 
00028 void BeamMonAna::SetBeamSummary(BeamSummary *b)
00029 {
00030     if (b) {
00031         bs=b;
00032         return;
00033     }
00034 }
00035 
00036 //void BeamMonAna::Analyze(int /*evtn*/, NtpSRRecord *srobj, 
00037 //                       NtpMCRecord */*mc*/, NtpTHRecord */*th*/)
00038 void BeamMonAna::Analyze(int /*evtn*/, RecRecordImp<RecCandHeader> *srobj)
00039 {
00040   if(srobj==0){
00041     return;
00042   }
00043   if(((dynamic_cast<NtpStRecord *>(srobj))==0)&&
00044      ((dynamic_cast<NtpSRRecord *>(srobj))==0)){
00045     return;
00046   }
00047 
00048   
00049   VldContext vc=srobj->GetHeader().GetVldContext();
00050   if(vc.GetSimFlag()!=SimFlag::kData){
00051     return;
00052   }
00053 
00054 
00055   VldTimeStamp vts = vc.GetTimeStamp();
00056   Int_t tsec = vts.GetSec();
00057   Int_t tnsec = vts.GetNanoSec();
00058 
00059   VldTimeStamp stnd = SpillTimeFinder::Instance().GetTimeOfNearestSpill(vc);
00060 
00061   if (bs) {
00062       bs->MatchSpillWithTime(tsec,tnsec);
00063       
00064       fBmon.bI=bs->beamIntensity;
00065       fBmon.hbw=bs->hBeamWidth;
00066       fBmon.vbw=bs->vBeamWidth;
00067       fBmon.hpos1=bs->hPosatTargetPM;
00068       fBmon.vpos1=bs->vPosatTargetPM;
00069       fBmon.hpos2=bs->hPosatTargetBPM;
00070       fBmon.vpos2=bs->vPosatTargetBPM;
00071       fBmon.htan=bs->tanHoriz;
00072       fBmon.vtan=bs->tanVert;
00073       fBmon.hornI=bs->hornPeakCurrent;
00074       fBmon.nuTarZ=bs->nuTarZ;
00075       fBmon.time=bs->timeStampD;
00076       fBmon.dt_bmst = ((double)(vts)) - fBmon.time;
00077       fBmon.dt_stnd = (double)(vts-stnd);
00078       return;
00079   }
00080 
00081   const BeamMonSpill* spill = BDSpillAccessor::Get().LoadSpill(vts);
00082 
00083       
00084   if (!spill) {
00085     MSG("BeamMonAna",Msg::kError)
00086         << "No BeamMonSpill for " << vts << endl;
00087     return;
00088   }
00089 
00090   double tor = spill->fTortgt;
00091   if (tor == 0) tor = spill->fTrtgtd;
00092   if (tor == 0) tor = spill->fTr101d;
00093   if (tor == 0) tor = spill->fTor101;
00094   fBmon.bI = tor;
00095 
00096   fBmon.hbw = spill->fProfWidX;
00097   fBmon.vbw = spill->fProfWidY;
00098 
00099   fBmon.hpos1 = spill->fTargProfX;
00100   fBmon.vpos1 = spill->fTargProfY;
00101 
00102   double xbpm,ybpm,xrms,yrms;
00103   spill->BpmAtTarget(xbpm,ybpm,xrms,yrms);
00104   fBmon.hpos2 = xbpm;
00105   fBmon.vpos2 = ybpm;
00106 
00107   fBmon.htan = 0;
00108   fBmon.vtan = 0;
00109 
00110   fBmon.hornI = spill->fHornCur;
00111 
00112   fBmon.nuTarZ = 0;
00113   int beam_type = spill->GetStatusBits().beam_type;
00114   if (beam_type==4)
00115       fBmon.nuTarZ = 1.50 * Munits::meter;
00116   if (beam_type==5)
00117       fBmon.nuTarZ = 2.50 * Munits::meter;
00118 
00119   VldTimeStamp st = spill->SpillTime();
00120   fBmon.time = (double)st;
00121   fBmon.dt_stnd = (double)(vts-stnd);
00122   fBmon.dt_bmst = (double)(vts-st);
00123   
00124   MSG("BeamMonAna",Msg::kDebug)
00125       << vts << " - " << st << " = " << (double)(vts-st)
00126       << " : " << tor << " (" << fBmon.hpos1 << " x " << fBmon.vpos1 << ") "
00127       << "(" << xbpm << " x " << ybpm << ") " << fBmon.hornI << " " << beam_type << endl;
00128 
00129 }
00130 

Generated on Mon Feb 15 11:06:24 2010 for loon by  doxygen 1.3.9.1