CondensedNtpModuleNC Class Reference

#include <CondensedNtpModuleNC.h>

Inheritance diagram for CondensedNtpModuleNC:
JobCModule

List of all members.

Public Member Functions

 CondensedNtpModuleNC ()
virtual ~CondensedNtpModuleNC ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void Help ()
void EndJob ()

Private Member Functions

void ResetTreeVariables ()

Private Attributes

TString fFileName
TString fTreeName
TFile * fNtpFile
TTree * fNtuple
int fDataType
int fFailedDeMux
ANtpNueInfofNueInfo
ANtpEventInfoNCfEventInfo
ANtpHeaderInfofHeaderInfo
ANtpBeamInfofBeamInfo
ANtpShowerInfoNCfShowerInfo
ANtpTrackInfoNCfTrackInfo
ANtpTruthInfoBeamfTruthInfo
ANtpEventInfoMRCCfEventInfoMRCC
ANtpInfoObjectFillerNCfInfoFiller
ANtpInfoObjectFillerMRCCfInfoFillerMRCC
ANtpInfoObjectFillerNuefInfoFillerNue
int fVHSPlanes
int fVHSStrips
int fMakeNueBranch

Detailed Description

Definition at line 36 of file CondensedNtpModuleNC.h.


Constructor & Destructor Documentation

CondensedNtpModuleNC::CondensedNtpModuleNC (  ) 

Definition at line 57 of file CondensedNtpModuleNC.cxx.

References fBeamInfo, fEventInfo, fEventInfoMRCC, fFailedDeMux, fHeaderInfo, fInfoFiller, fInfoFillerMRCC, fInfoFillerNue, fNueInfo, fShowerInfo, fTrackInfo, fTruthInfo, Msg::kDebug, and MSG.

00057                                            :
00058   fFileName("analysisNtuple.root"),
00059   fTreeName("analysisNtuple"),
00060   fNtpFile(0),
00061   fNtuple(0),
00062   fVHSPlanes(20),
00063   fVHSStrips(20)
00064 {
00065   MSG("JobC", Msg::kDebug) << "CondensedNtpModuleNC::Constructor" << endl;
00066 
00067   fHeaderInfo = new ANtpHeaderInfo;
00068   fEventInfo = new ANtpEventInfoNC;
00069   fNueInfo = new ANtpNueInfo;
00070   fTrackInfo = new ANtpTrackInfoNC;
00071   fShowerInfo = new ANtpShowerInfoNC;
00072   fTruthInfo = new ANtpTruthInfoBeam;
00073   fBeamInfo = new ANtpBeamInfo;
00074   fEventInfoMRCC = new ANtpEventInfoMRCC;
00075 
00076   fInfoFiller = new ANtpInfoObjectFillerNC;
00077   fInfoFillerNue = new ANtpInfoObjectFillerNue;
00078   fInfoFillerMRCC = new ANtpInfoObjectFillerMRCC;
00079 
00080   fFailedDeMux = 0;
00081 }

CondensedNtpModuleNC::~CondensedNtpModuleNC (  )  [virtual]

Definition at line 84 of file CondensedNtpModuleNC.cxx.

References fBeamInfo, fEventInfo, fEventInfoMRCC, fHeaderInfo, fNueInfo, fShowerInfo, fTrackInfo, fTruthInfo, Msg::kDebug, and MSG.

00085 {
00086 
00087   MSG("JobC", Msg::kDebug) << "CondensedNtpModuleNC::Destructor" << endl;
00088 
00089   if(fHeaderInfo) delete fHeaderInfo;
00090   if(fEventInfo) delete fEventInfo;
00091   if(fEventInfoMRCC) delete fEventInfoMRCC;
00092   if(fShowerInfo) delete fShowerInfo;
00093   if(fTrackInfo) delete fTrackInfo;
00094   if(fTruthInfo) delete fTruthInfo;
00095   if(fBeamInfo) delete fBeamInfo;
00096   if(fNueInfo) delete fNueInfo;
00097 }


Member Function Documentation

JobCResult CondensedNtpModuleNC::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 145 of file CondensedNtpModuleNC.cxx.

