ShieldPlankListModule Class Reference

#include <ShieldPlankListModule.h>

Inheritance diagram for ShieldPlankListModule:
JobCModule

List of all members.

Public Member Functions

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

Private Attributes

std::string fNameListOut
std::string fTitleListOut
std::string fAlgShieldPlankList
std::string fAlgShieldPlankConfig
std::string fListIn
bool fWriteNtp
TFile * fFile
TTree * fTree
int fRun
int fSnarl
double fTime
double fCharge
double fX
double fY
double fZ
int fSection
int f2End

Detailed Description

Definition at line 19 of file ShieldPlankListModule.h.


Constructor & Destructor Documentation

ShieldPlankListModule::ShieldPlankListModule (  ) 

Definition at line 36 of file ShieldPlankListModule.cxx.

00036                                             :
00037   fNameListOut("shieldstriplist"),
00038   fTitleListOut("FarDet Veto shield strips"),
00039   fListIn("canddigitlist"),
00040   fWriteNtp(1), fFile(0), fTree(0)
00041 {
00042   //======================================================================
00043   // Create the module and configure the default alg
00044   //======================================================================
00045   
00046 }

ShieldPlankListModule::~ShieldPlankListModule (  ) 

Definition at line 50 of file ShieldPlankListModule.cxx.

