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

FiltMBSpillModule.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #include "FiltMBSpillModule.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00014 #include "JobControl/JobCommand.h"  
00015 #include "Conventions/Munits.h"
00016 
00017 #include "RawData/RawRecord.h"
00018 #include "RawData/RawDaqSnarlHeader.h"
00019 
00020 #include "OnlineUtil/mdTriggerCodes.h"
00021 
00022 //Get MiniBooNE spill
00023 #include "MiniBooNEAna/MBSpillAccessor.h"
00024 #include "MiniBooNEAna/MBSpill.h"
00025 
00026 // ROOT includes
00027 #include "TSystem.h"
00028 #include "TFile.h"
00029 #include "TTree.h"
00030 #include "TMath.h"
00031 
00032 JOBMODULE(FiltMBSpillModule, "FiltMBSpillModule",
00033           "MBSpill");
00034 CVSID("$Id: FiltMBSpillModule.cxx,v 1.5 2008/03/14 16:44:51 tjyang Exp $");
00035 //......................................................................
00036 
00037 FiltMBSpillModule::FiltMBSpillModule() : 
00038   fTWin(0.0),
00039   fTrigMask(0)
00040 {
00044 
00045   // vector of timestamps to store miniboone data:
00046 }
00047 //......................................................................
00048 
00049 FiltMBSpillModule::~FiltMBSpillModule()
00050 {
00054 }
00055 
00056 //......................................................................
00057 
00058 void FiltMBSpillModule::BeginJob()
00059 {
00060  
00061 
00062 }
00063 
00064 //......................................................................
00065 
00066 void FiltMBSpillModule::EndJob()
00067 {
00071 }
00072 
00073 //......................................................................
00074 
00075 void FiltMBSpillModule::BeginFile()
00076 {
00080 }
00081 
00082 //......................................................................
00083 
00084 void FiltMBSpillModule::EndFile()
00085 {
00089 }
00090 
00091 //......................................................................
00092 
00093 void FiltMBSpillModule::BeginRun()
00094 {
00098 }
00099 
00100 //......................................................................
00101 
00102 void FiltMBSpillModule::EndRun()
00103 {
00107 }
00108 
00109 //......................................................................
00110 
00111 JobCResult FiltMBSpillModule::Ana(const MomNavigator* mom)
00112 {
00118 
00119   JobCResult result = JobCResult::kFailed;
00120   TObject* recObj = 0;
00121   int    nrawrec=0;
00122   int    nrawblk=0;
00123   int    nsnarlblk=0;
00124   int trgsrc=0;
00125   VldTimeStamp vldts;  
00126   time_t trgsec;
00127   int trgnsec;
00128 
00129   int snarl;
00130   int run;
00131 
00132   double dt = -9e9;
00133   int mbsec;
00134   int mbnsec;
00135 
00136   // Loop over rawrecords
00137   TIter recItr = mom->FragmentIter();
00138   while ( ( recObj = recItr.Next() ) ) {
00139     RawRecord* rawrec = dynamic_cast<RawRecord*>(recObj);
00140     if (!rawrec) continue;  // skip things in mom that aren't RawRecords
00141     nrawrec++;
00142 
00143     // Get trigger source
00144     const RawDaqSnarlHeader* snarlHdr = 
00145       dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetHeader());
00146     if ( snarlHdr ) {
00147       trgsrc =  snarlHdr->GetTrigSrc();
00148       run = snarlHdr->GetRun();
00149       snarl = snarlHdr->GetSnarl();
00150     } // snarl header
00151 
00152     // Loop over rawblocks
00153     TObject* blkObj = 0;
00154     TIter blkItr = rawrec->GetRawBlockIter();
00155     while ( ( blkObj = blkItr.Next() ) ) {
00156       const RawDataBlock* rawBlk = dynamic_cast<const RawDataBlock*>(blkObj);
00157       if (!rawBlk) continue;  
00158       nrawblk++;
00159     
00160       // Get trigger time
00161       const RawSnarlHeaderBlock* snarlblk = 
00162         dynamic_cast<const RawSnarlHeaderBlock*>(rawBlk);
00163       if (!snarlblk) continue;
00164       nsnarlblk++;
00165       vldts = snarlblk->GetTriggerTime();
00166       trgsec = vldts.GetSec();
00167       trgnsec = vldts.GetNanoSec();
00168     
00169     
00170       VldTimeStamp tmpnd=vldts;
00171       
00172       //get MinoBooNE spill
00173       MBSpillAccessor& spillAccess = MBSpillAccessor::Get();
00174       
00175       const MBSpill *spillInfo = spillAccess.LoadSpill(vldts);
00176       if (spillInfo) {
00177         dt = double(spillInfo->GetTimeStamp()-vldts);
00178         mbsec = spillInfo->GetSec();
00179         mbnsec = spillInfo->GetNanoSec();
00180       }
00181     
00182     
00183       //Select "good" snarl here. Good means: inside MB spill window and allowed trigger source
00184       // Cosmic (M/N = 4 (hex=4); Activity = 16 (hex=10)) or SGATE (65536) trigger source:
00185       if (trgsrc & fTrigMask) {
00186         
00187         if (TMath::Abs(dt)<fTWin) {
00188           MSG("Filt",Msg::kDebug) << "-------------------------------------------------" << endl;
00189           MSG("Filt",Msg::kDebug) << "ND snarl within +-" << fTWin << " seconds of MiniBooNE spill. The trigger source is: " << trgsrc << endl;
00190           MSG("Filt",Msg::kDebug) << "Run, Snarl: " << run << ", " << snarl << endl;
00191           MSG("Filt",Msg::kDebug) << "dt(MB-MINOS snarl)= " << TMath::Abs(dt) <<" seconds"<< endl;
00192           MSG("Filt",Msg::kDebug) << "ND vldtimestamp in sec, nsec, double: " << vldts.GetSec() << ", " << vldts.GetNanoSec() << ", " << vldts.AsString() << endl;
00193           MSG("Filt",Msg::kDebug) << "MB vldtimestamp in sec, nsec, double: " << mbsec << ", " << mbnsec << ", " << (spillInfo->GetTimeStamp()).AsString() << endl;
00194           result = JobCResult::kPassed;
00195         }  
00196       }
00197     
00198     } // loop over blocks
00199   }  // loop over records
00200 
00201 //  MSG("Filt",Msg::kDebug) << 
00202 //    nrawrec << " rawrecords found " << 
00203 //    nrawblk << " rawblocks found " << 
00204 //    nsnarlblk << " snarlblocks found " << endl;
00205 
00206   return result; // kNoDecision, kFailed, etc.
00207 
00208 
00209 
00210 }
00211 
00212 //......................................................................
00213 
00214 JobCResult FiltMBSpillModule::Reco(MomNavigator* /* mom */)
00215 {
00219   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00220 }
00221 
00222 //......................................................................
00223 
00224 const Registry& FiltMBSpillModule::DefaultConfig() const
00225 {
00229   static Registry r; // Default configuration for module
00230 
00231   // Set name of config
00232   std::string name = this->GetName();
00233   name += ".config.default";
00234   r.SetName(name.c_str());
00235 
00236   // Set values in configuration
00237   r.UnLockValues();
00238   r.Set("TWin",     1.0e-3);
00239 
00240   Int_t thisTrigMask = 0;
00241 
00242   // From OnlineUtil/mdTriggerCodes.h:
00243   // TRIGGER_BIT_NULL         0x1  /* Dump of Time Frame - ie singles */
00244   // TRIGGER_BIT_RAWLI        0x2  /* Raw LI events */
00245   // TRIGGER_BIT_PLANE        0x4  /* M/N Plane Trigger */
00246   // TRIGGER_BIT_TOF          0x8  /* Time Of Flight Trigger */
00247   // TRIGGER_BIT_ACTIVITY    0x10  /* Detector Activity Trigger */
00248   // TRIGGER_BIT_E4          0x20  /* E4 Trigger */
00249   // TRIGGER_BIT_MINBIAS   0x8000  /* Minimum Bias Sampling Trigger */
00250   // TRIGGER_BIT_SPILL    0x10000  /* Spill Trigger */
00251   // TRIGGER_BIT_SPILL_IP 0x20000  /* Remote Spill Trigger - ie spill over IP */
00252   thisTrigMask |= TRIGGER_BIT_PLANE;
00253   thisTrigMask |= TRIGGER_BIT_ACTIVITY;
00254   thisTrigMask |= TRIGGER_BIT_SPILL;
00255   //  cout << "Trigger mask set to: " << thisTrigMask << endl;
00256   
00257   r.Set("TrigMask", thisTrigMask);
00258   r.LockValues();
00259 
00260   return r;
00261 }
00262 
00263 //......................................................................
00264 
00265 void FiltMBSpillModule::Config(const Registry& r)
00266 {
00270   fTWin = r.GetDouble("TWin");
00271   fTrigMask = r.GetInt("TrigMask");
00272 }
00273 
00274 //......................................................................
00275 
00276 void FiltMBSpillModule::Report()
00277 {
00281 }
00282 
00283 //......................................................................
00284 
00285 void FiltMBSpillModule::Reset()
00286 {
00290 }
00291 
00292 //......................................................................
00293 
00294 void FiltMBSpillModule::HandleCommand(JobCommand* /* c */)
00295 {
00299 }
00300 

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