00001
00002
00003
00004
00005
00006
00008 #include "PrintStat.h"
00009 #include <cstdio>
00010
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "RawData/RawRecord.h"
00014 #include "RawData/RawDaqSnarlHeader.h"
00015
00016 #include "JobControl/JobCModuleRegistry.h"
00017 #include "Conventions/Munits.h"
00018 #include "Validity/VldContext.h"
00019 #include "TString.h"
00020
00021 CVSID("$Id: PrintStat.cxx,v 1.3 2004/09/11 17:35:43 weber Exp $");
00022 JOBMODULE(PrintStat,"PrintStat","Analyse Raw Hits\n");
00023
00024
00025
00026 PrintStat::PrintStat() :
00027 fActOutLine(-1)
00028 {
00029
00030
00031
00032
00033
00034 MSG("Stat",Msg::kDebug) << "Constructing PrintStat.\n";
00035
00036 }
00037
00038
00039
00040
00041 PrintStat::~PrintStat()
00042 {
00043
00044
00045
00046
00047 MSG("Stat",Msg::kDebug) << "Destructing PrintStat.\n";
00048
00049 }
00050
00051
00052
00053 void PrintStat::BeginJob()
00054 {
00055
00056
00057
00058
00059 MSG("Stat",Msg::kDebug) << "PrintStat::BeginJob starts here.\n";
00060
00061 }
00062
00063
00064
00065 const Registry& PrintStat::DefaultConfig() const
00066 {
00067
00068
00069
00070 static Registry r;
00071
00072 MSG("Stat",Msg::kDebug) << "PrintStat::DefaultConfig starts here.\n";
00073
00074
00075 std::string name = this->GetName();
00076 name += ".config.default";
00077 r.SetName(name.c_str());
00078
00079
00080 r.UnLockValues();
00081 r.Set("OutputRate", 10);
00082 r.Set("MaxOutLine", 100000);
00083 r.LockValues();
00084
00085 return r;
00086 }
00087
00088
00089
00090 void PrintStat::Config(const Registry& r)
00091 {
00092
00093
00094
00095
00096
00097
00098 int tmpi;
00099
00100 if (r.Get("OutputRate", tmpi)) { fOutputRate = tmpi; }
00101 if (fOutputRate<1) fOutputRate = 1;
00102
00103 if (r.Get("MaxOutLine", tmpi)) { fMaxOutLine = tmpi; }
00104
00105 }
00106
00107
00108
00109 JobCResult PrintStat::Ana(const MomNavigator *mom)
00110 {
00111
00112
00113
00114
00115
00116 MSG("Stat", Msg::kDebug) << "Starting PrintStat::Ana.\n";
00117
00118
00119
00120 fActOutLine++;
00121 if (fActOutLine%fOutputRate!=0) return JobCResult::kPassed;
00122 if (fActOutLine/fOutputRate>fMaxOutLine) return JobCResult::kPassed;
00123
00124
00125
00126 TObject* tobj;
00127 TIter fragiter = mom->FragmentIter();
00128
00129 RawRecord* rr = 0;
00130 const RawDaqSnarlHeader* rdsh = 0;
00131
00132
00133
00134 while( ( tobj = fragiter.Next() ) ) {
00135 if( ( rr = dynamic_cast<RawRecord*>(tobj) ) ) {
00136
00137 MSG("Stat", Msg::kDebug) << "Found Next RawRecord. rr= "
00138 << rr << endl;
00139
00140 if ( !rdsh ) rdsh = dynamic_cast<const RawDaqSnarlHeader*>
00141 (rr->GetRawHeader());
00142 } else {
00143 MSG("Stat", Msg::kVerbose) << "Not a RawRecord.\n";
00144
00145 }
00146 }
00147
00148
00149 if ( rdsh ) {
00150
00151 Int_t Run = rdsh->GetRun();
00152 Int_t Snarl = rdsh->GetSnarl();
00153 VldContext vldc = rdsh->GetVldContext();
00154 VldTimeStamp vldts = vldc.GetTimeStamp();
00155
00156 MSG("Stat",Msg::kInfo) << "===>> "
00157 << SimFlag::AsString(vldc.GetSimFlag())
00158 << " Snarl(" << setw(5) << fActOutLine << "):"
00159 << " -- run = " << setw(6) << Run
00160 << " -- snarl = " << setw(6) << Snarl
00161 << " -- time = " << vldts.AsString("c")
00162 << " <<===" << endl;
00163 } else {
00164
00165 MSG("Stat",Msg::kDebug) << "No RawDaqSnarlHeader.";
00166
00167 }
00168
00169 return JobCResult::kPassed;
00170
00171 }
00172
00173
00174
00175 void PrintStat::EndJob()
00176 {
00177
00178
00179
00180
00181
00182 MSG("Stat",Msg::kInfo) << "PrintStat: Total Events processed = "
00183 << fActOutLine << "\n";
00184
00185 }
00186