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

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
ANtpEventInfoNCfEventInfo
ANtpHeaderInfofHeaderInfo
ANtpBeamInfofBeamInfo
ANtpShowerInfoNCfShowerInfo
ANtpTrackInfoNCfTrackInfo
ANtpTruthInfoBeamfTruthInfo
ANtpInfoObjectFillerNCfInfoFiller
int fVHSPlanes
int fVHSStrips

Constructor & Destructor Documentation

CondensedNtpModuleNC::CondensedNtpModuleNC  ) 
 

Definition at line 80 of file CondensedNtpModuleNC.cxx.

References fBeamInfo, fEventInfo, fFailedDeMux, fHeaderInfo, fInfoFiller, fShowerInfo, fTrackInfo, fTruthInfo, and MSG.

00080                                            :
00081   fFileName("analysisNtuple.root"),
00082   fTreeName("analysisNtuple"),
00083   fNtpFile(0),
00084   fNtuple(0),
00085   fEventInfo(0),
00086   fHeaderInfo(0),
00087   fShowerInfo(0),
00088   fTrackInfo(0),
00089   fTruthInfo(0),
00090   fVHSPlanes(20),
00091   fVHSStrips(20)
00092 {
00093   MSG("JobC", Msg::kDebug) << "CondensedNtpModuleNC::Constructor" << endl;
00094     
00095   fHeaderInfo = new ANtpHeaderInfo();
00096   fEventInfo = new ANtpEventInfoNC();
00097   fTrackInfo = new ANtpTrackInfoNC();
00098   fShowerInfo = new ANtpShowerInfoNC();
00099   fTruthInfo = new ANtpTruthInfoBeam();
00100   fBeamInfo = new ANtpBeamInfo();
00101   
00102   fInfoFiller = new ANtpInfoObjectFillerNC();
00103   
00104   fFailedDeMux = 0;
00105 }

CondensedNtpModuleNC::~CondensedNtpModuleNC  )  [virtual]
 

Definition at line 108 of file CondensedNtpModuleNC.cxx.

References MSG.

00109 {
00110   
00111   MSG("JobC", Msg::kDebug) << "CondensedNtpModuleNC::Destructor" << endl;
00112   
00113   if(fHeaderInfo) delete fHeaderInfo;   
00114   if(fEventInfo) delete fEventInfo;     
00115   if(fShowerInfo) delete fShowerInfo;   
00116   if(fTrackInfo) delete fTrackInfo;     
00117   if(fTruthInfo) delete fTruthInfo;     
00118   if(fBeamInfo) delete fBeamInfo;
00119 
00120 }


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 167 of file CondensedNtpModuleNC.cxx.

References ANtpHeaderInfo::events, fBeamInfo, fEventInfo, fHeaderInfo, ANtpInfoObjectFillerBeam::FillBeamInformation(), ANtpInfoObjectFiller::FillHeaderInformation(), ANtpInfoObjectFillerNC::FillInformation(), fInfoFiller, fNtuple, fShowerInfo, fTrackInfo, fTruthInfo, ANtpRecoNtpManipulator::GetClusterArray(), VldContext::GetDetector(), MomNavigator::GetFragment(), VldContext::GetSimFlag(), ANtpRecoNtpManipulator::GetStripArray(), VldContext::GetTimeStamp(), RecRecordImp< T >::GetVldContext(), ANtpInfoObjectFillerNC::InitializekNN(), MAXMSG, MSG, ANtpHeaderInfo::newSnarl, ANtpHeaderInfo::passedDeMux, ANtpShowerInfoNC::Reset(), ANtpTrackInfoNC::Reset(), ANtpEventInfoNC::Reset(), ResetTreeVariables(), ANtpInfoObjectFillerNC::SetClusterArray(), ANtpInfoObjectFillerNC::SetDetector(), JobCResult::SetFailed(), ANtpRecoNtpManipulator::SetPrimaryShowerCriteria(), ANtpRecoNtpManipulator::SetPrimaryTrackCriteria(), ANtpInfoObjectFiller::SetStripArray(), JobCResult::SetWarning(), ANtpHeaderInfo::snarl, ANtpBeamInfo::tortgt, ANtpHeaderInfo::utc, and ANtpHeaderInfo::year.