References ANtpInfoObjectFillerNue::Analyze(), ANtpEventInfoMRCC::bestEvent, det, ANtpHeaderInfo::events, fBeamInfo, fDataType, fEventInfo, fEventInfoMRCC, fFailedDeMux, fHeaderInfo, ANtpInfoObjectFillerBeam::FillBeamInformation(), ANtpInfoObjectFillerMRCC::FillEventInformation(), ANtpInfoObjectFiller::FillHeaderInformation(), ANtpInfoObjectFillerNC::FillInformation(), fInfoFiller, fInfoFillerMRCC, fInfoFillerNue, fMakeNueBranch, fNtuple, fNueInfo, fShowerInfo, fTrackInfo, fTruthInfo, ANtpRecoNtpManipulator::GetClusterArray(), VldContext::GetDetector(), MomNavigator::GetFragment(), ANtpRecoNtpManipulator::GetNtpStRecord(), VldContext::GetSimFlag(), ANtpRecoNtpManipulator::GetStripArray(), VldContext::GetTimeStamp(), RecRecordImp< T >::GetVldContext(), ANtpEventInfo::index, ANtpInfoObjectFillerNC::InitializekNN(), Msg::kDebug, JobCResult::kFailed, ANtpDefaultValue::kInt, JobCResult::kPassed, Msg::kWarning, MAXMSG, MSG, ANtpHeaderInfo::newSnarl, ANtpHeaderInfo::passedDeMux, ANtpTrackInfoNC::Reset(), ANtpEventInfoMRCC::Reset(), ANtpEventInfoNC::Reset(), ANtpShowerInfoNC::Reset(), ResetTreeVariables(), ANtpInfoObjectFillerNC::SetClusterArray(), ANtpInfoObjectFillerNC::SetDetector(), JobCResult::SetFailed(), ANtpRecoNtpManipulator::SetPrimaryShowerCriteria(), ANtpRecoNtpManipulator::SetPrimaryTrackCriteria(), ANtpInfoObjectFiller::SetStripArray(), JobCResult::SetWarning(), and ANtpHeaderInfo::year.