00051 {
00052 //======================================================================
00053 // FILL_IN: [Document your code!!]
00054 //======================================================================
00055 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 101 of file ShieldPlankListModule.cxx.

References digit(), f2End, fCharge, CandRecord::FindCandHandle(), fRun, fSection, fSnarl, fTime, fTree, fX, fY, fZ, PlexSEIdAltL::GetBestSEId(), CandRecord::GetCandHeader(), CandHandle::GetDaughterIterator(), MomNavigator::GetFragment(), CandHandle::GetNDaughters(), CandHeader::GetRun(), CandHeader::GetSnarl(), UgliGeomHandle::GetStripHandle(), RecMinos::GetVldContext(), UgliStripHandle::GlobalPos(), UgliStripHandle::IsValid(), PlexSEIdAltL::IsValid(), CalDigitType::kNone, StripEnd::kNorth, JobCResult::kPassed, StripEnd::kSouth, JobCResult::kWarning, Msg::kWarning, and MSG.

00102 {
00103   cout.precision(4);
00104   cout.setf(ios_base::scientific,ios_base::floatfield);
00105   //======================================================================
00106   //Get pointers to Candidates 
00107   //
00108   const CandRecord *const candrec = dynamic_cast<const CandRecord *>
00109              (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00110   if (candrec == 0) {
00111     MSG("ShieldPlank", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."<< endl;
00112     return JobCResult::kWarning; // Raise warning flag
00113   }
00114  
00115   const CandHeader* ch =   candrec->GetCandHeader();
00116   fRun   =  ch->GetRun();
00117   fSnarl =  ch->GetSnarl();
00118   
00119 
00120   const CandShieldPlankListHandle* const shieldstriplisthandle = dynamic_cast<const CandShieldPlankListHandle* const>(candrec->FindCandHandle("CandShieldPlankListHandle"));
00121  
00122   UgliGeomHandle ugh(*(candrec->GetVldContext()));
00123  
00124   CandShieldPlankHandleItr sstripIter(shieldstriplisthandle->GetDaughterIterator());
00125   cout << "======================================================================================"<<endl;
00126   cout << "CandPlankList: "<< shieldstriplisthandle->GetNDaughters()<<endl;
00127   while(const CandShieldPlankHandle* const sstrip = dynamic_cast<const CandShieldPlankHandle* const>(sstripIter()))
00128     {
00129       fSection = sstrip->GetSection();
00130       fX = sstrip->GetMeanX();
00131       fY = sstrip->GetMeanY();
00132       
00133       if(sstrip->GetCharge(StripEnd::kNorth)>0.0)
00134         {
00135 
00136           fZ = sstrip->GetMeanZ(StripEnd::kNorth);
00137           fCharge = sstrip->GetCharge(StripEnd::kNorth);
00138           fTime = sstrip->GetMeanTime(StripEnd::kNorth);
00139           f2End = 0;
00140           if(sstrip->GetCharge(StripEnd::kSouth)>0.0) f2End=1;
00141           fTree->Fill();
00142         }
00143 
00144       if(sstrip->GetCharge(StripEnd::kSouth)>0.0)
00145         {
00146           fZ = sstrip->GetMeanZ(StripEnd::kSouth);
00147           fCharge = sstrip->GetCharge(StripEnd::kSouth);
00148           fTime = sstrip->GetMeanTime(StripEnd::kSouth);
00149           f2End = 0;
00150           if(sstrip->GetCharge(StripEnd::kNorth)>0.0) f2End=1;
00151           fTree->Fill();
00152         }
00153 
00154       cout << "Strip: "<< "Section:"<<sstrip->GetSection()<< ", "<<sstrip->GetSubSection()<<endl
00155            << "   XYZ      :"<<sstrip->GetMeanX()<< ", "<< sstrip->GetMeanY()<<", "<< sstrip->GetMeanZ(StripEnd::kSouth)<<"->"<<sstrip->GetMeanZ(StripEnd::kNorth)<<endl
00156            << "   #Errors  :" << sstrip->GetNErrors()<<endl
00157            << "   ChargeN/S:" << sstrip->GetCharge(StripEnd::kNorth)<<" / "<<  sstrip->GetCharge(StripEnd::kSouth)<<endl
00158            << "   Time  N/S:" << sstrip->GetMeanTime(StripEnd::kNorth)<< " / "<<  sstrip->GetMeanTime(StripEnd::kSouth)<<endl
00159            << "   NDigits  :" << sstrip->GetNDaughters()<<endl
00160            << "   Z        :" << sstrip->GetMeanZ(StripEnd::kNorth)<< " / "<<sstrip->GetMeanZ(StripEnd::kSouth)<<endl;
00161       
00162       TIter digitIter(sstrip->GetDaughterIterator());
00163       while(const CandDigitHandle* digit = dynamic_cast<const CandDigitHandle*>(digitIter()))
00164         {
00165           const PlexSEIdAltL& paltl = digit->GetPlexSEIdAltL();
00166 
00167           
00168           cout << "DIGIT:"<<endl;
00169           cout << "------"<<endl;
00170           cout << "adc:"<<digit->GetCharge(CalDigitType::kNone)<<"  "<< endl;
00171           for(PlexSEIdAltL::const_iterator iter = paltl.begin();
00172               iter!=paltl.end();
00173               ++iter){
00174             const PlexStripEndId  pseid = paltl.GetBestSEId();            
00175             //cout << "     plane:" << pseid.GetPlane()<<" spt:"<< pseid.GetStrip()<< " end:" <<pseid.GetEnd()<<endl;   
00176             if(paltl.IsValid())
00177               {
00178                 const UgliStripHandle ush  = ugh.GetStripHandle(pseid);
00179                 if(ush.IsValid())
00180                   {
00181                     TVector3 gpos(ush.GlobalPos(0.0));
00182                     cout << "    xyz:"<< gpos.X()<<", "<<gpos.Y()<<", "<<gpos.Z()<<endl;
00183                     
00184                 }else{
00185                   cout <<" ###INVALID GEOM###"<<endl;
00186                 }
00187 
00188             }else{
00189               cout <<" ###INVALID PLEX###"<<endl;
00190             }
00191           }
00192         }
00193     }
00194 
00195   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00196 }

void ShieldPlankListModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 59 of file ShieldPlankListModule.cxx.

References f2End, fCharge, fFile, fRun, fSection, fSnarl, fTime, fTree, fWriteNtp, fX, fY, and fZ.

00060 {
00061 //======================================================================
00062 // FILL_IN: [Document your code!!]
00063 //======================================================================
00064   TDirectory* cdir = gDirectory;
00065   if(fWriteNtp)
00066     {
00067       fFile = new TFile("shieldplank.root", "recreate");
00068       fFile->cd();     
00069       fTree = new TTree("splank", "ShieldPlanks");
00070       fTree->SetDirectory(fFile);
00071 
00072       fTree->Branch("fRun", &fRun, "fRun/I");
00073       fTree->Branch("fSnarl", &fSnarl, "fSnarl/I");
00074       fTree->Branch("fTime", &fTime, "fTime/D");
00075       fTree->Branch("fCharge", &fCharge, "fCharge/D");
00076       fTree->Branch("fX", &fX, "fX/D");
00077       fTree->Branch("fY", &fY, "fY/D");
00078       fTree->Branch("fZ", &fZ, "fZ/D");
00079       fTree->Branch("fSection", &fSection, "fSection/I");
00080       fTree->Branch("f2End", &f2End, "f2End/I");
00081       
00082     }
00083   gDirectory = cdir;
00084 }

void ShieldPlankListModule::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 277 of file ShieldPlankListModule.cxx.

References fAlgShieldPlankConfig, fAlgShieldPlankList, fListIn, fNameListOut, fTitleListOut, fWriteNtp, and Registry::Get().

00278 {
00279 //======================================================================
00280 // Configure the module given the Registry r
00281 //======================================================================
00282 //  double tmpd;
00283   const char* tmps;
00284   int tmpi;
00285 
00286   if (r.Get("NameListOut",tmps)) { fNameListOut = tmps; }
00287   if (r.Get("TitleListOut",tmps)) { fTitleListOut = tmps; }
00288   if (r.Get("AlgName",   tmps))  { fAlgShieldPlankList = tmps;}
00289   if (r.Get("AlgConfig", tmps))  { fAlgShieldPlankConfig = tmps;}
00290   
00291   if (r.Get("NameListIn", tmps))  { fListIn = tmps;}
00292   if (r.Get("WriteNtp", tmpi)) {fWriteNtp = tmpi;}
00293   
00294 
00295 }

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

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

00251 {
00252 //======================================================================
00253 // Supply the default configuration for the module
00254 //======================================================================
00255   static Registry r; // Default configuration for module
00256 // Find PrimaryCandidateRecord fragment in MOM.
00257   
00258   // Set values in configuration
00259   r.UnLockValues();
00260   r.Set("NameListOut",   "shieldstriplist");
00261   r.Set("TitleListOut",  "shieldstriplist");
00262   r.Set("AlgName",       "AlgShieldPlankList");
00263   r.Set("AlgConfig",     "default");
00264 
00265   r.LockValues();
00266 
00267   // Set name of config
00268   std::string name = this->JobCModule::GetName();
00269   name += ".config.default";
00270   r.SetName(name.c_str());
00271 
00272   return r;
00273 }

void ShieldPlankListModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 88 of file ShieldPlankListModule.cxx.

References fFile, and fTree.

00089 {
00090 //======================================================================
00091 // FILL_IN: [Document your code!!]
00092 //======================================================================
00093   TDirectory* cdir = gDirectory;
00094   fFile->cd();
00095   fTree->Write();
00096   gDirectory = cdir;
00097 }

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

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 200 of file ShieldPlankListModule.cxx.

References fAlgShieldPlankConfig, fAlgShieldPlankList, CandRecord::FindCandHandle(), fListIn, fNameListOut, fTitleListOut, AlgFactory::GetAlgHandle(), MomNavigator::GetFragment(), AlgFactory::GetInstance(), Msg::kDebug, JobCResult::kPassed, Msg::kWarning, CandShieldPlankList::MakeCandidate(), MSG, CandRecord::SecureCandHandle(), CandContext::SetCandRecord(), CandContext::SetDataIn(), JobCResult::SetFailed(), CandHandle::SetName(), CandHandle::SetTitle(), and JobCResult::SetWarning().

00201 {
00202 //======================================================================
00203 // FILL_IN: [Document your code!!]
00204 //======================================================================
00205   JobCResult result(JobCResult::kPassed);
00206  
00207   CandContext cx(this, mom);
00208     
00209   // Find PrimaryCandidateRecord fragment in MOM.
00210   CandRecord *candrec = dynamic_cast<CandRecord *>
00211              (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00212   if (candrec == 0) {
00213     MSG("ShieldPlank", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00214                                                                 << endl;
00215     result.SetWarning().SetFailed();
00216     return result;
00217   }else {
00218     MSG("ShieldPlank", Msg::kDebug)<< "Set CandRecord pointer in CandContext." << endl;
00219     cx.SetCandRecord(candrec);
00220   }
00221   
00222   CandDigitListHandle *cdlh = dynamic_cast<CandDigitListHandle *>
00223     (candrec->FindCandHandle("CandDigitListHandle", fListIn.c_str()));
00224   if(!cdlh)
00225     {
00226       MSG("ShieldPlank", Msg::kWarning) << "No CandDigitList called " << fListIn<<" in CandRecord."<< endl;
00227       result.SetWarning().SetFailed();
00228       return result;
00229       
00230     }  
00231   cx.SetDataIn(cdlh);
00232 
00233   AlgFactory &af = AlgFactory::GetInstance();
00234   AlgHandle adlh = af.GetAlgHandle(fAlgShieldPlankList.c_str(),
00235                                    fAlgShieldPlankConfig.c_str());
00236   
00237 
00238   CandShieldPlankListHandle csslh = CandShieldPlankList::MakeCandidate(adlh, cx);
00239   csslh.SetName(fNameListOut.c_str());
00240   csslh.SetTitle(fTitleListOut.c_str());
00241 
00242   //Give Candidate to candrecord to hold
00243   candrec->SecureCandHandle(csslh);
00244 
00245   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00246 }


Member Data Documentation

Definition at line 58 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

Definition at line 44 of file ShieldPlankListModule.h.

Referenced by Config(), and Reco().

Definition at line 43 of file ShieldPlankListModule.h.

Referenced by Config(), and Reco().

Definition at line 53 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

TFile* ShieldPlankListModule::fFile [private]

Definition at line 48 of file ShieldPlankListModule.h.

Referenced by BeginJob(), and EndJob().

std::string ShieldPlankListModule::fListIn [private]

Definition at line 45 of file ShieldPlankListModule.h.

Referenced by Config(), and Reco().

std::string ShieldPlankListModule::fNameListOut [private]

Definition at line 41 of file ShieldPlankListModule.h.

Referenced by Config(), and Reco().

Definition at line 50 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

Definition at line 57 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

Definition at line 51 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

double ShieldPlankListModule::fTime [private]

Definition at line 52 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

std::string ShieldPlankListModule::fTitleListOut [private]

Definition at line 42 of file ShieldPlankListModule.h.

Referenced by Config(), and Reco().

TTree* ShieldPlankListModule::fTree [private]

Definition at line 49 of file ShieldPlankListModule.h.

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

Definition at line 47 of file ShieldPlankListModule.h.

Referenced by BeginJob(), and Config().

double ShieldPlankListModule::fX [private]

Definition at line 54 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

double ShieldPlankListModule::fY [private]

Definition at line 55 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().

double ShieldPlankListModule::fZ [private]

Definition at line 56 of file ShieldPlankListModule.h.

Referenced by Ana(), and BeginJob().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1