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

Cluster3DModule.cxx

Go to the documentation of this file.
00001 
00002 // Module created with help of gen_module program by M.Messier
00003 //
00004 // Module for 3D Clustering
00005 //
00006 // Katarzyna Grzelak K.Grzelak1@physics.ox.ac.uk
00008 
00009 #include <cassert>
00010 
00011 #include "Cluster3D/Cluster3DModule.h"
00012 #include "Algorithm/AlgConfig.h"
00013 #include "Algorithm/AlgFactory.h"
00014 #include "Algorithm/AlgHandle.h"
00015 #include "CandData/CandHeader.h"
00016 #include "CandData/CandRecord.h"
00017 #include "Candidate/CandContext.h"
00018 #include "Conventions/Munits.h"
00019 #include "JobControl/JobCModuleRegistry.h"
00020 #include "JobControl/JobCommand.h"
00021 #include "MessageService/MsgService.h"
00022 #include "MinosObjectMap/MomNavigator.h"
00023 #include "Validity/VldContext.h"
00024 #include "CandDigit/CandDigitListHandle.h"
00025 #include "RecoBase/CandSliceListHandle.h"
00026 #include "RecoBase/CandStripListHandle.h"
00027 #include "Cluster3D/CandCluster3DListHandle.h"
00028 #include "Cluster3D/CandCluster3DList.h"
00029 #include "Cluster3D/CandCluster3DHandle.h"
00030 
00031 #include <iostream>
00032 
00033 using std::cout;
00034 using std::endl;
00035 
00036 ClassImp(Cluster3DModule)
00037 
00038 JOBMODULE(Cluster3DModule,"Cluster3DModule","Clustering in 3D");
00039 CVSID("$Id: Cluster3DModule.cxx,v 1.3 2007/03/01 17:44:17 rhatcher Exp $");
00040 //......................................................................
00041 
00042 Cluster3DModule::Cluster3DModule()  
00043 {
00044 //======================================================================
00045 // Purpose: Default constructor
00046 //======================================================================
00047 
00048   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule Constructor - " << endl;
00049 
00050   AlgFactory &af = AlgFactory::GetInstance();
00051   af.Register("AlgCluster3DList","default","libCluster3D.so","AlgConfig");
00052   af.Register("AlgCluster3D","default","libCluster3D.so","AlgConfig");
00053 
00054 }
00055 
00056 //......................................................................
00057 
00058 Cluster3DModule::~Cluster3DModule()
00059 {
00060 //======================================================================
00061 // Purpose: Default destructor
00062 //======================================================================
00063 
00064   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule Destructor - " << endl;
00065 
00066 }
00067 
00068 //......................................................................
00069 
00070 void Cluster3DModule::BeginJob()
00071 {
00072 //======================================================================
00073 // Purpose: Something that should be done at the begin of job
00074 //======================================================================
00075 
00076   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::BeginJob - " << endl;
00077 
00078 }
00079 
00080 //......................................................................
00081 
00082 void Cluster3DModule::EndJob()
00083 {
00084 //======================================================================
00085 // Purpose: Something that should be done at the end of job
00086 //======================================================================
00087 
00088   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::EndJob - " << endl;
00089 
00090 }
00091 
00092 //......................................................................
00093 
00094 void Cluster3DModule::BeginFile()
00095 {
00096 //======================================================================
00097 // Purpose: Something that should be done at the begin of file
00098 //======================================================================
00099 
00100   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::BeginFile - " << endl;
00101 
00102 }
00103 
00104 //......................................................................
00105 
00106 void Cluster3DModule::EndFile()
00107 {
00108 //======================================================================
00109 // Purpose: Something that should be done at the end of file
00110 //======================================================================
00111 
00112   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::EndFile - " << endl;
00113 
00114 }
00115 
00116 //......................................................................
00117 
00118 void Cluster3DModule::BeginRun()
00119 {
00120 //======================================================================
00121 // Purpose: Something that should be done at the begin of run
00122 //======================================================================
00123 
00124   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::BeginRun - " << endl;
00125 
00126 }
00127 
00128 //......................................................................
00129 
00130 void Cluster3DModule::EndRun()
00131 {
00132 //======================================================================
00133 // Purpose: Something that should be done at the end of run
00134 //======================================================================
00135 
00136   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::EndRun - " << endl;
00137 
00138 }
00139 
00140 //......................................................................
00141 
00142 JobCResult Cluster3DModule::Ana(const MomNavigator* /* mom */)
00143 {
00144 //======================================================================
00145 // Purpose: Analysis module 
00146 //======================================================================
00147 
00148   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::Ana - " << endl;
00149 
00150   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00151 }
00152 
00153 //......................................................................
00154 
00155 JobCResult Cluster3DModule::Reco(MomNavigator* mom)
00156 {
00157 //======================================================================
00158 // Purpose: Reconstruction module
00159 //======================================================================
00160 
00161   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::Reco - " << endl;
00162 
00163 // Find Candidate Record
00164 
00165   CandRecord* candrec = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00166   if(candrec==0){
00167     MSG("Cluster3D",Msg::kWarning) 
00168        << "Cluster3DModule::Reco: Failed to Find CandRecord " << endl;
00169     return (JobCResult::kWarning);
00170   }
00171 
00172   //
00173   // Find number of digits for debug purposes
00174   //
00175 
00176   CandDigitListHandle *digitlist = dynamic_cast<CandDigitListHandle*>
00177     (candrec->FindCandHandle("CandDigitListHandle"));
00178 
00179   if(!digitlist){
00180     MSG("Cluster3D",Msg::kDebug)
00181        << " No CandDigitListHandle in CandRecord" << endl;
00182   }
00183   else{
00184     Int_t ndigits = digitlist->GetNDaughters();
00185     MSG("Cluster3D",Msg::kDebug)  
00186        << " Found " << ndigits << " digits" << endl;
00187   }
00188 
00189   // Find CandSliceList in the primary Candidate Record
00190 
00191   CandSliceListHandle* slclisth = dynamic_cast<CandSliceListHandle*>
00192 (candrec->FindCandHandle("CandSliceListHandle") );
00193 
00194   //There should be non-zero number of slices
00195 
00196   if(!slclisth){
00197     MSG("Cluster3D",Msg::kWarning) << "Cluster3DModule::Reco:" 
00198              << "No CandSliceListHandle in CandRecord" << endl;
00199     return JobCResult::kFailed;
00200   }
00201   else{
00202     Int_t nslice = slclisth->GetNDaughters();
00203     MSG("Cluster3D",Msg::kDebug) << " Cluster3DModule::Reco: " 
00204        << " Found " << nslice << " slices" << endl;
00205   }
00206 
00207   // Select algorithm
00208 
00209   // create Singleton Instance of AlgFactory
00210   AlgFactory &af = AlgFactory::GetInstance();
00211 
00212   // create AlgHandle
00213   AlgHandle aclh = af.GetAlgHandle("AlgCluster3DList","default");
00214 
00215   // Define context : CandContext 
00216   CandContext cx(this, mom);
00217   cx.SetDataIn(slclisth);
00218   cx.SetCandRecord(candrec);
00219 
00220   // Make Candidate - MakeCandidate method creates  a CandCluster3DList
00221   // object using the Algorithm handle and the CandContext.
00222  
00223   CandCluster3DListHandle clustlisth = 
00224         CandCluster3DList::MakeCandidate(aclh, cx);
00225 
00226     CandCluster3DListHandle* cl = &clustlisth;
00227     Int_t nclust = cl->GetNDaughters();
00228     MSG("Cluster3D",Msg::kDebug) << " Cluster3DModule::Reco: " 
00229        << " Found " << nclust << " clusters" << endl;
00230 
00231   // Set Name and Title
00232 
00233    clustlisth.SetName("CandCluster3DList");
00234    clustlisth.SetTitle(TString("Created by Cluster3DModule from ").
00235                  Append(slclisth->GetName()));
00236 
00237 
00238 // Add handle to CandRecord
00239    candrec->SecureCandHandle(clustlisth);
00240 
00241   return JobCResult::kAOK; // possibilites: kPassed, kFailed, 
00242                            // kAOK, kWarning, kError, kFatal
00243 }
00244 
00245 //......................................................................
00246 
00247 const Registry& Cluster3DModule::DefaultConfig() const
00248 {
00249 //======================================================================
00250 // Purpose: Supply the default configuration for the module
00251 //======================================================================
00252   static Registry r; // Create registry that keeps the default 
00253                      // configuration for module
00254 
00255   // Set name of config
00256 
00257   std::string name = this->JobCModule::GetName();
00258   name += ".config.default";
00259   r.SetName(name.c_str());
00260 
00261 
00262   // Set parameters for the algorithm
00263 
00264   // Get singleton instance of AlgFactory.
00265 
00266   AlgFactory &af = AlgFactory::GetInstance();
00267 
00268   // Get algorithm handle and its config
00269    
00270   AlgHandle alglisthandle = af.GetAlgHandle("AlgCluster3DList","default");
00271   AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00272 
00273   //alglistconfig.UnLockValues();
00274 
00275   alglistconfig.Set("plnDist",4); // max distance between two cells in planes
00276   alglistconfig.Set("stpDist",8); // max distance between two cells in stps
00277   //
00278   // There should be enough strips OR enough energy 
00279   // (sum of pe's) to form a cluster 
00280   //
00281   alglistconfig.Set("minClustStp",4); // min number of strips to form a cluster
00282   alglistconfig.Set("minClustAmbStp",4); // min number of strips which belong
00283   // ONLY to a given cluster to treat this cluster as a real one
00284   alglistconfig.Set("minClustPe",10.); // min sum of pe's to form a cluster
00285   alglistconfig.Set("maxDist",3); // max distance between planes to form a cell
00286   //                               
00287   alglistconfig.Set("xTalk",1); // rejection of crossTalk hits:- 1=on 0=off
00288   alglistconfig.Set("xTalkMode",2); // 1 = rejection of all XTalk hits
00289                                     // 2 = rejection of the isolated XTalk hits
00290   alglistconfig.Set("xTalkPeCut",2.); // if strip has only one digit 
00291                     // and pulse height is < xTalkPeCut than it is a crosstalk
00292   alglistconfig.Set("timeInfo",0); // Timing information used:- 1=yes 0=no
00293   alglistconfig.Set("vLightInScint",2.179); // eff. velocity of light in scint
00294   alglistconfig.Set("t1-t2ResolutionInNs",3.5); // t1-t2 time resolution
00295   
00296   //alglistconfig.LockValues();
00297   // Keys = Names
00298   //alglistconfig.LockKeys();
00299 
00300   // Set general parameters for module
00301 
00302   // This bit is important if one wants to
00303   // guard against typos when configuring a module
00304   //   
00305   // a FILLED out default configuration Registry 
00306   // has to be returned
00307   
00308 
00309   static bool been_here = false;
00310   if (!been_here) {
00311       been_here = true;
00312 
00313       std::string name = this->JobCModule::GetName();
00314       name += ".config.default";
00315       r.SetName(name.c_str());
00316 
00317       /*  
00318 
00319       r.Set("ListIn","CandSliceSRList");
00320       r.Set("ListOut","CandClusterSRList");
00321 
00322       */
00323 
00324       r.Merge(alglistconfig);
00325       r.LockValues();
00326   }
00327 
00328   // returns registry with the default configuration to the JobModule 
00329 
00330   return r;
00331 }
00332 
00333 //......................................................................
00334 
00335 void Cluster3DModule::Config(const Registry& r)
00336 {
00337 //======================================================================
00338 // Purpose: Configure the module given the Registry r
00339 //======================================================================
00340 
00341   Int_t    tmpi;
00342   Double_t tmpd;
00343   //const char* tmps;
00344 
00345   
00346   //if (r.Get("Print",tmpb)) { fPrint = tmpb; }
00347   //if (r.Get("Cdist",tmpi)) { fCdist = tmpi; }
00348   //if (r.Get("Vscint",tmpd)) { fVscint = tmpd; }
00349   //if (r.Get("UseStream",tmps)) { fName = tmps; }
00350 
00351 
00352   // Get singleton instance of AlgFactory.
00353 
00354   AlgFactory &af = AlgFactory::GetInstance();
00355 
00356   // Get algorithm handle and its config
00357    
00358   AlgHandle alglisthandle = af.GetAlgHandle("AlgCluster3DList","default");
00359   AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00360 
00361   alglistconfig.UnLockValues();
00362 
00363   /*
00364   Int_t tmpi;
00365   Double_t tmpd;
00366   const Char_t *tmpc = 0;
00367 
00368   if (r.Get("ListIn",tmpc)) fListIn  = tmpc;
00369   if (r.Get("ListOut",tmpc)) fListOut = tmpc;
00370   */
00371 
00372   if (r.Get("plnDist",tmpi)) {
00373     alglistconfig.Set("plnDist",tmpi);
00374   }
00375   if (r.Get("stpDist",tmpi)) {
00376     alglistconfig.Set("stpDist",tmpi);
00377   }
00378   if (r.Get("minClustStp",tmpi)) {
00379     alglistconfig.Set("minClustStp",tmpi);
00380   }
00381   if (r.Get("minClustAmbStp",tmpi)) {
00382     alglistconfig.Set("minClustAmbStp",tmpi);
00383   }
00384   if (r.Get("minClustPe",tmpd)) {
00385     alglistconfig.Set("minClustPe",tmpd);
00386   }
00387   if (r.Get("maxDist",tmpi)) {
00388     alglistconfig.Set("maxDist",tmpi);
00389   }
00390   if (r.Get("xTalk",tmpi)) {
00391     alglistconfig.Set("xTalk",tmpi);
00392   }
00393   if (r.Get("xTalkMode",tmpi)) {
00394     alglistconfig.Set("xTalkMode",tmpi);
00395   }
00396   if (r.Get("xTalkPeCut",tmpd)) {
00397     alglistconfig.Set("xTalkPeCut",tmpd);
00398   }
00399   if (r.Get("timeInfo",tmpi)) {
00400     alglistconfig.Set("timeInfo",tmpi);
00401   }
00402   if (r.Get("vLightInScint",tmpd)) {
00403     alglistconfig.Set("vLightInScint",tmpd);
00404   }
00405   if (r.Get("t1-t2ResolutionInNs",tmpd)) {
00406     alglistconfig.Set("t1-t2ResolutionInNs",tmpd);
00407   }
00408 
00409   alglistconfig.LockValues();
00410 
00411 }
00412 
00413 //......................................................................
00414 
00415 void Cluster3DModule::Help()
00416 {
00417 //======================================================================
00418 // HELP
00419 // No longer needed. Use Module::Report() to see list of parameters
00420 // which can be set using Set("name=value"). You can override the 
00421 // default Report command
00422 //
00423 //======================================================================
00424 }
00425 
00426 //......................................................................
00427 
00428 /*
00429 void Cluster3DModule::Report()
00430 {
00431 //======================================================================
00432 // FILL_IN: [Document your code!!]
00433 //======================================================================
00434 }
00435 */
00436 
00437 
00438 //......................................................................
00439 
00440 void Cluster3DModule::Reset()
00441 {
00442 //======================================================================
00443 // FILL_IN: [Document your code!!]
00444 //======================================================================
00445 }
00446 
00447 //......................................................................
00448 
00449 JobCResult Cluster3DModule::Get(MomNavigator* /* mom */)
00450 {
00451 //======================================================================
00452 // FILL_IN: [Document your code!!]
00453 //======================================================================
00454 
00455   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::Get - " << endl;
00456 
00457   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00458 }
00459 
00460 //......................................................................
00461 
00462 JobCResult Cluster3DModule::Put(const MomNavigator* /* mom */)
00463 {
00464 //======================================================================
00465 // FILL_IN: [Document your code!!]
00466 //======================================================================
00467 
00468   MSG("Cluster3D",Msg::kDebug) << " - Cluster3DModule::Put - " << endl;
00469 
00470   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00471 }
00472 
00473 //......................................................................
00474 

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