00001 #include "emcRecoModuleFactory.h"
00002 #include "mEmcRecoModuleSimulationYear1.h"
00003 #include "mEmcRecoModuleSimulationYear2.h"
00004 #include "mEmcRecoModuleSimulationYear3.h"
00005 #include "mEmcRecoModuleRealYear2.h"
00006 #include "mEmcRecoModuleRealYear3.h"
00007 #include "mEmcRecoModuleRealYear3v1.h"
00008 #include "mEmcRecoModuleRealYear4.h"
00009 #include "PHFlag.h"
00010 #include <iostream>
00011
00012 using namespace std;
00013
00014 namespace {
00015
00016 int RunToYear(int runnumber)
00017 {
00018 if ( runnumber > 1 && runnumber < 20000 )
00019 {
00020 return 1;
00021 }
00022 else if ( runnumber >= 20000 && runnumber < 50000 )
00023 {
00024
00025 return 3;
00026
00027 }
00028 else if ( runnumber >= 50000 && runnumber < 95000 )
00029 {
00030 return 3;
00031 }
00032 else if ( runnumber >= 95000 )
00033 {
00034 return 4;
00035 }
00036 return -1;
00037 }
00038 };
00039
00040
00041 emcRecoModule*
00042 emcRecoModuleFactory::create(const PHFlag& flags)
00043 {
00044 int runnumber = flags.get_IntFlag("RUNNUMBER");
00045
00046 int year = RunToYear(abs(runnumber));
00047
00048 if ( year == 1 )
00049 {
00050 if ( flags.FlagExist("SIMULATIONFLAG") &&
00051 flags.get_IntFlag("SIMULATIONFLAG") )
00052 {
00053 return new mEmcRecoModuleSimulationYear1(flags);
00054 }
00055 else
00056 {
00057
00058 return 0;
00059 }
00060 }
00061 else if ( year == 2 )
00062 {
00063 if ( flags.FlagExist("SIMULATIONFLAG") &&
00064 flags.get_IntFlag("SIMULATIONFLAG") )
00065 {
00066 return 0;
00067 }
00068 else
00069 {
00070 return new mEmcRecoModuleRealYear2(flags);
00071 }
00072 }
00073 else if ( year >= 3 )
00074 {
00075 int simu = 0;
00076
00077 if ( flags.FlagExist("SIMULATIONFLAG") )
00078 {
00079 simu = flags.get_IntFlag("SIMULATIONFLAG");
00080 }
00081
00082 if ( simu == 2 )
00083 {
00084 return new mEmcRecoModuleSimulationYear3(flags);
00085 }
00086 else if ( simu == 0 )
00087 {
00088 if ( flags.FlagExist("EMCBACKWARD") &&
00089 flags.get_IntFlag("EMCBACKWARD") == 1 )
00090 {
00091 return new mEmcRecoModuleRealYear3(flags);
00092 }
00093 else if ( year == 3 )
00094 {
00095 return new mEmcRecoModuleRealYear3v1(flags);
00096 }
00097 else
00098 {
00099 return new mEmcRecoModuleRealYear4(flags);
00100 }
00101 }
00102 }
00103 else
00104 {
00105 cerr << "<ERROR-FATAL> emcRecoModuleFactory::create : runnumber "
00106 << runnumber << " lead me to year = " << year << " ?!"
00107 << endl;
00108 return 0;
00109 }
00110
00111 cerr << "emcRecoModuleFactory::create : failed to find a suitable "
00112 << " recoModule for those flags " << endl;
00113 flags.Print();
00114
00115 return 0;
00116 }