DemoCandNtpModule Class Reference

#include <DemoCandNtpModule.h>

Inheritance diagram for DemoCandNtpModule:
JobCModule

List of all members.

Public Member Functions

 DemoCandNtpModule ()
 ~DemoCandNtpModule ()
JobCResult Reco (MomNavigator *mom)
void BeginJob ()
void Config (const Registry &r)
const RegistryDefaultConfig () const

Detailed Description

Definition at line 16 of file DemoCandNtpModule.h.


Constructor & Destructor Documentation

DemoCandNtpModule::DemoCandNtpModule (  ) 

Definition at line 287 of file DemoCandNtpModule.cxx.

References Msg::kVerbose, and MSG.

00287                                      { 
00288   //
00289   //  Purpose:  Default constructor.
00290   //
00291   //  Arguments: none.
00292   //
00293   //  Return:    n/a.
00294   //
00295   //  Contact:   S. Kasahara
00296   // 
00297   //  Notes: none.
00298   // 
00299 
00300   MSG("DemoNtuple", Msg::kVerbose) << "DemoCandNtpModule::Constructor" << endl;
00301 
00302 }

DemoCandNtpModule::~DemoCandNtpModule (  ) 

Definition at line 304 of file DemoCandNtpModule.cxx.

References Msg::kVerbose, and MSG.

00304                                       {
00305   //
00306   //  Purpose:  Destructor.  
00307   //
00308   //  Contact:   S. Kasahara
00309   // 
00310 
00311   MSG("DemoNtuple", Msg::kVerbose) << "DemoCandNtpModule::Destructor" << endl;
00312 
00313 }


Member Function Documentation

void DemoCandNtpModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 230 of file DemoCandNtpModule.cxx.

References Msg::kVerbose, and MSG.

00230                                  {
00231   //
00232   //  Purpose:  Configure module at beginning of job.
00233   //
00234   //  Arguments: none.
00235   //  
00236   //  Return: none.
00237   //
00238   //  Contact:   S. Kasahara
00239   // 
00240 
00241   MSG("DemoNtuple", Msg::kVerbose) << "DemoCandNtpModule::BeginJob" << endl;
00242 
00243   // Configure module
00244  
00245 }

void DemoCandNtpModule::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 247 of file DemoCandNtpModule.cxx.

References Msg::kDebug, and MSG.

00247                                                 {
00248   //
00249   //  Purpose:  Configure the module based on the contents of the registry.
00250   //
00251   //  Arguments: none.
00252   //  
00253   //  Return: none.
00254   //
00255   //  Contact:   S. Kasahara
00256   // 
00257 
00258   MSG("DemoNtuple",Msg::kDebug) << "Config DemoCandNtpModule with r=" << r << endl;
00259 
00260 }

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

References Msg::kDebug, Registry::LockValues(), MSG, and Registry::UnLockValues().

00262                                                        {
00263   //
00264   //  Purpose:  Load default values into configuration registry.
00265   //
00266   //  Arguments: none.
00267   //  
00268   //  Return: registry of default configuration values.
00269   //
00270   //  Contact:   S. Kasahara
00271   // 
00272 
00273   static Registry r;
00274   r.SetName("DemoNtuple.config");
00275 
00276   r.UnLockValues();
00277 
00278   MSG("DemoNtuple",Msg::kDebug) << "Loading default config.\n" << endl;
00279 
00280   // r.Set("variable","argument");
00281 
00282   r.LockValues();
00283   return r;
00284 
00285 }

JobCResult DemoCandNtpModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 59 of file DemoCandNtpModule.cxx.

References NtpCandEvent::AddShowerAt(), NtpCandShower::AddStripAt(), NtpCandTrack::AddStripAt(), NtpCandSlice::AddStripAt(), NtpCandEvent::AddTrackAt(), DataUtil::GetCandHeader(), CandHandle::GetDaughterIterator(), RawDaqSnarlHeader::GetErrorCode(), CandHeader::GetEvent(), RawDaqSnarlHeader::GetRemoteSpillType(), CandHeader::GetRun(), RawDaqHeader::GetRunType(), CandHeader::GetSnarl(), RawDaqHeader::GetSubRun(), RawDaqHeader::GetTimeFrameNum(), RawDaqSnarlHeader::GetTrigSrc(), CandHandle::GetUidInt(), RecMinosHdr::GetVldContext(), JobCResult::kPassed, Msg::kVerbose, Msg::kWarning, MSG, VldContext::Print(), JobCResult::SetFailed(), and JobCResult::SetWarning().