00168 {
00169   // bool mc = false;
00170   
00171   JobCResult result(JobCResult::kPassed);
00172   
00173   //get the records from MOM
00174   assert(mom);
00175   
00176   NtpSRRecord *record = dynamic_cast<NtpSRRecord *>(mom->GetFragment("NtpSRRecord"));
00177   NtpStRecord *stRecord = dynamic_cast<NtpStRecord *>(mom->GetFragment("NtpStRecord"));
00178   
00179   if(!record && !stRecord){
00180     MSG("CondensedNtpModuleAtm", Msg::kWarning) << "Could not get NtpSR or NtpSt "
00181                                                 << "Record from MOM" << endl;
00182     result.SetWarning().SetFailed();
00183     return result;
00184   }//end if no NtpSRRecord
00185   
00186   NtpMCRecord *mcRecord = 0;
00187   NtpTHRecord *thRecord = 0;
00188   
00189   mcRecord = dynamic_cast<NtpMCRecord *>(mom->GetFragment("NtpMCRecord"));
00190   thRecord = dynamic_cast<NtpTHRecord *>(mom->GetFragment("NtpTHRecord"));
00191 
00192   //get the record for the beam tree
00193   NtpBDLiteRecord *bdRecord = 0;
00194   //bdRecord = dynamic_cast<NtpBDLiteRecord *>(mom->GetFragment("NtpBDLiteRecord"));
00195       
00196   //instantiate a NtpHelper object to help you get the info you want
00197   ANtpRecoNtpManipulator *ntpManipulator = 0;
00198   if(record) ntpManipulator = new ANtpRecoNtpManipulator(record, mcRecord, thRecord);
00199   else if(stRecord) ntpManipulator = new ANtpRecoNtpManipulator(stRecord);
00200 
00201   const VldContext *vldc = stRecord ? stRecord->GetVldContext() : record->GetVldContext();
00202   VldTimeStamp timeStamp = vldc->GetTimeStamp();
00203 
00204   //fill the header information
00205   Detector::Detector_t det = vldc->GetDetector();
00206 
00207   //get a sim flag
00208   SimFlag::SimFlag_t dataType = vldc->GetSimFlag();
00209 
00210   fInfoFiller->SetDetector(det);
00211   fInfoFiller->SetStripArray(ntpManipulator->GetStripArray());
00212   fInfoFiller->SetClusterArray(ntpManipulator->GetClusterArray());
00213   fInfoFiller->FillHeaderInformation(ntpManipulator, det, dataType, fHeaderInfo);
00214 
00215   MSG("CondensedNtpModuleNC", Msg::kDebug) << "snarl " << fHeaderInfo->snarl << endl;
00216   
00217 //   MAXMSG("CondensedNtpModuleNC",Msg::kDebug,20)
00218 //     << "detector = " << fHeaderInfo->detector << " " << det << endl;
00219 
00220   if(fHeaderInfo->year > 2004){
00221     if(bdRecord) {
00222       fInfoFiller->FillBeamInformation(bdRecord, fBeamInfo);
00223       MAXMSG("CondensedNtpModuleNC",Msg::kDebug,1) 
00224         << "Using NtpBDLiteRecord to fill beam info." << endl;
00225       MAXMSG("CondensedNtpModuleNC", Msg::kDebug,100) << timeStamp << " " 
00226                                                      << " " << fHeaderInfo->utc 
00227                                                      << " " << fBeamInfo->tortgt
00228                                                      << endl;
00229     }
00230     else {
00231       fInfoFiller->FillBeamInformation(timeStamp, det, dataType, fBeamInfo);
00232       MAXMSG("CondensedNtpModuleNC",Msg::kDebug,1)
00233         << "Calling db method to fill beam info." << endl;
00234     }
00235   }
00236 
00237   if(fHeaderInfo->passedDeMux == 0)
00238     ++fFailedDeMux;
00239   
00240   //set up which flags you want to use to determine the primary shower or track
00241   //a value of 0 for a flag means it will not be used
00242   ntpManipulator->SetPrimaryTrackCriteria(0,1,0); // nplanes, length, total pulse height
00243 
00244   //for now set the primary shower criteria both to 0, that will pick out the first
00245   //shower in the reco array, which has been determined to be the one to use.  some 
00246   //other cuts still apply, but can be put in at the analysis level, not the ntuple
00247   //making level.  this was settled at the reco meeting on 2/9/06 - bjr
00248   ntpManipulator->SetPrimaryShowerCriteria(0,0); // nplanes, total pulse height
00249   
00250   //--------------------------------------------------------------------
00251   //here is where you start looping over the events in the ntuple to fill 
00252   //your analysis tree
00253   
00254   //handle the special case where you have a spill but no events
00255   if(fHeaderInfo->events < 1){
00256     //reset all the event, track and shower info objects to their default values
00257     //the beam and header values remain
00258     fEventInfo->Reset();
00259     fTrackInfo->Reset();
00260     fShowerInfo->Reset();
00261     fNtuple->Fill();
00262     return result;
00263   }
00264 
00265   //initialize the kNN stuff as it should only be done once per snarl
00266   fInfoFiller->InitializekNN(ntpManipulator);
00267 
00268   //loop over the events in the snarl
00269   for(Int_t i = 0; i < fHeaderInfo->events; ++i){
00270     
00271     MSG("CondensedNtpModuleNC", Msg::kDebug) << "on event " << i << endl;
00272  
00273     //reset the variables for the tree
00274     ResetTreeVariables();
00275 
00276     //if this isnt the first event in the snarl, then set the fHeaderInfo->newSnarl
00277     //to 0
00278     if(i > 0) fHeaderInfo->newSnarl = 0;
00279 
00280     if( fInfoFiller->FillInformation(i, ntpManipulator, fEventInfo, fTrackInfo,
00281                                      fShowerInfo, fTruthInfo) ){
00282     
00283       fNtuple->Fill();
00284       
00285     }//end if filling succeeded
00286   }//end loop over events for this snarl
00287   //-------------------------------------------------------------------
00288   
00289   return result;
00290 }

