00001
00002
00003
00004
00005
00006
00007
00008 #include "Demo/DemoMCFilter.h"
00009 #include "MessageService/MsgService.h"
00010 #include "JobControl/JobCommand.h"
00011 #include "JobControl/JobCModuleRegistry.h"
00012
00013
00014
00015
00016 #include "MINF_Classes/MINFast.h"
00017 #include "REROOT_Classes/REROOT_Event.h"
00018 #include "REROOT_Classes/REROOT_NeuKin.h"
00019
00020
00021
00022 CVSID("$Id: DemoMCFilter.cxx,v 1.6 2002/12/15 16:25:12 rhatcher Exp $");
00023 JOBMODULE(DemoMCFilter,"MCFilter","Select MC events based on truth info.");
00024
00025
00026
00027 DemoMCFilter::DemoMCFilter() : fNuIntSelect(0), fModeSelect(0) { }
00028
00029
00030
00031 JobCResult DemoMCFilter::Ana(const MomNavigator* )
00032 {
00033
00034
00035
00036
00037
00038 const REROOT_Event* rrevt = gMINFast->GetREROOTEvent();
00039 const REROOT_NeuKin* nukin =
00040 dynamic_cast<REROOT_NeuKin*>(rrevt->neukins()->First());
00041
00042
00043 double Enu = this->GetEnu(nukin);
00044 if (Enu < fEnuMin) return JobCResult::kFailed;
00045 if (Enu > fEnuMax) return JobCResult::kFailed;
00046
00047
00048 double y = this->GetY(nukin);
00049 if (y < fYmin) return JobCResult::kFailed;
00050 if (y > fYmax) return JobCResult::kFailed;
00051
00052
00053 NuInt_t nuint = this->GetNuInt(nukin);
00054 if ((nuint & fNuIntSelect) == 0) return JobCResult::kFailed;
00055
00056
00057 Mode_t numode = this->GetMode(nukin);
00058 if ((numode & fModeSelect) == 0) return JobCResult::kFailed;
00059
00060
00061 if (fDoPrint) this->Print(nukin);
00062 return JobCResult::kPassed;
00063 }
00064
00065
00066
00067 const Registry& DemoMCFilter::DefaultConfig() const
00068 {
00069
00070
00071
00072 static Registry r;
00073 std::string name = this->GetName();
00074 name += ".config.default";
00075
00076 r.UnLockValues();
00077 r.Set("EnuMin", 0.0);
00078 r.Set("EnuMax", 999999.0);
00079 r.Set("Ymin", 0.0);
00080 r.Set("Ymax", 1.0);
00081
00082 r.Set("CCnue", false);
00083 r.Set("CCnuebar", false);
00084 r.Set("CCnumu", false);
00085 r.Set("CCnumubar", false);
00086 r.Set("CCnutau", false);
00087 r.Set("CCnutaubar",false);
00088 r.Set("NC", false);
00089 r.Set("AllNuInt", false);
00090
00091 r.Set("Elastic", false);
00092 r.Set("Resonant", false);
00093 r.Set("DIS", false);
00094 r.Set("AllMode", false);
00095
00096 r.Set("DoPrint", false);
00097 r.LockValues();
00098
00099 return r;
00100 }
00101
00102
00103
00104 void DemoMCFilter::Config(const Registry& r)
00105 {
00106
00107
00108
00109 int tmpb;
00110 double tmpd;
00111
00112 if (r.Get("EnuMin", tmpd)) { fEnuMin = tmpd; }
00113 if (r.Get("EnuMax", tmpd)) { fEnuMax = tmpd; }
00114 if (r.Get("Ymin", tmpd)) { fYmin = tmpd; }
00115 if (r.Get("Ymax", tmpd)) { fYmax = tmpd; }
00116
00117 if (r.Get("CCnue", tmpb)) {
00118 tmpb ? fNuIntSelect |= kCCnue : fNuIntSelect &= ~kCCnue;
00119 }
00120 if (r.Get("CCnuebar", tmpb)) {
00121 tmpb ? fNuIntSelect |= kCCnuebar : fNuIntSelect &= ~kCCnuebar;
00122 }
00123 if (r.Get("CCnumu", tmpb)) {
00124 tmpb ? fNuIntSelect |= kCCnumu : fNuIntSelect &= ~kCCnumu;
00125 }
00126 if (r.Get("CCnumubar", tmpb)) {
00127 tmpb ? fNuIntSelect |= kCCnumubar : fNuIntSelect &= ~kCCnumubar;
00128 }
00129 if (r.Get("CCnutau", tmpb)) {
00130 tmpb ? fNuIntSelect |= kCCnutau : fNuIntSelect &= ~kCCnutau;
00131 }
00132 if (r.Get("CCnutaubar", tmpb)) {
00133 tmpb ? fNuIntSelect |= kCCnutaubar : fNuIntSelect &= ~kCCnutaubar;
00134 }
00135 if (r.Get("NC", tmpb)) {
00136 tmpb ? fNuIntSelect |= kCCnumubar : fNuIntSelect &= ~kCCnumubar;
00137 }
00138 if (r.Get("AllNuInt", tmpb)) {
00139 if (tmpb) fNuIntSelect = kAllNuInt;
00140 }
00141
00142 if (!fNuIntSelect) fNuIntSelect = kAllNuInt;
00143
00144 if (r.Get("Elastic", tmpb)) {
00145 tmpb ? fModeSelect |= kElastic : fModeSelect &= ~kElastic;
00146 }
00147 if (r.Get("Resonant", tmpb)) {
00148 tmpb ? fModeSelect |= kResonant : fModeSelect &= ~kResonant;
00149 }
00150 if (r.Get("DIS", tmpb)) {
00151 tmpb ? fModeSelect |= kDIS : fModeSelect &= ~kDIS;
00152 }
00153 if (r.Get("AllMode", tmpb)) {
00154 if (tmpb) fModeSelect = kAllMode;
00155 }
00156
00157 if (!fModeSelect) fModeSelect = kAllMode;
00158
00159 if (r.Get("DoPrint", tmpb)) { fDoPrint = tmpb; }
00160 }
00161
00162
00163
00164 void DemoMCFilter::HandleCommand(JobCommand* cmd)
00165 {
00166 const char* c = cmd->PopCmd();
00167 if (c) {
00168 string cs(c);
00169 if (cs == "Report") {
00170 this->Report();
00171 return;
00172 }
00173 if (cs == "Accept") {
00174 NuInt_t nuIntAccept = 0;
00175 Mode_t modeAccept = 0;
00176 const char* opt = 0;
00177 while ( (opt=cmd->PopOpt()) !=0 ) {
00178 string sopt(opt);
00179
00180
00181 if (sopt == "CCnue") nuIntAccept |= kCCnue;
00182 else if (sopt == "CCnuebar") nuIntAccept |= kCCnuebar;
00183 else if (sopt == "CCnumu") nuIntAccept |= kCCnumu;
00184 else if (sopt == "CCnumubar") nuIntAccept |= kCCnumubar;
00185 else if (sopt == "CCnutau") nuIntAccept |= kCCnutau;
00186 else if (sopt == "CCnutaubar") nuIntAccept |= kCCnutaubar;
00187 else if (sopt == "NC") nuIntAccept |= kNC;
00188 else if (sopt == "AllNuInt") nuIntAccept |= kAllNuInt;
00189
00190 if (sopt == "Elastic") modeAccept |= kElastic;
00191 else if (sopt == "Resonant") modeAccept |= kResonant;
00192 else if (sopt == "DIS") modeAccept |= kDIS;
00193 else if (sopt == "AllMode") modeAccept |= kAllMode;
00194
00195
00196 if (sopt == "Emin") {
00197 float e = cmd->PopFloatOpt();
00198 this->SetEnuMin(e);
00199 }
00200
00201
00202 if (sopt == "Emax") {
00203 float e = cmd->PopFloatOpt();
00204 this->SetEnuMax(e);
00205 }
00206
00207
00208 if (sopt == "Ymin") {
00209 float y = cmd->PopFloatOpt();
00210 this->SetYmin(y);
00211 }
00212 if (sopt == "Ymax") {
00213 float y = cmd->PopFloatOpt();
00214 this->SetYmax(y);
00215 }
00216 }
00217
00218 if (nuIntAccept !=0 ) this->SetNuInt(nuIntAccept);
00219 if (modeAccept !=0 ) this->SetNuMode(modeAccept);
00220 return;
00221 }
00222 }
00223 }
00224
00225
00226
00227 void DemoMCFilter::Help() {}
00228
00229
00230
00231 void DemoMCFilter::Report()
00232 {
00233 MsgStream& msg = MSGSTREAM("Demo",Msg::kInfo);
00234
00235 msg <<
00236 this->GetName() << ": Selecting events with:\n" <<
00237 "-> Enu in range [" << fEnuMin << "," << fEnuMax << "]\n" <<
00238 "-> y in range [" << fYmin << "," << fYmax << "]\n" <<
00239 "-> Interactions types: ( ";
00240 if (fNuIntSelect>=kAllNuInt) {
00241 msg << "All ";
00242 }
00243 else {
00244 if (fNuIntSelect&kCCnue) msg << "CCnue ";
00245 if (fNuIntSelect&kCCnuebar) msg << "CCnuebar ";
00246 if (fNuIntSelect&kCCnumu) msg << "CCnumu ";
00247 if (fNuIntSelect&kCCnumubar) msg << "CCnumubar ";
00248 if (fNuIntSelect&kCCnutau) msg << "CCnutau ";
00249 if (fNuIntSelect&kCCnutaubar) msg << "CCnutaubar ";
00250 if (fNuIntSelect&kNC) msg << "NC ";
00251 }
00252 msg << ")\n";
00253 msg << "-> Interaction modes: ( ";
00254 if (fModeSelect>=kAllMode) {
00255 msg << "All ";
00256 }
00257 else {
00258 if (fModeSelect&kElastic) msg << "Elastic ";
00259 if (fModeSelect&kResonant) msg << "Resonant ";
00260 if (fModeSelect&kDIS) msg << "DIS ";
00261 }
00262 msg << ")\n";
00263 }
00264
00265
00266
00267 void DemoMCFilter::SetNuInt(NuInt_t i) {
00268 if (i>=kAllNuInt) {
00269 fNuIntSelect = kAllNuInt;
00270 }
00271 else {
00272 fNuIntSelect = i;
00273 }
00274 }
00275
00276
00277
00278 void DemoMCFilter::SetNuMode(Mode_t i)
00279 {
00280 if (i>=kAllMode) {
00281 fModeSelect = kAllMode;
00282 }
00283 else {
00284 fModeSelect = i;
00285 }
00286 }
00287
00288
00289
00290 void DemoMCFilter::SetEnuMin(double e) { fEnuMin = e; }
00291 void DemoMCFilter::SetEnuMax(double e) { fEnuMax = e; }
00292 void DemoMCFilter::SetYmin(double y) { fYmin = y; }
00293 void DemoMCFilter::SetYmax(double y) { fYmax = y; }
00294 void DemoMCFilter::SetPrint(bool doPrint) { fDoPrint = doPrint; }
00295
00296
00297
00298 DemoMCFilter::NuInt_t DemoMCFilter::GetNuInt(const REROOT_NeuKin* nukin)
00299 {
00300 bool isNC = (nukin->IAction()==0);
00301
00302 if (isNC) { return kNC; }
00303
00304 int ntype = nukin->INu();
00305 if (ntype == 12) { return kCCnue; }
00306 if (ntype == -12) { return kCCnuebar; }
00307 if (ntype == 14) { return kCCnumu; }
00308 if (ntype == -14) { return kCCnumubar; }
00309 if (ntype == 16) { return kCCnutau; }
00310 if (ntype == -16) { return kCCnutaubar; }
00311
00312 return 0;
00313 }
00314
00315
00316
00317 DemoMCFilter::Mode_t DemoMCFilter::GetMode(const REROOT_NeuKin* )
00318 {
00319 return kAllMode;
00320 }
00321
00322
00323
00324 double DemoMCFilter::GetEnu(const REROOT_NeuKin* nukin)
00325 {
00326 return nukin->P4Neu()[3];
00327 }
00328
00329
00330
00331 double DemoMCFilter::GetY(const REROOT_NeuKin* nukin)
00332 {
00333 return nukin->Y();
00334 }
00335
00336
00337
00338 void DemoMCFilter::Print(const REROOT_NeuKin* )
00339 {
00340 }
00341