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

NtpBDLiteModule.cxx

Go to the documentation of this file.
00001 #include "BeamDataNtuple/Module/NtpBDLiteModule.h"
00002 #include "BeamDataNtuple/NtpBDLiteRecord.h"
00003 #include "BeamDataNtuple/BeamDataLiteHeader.h"
00004 
00005 #include <BeamDataUtil/BDSpillAccessor.h>
00006 
00007 #include <Record/RecMinos.h>
00008 #include <Record/RecMinosHdr.h>
00009 #include <Record/RecRecord.h>
00010 
00011 #include <MessageService/MsgService.h>
00012 #include <MinosObjectMap/MomNavigator.h>
00013 
00014 #include <Validity/VldContext.h>
00015 #include <DataUtil/GetVldContext.h>
00016 
00017 #include <SpillTiming/SpillTimeFinder.h>
00018 
00019 #include <JobControl/JobCModuleRegistry.h> // For JOBMODULE macro
00020 
00021 #include <vector>
00022 
00023 ClassImp(NtpBDLiteModule)
00024 
00025 JOBMODULE(NtpBDLiteModule, "NtpBDLite",
00026           "Fill the beam monitoring data ntuple");
00027 CVSID("$Id: NtpBDLiteModule.cxx,v 1.1 2006/09/18 15:59:13 mdier Exp $");
00028 //......................................................................
00029 
00030 
00031 NtpBDLiteModule::NtpBDLiteModule()
00032     :fInputRecordsFilter("!ConfigRecord")
00033 {}
00034 
00035 //......................................................................
00036 
00037 NtpBDLiteModule::~NtpBDLiteModule()
00038 {}
00039 
00040 //......................................................................
00041 
00042 const Registry& NtpBDLiteModule::DefaultConfig() const
00043 {
00044     MSG("NtpBDLite",Msg::kDebug) <<
00045         "NtpBDLiteModule::DefaultConfig" << endl;
00046 
00047     static Registry r;
00048     std::string name = this->JobCModule::GetName();
00049     name += ".config.default";
00050     r.SetName(name.c_str());
00051 
00052     r.UnLockValues();
00053     r.Set("InputRecordsFilter","!ConfigRecord");
00054     r.LockValues();
00055 
00056     return r;
00057 }
00058 
00059 //......................................................................
00060 
00061 void NtpBDLiteModule::Config(const Registry& r)
00062 {
00063     MSG("NtpBDLite",Msg::kDebug) << "NtpBDLiteModule::Config" << endl;
00064 
00065     const char* tmps;
00066     if ( r.Get("InputRecordsFilter",tmps) ) fInputRecordsFilter = tmps;   
00067 }
00068 
00069 //......................................................................
00070 
00071 JobCResult NtpBDLiteModule::Reco(MomNavigator* mom)
00072 {
00073     MSG("NtpBDLite",Msg::kDebug)<<"In NtpBDLite::Reco"<<endl;
00074     
00075     // try to get the vld context from somewhere
00076 
00077     if (fInputRecordsFilter.empty()) {
00078         MAXMSG("NtpBDLite",Msg::kWarning,5)
00079             << "No input record name set. Might pick up wrong VldContext." << endl;
00080     }
00081     
00082     MSG("NtpBDLite",Msg::kDebug) << "Record filter = " << fInputRecordsFilter << endl;
00083 
00084     vector<VldContext> vldcv = DataUtil::GetVldContext(mom,fInputRecordsFilter.c_str());
00085     if (vldcv.size() == 0){
00086         MSG("NtpBDLite",Msg::kDebug)<< "In NtpBDLite::Reco: "
00087                                     << "Nothing interesting found in mom." <<  endl;
00088         return JobCResult::kFailed;
00089     }
00090 
00091     VldContext vldc = vldcv[0];
00092     // Look for earliest time in the streams
00093     for (UInt_t i=1; i<vldcv.size(); ++i) {
00094         if (vldcv[i].GetTimeStamp()<vldc.GetTimeStamp()) vldc = vldcv[i] ;
00095     }
00096 
00097     NtpBDLiteRecord* ntpbdr = FillNtpBDLite(vldc);
00098 
00099     //give the ntpbdr object to mom, she'll write it to the file
00100     mom->AdoptFragment(ntpbdr);
00101         
00102     return JobCResult::kPassed;
00103 
00104 }
00105 
00106 //......................................................................
00107 
00108 NtpBDLiteRecord* NtpBDLiteModule::FillNtpBDLite(const VldContext& vldc)
00109 {
00110 
00111     MSG("NtpBDLite",Msg::kDebug)<< "vldc = "  << vldc <<endl;
00112     BeamDataLiteHeader bdh(vldc);
00113 
00114     const BeamMonSpill* spill = BDSpillAccessor::Get().LoadSpill(vldc.GetTimeStamp());
00115     //BDSpillAccessor B;
00116     //const BeamMonSpill* spill = B.LoadSpill(vldc.GetTimeStamp());
00117     if (!spill){ 
00118         MSG("NtpBDLite",Msg::kDebug)<< "No spill found!" <<endl;
00119         NtpBDLiteRecord* ntpbdr = new NtpBDLiteRecord(bdh);
00120         return ntpbdr;
00121     }
00122     
00123     // fill members of the BeamDataLiteHeader
00124     
00125     VldTimeStamp spill_time = spill->SpillTime();
00126     bdh.SetEarliestTimeStamp(spill_time);
00127     VldTimeStamp vldd = spill_time-vldc.GetTimeStamp();
00128     bdh.SetTimeDiffStreamSpill(vldd.GetSeconds()); 
00129     bdh.SetFoundBD(1);
00130     bdh.SetStatus(spill->GetStatusInt());
00131     
00132     NtpBDLiteRecord* ntpbdr = new NtpBDLiteRecord(bdh);
00133     MSG("NtpBDLite",Msg::kDebug)<< spill->fTor101  <<endl;
00134     ntpbdr->tor101 = spill->fTor101;           
00135     ntpbdr->tr101d = spill->fTr101d;           
00136     ntpbdr->tortgt = spill->fTortgt;           
00137     ntpbdr->trtgtd = spill->fTrtgtd;
00138     ntpbdr->horncur = spill->fHornCur;     
00139     for (Int_t i=0;i<6;++i){
00140         ntpbdr->bposx[i]=spill->fTargBpmX[i];
00141         ntpbdr->bposy[i]=spill->fTargBpmY[i];
00142         ntpbdr->bpmint[i]=spill->fBpmInt[i];
00143     }
00144     ntpbdr->bwidx = spill->fProfWidX;  
00145     ntpbdr->bwidy = spill->fProfWidY;  
00146     ntpbdr->hadint = spill->fHadInt; 
00147     ntpbdr->muint1 = spill->fMuInt1;  
00148     ntpbdr->muint2 = spill->fMuInt2;  
00149     ntpbdr->muint3 = spill->fMuInt3;  
00150 
00151     SpillTimeFinder &stf = SpillTimeFinder::Instance();
00152     ntpbdr->dt_nearest = stf.GetTimeToNearestSpill(vldc);
00153     VldTimeStamp tons = stf.GetTimeOfNearestSpill(vldc);
00154     ntpbdr->nearest_sec = tons.GetSec();
00155     ntpbdr->nearest_nsec = tons.GetNanoSec();
00156 
00157     return ntpbdr;
00158 }
00159 
00160 //......................................................................
00161 
00162 
00163 
00164 
00165 
00166 

Generated on Fri Mar 28 15:36:00 2008 for loon by  doxygen 1.3.9.1