00001
00002
00003
00004
00005
00006
00008
00009 #include "RerootExodus/CheezyDisplayModule.h"
00010
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
00045
00046
00047
00048
00049
00050
00051
00052
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
00077
00078
00079
00080
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
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
00103
00104
00105
00106 CandRecord *candrec = dynamic_cast<CandRecord *>
00107 (mom->GetFragment("CandRecord"));
00108 if (candrec == 0) {
00109 MSG("Cheezy", Msg::kWarning)
00110 << "No "
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
00123 CandDigitHandleItr cmcdhItr(cmcdlh->GetDaughterIterator());
00124
00125
00126 while ( CandDigitHandle *cmcdh = cmcdhItr() ) {
00127
00128 PlexSEIdAltL altlist = cmcdh->GetPlexSEIdAltL();
00129 fDisplay->AddSEIdAltL(altlist,kTRUE);
00130 ndigits++;
00131 }
00132 }
00133
00134
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
00142 PlexSEIdAltL altlist = cdh->GetPlexSEIdAltL();
00143 fDisplay->AddSEIdAltL(altlist,kFALSE);
00144 ndigits++;
00145 }
00146
00147
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
00161
00162
00163
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 {
00173 if (fDisplay) fDisplay->SetDrawTruth(command->PopIntOpt() != 0);
00174 }
00175 else if (opt == "OnlyBest")
00176 {
00177 if (fDisplay) fDisplay->SetDrawOnlyBest(command->PopIntOpt() != 0);
00178 }
00179 else if (opt == "WgtThresh")
00180 {
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 }