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

CheezyDisplayModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CheezyDisplayModule.cxx,v 1.21 2002/12/13 23:18:44 rhatcher Exp $
00003 //
00004 // A JobControl Module for using the CheezyDisplay
00005 //
00006 // rhatcher@fnal.gov
00008 
00009 #include "RerootExodus/CheezyDisplayModule.h"
00010 // Used for drawing
00011 #include "RerootExodus/CheezyDisplay.h"
00012 
00013 #include "MinosObjectMap/MomNavigator.h"
00014 
00015 #include "MessageService/MsgService.h"
00016 #include "MessageService/MsgFormat.h"
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 
00020 #include "Plex/PlexStripEndId.h"
00021 #include "CandData/CandRecord.h"
00022 #include "CandDigit/CandDigitHandle.h"
00023 #include "CandDigit/CandDigitListHandle.h"
00024 
00025 #include "Record/RecMinos.h"
00026 #include "Record/RecMinosHdr.h"
00027 
00028 #include "TMath.h"
00029 
00030 ClassImp(CheezyDisplayModule)
00031 
00032 //......................................................................
00033 
00034 CVSID("$Id: CheezyDisplayModule.cxx,v 1.21 2002/12/13 23:18:44 rhatcher Exp $");
00035 JOBMODULE(CheezyDisplayModule, "CheezyDisplayModule",
00036          "Draw an event using the CheezyDisplay");
00037 
00038 //......................................................................
00039 
00040 CheezyDisplayModule::CheezyDisplayModule() 
00041    : fListPlex("canddigitlist"), fListTruth("candmcdigitlist"), 
00042      fDrawEmpty(false), fDisplay(0)
00043 {
00044    // construct a new "CheezyDisplayModule" JobControl module
00045    // by default:
00046    //    no specific choice of CandDigitList to use
00047    //    draw all possibilities in PlexSEIdAltL (w/ no miminum wgt)
00048 
00049    // Create a display
00050    // do it here in the ctor so that configuration state info can be
00051    // passed to it before any events are drawn
00052    // (eg. settings of DrawTruth, DrawOnlyBest, WgtThresh)
00053 
00054   if ( ! fDisplay ) {
00055      fDisplay = new CheezyDisplay("CheezyDisplayModule",
00056                                   "CheezyDisplayModule display");
00057      MSG("Cheezy",Msg::kDebug)
00058         << "create new CheezyDisplay within ctor" << endl;
00059   }
00060 
00061 }
00062 
00063 //......................................................................
00064 
00065 CheezyDisplayModule::~CheezyDisplayModule() 
00066 {
00067   MSG("Exodus", Msg::kVerbose) << "CheezyDisplayModule::Destructor\n";
00068 
00069   SafeDelete(fDisplay);
00070 }
00071 
00072 //......................................................................
00073 
00074 JobCResult CheezyDisplayModule::Ana(const MomNavigator *mom)
00075 {
00076   // Find the RawRecord for Header info (detector) and TRUTH (if available)
00077   // Find the CandDigitList
00078   // draw digits on CheezyDisplay
00079 
00080   // Get either RawRecord or CandRecord from Mom 
00081   RecMinos *rec = dynamic_cast<RecMinos *>(mom->GetFragment("RecMinos"));
00082                                         
00083   if ( ! rec ) {
00084      MSG("Exodus",Msg::kFatal) << "CheezyDisplayModule::Ana" <<
00085         " failed to fin a \"RecMinos\"" << endl;
00086      return JobCResult::kError;
00087   }
00088 
00089   VldContext vldc = rec->GetHeader()->GetVldContext();
00090 
00091   // Create (if necessary) a display
00092   if ( ! fDisplay ) {
00093      fDisplay = new CheezyDisplay("CheezyDisplayModule",
00094                                   "CheezyDisplayModule display");
00095      MSG("Cheezy",Msg::kWarning)
00096         << "create new CheezyDisplay within Ana" << endl;
00097   }
00098 
00099   fDisplay->ClearLists();
00100   fDisplay->SetVldContext(vldc);
00101 
00102   // Draw TRUTH first so other digits won't be obscured
00103   // Find MC version of CandDigitList fragment in MOM.
00104 
00105 // Find (Primary)CandidateRecord fragment in MOM.
00106   CandRecord *candrec = dynamic_cast<CandRecord *>
00107     (mom->GetFragment("CandRecord")); //, "PrimaryCandidateRecord"));
00108   if (candrec == 0) {
00109     MSG("Cheezy", Msg::kWarning) 
00110       << "No " // << "Primary"
00111       << "CandRecord in MOM." 
00112       << endl;
00113     return JobCResult::kError;
00114   }
00115 
00116   int ndigits = 0;
00117 
00118   CandDigitListHandle *cmcdlh = dynamic_cast<CandDigitListHandle *>
00119      (candrec->FindCandHandle("CandDigitListHandle",fListTruth.Data()));
00120 
00121   if (cmcdlh) {
00122      // do iteration only if there is a Truth list!
00123      CandDigitHandleItr cmcdhItr(cmcdlh->GetDaughterIterator());
00124 
00125      // loop over digits
00126      while ( CandDigitHandle *cmcdh = cmcdhItr() ) {
00127         // for each digit
00128         PlexSEIdAltL altlist = cmcdh->GetPlexSEIdAltL();
00129         fDisplay->AddSEIdAltL(altlist,kTRUE);
00130         ndigits++;
00131      }
00132   }  
00133 
00134   // Find requested CandDigitList fragment in MOM.
00135   CandDigitListHandle *cdlh = dynamic_cast<CandDigitListHandle *>
00136       (candrec->FindCandHandle("CandDigitListHandle",fListPlex.Data()));
00137 
00138   CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00139   
00140   while ( CandDigitHandle *cdh = cdhItr() ) {
00141      // for each digit
00142      PlexSEIdAltL altlist = cdh->GetPlexSEIdAltL();
00143      fDisplay->AddSEIdAltL(altlist,kFALSE);
00144      ndigits++;
00145   }
00146 
00147   // Now actually draw these things
00148   if (!fDisplay) MSG("Cheezy",Msg::kFatal) << " no display?? " << endl;
00149   if (ndigits || fDrawEmpty) fDisplay->Draw();
00150 
00151   return JobCResult::kAOK;
00152 
00153 }
00154 
00155 //......................................................................
00156 
00157 void CheezyDisplayModule::HandleCommand(JobCommand *command) 
00158 {
00159 //
00160 // Process configuration commands
00161 //
00162 
00163 //  MSG("Exodus", Msg::kInfo) << "CheezyDisplayModule::HandleCommand\n";
00164 
00165   TString cmd = command->PopCmd();
00166   if (cmd == "Set") {
00167      TString opt = command->PopOpt();
00168      if      (opt == "ListPlex")  fListPlex  = command->PopOpt();
00169      else if (opt == "ListTruth") fListTruth = command->PopOpt();
00170      else if (opt == "DrawEmpty") fDrawEmpty = command->PopIntOpt();
00171      else if (opt == "DrawTruth")
00172      { // damn braces needed to get scoping of "if" statement right
00173         if (fDisplay) fDisplay->SetDrawTruth(command->PopIntOpt() != 0);
00174      }
00175      else if (opt == "OnlyBest")
00176      { // damn braces needed to get scoping of "if" statement right
00177         if (fDisplay) fDisplay->SetDrawOnlyBest(command->PopIntOpt() != 0);
00178      }
00179      else if (opt == "WgtThresh")
00180      { // damn braces needed to get scoping of "if" statement right
00181         if (fDisplay) fDisplay->SetWgtThresh(command->PopFloatOpt());
00182      }
00183      else {
00184         MSG("Exodus", Msg::kWarning)
00185            << "CheezyDisplayModule: Unrecognized option " << opt << endl;
00186      }
00187   } else if (cmd == "Redraw") {
00188      if (fDisplay) fDisplay->Draw();
00189   } else {
00190      MSG("Exodus", Msg::kWarning)
00191         << "CheezyDisplayModule: Unrecognized command " << cmd << endl;
00192   }
00193 }

Generated on Mon Nov 23 05:26:26 2009 for loon by  doxygen 1.3.9.1