void CondensedNtpModuleNC::BeginJob  )  [virtual]
 

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 123 of file CondensedNtpModuleNC.cxx.

References fBeamInfo, fDataType, fEventInfo, fFileName, fHeaderInfo, fInfoFiller, fNtpFile, fNtuple, fShowerInfo, fTrackInfo, fTreeName, fTruthInfo, fVHSPlanes, fVHSStrips, ANtpInfoObjectFillerNC::InitializeVHSTraining(), and MSG.

00124 {
00125   MSG("CondensedNtpModuleNC", Msg::kDebug) 
00126     << "in BeginJob" << endl;
00127   
00128   // save the current working directory
00129   //TDirectory* savedir  = gDirectory;  
00130   
00131   //create the new TFile for holding the electronics tree
00132   // this changes the value of gDirectory
00133   fNtpFile = new TFile(fFileName,"RECREATE");  
00134 //   if(!fNtpFile->IsOpen() ) MSG("CondensedNtpModuleNC", Msg::kFatal) << "file not open " 
00135 //                                                                  << fFileName << endl;
00136 
00137   // create TTree, these will attach themselves to the current 
00138   //working directory   
00139   fNtuple = new TTree(fTreeName, "Analysis Tree");
00140   
00141   //-----------------------------------------------------------------------
00142   //here is where you define your tree
00143   fNtuple->Branch("header.", "ANtpHeaderInfo", &fHeaderInfo, 64000, 2);
00144   fNtuple->Branch("event.", "ANtpEventInfoNC", &fEventInfo, 64000, 2);
00145   fNtuple->Branch("shower.", "ANtpShowerInfoNC", &fShowerInfo, 64000, 2);
00146   fNtuple->Branch("track.", "ANtpTrackInfoNC", &fTrackInfo, 64000, 2);
00147   fNtuple->Branch("beam.", "ANtpBeamInfo", &fBeamInfo, 64000, 2);
00148   if(fDataType==1) 
00149     fNtuple->Branch("truth.", "ANtpTruthInfoBeam", &fTruthInfo, 64000, 2);
00150   
00151   MSG("CondensedNtpModuleNC", Msg::kDebug) << "got branches" << endl;
00152   
00153   //-----------------------------------------------------------------------
00154 
00155   // Setup Kregg's image recognition filling
00156   fInfoFiller->InitializeVHSTraining(fVHSPlanes, fVHSStrips);
00157     
00158   // change back to current working directory before leaving constructor
00159   //savedir->cd();   
00160   
00161   return;
00162 }

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 346 of file CondensedNtpModuleNC.cxx.

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

00347 {
00348   int         tmpb;  // a temp bool. See comment under DefaultConfig...
00349   int         tmpi;  // a temp int.
00350   double      tmpd;  // a temp double.
00351   const char* tmps;  // a temp string
00352   
00353   if (r.Get("FileName",               tmps)) fFileName             =  tmps;
00354   if (r.Get("TreeName",               tmps)) fTreeName             =  tmps;
00355   if (r.Get("DataType",               tmpi)) fDataType             =  tmpi;
00356 
00357   if (r.Get("VHSPlanes",              tmpi)) fVHSPlanes            =  tmpi;
00358   if (r.Get("VHSStrips",              tmpi)) fVHSStrips            =  tmpi;
00359 
00360   tmpb = 0;
00361   tmpd = 1.;
00362 
00363   return;
00364 }

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

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