00146 {
00147   JobCResult result(JobCResult::kPassed);
00148 
00149   //get the records from MOM
00150   assert(mom);
00151 
00152   NtpSRRecord* record     = (NtpSRRecord*)(mom->GetFragment("NtpSRRecord"));
00153   NtpMRRecord* mrRecord   = (NtpMRRecord*)(mom->GetFragment("NtpMRRecord"));
00154 
00155   NtpStRecord* stRecord=0;
00156   NtpStRecord* stRecordOrig=0;
00157   // Only want to create the MRCC output branch if the input file had MRCC in
00158   // This information isn't available to us in BeginJob, I can't think of a
00159   // better way than this.
00160   if(mrRecord){
00161 
00162     // This is a little fiddly: for MRCC processing, we need two
00163     // NtpStRecords; the one that got produced when we processed with
00164     // MRCC, and the one for the same snarl as processed without
00165     // MRCC. The former has name "MuonRemoved", while the latter has
00166     // name "Primary"
00167     stRecordOrig = (NtpStRecord*)(mom->GetFragment("NtpStRecord",
00168                                                    "Primary"));
00169     stRecord     = (NtpStRecord*)(mom->GetFragment("NtpStRecord",
00170                                                    "MuonRemoved"));
00171     
00172     if(!stRecordOrig){
00173       // Would really like to exit if this happens, to avoid the case
00174       // where only one file is given (although this check is done in
00175       // the macro). However, concatenation is not our friend, and
00176       // sometimes the concatenated sntp file gets chopped before the
00177       // mrnt file, so it doesn't have all the same subruns in it. In
00178       // this case, just ignore this snarl.
00179       MAXMSG("CondensedNtpModuleNC", Msg::kWarning, 10)
00180         << "No NtpStRecord found. Probably the sntp file is shorter than the mrnt."
00181         << "Ignoring this snarl" << endl;
00182       return JobCResult::kFailed;
00183     }
00184     static bool once = true;
00185     if(once){
00186       fNtuple->Branch("mrcc.", "ANtpEventInfoMRCC", &fEventInfoMRCC, 64000, 2);
00187       once = false;
00188     }
00189   }
00190   else{
00191     // If we're not running MRCC, the Primary NtpStRecord is the one to use
00192     stRecord = (NtpStRecord*)(mom->GetFragment("NtpStRecord",
00193                                                "Primary"));
00194   }
00195 
00196   if(!record && !stRecord){
00197     MSG("CondensedNtpModuleNC", Msg::kWarning) << "Could not get NtpSR or NtpSt "
00198                                                 << "Record from MOM" << endl;
00199     result.SetWarning().SetFailed();
00200     return result;
00201   }//end if no NtpSRRecord
00202 
00203   NtpMCRecord* mcRecord = (NtpMCRecord*)(mom->GetFragment("NtpMCRecord"));
00204   NtpTHRecord* thRecord = (NtpTHRecord*)(mom->GetFragment("NtpTHRecord"));
00205 
00206   //instantiate a NtpHelper object to help you get the info you want
00207   ANtpRecoNtpManipulator *ntpManipulator = 0;
00208   if(record) ntpManipulator = new ANtpRecoNtpManipulator(record, mcRecord, thRecord);
00209   else if(stRecord) ntpManipulator = new ANtpRecoNtpManipulator(stRecord);
00210 
00211   const VldContext *vldc = stRecord ? stRecord->GetVldContext() : record->GetVldContext();
00212   VldTimeStamp timeStamp = vldc->GetTimeStamp();
00213 
00214   //fill the header information
00215   Detector::Detector_t det = vldc->GetDetector();
00216 
00217   //get a sim flag
00218   SimFlag::SimFlag_t dataType = vldc->GetSimFlag();
00219 
00220   fInfoFiller->SetDetector(det);
00221   fInfoFiller->SetStripArray(ntpManipulator->GetStripArray());
00222   fInfoFiller->SetClusterArray(ntpManipulator->GetClusterArray());
00223   fInfoFiller->FillHeaderInformation(ntpManipulator, det, dataType, fHeaderInfo);
00224   
00225   //   MAXMSG("CondensedNtpModuleNC",Msg::kDebug,20)
00226   //     << "detector = " << fHeaderInfo->detector << " " << det << endl;
00227 
00228   if(fHeaderInfo->year > 2004){
00229     fInfoFiller->FillBeamInformation(timeStamp, det, dataType, fBeamInfo);
00230     MAXMSG("CondensedNtpModuleNC",Msg::kDebug,1)
00231       << "Calling db method to fill beam info." << endl;
00232   }
00233 
00234   if(fHeaderInfo->passedDeMux == 0)
00235     ++fFailedDeMux;
00236 
00237   //set up which flags you want to use to determine the primary shower or track
00238   //a value of 0 for a flag means it will not be used
00239   ntpManipulator->SetPrimaryTrackCriteria(0,1,0); // nplanes, length, total pulse height
00240 
00241   //for now set the primary shower criteria both to 0, that will pick out the first
00242   //shower in the reco array, which has been determined to be the one to use.  some
00243   //other cuts still apply, but can be put in at the analysis level, not the ntuple
00244   //making level.  this was settled at the reco meeting on 2/9/06 - bjr
00245   ntpManipulator->SetPrimaryShowerCriteria(0,0); // nplanes, total pulse height
00246 
00247   //--------------------------------------------------------------------
00248   //here is where you start looping over the events in the ntuple to fill
00249   //your analysis tree
00250 
00251   //handle the special case where you have a spill but no events
00252   if(fHeaderInfo->events < 1){
00253     //reset all the event, track and shower info objects to their default values
00254     //the beam and header values remain
00255     fEventInfo->Reset();
00256     fTrackInfo->Reset();
00257     fShowerInfo->Reset();
00258     fEventInfoMRCC->Reset();
00259     fNtuple->Fill();
00260     return result;
00261   }
00262 
00263   //initialize the kNN stuff as it should only be done once per snarl
00264   fInfoFiller->InitializekNN(ntpManipulator);
00265 
00266   //loop over the events in the snarl
00267   for(Int_t i = 0; i < fHeaderInfo->events; ++i){
00268 
00269     MSG("CondensedNtpModuleNC", Msg::kDebug) << "on event " << i << endl;
00270 
00271     //reset the variables for the tree
00272     ResetTreeVariables();
00273 
00274     //if this isnt the first event in the snarl, then set the fHeaderInfo->newSnarl
00275     //to 0
00276     if(i > 0) fHeaderInfo->newSnarl = 0;
00277 
00278     if(fMakeNueBranch)fInfoFillerNue->Analyze(i, ntpManipulator->GetNtpStRecord(), fNueInfo);
00279 
00280     // HACK HACK HACK: 
00281     //
00282     // With MRCC files, this line will fill fTruthInfo
00283     // with the truth found from the mrnt file. Sadly, due to the
00284     // processing snafu documented in docdb 6599, the truth
00285     // information in mrnts isn't filled, so we'll later on fill the
00286     // truth from fInfoFillerMRCC::FillEventInformation
00287     if( fInfoFiller->FillInformation(i, ntpManipulator, fEventInfo, fTrackInfo,
00288                                      fShowerInfo, fTruthInfo) ){
00289       // The index field should actually be the index in this snarl. If this
00290       // isn't true then I don't know how the indexing works.
00291       assert(fEventInfo->index == i);
00292       // Fill the MRCC branch if this appears to be an MRCC file. Will
00293       // also fill the truth information, because of the problem
00294       // explained a couple of lines above
00295       if(mrRecord){
00296         fInfoFillerMRCC->FillEventInformation(i, mrRecord, stRecordOrig, 
00297                                               fEventInfoMRCC, 
00298                                               fDataType==1 ? fTruthInfo : 0);
00299         // Make sure it did the right thing
00300         assert(fEventInfoMRCC->bestEvent == fEventInfo->index || 
00301                fEventInfoMRCC->bestEvent == ANtpDefaultValue::kInt);
00302       } // end if mrRecord
00303 
00304       fNtuple->Fill();
00305 
00306     }//end if filling succeeded
00307   }//end loop over events for this snarl
00308   //-------------------------------------------------------------------
00309 
00310   return result;
00311 }

