#include <FillFlux.h>
Inheritance diagram for Anp::FillFlux:

Public Member Functions | |
| FillFlux () | |
| virtual | ~FillFlux () |
| bool | Run (Record &record) |
| void | Config (const Registry ®) |
| bool | Init (const Header &) |
| void | End (const DataBlock &) |
Private Member Functions | |
| bool | Fill (Truth &truth, const Record &record, const BeamType::BeamType_t beamtype) |
| bool | Fill (Event &event, const Record &record, const BeamType::BeamType_t beamtype) |
Private Attributes | |
| std::string | fName |
| std::string | fFLUX |
| std::string | fRUNCYCLE |
| bool | fFluxDet |
| int | fNSigma |
| SKZPWeightCalculator * | fCalc |
|
|
Definition at line 16 of file FillFlux.cxx. 00017 :fName("PiMinus_CedarDaikon"), 00018 fFLUX(""), 00019 fRUNCYCLE(""), 00020 fFluxDet(false), 00021 fNSigma(0), 00022 fCalc(0) 00023 { 00024 }
|
|
|
Definition at line 27 of file FillFlux.cxx. References fCalc. 00028 {
00029 if(fCalc)
00030 {
00031 delete fCalc;
00032 fCalc = 0;
00033 }
00034 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 85 of file FillFlux.cxx. References fFLUX, fFluxDet, fName, fNSigma, fRUNCYCLE, Registry::Get(), Registry::KeyExists(), Anp::Read(), and reg. 00086 {
00087 //
00088 // Get fit name and FLUX type
00089 //
00090
00091 const char *value_name = 0;
00092 if(reg.Get("FillFluxName", value_name) && value_name)
00093 {
00094 fName = value_name;
00095 }
00096
00097 const char *value_flux = 0;
00098 if(reg.Get("FillFlux", value_flux) && value_flux)
00099 {
00100 fFLUX = value_flux;
00101 }
00102 else if(reg.Get("FLUX", value_flux) && value_flux)
00103 {
00104 fFLUX = value_flux;
00105 }
00106
00107 const char *value_runc = 0;
00108 if(reg.Get("RUNCYCLE", value_runc) && value_runc)
00109 {
00110 fRUNCYCLE = value_runc;
00111 }
00112
00113 Anp::Read(reg, "FillFluxDet", fFluxDet);
00114 reg.Get("FillFluxNSigma", fNSigma);
00115
00116 if(reg.KeyExists("PrintConfig"))
00117 {
00118 cout << "FillFlux::Config" << endl
00119 << " Name = " << fName << endl
00120 << " FLUX = " << fFLUX << endl
00121 << " RUNCYCLE = " << fRUNCYCLE << endl
00122 << " FluxDet = " << fFluxDet << endl
00123 << " NSigma = " << fNSigma << endl;
00124 }
00125 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 151 of file FillFlux.cxx. References fCalc. 00152 {
00153 //
00154 // Done with data processing
00155 //
00156
00157 if(fCalc)
00158 {
00159 delete fCalc;
00160 fCalc = 0;
00161 }
00162 }
|
|
||||||||||||||||
|
Definition at line 223 of file FillFlux.cxx. References beamtype, Anp::RecoNu::EHad(), Anp::RecoNu::ELep(), fCalc, Anp::Record::FindTruth(), Anp::Record::GetHeader(), Anp::Event::GetNu(), Anp::Event::GetRecoNu(), MCEventInfo::had_fs, MCEventInfo::iaction, MCEventInfo::initial_state, MCEventInfo::inu, MCEventInfo::iresonance, Anp::Header::IsFar(), Anp::Header::IsNear(), MCEventInfo::nucleus, MCEventInfo::nuE, MCEventInfo::nuPx, MCEventInfo::nuPy, MCEventInfo::nuPz, MCEventInfo::q2, Anp::RecoNu::SetEHad(), Anp::RecoNu::SetELep(), Anp::Event::SetWeight(), MCEventInfo::tarE, MCEventInfo::tarPx, MCEventInfo::tarPy, MCEventInfo::tarPz, Anp::Record::TruthEnd(), Anp::TruthIter, MCEventInfo::w2, Anp::Event::Weight(), MCEventInfo::x, and MCEventInfo::y. 00224 {
00225 //
00226 // Get beam weight using database as a source for the fit parameters.
00227 //
00228 if(!fCalc || beamtype == BeamType::kUnknown)
00229 {
00230 return false;
00231 }
00232
00233 int detector = 0;
00234 if (record.GetHeader().IsNear()) detector = 1;
00235 else if(record.GetHeader().IsFar()) detector = 2;
00236
00237 const TruthIter itruth = record.FindTruth(event);
00238 if(itruth == record.TruthEnd())
00239 {
00240 return false;
00241 }
00242
00243 double ehad = event.GetNu().EHad();
00244 double elep = event.GetNu().ELep();
00245
00246 MCEventInfo mcinfo;
00247 mcinfo.initial_state = itruth -> InitState();
00248 mcinfo.nucleus = itruth -> Nucleus();
00249 mcinfo.had_fs = itruth -> HadFS();
00250 mcinfo.iaction = itruth -> Interaction();
00251 mcinfo.inu = itruth -> INu();
00252 mcinfo.iresonance = itruth -> Resonance();
00253
00254 mcinfo.nuE = itruth -> ENeu();
00255 mcinfo.nuPx = itruth -> Px();
00256 mcinfo.nuPy = itruth -> Py();
00257 mcinfo.nuPz = itruth -> Pz();
00258
00259 mcinfo.tarE = itruth -> TgtE();
00260 mcinfo.tarPx = itruth -> TgtPx();
00261 mcinfo.tarPy = itruth -> TgtPy();
00262 mcinfo.tarPz = itruth -> TgtPz();
00263
00264 mcinfo.x = itruth -> TrueX();
00265 mcinfo.y = itruth -> TrueY();
00266 mcinfo.q2 = itruth -> TrueQ2();
00267 mcinfo.w2 = itruth -> TrueW2();
00268
00269
00270 const double weight = fCalc -> GetDetWeight(itruth -> Interaction(),
00271 itruth -> ENeu(),
00272 itruth -> INu(),
00273 elep,
00274 ehad,
00275 elep,
00276 ehad,
00277 itruth -> EHad(),
00278 &mcinfo);
00279
00280 //
00281 // Reset hadronic energy and muon energy
00282 //
00283 event.GetRecoNu().SetEHad(ehad);
00284 event.GetRecoNu().SetELep(elep);
00285
00286 //
00287 // Multiply new and previous weights
00288 //
00289 event.SetWeight(weight*event.Weight());
00290
00291 return true;
00292 }
|
|
||||||||||||||||
|
Definition at line 165 of file FillFlux.cxx. References beamtype, Anp::Truth::ENeu(), fCalc, Anp::Truth::Flux(), fNSigma, fRUNCYCLE, Anp::Record::GetHeader(), Anp::Truth::INu(), Anp::Header::IsFar(), Anp::Header::IsNear(), Anp::Truth::SetWeight(), Anp::FluxInfo::tptype, Anp::FluxInfo::tpx, Anp::FluxInfo::tpy, Anp::FluxInfo::tpz, and Anp::Truth::Weight(). 00166 {
00167 //
00168 // Get beam weight using database as a source for the fit parameters.
00169 //
00170 if(!fCalc || beamtype == BeamType::kUnknown)
00171 {
00172 return false;
00173 }
00174
00175 SKZPWeightCalculator::RunPeriod_t runperiod = SKZPWeightCalculator::kNone;
00176 if (fRUNCYCLE == "run-1") runperiod = SKZPWeightCalculator::kRunI;
00177 else if(fRUNCYCLE == "run-2") runperiod = SKZPWeightCalculator::kRunII;
00178 else
00179 {
00180 cerr << "FillFlux::Fill - unknown run period" << endl;
00181 return false;
00182 }
00183
00184 int detector = 0;
00185 if (record.GetHeader().IsNear()) detector = 1;
00186 else if(record.GetHeader().IsFar()) detector = 2;
00187 else
00188 {
00189 cerr << "FillFlux::Fill - unknown detector" << endl;
00190 return false;
00191 }
00192
00193 const FluxInfo &flux = truth.Flux();
00194 const double pt = std::sqrt(flux.tpy*flux.tpy + flux.tpx*flux.tpx);
00195
00196 double weight = truth.Weight() * fCalc -> GetBeamWeight(detector,
00197 BeamType::ToZarko(beamtype),
00198 flux.tptype,
00199 pt,
00200 flux.tpz,
00201 truth.ENeu(),
00202 truth.INu(),
00203 runperiod);
00204
00205 if(fNSigma != 0)
00206 {
00207 weight *= fCalc -> GetFluxError(detector,
00208 BeamType::ToZarko(beamtype),
00209 truth.INu(),
00210 truth.ENeu(),
00211 SKZPWeightCalculator::kTotalErrorAfterTune,
00212 static_cast<double>(fNSigma));
00213 }
00214
00215 //
00216 // !!!Set new weight and ERASE previous weight!!!
00217 //
00218 truth.SetWeight(weight);
00219
00220 return true;
00221 }
|
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 128 of file FillFlux.cxx. 00129 {
00130 if(fCalc)
00131 {
00132 cerr << "FillFlux::Init - SKZPWeightCalculator already exists" << endl;
00133 return false;
00134 }
00135
00136 if(fName.empty() || fName == "Unknown")
00137 {
00138 cerr << "FillFlux::Init - unknown beam fit type" << endl;
00139 return false;
00140 }
00141
00142 Anp::Lock<Mutex> lockM(Anp::GetMainMutex());
00143 Anp::Lock<Mutex> lockR(Anp::GetROOTMutex());
00144
00145 fCalc = new SKZPWeightCalculator(fName.c_str(), true);
00146
00147 return true;
00148 }
|
|
|
Implements Anp::AlgSnarl. Definition at line 37 of file FillFlux.cxx. References Anp::ApplyTrueWeights(), Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, Anp::Header::GetBEAMTYPE(), Anp::Record::GetHeader(), Anp::Header::IsData(), BeamType::TagToEnum(), Anp::Record::TruthBeg(), Anp::Record::TruthBegIterator(), Anp::Record::TruthEnd(), Anp::Record::TruthEndIterator(), and Anp::TruthIterator. 00038 {
00039 //
00040 // Apply beam weights to all reconstructed and true objects
00041 //
00042 if(record.GetHeader().IsData() || record.TruthBeg() == record.TruthEnd())
00043 {
00044 return true;
00045 }
00046
00047 //
00048 // Lock main PhysicsNtuple mutex
00049 //
00050 Anp::Lock<Mutex> lockM(Anp::GetMainMutex());
00051 Anp::Lock<Mutex> lockR(Anp::GetROOTMutex());
00052
00053 //
00054 // Check for valid beam type
00055 //
00056 const BeamType::BeamType_t beam = BeamType::TagToEnum(record.GetHeader().GetBEAMTYPE().c_str());
00057 if(beam == BeamType::kUnknown)
00058 {
00059 cerr << "FillFlux::Run - unknown beam type: " << beam << endl;
00060 return false;
00061 }
00062
00063 for(TruthIterator itruth = record.TruthBegIterator(); itruth != record.TruthEndIterator(); ++itruth)
00064 {
00065 FillFlux::Fill(*itruth, record, beam);
00066 }
00067
00068 //
00069 // Apply true weights to reconstructed objects
00070 //
00071 Anp::ApplyTrueWeights(record);
00072
00073 if(fFluxDet)
00074 {
00075 for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00076 {
00077 FillFlux::Fill(*ievent, record, beam);
00078 }
00079 }
00080
00081 return true;
00082 }
|
|
|
Definition at line 49 of file FillFlux.h. Referenced by End(), Fill(), Init(), and ~FillFlux(). |
|
|
Definition at line 43 of file FillFlux.h. Referenced by Config(). |
|
|
Definition at line 46 of file FillFlux.h. Referenced by Config(). |
|
|
Reimplemented from Anp::AlgSnarl. Definition at line 42 of file FillFlux.h. |
|
|
Definition at line 47 of file FillFlux.h. |
|
|
Definition at line 44 of file FillFlux.h. |
1.3.9.1