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