void CondensedNtpModuleNC::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 100 of file CondensedNtpModuleNC.cxx.

References fBeamInfo, fDataType, fEventInfo, fFileName, fHeaderInfo, fMakeNueBranch, fNtpFile, fNtuple, fNueInfo, fShowerInfo, fTrackInfo, fTreeName, fTruthInfo, Msg::kDebug, and MSG.

00101 {
00102   MSG("CondensedNtpModuleNC", Msg::kDebug)
00103     << "in BeginJob" << endl;
00104 
00105   // save the current working directory
00106   //TDirectory* savedir  = gDirectory;
00107 
00108   //create the new TFile for holding the electronics tree
00109   // this changes the value of gDirectory
00110   fNtpFile = new TFile(fFileName,"RECREATE");
00111 //   if(!fNtpFile->IsOpen() ) MSG("CondensedNtpModuleNC", Msg::kFatal) << "file not open "
00112 //                                                                  << fFileName << endl;
00113 
00114   // create TTree, these will attach themselves to the current
00115   //working directory
00116   fNtuple = new TTree(fTreeName, "Analysis Tree");
00117 
00118   //-----------------------------------------------------------------------
00119   //here is where you define your tree
00120   fNtuple->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00121   fNtuple->Branch("event.", "ANtpEventInfoNC", &fEventInfo, 64000, 2);
00122   fNtuple->Branch("shower.", "ANtpShowerInfoNC", &fShowerInfo, 64000, 2);
00123   fNtuple->Branch("track.", "ANtpTrackInfoNC", &fTrackInfo, 64000, 2);
00124   fNtuple->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00125   if(fMakeNueBranch)fNtuple->Branch("nue.", "ANtpNueInfo", &fNueInfo, 64000, 2);
00126   if(fDataType==1)
00127     fNtuple->Branch("truth.", "ANtpTruthInfoBeam", &fTruthInfo, 64000, 2);
00128 
00129   MSG("CondensedNtpModuleNC", Msg::kDebug) << "got branches" << endl;
00130 
00131   //-----------------------------------------------------------------------
00132 
00133   // Setup Kregg's image recognition filling
00134   //fInfoFiller->InitializeVHSTraining(fVHSPlanes, fVHSStrips);
00135 
00136   // change back to current working directory before leaving constructor
00137   //savedir->cd();
00138 
00139   return;
00140 }

void CondensedNtpModuleNC::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 369 of file CondensedNtpModuleNC.cxx.

References fDataType, fFileName, fMakeNueBranch, fTreeName, fVHSPlanes, fVHSStrips, and Registry::Get().

