00001
00002
00003
00004
00005
00006
00008 #include <dirent.h>
00009 #include "TChain.h"
00010 #include "TClonesArray.h"
00011 #include "TProfile2D.h"
00012 #include "StandardNtuple/NtpStRecord.h"
00013 #include "MessageService/MsgService.h"
00014 #include "MinosObjectMap/MomNavigator.h"
00015 #include "JobControl/JobCModuleRegistry.h"
00016 #include "Calibrator/CalMIPCalibration.h"
00017 #include "MCNtuple/NtpMCRecord.h"
00018 #include "MCNtuple/NtpMCTruth.h"
00019 #include "TruthHelperNtuple/NtpTHRecord.h"
00020 #include "CandNtupleSR/NtpSRRecord.h"
00021 #include "CandNtupleSR/NtpSRStrip.h"
00022 #include "CandNtupleSR/NtpSREvent.h"
00023 #include "CandNtupleSR/NtpSRTrack.h"
00024 #include "NueAna/SntpHelpers.h"
00025 #include "NueAna/NueModule.h"
00026 #include "NueAna/NueRecord.h"
00027 #include "NueAna/NueRecordAna.h"
00028 #include "BeamData/ana/Summary/BeamSummary.h"
00029 #include "NueAna/EventFilter.h"
00030
00031 #include "VertexFinder/Module/VtxModule.h"
00032 #include "VertexFinder/Module/VtxRecordAna.h"
00033
00034
00035 CVSID("$Id: VtxModule.cxx,v 1.2 2007/03/01 16:56:24 rhatcher Exp $");
00036
00037 #include "DatabaseInterface/DbiResultPtr.tpl"
00038
00039
00040 JOBMODULE(VtxModule, "VtxModule",
00041 "");
00042
00043
00044 VtxModule::VtxModule():
00045 counter(0),
00046 passcounter(0),
00047 passcutcounter(0),
00048 failcounter(0),
00049 writecounter(0),
00050 foundmeu(false),
00051 SIGCORRMEU(1.),
00052 pot(0.),
00053 MEUPERGEV(25.66)
00054 {}
00055
00056
00057
00058 VtxModule::~VtxModule()
00059 {
00060 }
00061
00062
00063
00064 JobCResult VtxModule::Reco(MomNavigator* mom)
00065 {
00066
00067
00068
00069
00070 MSG("VtxModule",Msg::kDebug)<<"In VtxModule::Reco"<<endl;
00071
00072 if(counter%1000==0){
00073 MSG("VtxModule",Msg::kInfo)<<"On entry "<<counter<<endl;
00074 }
00075 counter++;
00076 bool foundST=false;
00077
00078 VldContext vc;
00079
00080 NtpStRecord *str=dynamic_cast<NtpStRecord *>(mom->GetFragment("NtpStRecord"));
00081 if(str){
00082 foundST=true;
00083 vc=str->GetHeader().GetVldContext();
00084 }
00085
00086
00087
00088
00089 if(!foundST){
00090
00091 MSG("VtxModule",Msg::kWarning)<<"Got Nothing from mom"<<endl;
00092 failcounter++;
00093 return JobCResult::kFailed;
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 if(!foundmeu){
00108 DbiResultPtr<CalMIPCalibration> dbp(vc);
00109 if(dbp.GetNumRows()>0){
00110 const CalMIPCalibration *m = dbp.GetRow(0);
00111 float mip=m->GetMIP(1.);
00112 if(mip>0){
00113 SIGCORRMEU=1./mip;
00114 foundmeu=true;
00115 }
00116 }
00117 }
00118
00119 if(foundST){
00120
00121 int evtn=str->evthdr.nevent;
00122 MSG("VtxModule",Msg::kDebug)<<"Events in this snarl: "<<evtn<<endl;
00123
00124
00125 VldContext vc = str->GetHeader().GetVldContext();
00126
00127 if(evtn==0){
00128
00129
00130
00131 NueHeader h(vc);
00132
00133
00134 h.SetSnarl(str->GetHeader().GetSnarl());
00135 h.SetRun(str->GetHeader().GetRun());
00136 h.SetSubRun(str->GetHeader().GetSubRun());
00137 h.SetEventNo(-1);
00138 h.SetEvents(0);
00139 h.SetTrackLength(0);
00140 h.SetFoundBits(false,true,false);
00141
00142
00143 VtxRecord *vtxRec = new VtxRecord(h);
00144 vtxRec->SetName("VtxRecord");
00145
00146
00147 VtxRecordAna ana_vtx(*vtxRec);
00148
00149
00150
00151 ana_vtx.FillTrue(0,str);
00152
00153
00154 mom->AdoptFragment(vtxRec);
00155 writecounter++;
00156 failcounter++;
00157
00158 return JobCResult::kPassed;
00159 }
00160
00161
00162 for(int i=0;i<evtn;i++){
00163
00164
00165 NueHeader h(vc);
00166
00167
00168 h.SetSnarl(str->GetHeader().GetSnarl());
00169 h.SetRun(str->GetHeader().GetRun());
00170 h.SetSubRun(str->GetHeader().GetSubRun());
00171 h.SetEventNo(i);
00172 h.SetEvents(evtn);
00173 h.SetFoundBits(true,true,true);
00174
00175 MSG("VtxModule",Msg::kDebug)<<"Getting event"<<endl;
00176 NtpSREvent *event = SntpHelpers::GetEvent(i,str);
00177
00178
00179 int longtrack=0;
00180 for(int j=0;j<event->ntrack;j++){
00181 int tindex = SntpHelpers::GetTrackIndex(j,event);
00182 NtpSRTrack *track = SntpHelpers::GetTrack(tindex,str);
00183 if(longtrack<track->plane.n){
00184 longtrack = track->plane.n;
00185 }
00186 }
00187 h.SetTrackLength(longtrack);
00188
00189 VtxRecord *vtxRec = new VtxRecord(h);
00190 vtxRec->SetName("VtxRecord");
00191
00192
00193 VtxRecordAna ana_vtx(*vtxRec);
00194
00195
00196 passcutcounter++;
00197
00198
00199
00200 ana_vtx.ansia.SetParams(SIGCORRMEU, MEUPERGEV);
00201 ana_vtx.antia.SetParams(SIGCORRMEU, MEUPERGEV);
00202 ana_vtx.aneia.SetParams(SIGCORRMEU, MEUPERGEV);
00203
00204 ana_vtx.FillTrue(i,str);
00205 ana_vtx.FillReco(i,str);
00206 ana_vtx.Analyze(i,str);
00207
00208
00209 MSG("VtxModule",Msg::kDebug)<<"Giving Fragment to mom"<<endl;
00210 writecounter++;
00211 mom->AdoptFragment(vtxRec);
00212 MSG("VtxModule",Msg::kDebug)<<"Mom took it"<<endl;
00213 }
00214 MSG("VtxModule",Msg::kDebug)<<"Done with snarl"<<endl;
00215 passcounter++;
00216 return JobCResult::kPassed;
00217 }
00218
00219 return JobCResult::kFailed;
00220 }
00221
00222
00223
00224 const Registry& VtxModule::DefaultConfig() const
00225 {
00226
00227
00228
00229 MSG("VtxModule",Msg::kDebug)<<"In VtxModule::DefaultConfig"<<endl;
00230
00231 static Registry r;
00232
00233
00234 std::string name = this->GetName();
00235 name += ".config.default";
00236 r.SetName(name.c_str());
00237
00238
00239 r.UnLockValues();
00240 r.LockValues();
00241
00242 return r;
00243 }
00244
00245
00246
00247 void VtxModule::Config(const Registry& r)
00248 {
00249
00250
00251
00252 MSG("VtxModule",Msg::kDebug)<<"In VtxModule::Config"<<endl;
00253
00254 }
00255
00256 void VtxModule::BeginJob()
00257 {
00258 MSG("VtxModule",Msg::kDebug)<<"In VtxModule::BeginJob"<<endl;
00259 }
00260
00261 void VtxModule::EndJob()
00262 {
00263
00264 MSG("VtxModule",Msg::kInfo)<<"Counter "<<counter
00265 <<" passcutcounter "<<passcutcounter
00266 <<" passcounter "<<passcounter
00267 <<" failcounter "<<failcounter
00268 <<" writecounter "<<writecounter<<endl;
00269 MSG("VtxModule",Msg::kInfo)<<"Number of POT in this run: "<<pot<<endl;
00270
00271 }
00272