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

NtpCluster3DModule.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // NtpCluster3DModule (based on NtpSRModule)
00004 //
00005 // A JobControl Module for filling an NtpCluster3DRecord
00006 //
00008 #include <iostream>
00009 using namespace std;
00010 
00011 #include "Conventions/CalStripType.h"
00012 #include "TClonesArray.h"
00013 #include "Cluster3D/NtpCluster3DModule.h"
00014 #include "Cluster3D/NtpCluster3DRecord.h"
00015 #include "Cluster3D/NtpCluster3D.h"
00016 #include "MessageService/MsgService.h"
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "RawData/RawDigit.h"
00021 #include "RawData/RawRecord.h"
00022 #include "RawData/RawDaqSnarlHeader.h"
00023 #include "RawData/RawDigitDataBlock.h"
00024 #include "Record/RecCandHeader.h"
00025 #include "CandData/CandRecord.h"
00026 #include "CandData/CandHeader.h"
00027 #include "RecoBase/CandStripListHandle.h"
00028 #include "RecoBase/CandStripHandle.h"
00029 #include "Cluster3D/CandCluster3DListHandle.h"
00030 #include "Cluster3D/CandCluster3DHandle.h"
00031 #include "UgliGeometry/UgliGeomHandle.h"
00032 
00033 #include <cassert>
00034 
00035 ClassImp(NtpCluster3DModule)
00036 
00037 //   Definition of static data members
00038 //   *********************************
00039 
00040 CVSID("$Id: NtpCluster3DModule.cxx,v 1.5 2005/05/18 03:54:52 schubert Exp $");
00041 JOBMODULE(NtpCluster3DModule, "NtpCluster3DModule",
00042          "A module for filling Cluster3D ntuple records.");
00043 
00044 const Double_t NtpCluster3DModule::kCos45 = 0.70710678;  //used to convert u,v to x,y
00045 
00046 // Definition of methods (alphabetical order)
00047 // ***************************************************
00048 
00049 
00050 //......................................................................
00051 
00052 const Registry& NtpCluster3DModule::DefaultConfig() const {
00053   //
00054   // Purpose: Method to return default configuration.
00055   // 
00056   // Arguments: none.
00057   //
00058   // Return: Registry containing default configuration
00059   //
00060 
00061   MSG("NtpSR",Msg::kDebug) << 
00062     "NtpCluster3DModule::DefaultConfig" << endl;
00063 
00064   static Registry r; 
00065   std::string name = this->JobCModule::GetName();
00066   name += ".config.default";
00067   r.SetName(name.c_str());
00068 
00069   /*
00070   r.UnLockValues();
00071   r.LockValues();
00072   */
00073 
00074   return r;
00075 }
00076 
00077 //......................................................................
00078 
00079 void NtpCluster3DModule::Config(const Registry& /* r */) {
00080   //
00081   // Purpose: Configure the module given a registry.
00082   //
00083   // Arguments: Registry to use to configure the module.
00084   //
00085   // Return: none.
00086   //
00087 
00088   MSG("NtpSR",Msg::kDebug) << "NtpCluster3DModule::Config" << endl;
00089 
00090   /*  
00091   Int_t tmpi;
00092   Double_t tmpd;
00093   //const Char_t* tmps;
00094 
00095   if ( r.Get("PostTrigger",tmpi)) {
00096     fPostTrigger = fabs((Double_t)(tmpi)*1.e-9);
00097   }
00098   if ( r.Get("PostTrigger",tmpd)) {
00099     fPostTrigger = fabs(tmpd*1.e-9);
00100   }
00101 
00102   */
00103 }
00104 
00105 //......................................................................
00106 
00107 JobCResult NtpCluster3DModule::Reco(MomNavigator *mom) {
00108   //
00109   //  Purpose:  Create and fill ntuple record.
00110   //
00111   //  Arguments: mom.
00112   //  
00113   //  Return: status.
00114   // 
00115 
00116   JobCResult result(JobCResult::kPassed);  
00117   MSG("NtpSR",Msg::kDebug) << "NtpCluster3DModule::Reco" << endl;
00118 
00119   // Reset maps used to associate uid of reconstructed object with array index
00120   fStripUidMap.clear();
00121   //fSliceUidMap.clear();
00122   fClusterUidMap.clear();
00123   //fTrackUidMap.clear();
00124   //fEventUidMap.clear();
00125 
00126   // Check that mom exists.
00127   assert(mom);
00128 
00129   const RawRecord* rawrec = 
00130    dynamic_cast<const RawRecord*>(mom->GetFragment("RawRecord","","DaqSnarl"));
00131   if (!rawrec) {
00132     MSG("NtpSR",Msg::kWarning) << "No DaqSnarl RawRecord in Mom" << endl;
00133     result.SetWarning().SetFailed();
00134     return result;
00135   }
00136 
00137   const CandRecord* cndrec = dynamic_cast<const CandRecord*>
00138           (mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00139   if (!cndrec) {
00140     MSG("NtpSR",Msg::kWarning) << "No PrimaryCandidateRecord in Mom" << endl;
00141     result.SetWarning().SetFailed();
00142     return result;
00143   }
00144 
00145   // Extract header from CandRecord and use this to create RecCandHeader
00146   // and NtpCluster3DRecord.
00147   const CandHeader* cndhdr = cndrec -> GetCandHeader();
00148   const RawDaqSnarlHeader* rawhdr = dynamic_cast<const RawDaqSnarlHeader*>
00149                                     (rawrec -> GetRawHeader());
00150   RecCandHeader ntphdr(rawhdr->GetVldContext(),rawhdr->GetRun(),
00151          rawhdr->GetSubRun(),rawhdr->GetRunType(),rawhdr->GetErrorCode(),
00152          rawhdr->GetSnarl(),rawhdr->GetTrigSrc(),rawhdr->GetTimeFrameNum(),
00153          rawhdr->GetRemoteSpillType(),cndhdr->GetEvent());
00154   NtpCluster3DRecord* ntprec = new NtpCluster3DRecord(ntphdr);
00155   
00156   this -> FillNtpStrip(ntprec,cndrec);
00157   this -> FillNtpCluster(ntprec,cndrec);
00158   this -> FillNtpClusterSummary(ntprec,cndrec);
00159 
00160   mom -> AdoptFragment(ntprec);  // pass record to mom to own
00161 
00162   return result;
00163 
00164 }
00165 
00166 
00167 void NtpCluster3DModule::FillNtpStrip(NtpCluster3DRecord* /* ntprec */,const CandRecord* cndrec) {
00168   //
00169   //  Purpose:  Private method used to fill strip portion of ntuple record.
00170   //
00171   //  Arguments: NtpCluster3DRecord and CandRecord
00172   //  
00173   //  Return: status.
00174   // 
00175 
00176   MSG("NtpSR",Msg::kVerbose) << "NtpCluster3DModule::FillNtpStrip" << endl;
00177 
00178   const CandStripListHandle *striplisthandle 
00179    = dynamic_cast <const CandStripListHandle*> 
00180      (cndrec->FindCandHandle("CandStripListHandle"));
00181   if ( !striplisthandle ) return; // no strips => done
00182 
00183   Int_t nstrip = 0;
00184   TIter stripItr(striplisthandle->GetDaughterIterator());
00185   while ( CandStripHandle* strip=dynamic_cast<CandStripHandle*>(stripItr())) {
00186     Int_t uid = strip->GetUidInt();
00187     fStripUidMap.insert(std::make_pair(uid,nstrip));
00188     ++nstrip; 
00189 
00190   } // done with all strips
00191 
00192  
00193   return;
00194 
00195 }
00196 
00197 void NtpCluster3DModule::FillNtpCluster(NtpCluster3DRecord* ntprec,const CandRecord* cndrec) {
00198   //
00199   //  Purpose:  Private method used to fill cluster portion of ntuple record.
00200   //
00201   //  Arguments: pointers to NtpCluster3DRecord and CandRecord
00202   //  
00203   //  Return: status.
00204   // 
00205 
00206   MSG("NtpSR",Msg::kVerbose) << "NtpCluster3DModule::FillNtpCluster" << endl;
00207 
00208     const CandCluster3DListHandle *clusterlisthandle 
00209      = dynamic_cast <const CandCluster3DListHandle*> 
00210        (cndrec -> FindCandHandle("CandCluster3DListHandle","CandCluster3DList"));
00211 
00212   if ( !clusterlisthandle ) return; // all done
00213 
00214 
00215   Int_t ncluster = 0;
00216 
00217   CandCluster3DHandleItr clItr(clusterlisthandle->GetDaughterIterator());
00218 
00219   TClonesArray& clusterarray = *(ntprec->clu3D);
00220 
00221   while ( clItr.IsValid() ) {
00222      CandCluster3DHandle *cluster = clItr.Ptr();    
00223 
00224     Int_t uid = cluster->GetUidInt();
00225 
00226     fClusterUidMap.insert(std::make_pair(uid,ncluster));
00227     // Uses new with placement to efficiently create cluster ntp
00228     NtpCluster3D* ntpcluster 
00229          = new(clusterarray[ncluster++])NtpCluster3D(cluster->GetNStrip());
00230     // Fill indices of associated strips in cluster tree
00231     ntpcluster->index = ncluster - 1;
00232 
00233      CandStripHandleItr stpItr(cluster->GetDaughterIterator());
00234     Int_t nclusterstrip = 0;
00235      while ( stpItr.IsValid() ) {
00236       CandStripHandle *clusterstrip = stpItr.Ptr();
00237       Int_t uid = clusterstrip->GetUidInt();
00238       Int_t stripindex = fStripUidMap[uid];
00239       ntpcluster->AddStripAt(stripindex,nclusterstrip); // add index to strip
00240 
00241     // Set summed charge in cluster
00242       ntpcluster->ph.raw = cluster->GetCharge(CalStripType::kNone);
00243       ntpcluster->ph.siglin = cluster->GetCharge(CalStripType::kSigLin);
00244       ntpcluster->ph.sigcor = cluster->GetCharge(CalStripType::kSigCorr);
00245       ntpcluster->ph.pe = cluster->GetCharge(CalStripType::kPE);
00246       //ntpcluster->ph.sigmap = cluster->GetCharge(CalStripType::kSigMapped);
00247       //ntpcluster->ph.mip = cluster->GetCharge(CalStripType::kMIP);
00248       //ntpcluster->ph.gev = cluster->GetCharge(CalStripType::kGeV);
00249 
00250       nclusterstrip++;
00251       stpItr.Next();
00252      }
00253 
00254     clItr.Next();
00255   }
00256 
00257   return;
00258 }
00259 
00260 
00261 void NtpCluster3DModule::FillNtpClusterSummary(NtpCluster3DRecord* ntprec,
00262                                             const CandRecord* /* cndrec */) {
00263   //
00264   //  Purpose:  Private method used to fill event summary portion of ntuple 
00265   //            record.
00266   //
00267   //  Arguments: pointers to NtpCluster3DRecord and CandRecord
00268   //  
00269   //  Return: none.
00270   // 
00271 
00272 
00273   MSG("NtpSR",Msg::kVerbose) << "NtpCluster3DModule::FillNtpClusterSummary" << endl;
00274 
00275   NtpCluster3DSummary& ntpclustersummary = ntprec->hdr3D;
00276   ntpclustersummary.ncluster = fClusterUidMap.size();
00277 
00278   return;
00279 
00280 }
00281 
00282 
00283 
00284 
00285 
00286 

Generated on Mon Feb 15 11:07:05 2010 for loon by  doxygen 1.3.9.1