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

DmxDeMuxFilterModule.cxx

Go to the documentation of this file.
00001 
00002 //$Id: DmxDeMuxFilterModule.cxx,v 1.12 2003/05/21 16:24:35 bv Exp $
00003 //
00004 //DmxDeMuxFilterModule.cxx
00005 //
00006 //Module for demultiplexing cosmic ray events in the far detector
00007 //
00008 //Author:  B. Rebel 6/2001
00010 
00011 #include "DeMux/DmxDeMuxFilterModule.h"
00012 #include "DeMux/DmxChiSqrStat.h"
00013 #include "JobControl/JobCModuleRegistry.h"
00014 #include "JobControl/JobCommand.h"
00015 #include "MessageService/MsgService.h"
00016 #include "MinosObjectMap/MomNavigator.h"
00017 #include "Algorithm/AlgConfig.h"
00018 #include "CandDigit/CandDigitListHandle.h"
00019 #include "CandDigit/CandDigitHandle.h"
00020 #include "Algorithm/AlgFactory.h"
00021 #include "Algorithm/AlgHandle.h"
00022 #include "CandData/CandRecord.h"
00023 #include "CandData/CandHeader.h"
00024 #include "Candidate/CandContext.h"
00025 #include "Navigation/NavKey.h"
00026 #include "Navigation/NavSet.h"
00027 #include "Conventions/PlaneView.h"
00028 #include "Navigation/XxxItr.h"
00029 #include "DeMux/DmxShowerPlane.h"
00030 #include "DeMux/DmxMuonPlane.h"
00031 #include "DeMux/DmxPlane.h"
00032 #include "DeMux/DmxHypothesis.h"
00033 #include "TFile.h"
00034 #include "TH1.h"
00035 #include "TH2.h"
00036 #include "TClonesArray.h"
00037 #include "Validity/VldContext.h"
00038 #include "UgliGeometry/UgliGeomHandle.h"
00039 
00040 #include <cassert>
00041 
00042 //define the NavKey to sort the digits by plane
00043 //static NavKey KeyFromDigitPlane( const CandDigitHandle *cdh){
00044 //  return const_cast<CandDigitHandle*>(cdh)->GetPlexSEIdAltL().GetPlane();}
00045 
00046 //define the NavKey to sort the planes
00047 //static NavKey KeyOnPlaneNumber( const TObject *tobj){
00048 //  DmxPlane *currentPlane = dynamic_cast<DmxPlane *>(const_cast<TObject*>(tobj));
00049 //  return currentPlane->GetPlaneNumber();
00050 //}
00051 
00052 ClassImp(DmxDeMuxFilterModule)
00053 
00054 CVSID("$Id: DmxDeMuxFilterModule.cxx,v 1.12 2003/05/21 16:24:35 bv Exp $");
00055 
00056 // Declare this module to JobControll. Arguments are:
00057 //  (1) The class name 
00058 //  (2) The human-readable name 
00059 //  (3) A short, human-readable description of what the module does
00060 JOBMODULE(DmxDeMuxFilterModule, 
00061           "DeMuxFilterModule",
00062           "A module used for demultiplexing cosmics in the far detector");
00063 
00064 //......................................................................
00065 DmxDeMuxFilterModule::DmxDeMuxFilterModule() :
00066   fDontUseCandDigitMasks(false),
00067   fSignalFractionLimit(0.1)
00068 {
00069 
00070   MSG("JobC", Msg::kDebug) << "DmxDeMuxFilterModule::Constructor" << endl;
00071   //MSG("DMX", Msg::kInfo) << fSignalFractionLimit << endl;
00072 
00073 }
00074 
00075 //----------------------------------------------------------------------
00076 DmxDeMuxFilterModule::~DmxDeMuxFilterModule()
00077 {
00078   MSG("JobC", Msg::kDebug) << "DmxDeMuxFilterModule::Destructor" << endl;
00079 }
00080 
00081 //......................................................................
00082 
00083 void DmxDeMuxFilterModule::BeginJob()
00084 {
00085   AlgFactory &af = AlgFactory::GetInstance();
00086   af.Register("AlgDeMuxCosmics", "default", "libDeMux.so", "AlgConfigDeMux");
00087   AlgHandle ah = af.GetAlgHandle("AlgDeMuxCosmics", "default");
00088   //MSG("DMX", Msg::kInfo) << fSignalFractionLimit << endl;
00089 
00090   //get the AlgConfigDeMux class and set some variables
00091   AlgConfig &acd = ah.GetAlgConfig();
00092   acd.UnLockValues();
00093   acd.Set("HoughInterceptLimit",1.5);
00094   acd.Set("HoughPeakLimit",0.66);
00095   acd.Set("HoughSlopeLimit",1.);
00096   acd.Set("HypothesisSize",24);
00097   acd.Set("MuonTrackSlopeLimit",0.09);
00098   acd.Set("NumberOfHypotheses",169);
00099   acd.Set("NumberOfStrips", 192);
00100   acd.Set("PlanesInSet",6);
00101   acd.Set("RatioMatedSignalForValid",0.3);
00102   acd.Set("UseCandDigitMask", 1);
00103   acd.Set("XTalkFractionLimit", 0.1);
00104   acd.Set("IgnoreFractionLimit", 0.05);
00105   acd.Set("AveragePEGainConversion", 55.);
00106   acd.Set("StrayDeltaStripLimit",6);
00107   acd.Set("StrayPlanesLimit",10);
00108   acd.Set("UseStrayPlaneCheck", 0);
00109   
00110   acd.LockValues();
00111   acd.LockKeys();
00112   
00113   //MSG("DMX", Msg::kInfo) << fSignalFractionLimit << endl;
00114 
00115   fStatus = DmxStatus();
00116 
00117   return;
00118 }
00119 
00120 //......................................................................
00121 
00122 JobCResult DmxDeMuxFilterModule::Reco(MomNavigator *mom)
00123 {
00124   JobCResult result(JobCResult::kPassed);
00125 
00126   MSG("JobC", Msg::kDebug) << "DeMuxFilterModule::Reco\n";
00127 
00128   fStatus.ClearPlaneArray();
00129 
00130   // Check that mom exists.
00131   assert(mom);
00132 
00133   // Find PrimaryCandidateRecord fragment in MOM.
00134   CandRecord *candrec = dynamic_cast<CandRecord *>
00135     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00136   if (candrec == 0) {
00137     result.SetError().SetFailed();
00138     return result;
00139   }
00140   
00141   //*-* Find Raw Data CandDigitList fragment in PrimaryCandidateRecord.
00142   CandDigitListHandle *crdlh = dynamic_cast<CandDigitListHandle *>
00143     (candrec->FindCandHandle("CandDigitListHandle", "canddigitlist"));
00144   if (crdlh == 0) {
00145     result.SetError().SetFailed();
00146     return result;
00147   }
00148   
00149   Int_t event = fStatus.GetEventNumber();
00150   const CandHeader* chead = candrec->GetCandHeader();
00151   if (!chead) {
00152     MSG("JobC",Msg::kWarning) << "No CandHeader, but continuing" << endl;
00153   }
00154   ++event;// chead->GetEvent();
00155   //MSG("Dmx", Msg::kInfo) << "event = " << event << endl;
00156 
00157   AlgFactory &af = AlgFactory::GetInstance();
00158   AlgHandle ah = af.GetAlgHandle("AlgDeMuxCosmics", "default");
00159   //AlgConfigDeMux &acd = dynamic_cast<AlgConfigDeMux &>(ah.GetAlgConfig());
00160   
00161   //set fStatus.fEventDeMuxed to be true as a default, it gets reset to false
00162   //if there is no vertex found or no valid planes
00163   fStatus.SetEventDeMuxed(true);
00164   fStatus.SetMultipleMuon(false);
00165 
00166   CandContext cx(this, mom);
00167   cx.SetDataIn(&fStatus);
00168   
00169   ah.RunAlg(*crdlh, cx);
00170   
00171   if( !fStatus.GetEventDeMuxed() ){
00172     result.SetError().SetFailed();
00173     return result;
00174   }
00175   
00176   //MSG("JobC", Msg::kInfo) << "Event DeMuxed" << endl;
00177   
00178   //get the TObjArray of DmxPlane objects
00179   //  const TObjArray *planeArray = fStatus.GetPlaneArray();
00180   
00181 //    //create a TObjectItr
00182 //    TObjectItr planeItr(planeArray);
00183     
00184 //    //create a KeyFunc to sort planes by number
00185 //    TObjectKeyFunc *pnKF = planeItr.CreateKeyFunc();
00186   
00187 //    //program the KeyFunc with the sort function
00188 //    pnKF->SetFun(KeyOnPlaneNumber);
00189   
00190 //    //get the NavSet from the iterator and pass the KeyFunc to it
00191 //    planeItr.GetSet()->AdoptSortKeyFunc(pnKF);
00192   
00193 //    //clear the KF pointer because we no longer own the KeyFunc
00194 //    pnKF = 0;
00195   
00196 //    //zero values that need to start over with each event
00197 //    Int_t vertexPlane = fStatus.GetVertexPlaneNumber();
00198 //    Int_t endPlane = fStatus.GetEndPlaneNumber();
00199 
00200 //    if(!fStatus.GetMultipleMuon()){planeItr.GetSet()->Slice(vertexPlane, endPlane);}
00201 //    else if(fStatus.GetMultipleMuon()){planeItr.GetSet()->Slice(vertexPlane, 500);}
00202 
00203 //    Float_t fracStray = (1.*(fStatus.GetUStrayPlanes()+fStatus.GetVStrayPlanes())) / (1.*planeItr.SizeSelect());
00204 //    if( fStatus.GetUSlopeRMS()>15. && fracStray>0.3333){
00205 //      result.SetError().SetFailed();
00206 //      return result;
00207 //    }
00208 //    else if( fStatus.GetVSlopeRMS()>15. && fracStray>0.3333){
00209 //      result.SetError().SetFailed();
00210 //      return result;
00211 //    }
00212     
00213   return result;
00214 }
00215 
00216 //......................................................................
00217 
00218 void DmxDeMuxFilterModule::HandleCommand(JobCommand *command) 
00219 {
00220   //
00221   //  Purpose:  Method to interpret module commands.
00222   //
00223   //  Arguments:
00224   //    command   in    Command to interpret.
00225   //
00226   //  Return:   n/a
00227   //
00228   //  Commands implemented:
00229   //    Set TestToMake  Set the test to make to obtain a figure of merit - fraction of
00230   //                    digits within n strips from a track, fraction of mated signal
00231   //                    DigitsAlongTrack, and MatedSignalFraction respectively
00232   //    Set DataType    Set the type of data to test - MonteCarlo or FarDetector
00233   //    Set MatedSignalLimit  Set the lower limit for fraction of signal coming from opposite
00234   //                          sides of the same strip in a plane.
00235   //    Set DeltaStripsFromTrack  Set the number of strips a digit can be off from a track and
00236   //                              still be considered along that track.
00237   //
00238   //  see http://beaker.astro.indiana.edu/brebel/demux_notes/how_to_demux.html for details
00239    MSG("JobC", Msg::kDebug) << "DeMuxFilterModule::HandleCommand" << endl;
00240 
00241    TString cmd = command->PopCmd();
00242    if(cmd == "Set"){   
00243      TString opt = command->PopOpt();
00244      if(opt == "DontUseCandDigitMasks"){ fDontUseCandDigitMasks = true;}
00245      else if(opt = "SignalFractionLimit"){ fSignalFractionLimit = command->PopFloatOpt();}
00246      else {
00247          MSG("JobC", Msg::kWarning)<< "DeMuxFilterModule: Unrecognized option " << opt << endl;
00248       }
00249    }
00250    else {
00251      MSG("JobC", Msg::kWarning)<< "DeMuxFilterModule: Unrecognized command " << cmd << endl;
00252    }
00253    return;
00254 }
00255 
00256 //......................................................................
00257 void DmxDeMuxFilterModule::ClearStatusObject() 
00258 {
00259   fStatus.ClearPlaneArray();
00260   return;
00261 }
00262 
00263 void DmxDeMuxFilterModule::Help() 
00264 {
00265   MSG("JobC", Msg::kInfo) 
00266     << "DeMuxFilterModule::Help\n"
00267     <<"DmxDeMuxFilterModule is a module which demultiplexes events "
00268     <<"in the far detector." << endl
00269     << "see http://beaker.astro.indiana.edu/brebel/demux_notes/how_to_demux.html for details"
00270     << endl;
00271 }
00272 
00273 
00274 
00275 

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