00370 {
00371   int         tmpb;  // a temp bool. See comment under DefaultConfig...
00372   int         tmpi;  // a temp int.
00373   const char* tmps;  // a temp string
00374 
00375   if (r.Get("FileName",               tmps)) fFileName             =  tmps;
00376   if (r.Get("TreeName",               tmps)) fTreeName             =  tmps;
00377   if (r.Get("DataType",               tmpi)) fDataType             =  tmpi;
00378 
00379   if (r.Get("VHSPlanes",              tmpi)) fVHSPlanes            =  tmpi;
00380   if (r.Get("VHSStrips",              tmpi)) fVHSStrips            =  tmpi;
00381 
00382   if (r.Get("MakeNueBranch",          tmpb)) fMakeNueBranch        =  tmpb;
00383 
00384 }

const Registry & CondensedNtpModuleNC::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 341 of file CondensedNtpModuleNC.cxx.

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

00342 {
00343 
00344   int itrue = 1;  // work around for lack of bool in registry
00345   int ifalse = 0; // work around for lack of bool in registry
00346 
00347   static Registry r;
00348 
00349   r.UnLockValues();
00350 
00351   r.Set("FileName",               "analysisTree.root");
00352   r.Set("TreeName",               "analysisTree");
00353   r.Set("DataType",               1);
00354 
00355   r.Set("VHSPlanes",20);
00356   r.Set("VHSStrips",20);
00357 
00358   r.Set("MakeNueBranch",          false);
00359 
00360   r.LockValues();
00361 
00362   //quiet the compiler
00363   itrue = ifalse;
00364 
00365   return r;
00366 }

void CondensedNtpModuleNC::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 324 of file CondensedNtpModuleNC.cxx.

References fFailedDeMux, fNtpFile, Msg::kInfo, and MSG.

00325 {
00326 
00327   MSG("CondensedNtpModuleNC", Msg::kInfo) << "start end job method " << fFailedDeMux
00328                                           << " failed demuxing" << endl;
00329 
00330   //cd to the "directory" of the file
00331   fNtpFile->cd();
00332 
00333   // only write file  -- this is enough and prevents duplication
00334   fNtpFile->Write();
00335   fNtpFile->Close();
00336 
00337   return;
00338 }

void CondensedNtpModuleNC::Help (  )  [virtual]

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 314 of file CondensedNtpModuleNC.cxx.

References Msg::kDebug, and MSG.

00315 {
00316   MSG("JobC", Msg::kDebug)
00317     << "CondensedNtpModuleNC::Help\n"
00318     <<"CondensedNtpModuleNC is a module which demultiplexes events "
00319     <<"in the far detector."
00320     << endl;
00321 }

void CondensedNtpModuleNC::ResetTreeVariables (  )  [private]

Member Data Documentation

Definition at line 62 of file CondensedNtpModuleNC.h.

Referenced by Ana(), BeginJob(), CondensedNtpModuleNC(), and ~CondensedNtpModuleNC().

Definition at line 56 of file CondensedNtpModuleNC.h.

Referenced by Ana(), BeginJob(), and Config().

Definition at line 57 of file CondensedNtpModuleNC.h.

Referenced by Ana(), CondensedNtpModuleNC(), and EndJob().

Definition at line 52 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

Definition at line 61 of file CondensedNtpModuleNC.h.

Referenced by Ana(), BeginJob(), CondensedNtpModuleNC(), and ~CondensedNtpModuleNC().

Definition at line 68 of file CondensedNtpModuleNC.h.

Referenced by Ana(), and CondensedNtpModuleNC().

Definition at line 69 of file CondensedNtpModuleNC.h.

Referenced by Ana(), and CondensedNtpModuleNC().

Definition at line 70 of file CondensedNtpModuleNC.h.

Referenced by Ana(), and CondensedNtpModuleNC().

Definition at line 76 of file CondensedNtpModuleNC.h.

Referenced by Ana(), BeginJob(), Config(), and ResetTreeVariables().

Definition at line 54 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and EndJob().

Definition at line 55 of file CondensedNtpModuleNC.h.

Referenced by Ana(), and BeginJob().

Definition at line 53 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

Definition at line 73 of file CondensedNtpModuleNC.h.

Referenced by Config().

Definition at line 74 of file CondensedNtpModuleNC.h.

Referenced by Config().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1