00059                                                     {
00060   //
00061   //  Purpose:  Create ntuple record if not present on input
00062   //            stream.
00063   //
00064   //  Arguments: none.
00065   //  
00066   //  Return: none.
00067   //
00068   //  Contact:   S. Kasahara
00069   // 
00070 
00071 
00072   JobCResult result(JobCResult::kPassed);  
00073   MSG("DemoNtuple",Msg::kVerbose) << "DemoCandNtpModule::Get" << endl;
00074 
00075   // Check that mom exists.
00076   assert(mom);
00077     
00078   // Check for existing NtpCand fragment in MOM.
00079   CandRecordSRNtuple *candNtp = dynamic_cast<CandRecordSRNtuple*>
00080      (mom->GetFragment("CandRecordSRNtuple","PrimaryCandidateRecord"));
00081 
00082   if ( candNtp ) return result;
00083 
00084   // Otherwise, create a new one 
00085   CandRecord *candRec = dynamic_cast<CandRecord*>
00086     (mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00087   if ( !candRec ) {
00088     MSG("DemoNtuple",Msg::kWarning) << "No PrimaryCandidateRecord in MOM"<<endl;
00089     result.SetWarning().SetFailed();
00090     return result;
00091   }
00092 
00093   // Need to convert from old CandHeader format to new.
00094   // This ugliness will go away if the CandRecord adopts the new header class.
00095   // Need rawrecord to properly construct new header
00096   RawRecord *rawRec = dynamic_cast<RawRecord*>
00097     (mom->GetFragment("RawRecord")); // should iterate but this is just a demo
00098   if ( !rawRec ) {
00099     MSG("DemoNtuple",Msg::kWarning) << "No RawRecord in MOM"<<endl;
00100     result.SetWarning().SetFailed();
00101     return result;
00102   }
00103   const CandHeader* cndHdr = candRec -> GetCandHeader();
00104   const RawDaqSnarlHeader* rawHdr = dynamic_cast<const RawDaqSnarlHeader*>
00105                               (rawRec -> GetHeader());
00106   rawHdr->GetVldContext().Print();
00107   RecCandHeader* newHdr = new RecCandHeader(rawHdr->GetVldContext(),
00108         cndHdr->GetRun(),rawHdr->GetSubRun(),rawHdr->GetRunType(),
00109         rawHdr->GetErrorCode(),cndHdr->GetSnarl(),rawHdr->GetTrigSrc(),
00110         rawHdr->GetTimeFrameNum(),rawHdr->GetRemoteSpillType(),cndHdr->GetEvent());
00111 
00112   // Create new record
00113   CandRecordSRNtuple* ntpRec = new CandRecordSRNtuple(*newHdr);
00114 
00115   ntpRec->SetName("PrimaryCandidateRecord"); //associate with parent CandRecord
00116   // And pass it to Mom, mom now has memory management responsibility
00117   mom->AdoptFragment(ntpRec);
00118   
00119   // An option will be provided to not write out strip data as in 
00120   // EventSRListModule
00121   std::map<Int_t,Int_t> stripmap; // uid, stripindex
00122   CandStripListHandle* strips = dynamic_cast<CandStripListHandle*>
00123     (candRec -> FindCandHandle("CandStripListHandle"));
00124   if ( !strips ) return result;  // but warn first
00125   TIter stItr(strips->GetDaughterIterator());
00126   Int_t nstrip=0;
00127   while ( CandStripHandle *strip = dynamic_cast<CandStripHandle*>(stItr()) ) {
00128     // For each new strip, an ntuple object is created and added to the TClones
00129     Int_t uid = strip->GetUidInt();
00130     stripmap.insert(std::make_pair(uid,nstrip));
00131     new((ntpRec->GetStrips())[nstrip++]) NtpCandStrip(*strip);
00132   }
00133 
00134   // Slices
00135   CandSliceListHandle* slices = dynamic_cast<CandSliceListHandle*>
00136     (candRec -> FindCandHandle("CandSliceListHandle"));
00137   if ( slices ) {
00138     TIter slitr(slices->GetDaughterIterator());
00139     Int_t nslice=0;
00140     while (CandSliceHandle *slice = dynamic_cast<CandSliceHandle*>(slitr())) {
00141       // For each new slice, an ntp object is created and added to the TClones
00142       NtpCandSlice* slicentp = 
00143           new((ntpRec->GetSlices())[nslice++]) NtpCandSlice(*slice);
00144       TIter stripitr(slice->GetDaughterIterator());
00145       Int_t nslicestrip=0;
00146       while (CandStripHandle* strip
00147                             = dynamic_cast<CandStripHandle*>(stripitr())) {
00148         Int_t uid = strip->GetUidInt();
00149         Int_t stripindex = stripmap[uid];
00150         slicentp->AddStripAt(stripindex,nslicestrip); // add index to strip
00151         nslicestrip++;
00152       } 
00153     }
00154   }
00155 
00156   CandTrackListHandle* tracks = dynamic_cast<CandTrackListHandle*>
00157     (candRec -> FindCandHandle("CandTrackListHandle"));
00158   Int_t ntrack=0;
00159   std::map<Int_t,Int_t> trackmap; // uid,index
00160   if ( tracks ) {
00161     TIter tritr(tracks->GetDaughterIterator());
00162     while (CandTrackSRHandle *track=dynamic_cast<CandTrackSRHandle*>(tritr()))
00163     {
00164       trackmap.insert(std::make_pair(track->GetUidInt(),ntrack));
00165       // For each new track, an ntp object is created and added to the TClones
00166       CandTrackSRNtuple* trackntp = 
00167            new((ntpRec->GetTracks())[ntrack++]) CandTrackSRNtuple(*track);
00168       TIter stripitr(track->GetDaughterIterator());
00169       Int_t ntrackstrip = 0;
00170       while (CandStripHandle* strip
00171              =dynamic_cast<CandStripHandle*>(stripitr())) {
00172         Int_t stripindex = stripmap[strip->GetUidInt()];
00173         trackntp->AddStripAt(stripindex,ntrackstrip); // add reference to strip
00174         ntrackstrip++;
00175       } 
00176     }
00177   }
00178 
00179   CandShowerListHandle* showers = dynamic_cast<CandShowerListHandle*>
00180     (candRec -> FindCandHandle("CandShowerListHandle"));
00181   Int_t nshower=0;
00182   std::map<Int_t,Int_t> showermap;
00183   if ( showers ) {
00184     TIter shitr(showers->GetDaughterIterator());
00185     while (CandShowerHandle *shower 
00186            = dynamic_cast<CandShowerHandle*>(shitr())) {
00187       showermap.insert(std::make_pair(shower->GetUidInt(),nshower));
00188       // For each new shower,an ntp object is created and added to the TClones
00189       NtpCandShower* showerntp = 
00190            new((ntpRec->GetShowers())[nshower++]) NtpCandShower(*shower);
00191       Int_t nshowerstrip=0;
00192       TIter stripitr(shower->GetDaughterIterator());
00193       while(CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stripitr())){
00194         Int_t stripindex = stripmap[strip->GetUidInt()];
00195         showerntp->AddStripAt(stripindex,nshowerstrip); // add ref to strip
00196         nshowerstrip++;
00197       } 
00198     }
00199   }
00200 
00201   CandEventListHandle* events = dynamic_cast<CandEventListHandle*>
00202     (candRec -> FindCandHandle("CandEventListHandle"));
00203   if ( events ) {
00204     TIter evitr(events->GetDaughterIterator());
00205     Int_t nevent=0;
00206     while (CandEventHandle *event = dynamic_cast<CandEventHandle*>(evitr())) {
00207       // For each new strip, an ntp object is created and added to the TClones
00208       NtpCandEvent* eventntp = 
00209            new((ntpRec->GetEvents())[nevent++]) NtpCandEvent(*event);
00210       // An iterator over the tracks&showers is not provided, why?
00211       for ( Int_t i = 0; i <= event->GetLastTrack(); i++ ) {
00212         CandTrackHandle* track 
00213                        = const_cast<CandTrackHandle*>(event->GetTrack(i));
00214         Int_t trackindex = trackmap[track->GetUidInt()];
00215         eventntp->AddTrackAt(trackindex,i);
00216       }
00217       for ( Int_t i = 0; i <= event->GetLastShower(); i++ ) {
00218         CandShowerHandle* shower 
00219                       = const_cast<CandShowerHandle*>(event->GetShower(i));
00220         Int_t showerindex = showermap[shower->GetUidInt()];
00221         eventntp->AddShowerAt(showerindex,i);
00222       }
00223     }
00224   }
00225 
00226   return result;
00227 
00228 }


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1