#include <NueExpBuilder.h>
Public Member Functions | |
| NueExpBuilder () | |
| void | AddFiles (std::string files) |
| void | SetOutputFile (std::string name) |
| void | SetCuts (std::string type, int level=0) |
| bool | EvaluateCuts (NueRecord *nr) |
| void | SetDeltaMSquare (double dm2) |
| void | SetUe3Square (double dUe32) |
| void | SetTheta23 (double t23) |
| void | SetBaseline (double bl) |
| void | SetTargetPOT (double num) |
| void | SetMeanNumberOfEvents (double num) |
| void | SetNumberOfEvents (int num) |
| void | GenerateExperiment (int nExp) |
| void | SetSeed (int in) |
| void | SetMaxProb (double max) |
| double | GetMaxProb () |
Private Attributes | |
| std::string | outFile |
| bool | outSet |
| std::vector< std::string > | files |
| double | fDeltaMSquare |
| double | fUe3Square |
| double | fTheta23 |
| double | fBaseline |
| bool | fReweight |
| std::string | cutSet |
| int | cutLevel |
| OscCalc | fOsc |
| int | fNumberOfEvents |
| double | fMeanNumber |
| double | fMaxProb |
| double | fTargetPOT |
| int | fSeed |
|
|
Definition at line 7 of file NueExpBuilder.cxx. References cutSet, fBaseline, fDeltaMSquare, fReweight, fSeed, fTheta23, fUe3Square, and outSet. 00007 {
00008 outSet = false;
00009 fReweight = false;
00010 fBaseline = 735;
00011 fDeltaMSquare = 0.0027;
00012 fUe3Square = 0.025;
00013 fTheta23 = TMath::Pi()/4;
00014
00015 fSeed = -10;
00016 cutSet = "Default";
00017 }
|
|
|
Definition at line 19 of file NueExpBuilder.cxx. References files. 00020 {
00021 files.push_back(infiles);
00022 }
|
|
|
Definition at line 196 of file NueExpBuilder.cxx. References cutLevel, cutSet, NueStandard::IsInFid(), NueStandard::PassesMREFiducial(), NueStandard::PassesMREPreSelection(), NueStandard::PassesNonHEPreSelection(), NueStandard::PassesSelection(), NueStandard::PassesSysPreSelection(), and NueStandard::PassesSysPreSelectionNoHE(). Referenced by GenerateExperiment(). 00197 {
00198 if(cutSet == "Default") return true;
00199
00200 if(cutSet == "Fiducial")
00201 return NueStandard::IsInFid(nr);
00202
00203 if(cutSet == "Standard"){
00204 bool ret;
00205 switch(cutLevel){
00206 case 0: return NueStandard::PassesSelection(nr, Selection::kDataQual);
00207 case 1: return NueStandard::PassesSelection(nr, Selection::kFid);
00208 case 2:
00209 ret = NueStandard::PassesSelection(nr, Selection::kFid);
00210 ret = ret && NueStandard::PassesNonHEPreSelection(nr);
00211 return ret;
00212 case 3: return NueStandard::PassesSelection(nr, Selection::kPre);
00213 }
00214 }
00215 if(cutSet == "MRE" || cutSet == "MRCC"){
00216 bool dq = NueStandard::PassesSelection(nr, Selection::kDataQual);
00217 bool mrefid = NueStandard::PassesMREFiducial(nr);
00218 bool mrepre = NueStandard::PassesMREPreSelection(nr) && mrefid && dq;
00219 bool ret;
00220 switch(cutLevel){
00221 case 0: return mrefid && dq;
00222 case 1: return mrepre;
00223 case 2:
00224 return NueStandard::PassesSelection(nr, Selection::kFid) && mrepre;
00225 case 3:
00226 ret = NueStandard::PassesSelection(nr, Selection::kFid);
00227 ret = ret && NueStandard::PassesNonHEPreSelection(nr);
00228 return ret && mrepre;
00229 case 4:
00230 return NueStandard::PassesSelection(nr, Selection::kPre) && mrepre;
00231 }
00232 }
00233 if(cutSet == "Presel")
00234 return NueStandard::PassesSelection(nr, Selection::kPre);
00235
00236 if(cutSet == "PreselNoHE")
00237 return NueStandard::PassesNonHEPreSelection(nr);
00238
00239 if(cutSet == "Systematic"){
00240 // O - standard systematic envelope
00241 // 1 - standard systematic w/out HE cut
00242 if(!NueStandard::IsInFid(nr)) return false;
00243
00244 switch(cutLevel){
00245 case 0: return NueStandard::PassesSysPreSelection(nr);
00246 case 1: return NueStandard::PassesSysPreSelectionNoHE(nr);
00247 }
00248 }
00249
00250
00251 if(cutSet == "CC")
00252 return NueStandard::PassesSelection(nr, Selection::kCC);
00253
00254
00255
00256
00257 std::cout<<"Invalid Cut Level for "<<cutSet<<": "<<cutLevel<<std::endl;
00258 return false;
00259 }
|
|
|
Definition at line 41 of file NueExpBuilder.cxx. References NuePOT::beamtype, count, ANtpTruthInfoBeamNue::DeltamSquared23, EvaluateCuts(), fDeltaMSquare, files, fMaxProb, fMeanNumber, fNumberOfEvents, ANtpTruthInfoBeamNue::fOscProb, fReweight, fSeed, fTheta23, fUe3Square, NueStandard::GetRPWBeamWeight(), max, NueRecord::mctrue, ANtpTruthInfoBeam::nonOscNuFlavor, ANtpTruthInfo::nuEnergy, ANtpTruthInfo::nuFlavor, NueConvention::Oscillate(), outFile, NuePOT::pot, ANtpTruthInfoBeamNue::Theta23, total(), and ANtpTruthInfoBeamNue::Ue3Squared. 00042 {
00043 NueRecord *nr = new NueRecord();
00044 NuePOT *np = new NuePOT();
00045 NuePOT *total = new NuePOT();
00046
00047 TChain *chain = new TChain("ana_nue");
00048
00049 for(unsigned int i = 0; i < files.size(); i++)
00050 {
00051 chain->Add(files[i].c_str());
00052 }
00053
00054 chain->SetBranchAddress("NueRecord",&nr);
00055 chain->SetBranchStatus("fHeader*",1);
00056 chain->SetBranchStatus("fHeader.fVld*",1);
00057 chain->SetBranchStatus("fluxweight*", 1);
00058 chain->SetBranchStatus("mctrue*", 1);
00059
00060 chain->SetBranchStatus("dtree*", 0);
00061 chain->SetBranchStatus("mcnnv*", 0);
00062 chain->SetBranchStatus("timing*", 0);
00063 chain->SetBranchStatus("cdi*", 0);
00064 chain->SetBranchStatus("mri*", 0);
00065 chain->SetBranchStatus("mri*", 0);
00066 chain->SetBranchStatus("treepid*", 0);
00067 chain->SetBranchStatus("highhit*", 0);
00068 chain->SetBranchStatus("mstvar*", 0);
00069 chain->SetBranchStatus("fracvars*", 0);
00070 chain->SetBranchStatus("shield*", 0);
00071 chain->SetBranchStatus("angcluster*", 0);
00072 chain->SetBranchStatus("shwfit*", 0);
00073 chain->SetBranchStatus("hitcalc*", 0);
00074 chain->SetBranchStatus("anainfo*", 0);
00075 chain->SetBranchStatus("mda*", 0);
00076 chain->SetBranchStatus("srshower*", 0);
00077 chain->SetBranchStatus("srtrack*", 0);
00078
00079 std::vector<double> weights;
00080 double max = 0;
00081
00082 Int_t n = chain->GetEntries();
00083
00084 for(int i = 0; i < n; i++){
00085 chain->GetEvent(i);
00086 if(i%10000 == 0) std::cout<<"On call "<<i<<"/"<<n<<std::endl;
00087 double weight =1.0;
00088
00089 if(EvaluateCuts(nr)){
00090 weight *= NueStandard::GetRPWBeamWeight(nr);
00091
00092 if(fReweight && nr->mctrue.nuFlavor > -100)
00093 {
00094 int nuFlavor = nr->mctrue.nuFlavor;
00095 int nonOsc = nr->mctrue.nonOscNuFlavor;
00096 float energy = nr->mctrue.nuEnergy;
00097
00098 Float_t newWeight = NueConvention::Oscillate(nuFlavor, nonOsc, energy, 735, fDeltaMSquare, fTheta23, fUe3Square);
00099
00100 nr->mctrue.Ue3Squared = fUe3Square;
00101 nr->mctrue.DeltamSquared23 = fDeltaMSquare;
00102 nr->mctrue.Theta23 = fTheta23;
00103 nr->mctrue.fOscProb = newWeight;
00104 weight *= newWeight;
00105 }else{ weight *= nr->mctrue.fOscProb; }
00106 }else{weight = 0.0;}
00107
00108 weights.push_back(weight);
00109 if(weight > fMaxProb)
00110 std::cout<<"MaxWeight too small "<<weight<<" "<<fMaxProb<<std::endl;
00111 if(weight > max) max = weight;
00112 }
00113 std::cout<<"Maximum weight: "<<max<<std::endl;
00114
00115
00116 TChain *schain = new TChain("ana_nue");
00117 schain->SetBranchAddress("NueRecord",&nr);
00118
00119 TChain *pchain = new TChain("pottree");
00120 pchain->SetBranchAddress("NuePOT", &np);
00121
00122 TRandom3 fRand;
00123
00124 if(fSeed > -1) fRand.SetSeed(fSeed);
00125
00126
00127 for(unsigned int i = 0; i < files.size(); i++)
00128 {
00129 pchain->Add(files[i].c_str());
00130 schain->Add(files[i].c_str());
00131 }
00132
00133
00134 for(int i = 0; i < nExp; i++){
00135
00136 //check if the target number was given
00137 fNumberOfEvents = fRand.Poisson(fMeanNumber);
00138
00139 char suffix[10];
00140 sprintf(suffix, "Exp%d", i);
00141
00142 std::string outName = outFile + std::string(suffix) + ".root";
00143
00144 TFile *save = new TFile(outName.c_str(),"RECREATE");
00145 TTree *tree = new TTree("ana_nue","ana_nue");
00146 TTree::SetBranchStyle(1);
00147 TBranch* br = tree->Branch("NueRecord","NueRecord", &nr );
00148 br->SetAutoDelete(kFALSE);
00149
00150 int count = 0;
00151 int calls = 0;
00152 std::vector<int> pos;
00153
00154 while( count < fNumberOfEvents){
00155 int entry = (int) fRand.Uniform(n);
00156 double weight = weights[entry];
00157 calls++;
00158
00159 if(calls%200 == 0) std::cout<<"On call "<<calls<<"/"<<count<<std::endl;
00160
00161 double prob = fRand.Uniform(fMaxProb);
00162 if(prob <= weight){
00163 chain->GetEntry(entry);
00164 tree->Fill();
00165 count++;
00166 }
00167 }
00168
00169 std::cout<<"Finished "<<suffix<<" with "<<count <<" events after "<<calls<<std::endl;
00170
00171 TTree *ptree = new TTree("pottree","pottree");
00172 TBranch* br2 = ptree->Branch("NuePOT","NuePOT", &total );
00173 br2->SetAutoDelete(kFALSE);
00174 pchain->GetEntry(0);
00175 total->beamtype = np->beamtype;
00176 total->pot = fTargetPOT;
00177 ptree->Fill();
00178
00179 save->cd();
00180 tree->Write();
00181 ptree->Write();
00182 save->Close();
00183
00184
00185 // delete tree;
00186 // delete ptree;
00187 }
00188 }
|
|
|
Definition at line 36 of file NueExpBuilder.cxx. 00036 {return fMaxProb;}
|
|
|
Definition at line 33 of file NueExpBuilder.cxx. References fBaseline, and fReweight.
|
|
||||||||||||
|
Definition at line 190 of file NueExpBuilder.cxx. References cutLevel, and cutSet.
|
|
|
Definition at line 30 of file NueExpBuilder.cxx. References fDeltaMSquare, and fReweight. 00030 { fDeltaMSquare = dm2; fReweight = true;}
|
|
|
Definition at line 35 of file NueExpBuilder.cxx. References fMaxProb. 00035 {fMaxProb = max;}
|
|
|
Definition at line 38 of file NueExpBuilder.cxx. References fMeanNumber. 00038 {fMeanNumber = num;}
|
|
|
Definition at line 39 of file NueExpBuilder.cxx. References fNumberOfEvents. 00039 {fNumberOfEvents = num; }
|
|
|
Definition at line 24 of file NueExpBuilder.cxx. References outFile, and outSet.
|
|
|
Definition at line 47 of file NueExpBuilder.h. 00047 {fSeed = in;};
|
|
|
Definition at line 40 of file NueExpBuilder.h. 00040 {fTargetPOT = num;};
|
|
|
Definition at line 32 of file NueExpBuilder.cxx. References fReweight, and fTheta23.
|
|
|
Definition at line 31 of file NueExpBuilder.cxx. References fReweight, and fUe3Square. 00031 { fUe3Square = dUe32; fReweight = true;}
|
|
|
Definition at line 64 of file NueExpBuilder.h. Referenced by EvaluateCuts(), and SetCuts(). |
|
|
Definition at line 63 of file NueExpBuilder.h. Referenced by EvaluateCuts(), NueExpBuilder(), and SetCuts(). |
|
|
Definition at line 60 of file NueExpBuilder.h. Referenced by NueExpBuilder(), and SetBaseline(). |
|
|
Definition at line 57 of file NueExpBuilder.h. Referenced by GenerateExperiment(), NueExpBuilder(), and SetDeltaMSquare(). |
|
|
Definition at line 55 of file NueExpBuilder.h. Referenced by AddFiles(), and GenerateExperiment(). |
|
|
Definition at line 70 of file NueExpBuilder.h. Referenced by GenerateExperiment(), and SetMaxProb(). |
|
|
Definition at line 69 of file NueExpBuilder.h. Referenced by GenerateExperiment(), and SetMeanNumberOfEvents(). |
|
|
Definition at line 68 of file NueExpBuilder.h. Referenced by GenerateExperiment(), and SetNumberOfEvents(). |
|
|
Definition at line 66 of file NueExpBuilder.h. |
|
|
Definition at line 61 of file NueExpBuilder.h. Referenced by GenerateExperiment(), NueExpBuilder(), SetBaseline(), SetDeltaMSquare(), SetTheta23(), and SetUe3Square(). |
|
|
Definition at line 72 of file NueExpBuilder.h. Referenced by GenerateExperiment(), and NueExpBuilder(). |
|
|
Definition at line 71 of file NueExpBuilder.h. |
|
|
Definition at line 59 of file NueExpBuilder.h. Referenced by GenerateExperiment(), NueExpBuilder(), and SetTheta23(). |
|
|
Definition at line 58 of file NueExpBuilder.h. Referenced by GenerateExperiment(), NueExpBuilder(), and SetUe3Square(). |
|
|
Definition at line 53 of file NueExpBuilder.h. Referenced by GenerateExperiment(), and SetOutputFile(). |
|
|
Definition at line 54 of file NueExpBuilder.h. Referenced by NueExpBuilder(), and SetOutputFile(). |
1.3.9.1