00001 #include "ANtpInfoObjectFillerMRCC.h"
00002
00003 #include "../ANtpEventInfoMRCC.h"
00004 #include "../ANtpTruthInfoBeam.h"
00005
00006 #include "ANtpInfoObjectFiller.h"
00007 #include "ANtpInfoObjectFillerBeam.h"
00008
00009 #include "MuonRemoval/NtpMREvent.h"
00010 #include "MuonRemoval/NtpMRRecord.h"
00011 #include "StandardNtuple/NtpStRecord.h"
00012 #include "Conventions/DetectorType.h"
00013 #include "Conventions/BeamType.h"
00014 #include "MessageService/MsgService.h"
00015 #include "Mad/MadAbID.h"
00016 #include "PhysicsNtuple/Store/Interface.h"
00017
00018 #include "TClonesArray.h"
00019 #include "TSystem.h"
00020
00021 #include <cassert>
00022 #include <string>
00023 #include <vector>
00024
00025 using namespace std;
00026
00027 CVSID("$Id: ANtpInfoObjectFillerMRCC.cxx,v 1.3 2009/11/24 16:50:39 rodriges Exp $");
00028
00029 void ANtpInfoObjectFillerMRCC::
00030 FillEventInformation(int i,
00031 const NtpMRRecord* mrRecord,
00032 const NtpStRecord* stRecord,
00033 ANtpEventInfoMRCC* antp,
00034 ANtpTruthInfoBeam* truth) const
00035 {
00036 assert(i >= 0);
00037 assert(mrRecord);
00038
00039
00040 const int J = mrRecord->mrevt->GetEntriesFast();
00041
00042 for(int j = 0; j < J; ++j){
00043 const NtpMREvent* mrevt = (NtpMREvent*)(mrRecord->mrevt->At(j));
00044 assert(mrevt);
00045
00046 if(mrevt->best_event == i){
00047 FillEventInformationHelper(mrevt, stRecord, antp, truth);
00048
00049
00050 return;
00051 }
00052 }
00053
00054 }
00055
00056
00057 void ANtpInfoObjectFillerMRCC::
00058 FillEventInformationHelper(const NtpMREvent* mrnt,
00059 const NtpStRecord* sntp_orig,
00060 ANtpEventInfoMRCC* antp,
00061 ANtpTruthInfoBeam* truth) const
00062 {
00063 assert(mrnt);
00064 assert(sntp_orig);
00065 assert(antp);
00066
00067 antp->index = mrnt->index;
00068 antp->digits = mrnt->ndigit;
00069 antp->strips = mrnt->nstrip;
00070
00071 antp->origEvent = mrnt->orig_event;
00072 antp->bestEvent = mrnt->best_event;
00073 antp->bestPurity = mrnt->best_purity;
00074 antp->bestComplete = mrnt->best_complete;
00075 antp->bestPurityPHw = mrnt->best_purity_phw;
00076 antp->bestCompletePHw = mrnt->best_complete_phw;
00077
00078 MSG("ObjectFillerMRCC",Msg::kDebug)
00079 << "orig_event=" << mrnt->orig_event << endl
00080
00081 << "sntp_orig->snarl=" << sntp_orig->GetHeader().GetSnarl() << endl;
00082
00083 vector<const NtpSREvent*> orig_evts=sntp_orig->GetEvents();
00084 assert(mrnt->orig_event < (int)orig_evts.size());
00085
00086 const NtpSREvent* orig_event=orig_evts[mrnt->orig_event];
00087 antp->origABPID = ABPID(orig_event, sntp_orig);
00088 antp->origROPID = ROPID(orig_event, sntp_orig);
00089
00090 if(truth){
00091
00092
00093 truth->Reset();
00094
00095 NtpMCTruth* ntpMCTruth=const_cast<NtpMCTruth*>(sntp_orig->GetEventMCTruth(mrnt->orig_event));
00096
00097 ANtpInfoObjectFiller::FillMCTruthInformation(ntpMCTruth, truth);
00098 ANtpInfoObjectFillerBeam::FillBeamMCTruthInformation(ntpMCTruth, sntp_orig->stdhep,
00099 truth);
00100 }
00101
00102 antp->showerVtxX = mrnt->shwvtxx;
00103 antp->showerVtxY = mrnt->shwvtxy;
00104 antp->showerVtxZ = mrnt->shwvtxz;
00105 antp->showerEndX = mrnt->shwendx;
00106 antp->showerEndY = mrnt->shwendy;
00107 antp->showerEndZ = mrnt->shwendz;
00108 antp->showerVtxPlane = mrnt->shwvtxplane;
00109 antp->showerEndPlane = mrnt->shwendplane;
00110 antp->showerPlanes = mrnt->shwnplane;
00111 antp->showerCharge = mrnt->shwcharge;
00112
00113 antp->trackVtxX = mrnt->vtxx;
00114 antp->trackVtxY = mrnt->vtxy;
00115 antp->trackVtxZ = mrnt->vtxz;
00116 antp->trackVtxDistanceToEdge = mrnt->vtxdistance;
00117 antp->trackEndX = mrnt->endx;
00118 antp->trackEndY = mrnt->endy;
00119 antp->trackEndZ = mrnt->endz;
00120 antp->trackEndDistanceToEdge = mrnt->enddistance;
00121
00122 antp->trackVtxPlane = mrnt->vtxp;
00123 antp->trackEndPlane = mrnt->endp;
00124 antp->trackPlanes = mrnt->npln;
00125 antp->rangeMomentum = mrnt->prng;
00126 antp->fitMomentum = mrnt->pcrv;
00127 antp->trackDcosXVtx = mrnt->pvdx;
00128 antp->trackDcosYVtx = mrnt->pvdy;
00129 antp->trackDcosZVtx = mrnt->pvdz;
00130
00131 antp->passedFit = mrnt->fitp;
00132 antp->contained = mrnt->endc;
00133 antp->containedOrGoodFit = mrnt->pass;
00134 antp->trackMomentumX = mrnt->pmux;
00135 antp->trackMomentumY = mrnt->pmuy;
00136 antp->trackMomentumZ = mrnt->pmuz;
00137 antp->maxTrackPlane = mrnt->mxpl;
00138 antp->qp = mrnt->qp;
00139
00140 antp->trueMomentumX = mrnt->mrmpmux;
00141 antp->trueMomentumY = mrnt->mrmpmuy;
00142 antp->trueMomentumZ = mrnt->mrmpmuz;
00143 antp->trueQ2 = mrnt->mrmQ2;
00144 antp->trueShowerEnergy = mrnt->mrmEshw;
00145
00146 }
00147
00148 double ANtpInfoObjectFillerMRCC::
00149 ABPID(const NtpSREvent* ev, const NtpStRecord* st) const
00150 {
00151 static bool once=false;
00152 static MadAbID ABID;
00153
00154
00155 if(!once){
00156 once=true;
00157 string base=getenv("SRT_PRIVATE_CONTEXT");
00158 if(base!="" && base!="."){
00159
00160 string path = base + "/Mad/data";
00161 void* dir_ptr = gSystem->OpenDirectory(path.c_str());
00162 if(!dir_ptr){
00163 base=getenv("SRT_PUBLIC_CONTEXT");
00164 }
00165 }
00166 else{
00167 base=getenv("SRT_PUBLIC_CONTEXT");
00168 }
00169 if(base=="") {
00170 MSG("ObjectFillerMRCC",Msg::kFatal)<<"No SRT_PUBLIC_CONTEXT set "
00171 <<"Do not know where to look "
00172 <<"for AB pdf files "<<std::endl;
00173
00174 MSG("ObjectFillerMRCC",Msg::kFatal) << "Goodbye" << endl;
00175 }
00176 base+="/Mad/data";
00177 string fname=base;
00178 string rmc="";
00179
00180
00181
00182
00183 ReleaseType::Release_t release=st->GetRelease();
00184 if(ReleaseType::IsCedar(release)){
00185 rmc="cedar_daikon";
00186 }
00187 else{
00188 MSG("ObjectFillerMRCC",Msg::kWarning)
00189 << "Running on release type " << ReleaseType::AsString(release)
00190 << " which has no PDFs. Using cedar_daikon instead." << endl;
00191 rmc="cedar_daikon";
00192 }
00193
00194 string sdet="";
00195 Detector::Detector_t det=st->GetVldContext()->GetDetector();
00196 if(det==Detector::kNear){
00197 sdet="near";
00198 }
00199 else if(det==Detector::kFar){
00200 sdet="far";
00201 }
00202 else{
00203 MSG("ObjectFillerMRCC",Msg::kFatal) << "Dont know detector type."
00204 << " Bailing"<<endl;
00205
00206 MSG("ObjectFillerMRCC",Msg::kFatal) << "Goodbye" << endl;
00207 }
00208 string sbeam="le";
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 fname+="/ab_pdf_"+sdet+"_"+sbeam+"_"+rmc+".root";
00248
00249 ABID.ReadPDFs(fname.c_str());
00250 }
00251
00252 return ABID.CalcPID(ev, st);
00253 }
00254
00255 double ANtpInfoObjectFillerMRCC::
00256 ROPID(const NtpSREvent* , const NtpStRecord* ) const
00257 {
00258
00259
00260
00261 return -1;
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 }