00321 {
00322   
00323   int itrue = 1;  // work around for lack of bool in registry
00324   int ifalse = 0; // work around for lack of bool in registry
00325   
00326   static Registry r;
00327   
00328   r.UnLockValues();
00329   
00330   r.Set("FileName",               "analysisTree.root");
00331   r.Set("TreeName",               "analysisTree");
00332   r.Set("DataType",               1);
00333 
00334   r.Set("VHSPlanes",20);
00335   r.Set("VHSStrips",20);
00336 
00337   r.LockValues();
00338 
00339   //quiet the compiler
00340   itrue = ifalse;
00341   
00342   return r;
00343 }

void CondensedNtpModuleNC::EndJob  )  [virtual]
 

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 303 of file CondensedNtpModuleNC.cxx.

References fFailedDeMux, fNtpFile, and MSG.

00304 {
00305   
00306   MSG("CondensedNtpModuleNC", Msg::kInfo) << "start end job method " << fFailedDeMux 
00307                                           << " failed demuxing" << endl;        
00308   
00309   //cd to the "directory" of the file
00310   fNtpFile->cd();
00311   
00312   // only write file  -- this is enough and prevents duplication
00313   fNtpFile->Write();
00314   fNtpFile->Close();
00315   
00316   return;
00317 }

void CondensedNtpModuleNC::Help  )  [virtual]
 

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 293 of file CondensedNtpModuleNC.cxx.

References MSG.

00294 {
00295   MSG("JobC", Msg::kDebug) 
00296     << "CondensedNtpModuleNC::Help\n"
00297     <<"CondensedNtpModuleNC is a module which demultiplexes events "
00298     <<"in the far detector."
00299     << endl;
00300 }

void CondensedNtpModuleNC::ResetTreeVariables  )  [private]
 

Definition at line 367 of file CondensedNtpModuleNC.cxx.

References fEventInfo, fShowerInfo, fTrackInfo, fTruthInfo, ANtpTruthInfoBeam::Reset(), ANtpShowerInfoNC::Reset(), ANtpTrackInfoNC::Reset(), and ANtpEventInfoNC::Reset().

Referenced by Ana().

00368 {
00369 
00370   fEventInfo->Reset();
00371   fTrackInfo->Reset();
00372   fShowerInfo->Reset();
00373   fTruthInfo->Reset();
00374 
00375   return;
00376 }


Member Data Documentation

ANtpBeamInfo* CondensedNtpModuleNC::fBeamInfo [private]
 

Definition at line 68 of file CondensedNtpModuleNC.h.

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

int CondensedNtpModuleNC::fDataType [private]
 

Definition at line 63 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

ANtpEventInfoNC* CondensedNtpModuleNC::fEventInfo [private]
 

Definition at line 66 of file CondensedNtpModuleNC.h.

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

int CondensedNtpModuleNC::fFailedDeMux [private]
 

Definition at line 64 of file CondensedNtpModuleNC.h.

Referenced by CondensedNtpModuleNC(), and EndJob().

TString CondensedNtpModuleNC::fFileName [private]
 

Definition at line 59 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

ANtpHeaderInfo* CondensedNtpModuleNC::fHeaderInfo [private]
 

Definition at line 67 of file CondensedNtpModuleNC.h.

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

ANtpInfoObjectFillerNC* CondensedNtpModuleNC::fInfoFiller [private]
 

Definition at line 73 of file CondensedNtpModuleNC.h.

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

TFile* CondensedNtpModuleNC::fNtpFile [private]
 

Definition at line 61 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and EndJob().

TTree* CondensedNtpModuleNC::fNtuple [private]
 

Definition at line 62 of file CondensedNtpModuleNC.h.

Referenced by Ana(), and BeginJob().

ANtpShowerInfoNC* CondensedNtpModuleNC::fShowerInfo [private]
 

Definition at line 69 of file CondensedNtpModuleNC.h.

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

ANtpTrackInfoNC* CondensedNtpModuleNC::fTrackInfo [private]
 

Definition at line 70 of file CondensedNtpModuleNC.h.

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

TString CondensedNtpModuleNC::fTreeName [private]
 

Definition at line 60 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

ANtpTruthInfoBeam* CondensedNtpModuleNC::fTruthInfo [private]
 

Definition at line 71 of file CondensedNtpModuleNC.h.

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

int CondensedNtpModuleNC::fVHSPlanes [private]
 

Definition at line 76 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().

int CondensedNtpModuleNC::fVHSStrips [private]
 

Definition at line 77 of file CondensedNtpModuleNC.h.

Referenced by BeginJob(), and Config().


The documentation for this class was generated from the following files:
Generated on Fri Mar 28 15:58:04 2008 for loon by  doxygen 1.3.9.1