void CrossTalk::CreateHistograms() { fH2.clear(); for(int det_num=1; det_num<=16; ++det_num){ std::string aedet_str = Form("aEdet%d",det_num); std::string gedet_str = Form("gEdet%d",det_num); std::string ae2det_str = Form("aE2det%d",det_num); fH1[aedet_str] = new TH1D(Form("aEdet%d",det_num),Form("Addback detector %d",det_num),1500,0,1500); fH1[gedet_str] = new TH1D(Form("geEdet%d",det_num),Form("Singles detector %d",det_num),1500,0,1500); fH1[ae2det_str] = new TH1D(Form("aE2det%d",det_num),Form("Addback with 2 hits, detector %d",det_num),1500,0,1500); for(int crys_1=0; crys_1 <4; ++crys_1){ for(int crys_2=crys_1+1;crys_2<4;++crys_2){ std::string name_str = Form("det_%d_%d_%d",det_num,crys_1,crys_2); const char* hist_name = name_str.c_str(); std::cout << "Creating histogram: " << hist_name; fH2[name_str] = new TH2I(hist_name,hist_name,1500,0,1500,1500,0,1500); std::cout << " at address: " << fH2[hist_name] << std::endl; } } } fH1["aMult"] = new TH1D("aMult","addback multilpicity",20,0,20); fH2["gE_chan"] = new TH2D("gE_chan","gE_chan",65,0,65,1500,0,1500); fH1["aE"] = new TH1D("aE", "Summed Addback", 1500,0,1500); fH1["gE"] = new TH1D("gE", "Summed Singles", 1500,0,1500); fH1["gEnoCT"] = new TH1D("gEnoCT", "Singles, no CT correction", 1500,0,1500); for(auto it : fH1) { GetOutputList()->Add(it.second); } for(auto it : fH2) { GetOutputList()->Add(it.second); } for(auto it : fHSparse) { GetOutputList()->Add(it.second); } }
void Expectation::Terminate() { GetOutputList()->Print(); std::cout << "tExpectation_:" << tExpectation_ << '\n'; tExpectation_ = dynamic_cast<TTree*>(GetOutputList()->FindObject("LostLeptonExpectation")); std::cout << "tExpectation_:" << tExpectation_ << '\n'; TFile *outPutFile = new TFile("macros/junews/lostleptons/arne/Expectation/Expectation_data.root","RECREATE"); outPutFile->cd(); tExpectation_->Write(); outPutFile->Close(); }
void ExampleEventSelector::CreateHistograms() { fH1["gE"] = new TH1D("gE","#gamma Singles",12000,0,3000); fH1["gE_b"] = new TH1D("gE_b","#gamma Singles in rough #beta coincidence",12000,0,3000); for(auto it : fH1) { GetOutputList()->Add(it.second); } for(auto it : fH2) { GetOutputList()->Add(it.second); } for(auto it : fHSparse) { GetOutputList()->Add(it.second); } }
void analysis_t_test1::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. TFile file_out("analysis_t_test1_output.root","recreate"); TList *outlist = GetOutputList(); outlist->Write(); file_out.Write(); file_out.Close(); }
void TagAndProbe::Terminate() { GetOutputList()->Print(); tTagAndProbeMuIso_ = dynamic_cast<TTree*>(GetOutputList()->FindObject("TagAndProbeMuIso")); TFile *outPutFile = new TFile("TagAndProbe_HT400_NJets3_4_MinDeltaPhi-9999_activity0DR1_test.root","RECREATE"); outPutFile->cd(); outPutFile->mkdir("MuIso"); TDirectory *dMuIso = (TDirectory*)outPutFile->Get("MuIso"); dMuIso->cd(); tTagAndProbeMuIso_->Write(); outPutFile->mkdir("MuReco"); TDirectory *dMuReco = (TDirectory*)outPutFile->Get("MuReco"); dMuReco->cd(); tTagAndProbeMuReco_->Write(); outPutFile->mkdir("ElecIso"); TDirectory *dElecIso = (TDirectory*)outPutFile->Get("ElecIso"); dElecIso->cd(); tTagAndProbeElecIso_->Write(); outPutFile->mkdir("ElecReco"); TDirectory *dElecReco = (TDirectory*)outPutFile->Get("ElecReco"); dElecReco->cd(); tTagAndProbeElecReco_->Write(); outPutFile->Close(); if(truthMatching_) { std::cout<<"Truth matching result for the Tag lepton:\n"; std::cout<<"IsoMuon: Matched to truth: "<<eventsGenMatchForTagLeptonIsoMu_<<" not matched: "<<eventsFailingGenMatchForTagLeptonIsoMu_<<" loss: "<<eventsFailingGenMatchForTagLeptonIsoMu_/(eventsFailingGenMatchForTagLeptonIsoMu_ + eventsGenMatchForTagLeptonIsoMu_)*100<<"%\n"; std::cout<<"RecoMuon: Matched to truth: "<<eventsGenMatchForTagLeptonRecoMu_<<" not matched: "<<eventsFailingGenMatchForTagLeptonRecoMu_<<" loss: "<<eventsFailingGenMatchForTagLeptonRecoMu_/(eventsFailingGenMatchForTagLeptonRecoMu_ + eventsGenMatchForTagLeptonRecoMu_)*100<<"%\n"; std::cout<<"IsoElec: Matched to truth: "<<eventsGenMatchForTagLeptonIsoElec_<<" not matched: "<<eventsFailingGenMatchForTagLeptonIsoElec_<<" loss: "<<eventsFailingGenMatchForTagLeptonIsoElec_/(eventsFailingGenMatchForTagLeptonIsoElec_ + eventsGenMatchForTagLeptonIsoElec_)*100<<"%\n"; std::cout<<"RecoElec: Matched to truth: "<<eventsGenMatchForTagLeptonRecoElec_<<" not matched: "<<eventsFailingGenMatchForTagLeptonRecoElec_<<" loss: "<<eventsFailingGenMatchForTagLeptonRecoElec_/(eventsFailingGenMatchForTagLeptonRecoElec_ + eventsGenMatchForTagLeptonRecoElec_)*100<<"%\n"; } // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. }
void TagAndProbe::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // mu iso tree tTagAndProbeMuIso_ = new TTree("TagAndProbeMuIso","a simple Tree with simple variables"); tTagAndProbeMuIso_->Branch("EvtNum",&EvtNum,"EvtNum/i"); tTagAndProbeMuIso_->Branch("HT",&HT,"HT/F"); tTagAndProbeMuIso_->Branch("MHT",&MHT,"MHT/F"); tTagAndProbeMuIso_->Branch("NJets",&NJets,"NJets/s"); tTagAndProbeMuIso_->Branch("BTags",&BTags,"BTags/s"); tTagAndProbeMuIso_->Branch("Leptons",&Leptons,"Leptons/s"); tTagAndProbeMuIso_->Branch("NVtx",&NVtx,"NVtx/s"); tTagAndProbeMuIso_->Branch("DeltaPhi1",&DeltaPhi1,"DeltaPhi1/F"); tTagAndProbeMuIso_->Branch("DeltaPhi2",&DeltaPhi2,"DeltaPhi2/F"); tTagAndProbeMuIso_->Branch("DeltaPhi3",&DeltaPhi3,"DeltaPhi3/F"); tTagAndProbeMuIso_->Branch("minDeltaPhiN",&minDeltaPhiN,"minDeltaPhiN/F"); tTagAndProbeMuIso_->Branch("DeltaPhiN1",&DeltaPhiN1,"DeltaPhiN1/F"); tTagAndProbeMuIso_->Branch("DeltaPhiN2",&DeltaPhiN2,"DeltaPhiN2/F"); tTagAndProbeMuIso_->Branch("DeltaPhiN3",&DeltaPhiN3,"DeltaPhiN3/F"); tTagAndProbeMuIso_->Branch("Weight", &Weight, "Weight/F"); tTagAndProbeMuIso_->Branch("Pass", &Probe_PassingOrFail_, "Pass/I"); tTagAndProbeMuIso_->Branch("InvariantMass", &Probe_InvariantMass_, "InvariantMass/F"); tTagAndProbeMuIso_->Branch("Pt", &ProbePt_, "Pt/F"); tTagAndProbeMuIso_->Branch("Eta", &ProbeEta_, "Eta/F"); tTagAndProbeMuIso_->Branch("Phi", &ProbePhi_, "Phi/F"); tTagAndProbeMuIso_->Branch("Activity", &ProbeActivity_, "Activity/F"); GetOutputList()->Add(tTagAndProbeMuIso_); // mu reco tree tTagAndProbeMuReco_ = new TTree("TagAndProbeMuReco","a simple Tree with simple variables"); tTagAndProbeMuReco_->Branch("EvtNum",&EvtNum,"EvtNum/i"); tTagAndProbeMuReco_->Branch("HT",&HT,"HT/F"); tTagAndProbeMuReco_->Branch("MHT",&MHT,"MHT/F"); tTagAndProbeMuReco_->Branch("NJets",&NJets,"NJets/s"); tTagAndProbeMuReco_->Branch("BTags",&BTags,"BTags/s"); tTagAndProbeMuReco_->Branch("Leptons",&Leptons,"Leptons/s"); tTagAndProbeMuReco_->Branch("NVtx",&NVtx,"NVtx/s"); tTagAndProbeMuReco_->Branch("DeltaPhi1",&DeltaPhi1,"DeltaPhi1/F"); tTagAndProbeMuReco_->Branch("DeltaPhi2",&DeltaPhi2,"DeltaPhi2/F"); tTagAndProbeMuReco_->Branch("DeltaPhi3",&DeltaPhi3,"DeltaPhi3/F"); tTagAndProbeMuReco_->Branch("minDeltaPhiN",&minDeltaPhiN,"minDeltaPhiN/F"); tTagAndProbeMuReco_->Branch("DeltaPhiN1",&DeltaPhiN1,"DeltaPhiN1/F"); tTagAndProbeMuReco_->Branch("DeltaPhiN2",&DeltaPhiN2,"DeltaPhiN2/F"); tTagAndProbeMuReco_->Branch("DeltaPhiN3",&DeltaPhiN3,"DeltaPhiN3/F"); tTagAndProbeMuReco_->Branch("Weight", &Weight, "Weight/F"); tTagAndProbeMuReco_->Branch("Pass", &Probe_PassingOrFail_, "Pass/I"); tTagAndProbeMuReco_->Branch("InvariantMass", &Probe_InvariantMass_, "InvariantMass/F"); tTagAndProbeMuReco_->Branch("Pt", &ProbePt_, "Pt/F"); tTagAndProbeMuReco_->Branch("Eta", &ProbeEta_, "Eta/F"); tTagAndProbeMuReco_->Branch("Phi", &ProbePhi_, "Phi/F"); tTagAndProbeMuReco_->Branch("Activity", &ProbeActivity_, "Activity/F"); GetOutputList()->Add(tTagAndProbeMuReco_); // elec iso tree tTagAndProbeElecIso_ = new TTree("TagAndProbeElecIso","a simple Tree with simple variables"); tTagAndProbeElecIso_->Branch("EvtNum",&EvtNum,"EvtNum/i"); tTagAndProbeElecIso_->Branch("HT",&HT,"HT/F"); tTagAndProbeElecIso_->Branch("MHT",&MHT,"MHT/F"); tTagAndProbeElecIso_->Branch("NJets",&NJets,"NJets/s"); tTagAndProbeElecIso_->Branch("BTags",&BTags,"BTags/s"); tTagAndProbeElecIso_->Branch("Leptons",&Leptons,"Leptons/s"); tTagAndProbeElecIso_->Branch("NVtx",&NVtx,"NVtx/s"); tTagAndProbeElecIso_->Branch("DeltaPhi1",&DeltaPhi1,"DeltaPhi1/F"); tTagAndProbeElecIso_->Branch("DeltaPhi2",&DeltaPhi2,"DeltaPhi2/F"); tTagAndProbeElecIso_->Branch("DeltaPhi3",&DeltaPhi3,"DeltaPhi3/F"); tTagAndProbeElecIso_->Branch("minDeltaPhiN",&minDeltaPhiN,"minDeltaPhiN/F"); tTagAndProbeElecIso_->Branch("DeltaPhiN1",&DeltaPhiN1,"DeltaPhiN1/F"); tTagAndProbeElecIso_->Branch("DeltaPhiN2",&DeltaPhiN2,"DeltaPhiN2/F"); tTagAndProbeElecIso_->Branch("DeltaPhiN3",&DeltaPhiN3,"DeltaPhiN3/F"); tTagAndProbeElecIso_->Branch("Weight", &Weight, "Weight/F"); tTagAndProbeElecIso_->Branch("Pass", &Probe_PassingOrFail_, "Pass/I"); tTagAndProbeElecIso_->Branch("InvariantMass", &Probe_InvariantMass_, "InvariantMass/F"); tTagAndProbeElecIso_->Branch("Pt", &ProbePt_, "Pt/F"); tTagAndProbeElecIso_->Branch("Eta", &ProbeEta_, "Eta/F"); tTagAndProbeElecIso_->Branch("Phi", &ProbePhi_, "Phi/F"); tTagAndProbeElecIso_->Branch("Activity", &ProbeActivity_, "Activity/F"); GetOutputList()->Add(tTagAndProbeElecIso_); // elec reco tree tTagAndProbeElecReco_ = new TTree("TagAndProbeElecReco","a simple Tree with simple variables"); tTagAndProbeElecReco_->Branch("EvtNum",&EvtNum,"EvtNum/i"); tTagAndProbeElecReco_->Branch("HT",&HT,"HT/F"); tTagAndProbeElecReco_->Branch("MHT",&MHT,"MHT/F"); tTagAndProbeElecReco_->Branch("NJets",&NJets,"NJets/s"); tTagAndProbeElecReco_->Branch("BTags",&BTags,"BTags/s"); tTagAndProbeElecReco_->Branch("Leptons",&Leptons,"Leptons/s"); tTagAndProbeElecReco_->Branch("NVtx",&NVtx,"NVtx/s"); tTagAndProbeElecReco_->Branch("DeltaPhi1",&DeltaPhi1,"DeltaPhi1/F"); tTagAndProbeElecReco_->Branch("DeltaPhi2",&DeltaPhi2,"DeltaPhi2/F"); tTagAndProbeElecReco_->Branch("DeltaPhi3",&DeltaPhi3,"DeltaPhi3/F"); tTagAndProbeElecReco_->Branch("minDeltaPhiN",&minDeltaPhiN,"minDeltaPhiN/F"); tTagAndProbeElecReco_->Branch("DeltaPhiN1",&DeltaPhiN1,"DeltaPhiN1/F"); tTagAndProbeElecReco_->Branch("DeltaPhiN2",&DeltaPhiN2,"DeltaPhiN2/F"); tTagAndProbeElecReco_->Branch("DeltaPhiN3",&DeltaPhiN3,"DeltaPhiN3/F"); tTagAndProbeElecReco_->Branch("Weight", &Weight, "Weight/F"); tTagAndProbeElecReco_->Branch("Pass", &Probe_PassingOrFail_, "Pass/I"); tTagAndProbeElecReco_->Branch("InvariantMass", &Probe_InvariantMass_, "InvariantMass/F"); tTagAndProbeElecReco_->Branch("Pt", &ProbePt_, "Pt/F"); tTagAndProbeElecReco_->Branch("Eta", &ProbeEta_, "Eta/F"); tTagAndProbeElecReco_->Branch("Phi", &ProbePhi_, "Phi/F"); tTagAndProbeElecReco_->Branch("Activity", &ProbeActivity_, "Activity/F"); GetOutputList()->Add(tTagAndProbeElecReco_); std::cout<<"Applying filters: "<<applyFilters_<<std::endl; if(truthMatching_)std::cout<<"WARNING::Using Truth Matching ONLY FOR TESTING DO NOT USE FOR PHYSIC RESULTS!!!!!"<<std::endl; eventsGenMatchForTagLeptonIsoMu_=0; eventsGenMatchForTagLeptonRecoMu_=0; eventsGenMatchForTagLeptonIsoElec_=0; eventsGenMatchForTagLeptonRecoElec_=0; eventsFailingGenMatchForTagLeptonIsoMu_=0; eventsFailingGenMatchForTagLeptonRecoMu_=0; eventsFailingGenMatchForTagLeptonIsoElec_=0; eventsFailingGenMatchForTagLeptonRecoElec_=0; }
void AngularCorrelationSelector::CreateHistograms() { std::cout<<"creating histograms ..."<<std::endl; //for each angle (and the sum) we want //for single crystal and addback //with and without coincident betas //coincident and time-random gamma-gamma for(int i = 0; i < static_cast<int>(fAngleCombinations.size()); ++i) { fH2[Form("gammaGamma%d", i)] = new TH2D(Form("gammaGamma%d", i), Form("%.1f^{o}: #gamma-#gamma, |#Deltat_{#gamma-#gamma}| < %.1f", fAngleCombinations[i].first, ggHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("gammaGammaBeta%d", i)] = new TH2D(Form("gammaGammaBeta%d", i), Form("%.1f^{o}: #gamma-#gamma, |#Deltat_{#gamma-#gamma}| < %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinations[i].first, ggHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("gammaGammaBG%d", i)] = new TH2D(Form("gammaGammaBG%d", i), Form("%.1f^{o}: #gamma-#gamma, #Deltat_{#gamma-#gamma} = %.1f - %.1f", fAngleCombinations[i].first, bgLow, bgHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("gammaGammaBetaBG%d", i)] = new TH2D(Form("gammaGammaBetaBG%d", i), Form("%.1f^{o}: #gamma-#gamma, #Deltat_{#gamma-#gamma} = %.1f - %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinations[i].first, bgLow, bgHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); } for(int i = 0; i < static_cast<int>(fAngleCombinationsAddback.size()); ++i) { fH2[Form("addbackAddback%d", i)] = new TH2D(Form("addbackAddback%d", i), Form("%.1f^{o}: #gamma-#gamma with addback, |#Deltat_{#gamma-#gamma}| < %.1f", fAngleCombinationsAddback[i].first, ggHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("addbackAddbackBeta%d", i)] = new TH2D(Form("addbackAddbackBeta%d", i), Form("%.1f^{o}: #gamma-#gamma with addback, |#Deltat_{#gamma-#gamma}| < %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinationsAddback[i].first, ggHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("addbackAddbackBG%d", i)] = new TH2D(Form("addbackAddbackBG%d", i), Form("%.1f^{o}: #gamma-#gamma with addback, #Deltat_{#gamma-#gamma} = %.1f - %.1f", fAngleCombinationsAddback[i].first, bgLow, bgHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("addbackAddbackBetaBG%d", i)] = new TH2D(Form("addbackAddbackBetaBG%d", i), Form("%.1f^{o}: #gamma-#gamma with addback, #Deltat_{#gamma-#gamma} = %.1f - %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinationsAddback[i].first, bgLow, bgHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); } fH2["gammaGamma"] = new TH2D("gammaGamma",Form("#gamma-#gamma, |#Deltat_{#gamma-#gamma}| < %.1f", ggHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["gammaGammaBeta"] = new TH2D("gammaGammaBeta",Form("#gamma-#gamma, |#Deltat_{#gamma-#gamma}| < %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", ggHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["gammaGammaBG"] = new TH2D("gammaGammaBG",Form("#gamma-#gamma, #Deltat_{#gamma-#gamma} = %.1f - %.1f", bgLow, bgHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["gammaGammaBetaBG"] = new TH2D("gammaGammaBetaBG",Form("#gamma-#gamma, #Deltat_{#gamma-#gamma} = %.1f - %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", bgLow, bgHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddback"] = new TH2D("addbackAddback",Form("#gamma-#gamma with addback, |#Deltat_{#gamma-#gamma}| < %.1f", ggHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddbackBeta"] = new TH2D("addbackAddbackBeta",Form("#gamma-#gamma with addback, |#Deltat_{#gamma-#gamma}| < %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f",ggHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddbackBG"] = new TH2D("addbackAddbackBG",Form("#gamma-#gamma with addback, #Deltat_{#gamma-#gamma} = %.1f - %.1f", bgLow, bgHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddbackBetaBG"] = new TH2D("addbackAddbackBetaBG",Form("#gamma-#gamma with addback, #Deltat_{#gamma-#gamma} = %.1f - %.1f, #Deltat_{#gamma-#beta} = %.1f - %.1f", bgLow, bgHigh, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); //plus hitpatterns for gamma-gamma and beta-gamma for single crystals fH2["gammaGammaHP"] = new TH2D("gammaGammaHP","#gamma-#gamma hit pattern", 65, 0., 65., 65, 0., 65.); fH2["betaGammaHP"] = new TH2D("betaGammaHP","#beta-#gamma hit pattern", 21, 0., 21., 65, 0., 65.); fH2["addbackAddbackHP"] = new TH2D("addbackAddbackHP","#gamma-#gamma hit pattern with addback", 65, 0., 65., 65, 0., 65.); fH2["betaAddbackHP"] = new TH2D("betaAddbackHP","#beta-#gamma hit pattern with addback", 21, 0., 21., 65, 0., 65.); //same for event mixing for(int i = 0; i < static_cast<int>(fAngleCombinations.size()); ++i) { fH2[Form("gammaGammaMixed%d", i)] = new TH2D(Form("gammaGammaMixed%d", i), Form("%.1f^{o}: #gamma-#gamma", fAngleCombinations[i].first), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("gammaGammaBetaMixed%d", i)] = new TH2D(Form("gammaGammaBetaMixed%d", i), Form("%.1f^{o}: #gamma-#gamma, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinations[i].first, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); } for(int i = 0; i < static_cast<int>(fAngleCombinationsAddback.size()); ++i) { fH2[Form("addbackAddbackMixed%d", i)] = new TH2D(Form("addbackAddbackMixed%d", i), Form("%.1f^{o}: #gamma-#gamma with addback", fAngleCombinationsAddback[i].first), 2000, 0., 2000., 2000, 0., 2000.); fH2[Form("addbackAddbackBetaMixed%d", i)] = new TH2D(Form("addbackAddbackBetaMixed%d", i), Form("%.1f^{o}: #gamma-#gamma with addback, #Deltat_{#gamma-#beta} = %.1f - %.1f", fAngleCombinationsAddback[i].first, gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); } fH2["gammaGammaMixed"] = new TH2D("gammaGammaMixed","#gamma-#gamma", 2000, 0., 2000., 2000, 0., 2000.); fH2["gammaGammaBetaMixed"] = new TH2D("gammaGammaBetaMixed",Form("#gamma-#gamma, #Deltat_{#gamma-#beta} = %.1f - %.1f", gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddbackMixed"] = new TH2D("addbackAddbackMixed","#gamma-#gamma with addback", 2000, 0., 2000., 2000, 0., 2000.); fH2["addbackAddbackBetaMixed"] = new TH2D("addbackAddbackBetaMixed",Form("#gamma-#gamma with addback, #Deltat_{#gamma-#beta} = %.1f - %.1f", gbLow, gbHigh), 2000, 0., 2000., 2000, 0., 2000.); //plus hitpatterns for gamma-gamma and beta-gamma for single crystals fH2["gammaGammaHPMixed"] = new TH2D("gammaGammaHPMixed","#gamma-#gamma hit pattern", 65, 0., 65., 65, 0., 65.); fH2["betaGammaHPMixed"] = new TH2D("betaGammaHPMixed","#beta-#gamma hit pattern", 21, 0., 21., 65, 0., 65.); fH2["addbackAddbackHPMixed"] = new TH2D("addbackAddbackHPMixed","#gamma-#gamma hit pattern with addback", 65, 0., 65., 65, 0., 65.); fH2["betaAddbackHPMixed"] = new TH2D("betaAddbackHPMixed","#beta-#gamma hit pattern with addback", 21, 0., 21., 65, 0., 65.); //additionally 1D spectra of gammas //for single crystal and addback //with and without coincident betas fH1["gammaEnergy"] = new TH1D("gammaEnergy","#gamma Singles", 12000, 0, 3000); fH1["gammaEnergyBeta"] = new TH1D("gammaEnergyBeta","#gamma singles in rough #beta coincidence", 12000, 0, 3000); fH1["addbackEnergy"] = new TH1D("addbackEnergy","#gamma singles with addback", 12000, 0, 3000); fH1["addbackEnergyBeta"] = new TH1D("addbackEnergyBeta","#gamma singles with addback in rough #beta coincidence", 12000, 0, 3000); //and timing spectra for gamma-gamma and beta-gamma fH1["gammaGammaTiming"] = new TH1D("gammaGammaTiming","#Deltat_{#gamma-#gamma}", 3000, 0., 3000.); fH1["betaGammaTiming"] = new TH1D("betaGammaTiming","#Deltat_{#beta-#gamma}", 2000, -1000., 1000.); fH1["addbackAddbackTiming"] = new TH1D("addbackAddbackTiming","#Deltat_{#addback-#addback}", 2000, 0., 3000.); fH1["betaAddbackTiming"] = new TH1D("betaAddbackTiming","#Deltat_{#beta-#gamma}", 2000, -1000., 1000.); for(auto it : fH1) { GetOutputList()->Add(it.second); } for(auto it : fH2) { GetOutputList()->Add(it.second); } for(auto it : fHSparse) { GetOutputList()->Add(it.second); } std::cout<<"done"<<std::endl; }
void ExampleFragmentSelector::CreateHistograms() { hp_charge = new TH2F("hp_charge","Channel vs Charge",128,0,128,24000,0,12000); hp_energy = new TH2F("hp_energy","Channel vs Energy",128,0,128,16000,0,8000); GetOutputList()->AddAll(gDirectory->GetList()); }
void EventSelector_Unf::SlaveBegin(TTree*) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); this_momCorrType = dynamic_cast<TNamed *>(fInput->FindObject("momCorrType")); momCorrType = this_momCorrType ? this_momCorrType->GetTitle() : ""; this_mode = dynamic_cast<TNamed *>(fInput->FindObject("mode")); mode = this_mode ? this_mode->GetTitle() : ""; //rochcorr rmcor = new rochcor2012(); //normalization histogram Nntuple = new TH1D("norm", "norm", 1,0,1); //1D set up const int nbin = 40; double mass_xbin[nbin+1] = {15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 64, 68, 72, 76, 81, 86, 91, 96, 101, 106, 110, 115, 120, 126, 133, 141, 150, 160, 171, 185, 200, 220, 243, 273, 320, 380, 440, 510, 600, 1000, 1500}; hmeas = new TH1D("hmeas", "hmeas", nbin, mass_xbin); htrue = new TH1D("htrue", "htrue", nbin, mass_xbin); hden = new TH2D("hden", "hden", nbin, mass_xbin, nbin, mass_xbin); hmeas_Roch = new TH1D("hmeas_Roch", "hmeas_Roch", nbin, mass_xbin); htrue_Roch = new TH1D("htrue_Roch", "htrue_Roch", nbin, mass_xbin); hden_Roch = new TH2D("hden_Roch", "hden_Roch", nbin, mass_xbin, nbin, mass_xbin); hmeas_PU = new TH1D("hmeas_PU", "hmeas_PU", nbin, mass_xbin); htrue_PU = new TH1D("htrue_PU", "htrue_PU", nbin, mass_xbin); hden_PU = new TH2D("hden_PU", "hden_PU", nbin, mass_xbin, nbin, mass_xbin); hmeas_corr = new TH1D("hmeas_corr", "hmeas_corr", nbin, mass_xbin); htrue_corr = new TH1D("htrue_corr", "htrue_corr", nbin, mass_xbin); hden_corr = new TH2D("hden_corr", "hden_corr", nbin, mass_xbin, nbin, mass_xbin); //2D set up // 20-30: 24 bins // 30-45: 24 bins // 45-60: 24 bins // 60-120: 24 bins // 120-200: 24 bins // 200-1500: 12 bins // total 132 bins const int nbin2 = 132; double mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500}; hmeas2 = new TH1D("hmeas2", "hmeas2", nbin2, 0, 132); htrue2 = new TH1D("htrue2", "htrue2", nbin2, 0, 132); hden2 = new TH2D("hden2", "hden2", nbin2, 0, 132, nbin2, 0, 132); hmeas2_Roch = new TH1D("hmeas2_Roch", "hmeas2_Roch", nbin2, 0, 132); htrue2_Roch = new TH1D("htrue2_Roch", "htrue2_Roch", nbin2, 0, 132); hden2_Roch = new TH2D("hden2_Roch", "hden2_Roch", nbin2, 0, 132, nbin2, 0, 132); hmeas2_PU = new TH1D("hmeas2_PU", "hmeas2_PU", nbin2, 0, 132); htrue2_PU = new TH1D("htrue2_PU", "htrue2_PU", nbin2, 0, 132); hden2_PU = new TH2D("hden2_PU", "hden2_PU", nbin2, 0, 132, nbin2, 0, 132); hmeas2_corr = new TH1D("hmeas2_corr", "hmeas2_corr", nbin2, 0, 132); htrue2_corr = new TH1D("htrue2_corr", "htrue2_corr", nbin2, 0, 132); hden2_corr = new TH2D("hden2_corr", "hden2_corr", nbin2, 0, 132, nbin2, 0, 132); //FIXME over under flow hmeas2_24 = new TH1D("hmeas2_24", "hmeas2_24", 24,0,24); htrue2_24 = new TH1D("htrue2_24", "htrue2_24", 24,0,24); //hmeas2_12 = new TH1D("hmeas2_12", "hmeas2_12", 12,0,24); //htrue2_12 = new TH1D("htrue2_12", "htrue2_12", 12,0,24); hden2_156 = new TH2D("hden2_156", "hden2_156", 156,0,156,156,0,156); hmeas2_24_Roch = new TH1D("hmeas2_24_Roch", "hmeas2_24_Roch", 24,0,24); htrue2_24_Roch = new TH1D("htrue2_24_Roch", "htrue2_24_Roch", 24,0,24); //hmeas2_12_Roch = new TH1D("hmeas2_12_Roch", "hmeas2_12_Roch", 12,0,24); //htrue2_12_Roch = new TH1D("htrue2_12_Roch", "htrue2_12_Roch", 12,0,24); hden2_156_Roch = new TH2D("hden2_156_Roch", "hden2_156_Roch", 156,0,156,156,0,156); hmeas2_24_PU = new TH1D("hmeas2_24_PU", "hmeas2_24_PU", 24,0,24); htrue2_24_PU = new TH1D("htrue2_24_PU", "htrue2_24_PU", 24,0,24); //hmeas2_12_PU = new TH1D("hmeas2_12_PU", "hmeas2_12_PU", 12,0,24); //htrue2_12_PU = new TH1D("htrue2_12_PU", "htrue2_12_PU", 12,0,24); hden2_156_PU = new TH2D("hden2_156_PU", "hden2_156_PU", 156,0,156,156,0,156); hmeas2_24_corr = new TH1D("hmeas2_24_corr", "hmeas2_24_corr", 24,0,24); htrue2_24_corr = new TH1D("htrue2_24_corr", "htrue2_24_corr", 24,0,24); //hmeas2_12_corr = new TH1D("hmeas2_12_corr", "hmeas2_12_corr", 12,0,24); //htrue2_12_corr = new TH1D("htrue2_12_corr", "htrue2_12_corr", 12,0,24); hden2_156_corr = new TH2D("hden2_156_corr", "hden2_156_corr", 156,0,156,156,0,156); GetOutputList()->Add(Nntuple); GetOutputList()->Add(hmeas); GetOutputList()->Add(htrue); GetOutputList()->Add(hden); GetOutputList()->Add(hmeas2); GetOutputList()->Add(htrue2); GetOutputList()->Add(hden2); GetOutputList()->Add(hmeas_Roch); GetOutputList()->Add(htrue_Roch); GetOutputList()->Add(hden_Roch); GetOutputList()->Add(hmeas2_Roch); GetOutputList()->Add(htrue2_Roch); GetOutputList()->Add(hden2_Roch); GetOutputList()->Add(hmeas_PU); GetOutputList()->Add(htrue_PU); GetOutputList()->Add(hden_PU); GetOutputList()->Add(hmeas2_PU); GetOutputList()->Add(htrue2_PU); GetOutputList()->Add(hden2_PU); GetOutputList()->Add(hmeas_corr); GetOutputList()->Add(htrue_corr); GetOutputList()->Add(hden_corr); GetOutputList()->Add(hmeas2_corr); GetOutputList()->Add(htrue2_corr); GetOutputList()->Add(hden2_corr); GetOutputList()->Add(hmeas2_24); GetOutputList()->Add(htrue2_24); //GetOutputList()->Add(hmeas2_12); //GetOutputList()->Add(htrue2_12); GetOutputList()->Add(hden2_156); GetOutputList()->Add(hmeas2_24_Roch); GetOutputList()->Add(htrue2_24_Roch); //GetOutputList()->Add(hmeas2_12_Roch); //GetOutputList()->Add(htrue2_12_Roch); GetOutputList()->Add(hden2_156_Roch); GetOutputList()->Add(hmeas2_24_PU); GetOutputList()->Add(htrue2_24_PU); //GetOutputList()->Add(hmeas2_12_PU); //GetOutputList()->Add(htrue2_12_PU); GetOutputList()->Add(hden2_156_PU); GetOutputList()->Add(hmeas2_24_corr); GetOutputList()->Add(htrue2_24_corr); //GetOutputList()->Add(hmeas2_12_corr); //GetOutputList()->Add(htrue2_12_corr); GetOutputList()->Add(hden2_156_corr); ds = new TNamed(TString("outfile"),dataset); GetOutputList()->Add(ds); }
void EventAnalyzer::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // Defining histograms const Double_t areaL = 200.; const Double_t areaW = 140.; const Double_t plateL = 125.; const Double_t plateW = 82.4; //Double_t binW = 0.02; fHisAll = new TH3D("HisAll", "Deposited Energy", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 450, -10., 35.); fHisAll->SetXTitle("[mm]"); fHisAll->SetYTitle("[mm]"); fHisAll->SetZTitle("[mm]"); GetOutputList()->Add(fHisAll); fHisSealing = new TH3D("HisSealing", "Deposited Energy at Sealing", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 60, -6., 0.); fHisSealing->SetXTitle("[mm]"); fHisSealing->SetYTitle("[mm]"); fHisSealing->SetZTitle("[mm]"); GetOutputList()->Add(fHisSealing); fHisWindow = new TH3D("HisWindow", "Deposited Energy at Window", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 20, -1., 1.); fHisWindow->SetXTitle("[mm]"); fHisWindow->SetYTitle("[mm]"); fHisWindow->SetZTitle("[mm]"); GetOutputList()->Add(fHisWindow); fHisFoil = new TH3D("HisFoil", "Deposited Energy at Foil", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 15, 0., 1.5); fHisFoil->SetXTitle("[mm]"); fHisFoil->SetYTitle("[mm]"); fHisFoil->SetZTitle("[mm]"); GetOutputList()->Add(fHisFoil); fHisHolder = new TH3D("HisHolder", "Deposited Energy at Holder", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 30, 0., 3.); fHisHolder->SetXTitle("[mm]"); fHisHolder->SetYTitle("[mm]"); fHisHolder->SetZTitle("[mm]"); GetOutputList()->Add(fHisHolder); fHisCassette = new TH3D("HisCassette", "Deposited Energy at Cassette", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 300, 0., 30.); fHisCassette->SetXTitle("[mm]"); fHisCassette->SetYTitle("[mm]"); fHisCassette->SetZTitle("[mm]"); GetOutputList()->Add(fHisCassette); fHisAir = new TH3D("HisAir", "Deposited Energy at Air", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 300, 0., 30.); fHisAir->SetXTitle("[mm]"); fHisAir->SetYTitle("[mm]"); fHisAir->SetZTitle("[mm]"); GetOutputList()->Add(fHisAir); fHisPlate = new TH3D("HisPlate", "Deposited Energy at Plate", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 300, 0., 30.); fHisPlate->SetXTitle("[mm]"); fHisPlate->SetYTitle("[mm]"); fHisPlate->SetZTitle("[mm]"); GetOutputList()->Add(fHisPlate); fHisFilm = new TH3D("HisFilm", "Deposited Energy at Film", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 300, 0., 30.); fHisFilm->SetXTitle("[mm]"); fHisFilm->SetYTitle("[mm]"); fHisFilm->SetZTitle("[mm]"); GetOutputList()->Add(fHisFilm); fHisWell = new TH3D("HisWell", "Deposited Energy at Well", Int_t(areaL), -areaL / 2., areaL / 2., Int_t(areaW), -areaW / 2., areaW / 2., 300, 0., 30.); fHisWell->SetXTitle("[mm]"); fHisWell->SetYTitle("[mm]"); fHisWell->SetZTitle("[mm]"); GetOutputList()->Add(fHisWell); fHisCell = new TH2D("HisCell", "Deposited Energy at Cell", Int_t(plateL * 10), -plateL / 2., plateL / 2., Int_t(plateW * 10), -plateW / 2., plateW / 2.); fHisCell->SetXTitle("[mm]"); fHisCell->SetYTitle("[mm]"); GetOutputList()->Add(fHisCell); /* const Double_t wellPitch = 9.; const Double_t bin20W = 0.02; UInt_t hisIt = 0; for(Double_t y = -36.; y < 32.; y += 9.){ for(Double_t x = -54.; x < 50.; x += 9.){ TString name = "His" + XYtoWell(x, y); TString title = "Deposited Energy at " + XYtoWell(x, y); fHisEachCell[hisIt] = new TH2D(name, title, Int_t(wellPitch / bin20W), x, x + wellPitch, Int_t(wellPitch / bin20W), y, y + wellPitch); GetOutputList()->Add(fHisEachCell[hisIt++]); } } */ }
bool DeviceSource::LoadFilters() { if(bCapturing || bFiltersLoaded) return false; bool bSucceeded = false; List<MediaOutputInfo> outputList; IAMStreamConfig *config = NULL; bool bAddedVideoCapture = false, bAddedAudioCapture = false, bAddedDevice = false; GUID expectedMediaType; IPin *devicePin = NULL, *audioPin = NULL; HRESULT err; String strShader; bUseThreadedConversion = API->UseMultithreadedOptimizations() && (OSGetTotalCores() > 1); //------------------------------------------------ // basic initialization vars bool bForceCustomAudio = data->GetInt(TEXT("forceCustomAudioDevice")) != 0; bUseCustomResolution = data->GetInt(TEXT("customResolution")); strDevice = data->GetString(TEXT("device")); strDeviceName = data->GetString(TEXT("deviceName")); strDeviceID = data->GetString(TEXT("deviceID")); strAudioDevice = data->GetString(TEXT("audioDevice")); strAudioName = data->GetString(TEXT("audioDeviceName")); strAudioID = data->GetString(TEXT("audioDeviceID")); bFlipVertical = data->GetInt(TEXT("flipImage")) != 0; bFlipHorizontal = data->GetInt(TEXT("flipImageHorizontal")) != 0; bUsePointFiltering = data->GetInt(TEXT("usePointFiltering")) != 0; opacity = data->GetInt(TEXT("opacity"), 100); float volume = data->GetFloat(TEXT("volume"), 1.0f); bUseBuffering = data->GetInt(TEXT("useBuffering")) != 0; bufferTime = data->GetInt(TEXT("bufferTime"))*10000; //------------------------------------------------ // chrom key stuff bUseChromaKey = data->GetInt(TEXT("useChromaKey")) != 0; keyColor = data->GetInt(TEXT("keyColor"), 0xFFFFFFFF); keySimilarity = data->GetInt(TEXT("keySimilarity")); keyBlend = data->GetInt(TEXT("keyBlend"), 80); keySpillReduction = data->GetInt(TEXT("keySpillReduction"), 50); if(keyBaseColor.x < keyBaseColor.y && keyBaseColor.x < keyBaseColor.z) keyBaseColor -= keyBaseColor.x; else if(keyBaseColor.y < keyBaseColor.x && keyBaseColor.y < keyBaseColor.z) keyBaseColor -= keyBaseColor.y; else if(keyBaseColor.z < keyBaseColor.x && keyBaseColor.z < keyBaseColor.y) keyBaseColor -= keyBaseColor.z; //------------------------------------------------ // get the device filter and pins if(strDeviceName.IsValid()) deviceFilter = GetDeviceByValue(CLSID_VideoInputDeviceCategory, L"FriendlyName", strDeviceName, L"DevicePath", strDeviceID); else { if(!strDevice.IsValid()) { AppWarning(TEXT("DShowPlugin: Invalid device specified")); goto cleanFinish; } deviceFilter = GetDeviceByValue(CLSID_VideoInputDeviceCategory, L"FriendlyName", strDevice); } if(!deviceFilter) { AppWarning(TEXT("DShowPlugin: Could not create device filter")); goto cleanFinish; } devicePin = GetOutputPin(deviceFilter, &MEDIATYPE_Video); if(!devicePin) { AppWarning(TEXT("DShowPlugin: Could not get device video pin")); goto cleanFinish; } soundOutputType = data->GetInt(TEXT("soundOutputType")); //0 is for backward-compatibility if (strAudioID.CompareI(TEXT("Disabled"))) soundOutputType = 0; if(soundOutputType != 0) { if(!bForceCustomAudio) { err = capture->FindPin(deviceFilter, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, FALSE, 0, &audioPin); bDeviceHasAudio = SUCCEEDED(err); } else bDeviceHasAudio = false; if(!bDeviceHasAudio) { if(strDeviceName.IsValid()) { audioDeviceFilter = GetDeviceByValue(CLSID_AudioInputDeviceCategory, L"FriendlyName", strAudioName, L"DevicePath", strAudioID); if(!audioDeviceFilter) AppWarning(TEXT("DShowPlugin: Invalid audio device: name '%s', path '%s'"), strAudioName.Array(), strAudioID.Array()); } else if(strAudioDevice.IsValid()) { audioDeviceFilter = GetDeviceByValue(CLSID_AudioInputDeviceCategory, L"FriendlyName", strAudioDevice); if(!audioDeviceFilter) AppWarning(TEXT("DShowPlugin: Could not create audio device filter")); } if(audioDeviceFilter) err = capture->FindPin(audioDeviceFilter, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, FALSE, 0, &audioPin); else err = E_FAIL; } if(FAILED(err) || !audioPin) { Log(TEXT("DShowPlugin: No audio pin, result = %lX"), err); soundOutputType = 0; } } else bDeviceHasAudio = bForceCustomAudio = false; int soundTimeOffset = data->GetInt(TEXT("soundTimeOffset")); GetOutputList(devicePin, outputList); //------------------------------------------------ // initialize the basic video variables and data renderCX = renderCY = 0; frameInterval = 0; if(bUseCustomResolution) { renderCX = data->GetInt(TEXT("resolutionWidth")); renderCY = data->GetInt(TEXT("resolutionHeight")); frameInterval = data->GetInt(TEXT("frameInterval")); } else { SIZE size; if (!GetClosestResolution(outputList, size, frameInterval)) { AppWarning(TEXT("DShowPlugin: Unable to find appropriate resolution")); renderCX = renderCY = 64; goto cleanFinish; } renderCX = size.cx; renderCY = size.cy; } if(!renderCX || !renderCY || !frameInterval) { AppWarning(TEXT("DShowPlugin: Invalid size/fps specified")); goto cleanFinish; } preferredOutputType = (data->GetInt(TEXT("usePreferredType")) != 0) ? data->GetInt(TEXT("preferredType")) : -1; int numThreads = MAX(OSGetTotalCores()-2, 1); for(int i=0; i<numThreads; i++) { convertData[i].width = renderCX; convertData[i].height = renderCY; convertData[i].sample = NULL; convertData[i].hSignalConvert = CreateEvent(NULL, FALSE, FALSE, NULL); convertData[i].hSignalComplete = CreateEvent(NULL, FALSE, FALSE, NULL); if(i == 0) convertData[i].startY = 0; else convertData[i].startY = convertData[i-1].endY; if(i == (numThreads-1)) convertData[i].endY = renderCY; else convertData[i].endY = ((renderCY/numThreads)*(i+1)) & 0xFFFFFFFE; } bFirstFrame = true; //------------------------------------------------ // get the closest media output for the settings used MediaOutputInfo *bestOutput = GetBestMediaOutput(outputList, renderCX, renderCY, preferredOutputType, frameInterval); if(!bestOutput) { AppWarning(TEXT("DShowPlugin: Could not find appropriate resolution to create device image source")); goto cleanFinish; } //------------------------------------------------ // log video info { String strTest = FormattedString(TEXT(" device: %s,\r\n device id %s,\r\n chosen type: %s, usingFourCC: %s, res: %ux%u - %ux%u, frameIntervals: %llu-%llu"), strDevice.Array(), strDeviceID.Array(), EnumToName[(int)bestOutput->videoType], bestOutput->bUsingFourCC ? TEXT("true") : TEXT("false"), bestOutput->minCX, bestOutput->minCY, bestOutput->maxCX, bestOutput->maxCY, bestOutput->minFrameInterval, bestOutput->maxFrameInterval); BITMAPINFOHEADER *bmiHeader = GetVideoBMIHeader(bestOutput->mediaType); char fourcc[5]; mcpy(fourcc, &bmiHeader->biCompression, 4); fourcc[4] = 0; if(bmiHeader->biCompression > 1000) strTest << FormattedString(TEXT(", fourCC: '%S'\r\n"), fourcc); else strTest << FormattedString(TEXT(", fourCC: %08lX\r\n"), bmiHeader->biCompression); if(!bDeviceHasAudio) strTest << FormattedString(TEXT(" audio device: %s,\r\n audio device id %s,\r\n"), strAudioDevice.Array(), strAudioID.Array()); Log(TEXT("------------------------------------------")); Log(strTest.Array()); } //------------------------------------------------ // set up shaders and video output data expectedMediaType = bestOutput->mediaType->subtype; colorType = DeviceOutputType_RGB; if(bestOutput->videoType == VideoOutputType_I420) colorType = DeviceOutputType_I420; else if(bestOutput->videoType == VideoOutputType_YV12) colorType = DeviceOutputType_YV12; else if(bestOutput->videoType == VideoOutputType_YVYU) colorType = DeviceOutputType_YVYU; else if(bestOutput->videoType == VideoOutputType_YUY2) colorType = DeviceOutputType_YUY2; else if(bestOutput->videoType == VideoOutputType_UYVY) colorType = DeviceOutputType_UYVY; else if(bestOutput->videoType == VideoOutputType_HDYC) colorType = DeviceOutputType_HDYC; else { colorType = DeviceOutputType_RGB; expectedMediaType = MEDIASUBTYPE_RGB32; } strShader = ChooseShader(); if(strShader.IsValid()) colorConvertShader = CreatePixelShaderFromFile(strShader); if(colorType != DeviceOutputType_RGB && !colorConvertShader) { AppWarning(TEXT("DShowPlugin: Could not create color space conversion pixel shader")); goto cleanFinish; } if(colorType == DeviceOutputType_YV12 || colorType == DeviceOutputType_I420) { for(int i=0; i<numThreads; i++) hConvertThreads[i] = OSCreateThread((XTHREAD)PackPlanarThread, convertData+i); } //------------------------------------------------ // set chroma details keyBaseColor = Color4().MakeFromRGBA(keyColor); Matrix4x4TransformVect(keyChroma, (colorType == DeviceOutputType_HDYC) ? (float*)yuv709Mat : (float*)yuvMat, keyBaseColor); keyChroma *= 2.0f; //------------------------------------------------ // configure video pin if(FAILED(err = devicePin->QueryInterface(IID_IAMStreamConfig, (void**)&config))) { AppWarning(TEXT("DShowPlugin: Could not get IAMStreamConfig for device pin, result = %08lX"), err); goto cleanFinish; } AM_MEDIA_TYPE outputMediaType; CopyMediaType(&outputMediaType, bestOutput->mediaType); VIDEOINFOHEADER *vih = reinterpret_cast<VIDEOINFOHEADER*>(outputMediaType.pbFormat); BITMAPINFOHEADER *bmi = GetVideoBMIHeader(&outputMediaType); vih->AvgTimePerFrame = frameInterval; bmi->biWidth = renderCX; bmi->biHeight = renderCY; bmi->biSizeImage = renderCX*renderCY*(bmi->biBitCount>>3); if(FAILED(err = config->SetFormat(&outputMediaType))) { if(err != E_NOTIMPL) { AppWarning(TEXT("DShowPlugin: SetFormat on device pin failed, result = %08lX"), err); goto cleanFinish; } } FreeMediaType(outputMediaType); //------------------------------------------------ // get audio pin configuration, optionally configure audio pin to 44100 GUID expectedAudioType; if(soundOutputType == 1) { IAMStreamConfig *audioConfig; if(SUCCEEDED(audioPin->QueryInterface(IID_IAMStreamConfig, (void**)&audioConfig))) { AM_MEDIA_TYPE *audioMediaType; if(SUCCEEDED(err = audioConfig->GetFormat(&audioMediaType))) { SetAudioInfo(audioMediaType, expectedAudioType); } else if(err == E_NOTIMPL) //elgato probably { IEnumMediaTypes *audioMediaTypes; if(SUCCEEDED(err = audioPin->EnumMediaTypes(&audioMediaTypes))) { ULONG i = 0; if((err = audioMediaTypes->Next(1, &audioMediaType, &i)) == S_OK) SetAudioInfo(audioMediaType, expectedAudioType); else { AppWarning(TEXT("DShowPlugin: audioMediaTypes->Next failed, result = %08lX"), err); soundOutputType = 0; } audioMediaTypes->Release(); } else { AppWarning(TEXT("DShowPlugin: audioMediaTypes->Next failed, result = %08lX"), err); soundOutputType = 0; } } else { AppWarning(TEXT("DShowPlugin: Could not get audio format, result = %08lX"), err); soundOutputType = 0; } audioConfig->Release(); } else { soundOutputType = 0; } } //------------------------------------------------ // add video capture filter if any captureFilter = new CaptureFilter(this, MEDIATYPE_Video, expectedMediaType); if(FAILED(err = graph->AddFilter(captureFilter, NULL))) { AppWarning(TEXT("DShowPlugin: Failed to add video capture filter to graph, result = %08lX"), err); goto cleanFinish; } bAddedVideoCapture = true; //------------------------------------------------ // add audio capture filter if any if(soundOutputType == 1) { audioFilter = new CaptureFilter(this, MEDIATYPE_Audio, expectedAudioType); if(!audioFilter) { AppWarning(TEXT("Failed to create audio capture filter")); soundOutputType = 0; } } else if(soundOutputType == 2) { if(FAILED(err = CoCreateInstance(CLSID_AudioRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&audioFilter))) { AppWarning(TEXT("DShowPlugin: failed to create audio renderer, result = %08lX"), err); soundOutputType = 0; } IBasicAudio *basicAudio; if(SUCCEEDED(audioFilter->QueryInterface(IID_IBasicAudio, (void**)&basicAudio))) { long lVol = long((double(volume)*NEAR_SILENTf)-NEAR_SILENTf); if(lVol <= -NEAR_SILENT) lVol = -10000; basicAudio->put_Volume(lVol); basicAudio->Release(); } } if(soundOutputType != 0) { if(FAILED(err = graph->AddFilter(audioFilter, NULL))) AppWarning(TEXT("DShowPlugin: Failed to add audio capture filter to graph, result = %08lX"), err); bAddedAudioCapture = true; } //------------------------------------------------ // add primary device filter if(FAILED(err = graph->AddFilter(deviceFilter, NULL))) { AppWarning(TEXT("DShowPlugin: Failed to add device filter to graph, result = %08lX"), err); goto cleanFinish; } if(soundOutputType != 0 && !bDeviceHasAudio) { if(FAILED(err = graph->AddFilter(audioDeviceFilter, NULL))) AppWarning(TEXT("DShowPlugin: Failed to add audio device filter to graph, result = %08lX"), err); } bAddedDevice = true; //------------------------------------------------ // connect all pins and set up the whole capture thing //THANK THE NINE DIVINES I FINALLY GOT IT WORKING bool bConnected = SUCCEEDED(err = capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, deviceFilter, NULL, captureFilter)); if(!bConnected) { if(FAILED(err = graph->Connect(devicePin, captureFilter->GetCapturePin()))) { AppWarning(TEXT("DShowPlugin: Failed to connect the video device pin to the video capture pin, result = %08lX"), err); goto cleanFinish; } } if(soundOutputType != 0) { if(!bDeviceHasAudio) bConnected = SUCCEEDED(err = capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, audioDeviceFilter, NULL, audioFilter)); else bConnected = SUCCEEDED(err = capture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, deviceFilter, NULL, audioFilter)); if(!bConnected) { AppWarning(TEXT("DShowPlugin: Failed to connect the audio device pin to the audio capture pin, result = %08lX"), err); soundOutputType = 0; } } if(FAILED(err = graph->QueryInterface(IID_IMediaControl, (void**)&control))) { AppWarning(TEXT("DShowPlugin: Failed to get IMediaControl, result = %08lX"), err); goto cleanFinish; } if (bUseBuffering) { if (!(hStopSampleEvent = CreateEvent(NULL, FALSE, FALSE, NULL))) { AppWarning(TEXT("DShowPlugin: Failed to create stop event"), err); goto cleanFinish; } if (!(hSampleThread = OSCreateThread((XTHREAD)SampleThread, this))) { AppWarning(TEXT("DShowPlugin: Failed to create sample thread"), err); goto cleanFinish; } } if(soundOutputType == 1) { audioOut = new DeviceAudioSource; audioOut->Initialize(this); API->AddAudioSource(audioOut); audioOut->SetAudioOffset(soundTimeOffset); audioOut->SetVolume(volume); } bSucceeded = true; cleanFinish: SafeRelease(config); SafeRelease(devicePin); SafeRelease(audioPin); for(UINT i=0; i<outputList.Num(); i++) outputList[i].FreeData(); if(!bSucceeded) { bCapturing = false; if(bAddedVideoCapture) graph->RemoveFilter(captureFilter); if(bAddedAudioCapture) graph->RemoveFilter(audioFilter); if(bAddedDevice) { if(!bDeviceHasAudio && audioDeviceFilter) graph->RemoveFilter(audioDeviceFilter); graph->RemoveFilter(deviceFilter); } SafeRelease(audioDeviceFilter); SafeRelease(deviceFilter); SafeRelease(captureFilter); SafeRelease(audioFilter); SafeRelease(control); if (hSampleThread) { SetEvent(hStopSampleEvent); WaitForSingleObject(hSampleThread, INFINITE); CloseHandle(hSampleThread); hSampleThread = NULL; } if (hStopSampleEvent) { CloseHandle(hStopSampleEvent); hStopSampleEvent = NULL; } if(colorConvertShader) { delete colorConvertShader; colorConvertShader = NULL; } if(audioOut) { delete audioOut; audioOut = NULL; } if(lpImageBuffer) { Free(lpImageBuffer); lpImageBuffer = NULL; } bReadyToDraw = true; } else bReadyToDraw = false; if(!renderCX) renderCX = 32; if(!renderCY) renderCY = 32; //----------------------------------------------------- // create the texture regardless, will just show up as red to indicate failure BYTE *textureData = (BYTE*)Allocate(renderCX*renderCY*4); if(colorType == DeviceOutputType_RGB) //you may be confused, but when directshow outputs RGB, it's actually outputting BGR { msetd(textureData, 0xFFFF0000, renderCX*renderCY*4); texture = CreateTexture(renderCX, renderCY, GS_BGR, textureData, FALSE, FALSE); } else //if we're working with planar YUV, we can just use regular RGB textures instead { msetd(textureData, 0xFF0000FF, renderCX*renderCY*4); texture = CreateTexture(renderCX, renderCY, GS_RGB, textureData, FALSE, FALSE); } if(bSucceeded && bUseThreadedConversion) { if(colorType == DeviceOutputType_I420 || colorType == DeviceOutputType_YV12) { LPBYTE lpData; if(texture->Map(lpData, texturePitch)) texture->Unmap(); else texturePitch = renderCX*4; lpImageBuffer = (LPBYTE)Allocate(texturePitch*renderCY); } } Free(textureData); bFiltersLoaded = bSucceeded; return bSucceeded; }
void EventSelector_FSRUnfBBB::SlaveBegin(TTree*) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); this_useNtupleWeightFlag = dynamic_cast<TNamed *>(fInput->FindObject("useNtupleWeightFlag")); useNtupleWeightFlag = this_useNtupleWeightFlag ? this_useNtupleWeightFlag->GetTitle() : ""; const int nbin = 41; double mass_xbin[nbin+1] = {15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 64, 68, 72, 76, 81, 86, 91, 96, 101, 106, 110, 115, 120, 126, 133, 141, 150, 160, 171, 185, 200, 220, 243, 273, 320, 380, 440, 510, 600, 1000, 1500, 2000}; //normalization histogram Nntuple = new TH1D("norm", "norm", 1,0,1); //FIXME change matrixces here hpostFSR = new TH1D("hpostFSR", "hpostFSR", nbin, mass_xbin); hpreFSR = new TH1D("hpreFSR", "hpreFSR", nbin, mass_xbin); //FIXME change matrixces here hpostFSR_corr = new TH1D("hpostFSR_corr", "hpostFSR_corr", nbin, mass_xbin); hpreFSR_corr = new TH1D("hpreFSR_corr", "hpreFSR_corr", nbin, mass_xbin); //2D set up // 20-30: 24 bins // 30-45: 24 bins // 45-60: 24 bins // 60-120: 24 bins // 120-200: 24 bins // 200-1500: 12 bins // total 138 bins const int nbin2 = 138; double mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500}; hpostFSR2 = new TH1D("hpostFSR2", "hpostFSR2", nbin2, 0, 138); hpreFSR2 = new TH1D("hpreFSR2", "hpreFSR2", nbin2, 0, 138); //FIXME change matrixces here hpostFSR_corr2 = new TH1D("hpostFSR2_corr", "hpostFSR2_corr", nbin2, 0, 138); hpreFSR_corr2 = new TH1D("hpreFSR2_corr", "hpreFSR2_corr", nbin2, 0, 138); GetOutputList()->Add(Nntuple); GetOutputList()->Add(hpostFSR); GetOutputList()->Add(hpreFSR); GetOutputList()->Add(hpostFSR_corr); GetOutputList()->Add(hpreFSR_corr); GetOutputList()->Add(hpostFSR2); GetOutputList()->Add(hpreFSR2); GetOutputList()->Add(hpostFSR_corr2); GetOutputList()->Add(hpreFSR_corr2); ds = new TNamed(TString("outfile"),dataset); GetOutputList()->Add(ds); }
void EventSelector_MCTruthEff::SlaveBegin(TTree*) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); this_useNtupleWeightFlag = dynamic_cast<TNamed *>(fInput->FindObject("useNtupleWeightFlag")); useNtupleWeightFlag = this_useNtupleWeightFlag ? this_useNtupleWeightFlag->GetTitle() : ""; const int nbin = 40; double mass_xbin[nbin+1] = {15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 64, 68, 72, 76, 81, 86, 91, 96, 101, 106, 110, 115, 120, 126, 133, 141, 150, 160, 171, 185, 200, 220, 243, 273, 320, 380, 440, 510, 600, 1000, 1500}; //normalization histogram Nntuple = new TH1D("norm", "norm", 1,0,1); //1D hacc = new TH1D("hacc", "hacc", nbin, mass_xbin); hsim = new TH1D("hsim", "hsim", nbin, mass_xbin); haccFSR = new TH1D("haccFSR", "haccFSR", nbin, mass_xbin); hsel = new TH1D("hsel", "hsel", nbin, mass_xbin); hfull = new TH1D("hfull", "hfull", nbin, mass_xbin); hacc_PU = new TH1D("hacc_PU", "hacc_PU", nbin, mass_xbin); hsim_PU = new TH1D("hsim_PU", "hsim_PU", nbin, mass_xbin); haccFSR_PU = new TH1D("haccFSR_PU", "haccFSR_PU", nbin, mass_xbin); hsel_PU = new TH1D("hsel_PU", "hsel_PU", nbin, mass_xbin); hfull_PU = new TH1D("hfull_PU", "hfull_PU", nbin, mass_xbin); hacc_corr = new TH1D("hacc_corr", "hacc_corr", nbin, mass_xbin); hsim_corr = new TH1D("hsim_corr", "hsim_corr", nbin, mass_xbin); haccFSR_corr = new TH1D("haccFSR_corr", "haccFSR_corr", nbin, mass_xbin); hsel_corr = new TH1D("hsel_corr", "hsel_corr", nbin, mass_xbin); hfull_corr = new TH1D("hfull_corr", "hfull_corr", nbin, mass_xbin); //2D sliced // 20-30: 24 bins // 30-45: 24 bins // 45-60: 24 bins // 60-120: 24 bins // 120-200: 24 bins // 200-1500: 12 bins // total 132 bins const int nbin2 = 132; double mass_xbin2[7] = {20, 30, 45, 60, 120, 200, 1500}; fAbsRap_full = new TH1D("rap_full", "rap_full", nbin2, 0, 132); fAbsRap_acc = new TH1D("rap_acc", "rap_acc", nbin2, 0, 132); fAbsRap_accFSR = new TH1D("rap_accFSR", "rap_accFSR", nbin2, 0, 132); fAbsRap_sim = new TH1D("rap_sim", "rap_sim", nbin2, 0, 132); fAbsRap_sel = new TH1D("rap_sel", "rap_sel", nbin2, 0, 132); fAbsRap_full_PU = new TH1D("rap_full_PU", "rap_full_PU", nbin2, 0, 132); fAbsRap_acc_PU = new TH1D("rap_acc_PU", "rap_acc_PU", nbin2, 0, 132); fAbsRap_accFSR_PU = new TH1D("rap_accFSR_PU", "rap_accFSR_PU", nbin2, 0, 132); fAbsRap_sim_PU = new TH1D("rap_sim_PU", "rap_sim_PU", nbin2, 0, 132); fAbsRap_sel_PU = new TH1D("rap_sel_PU", "rap_sel_PU", nbin2, 0, 132); fAbsRap_full_corr = new TH1D("rap_full_corr", "rap_full_corr", nbin2, 0, 132); fAbsRap_acc_corr = new TH1D("rap_acc_corr", "rap_acc_corr", nbin2, 0, 132); fAbsRap_accFSR_corr = new TH1D("rap_accFSR_corr", "rap_accFSR_corr", nbin2, 0, 132); fAbsRap_sim_corr = new TH1D("rap_sim_corr", "rap_sim_corr", nbin2, 0, 132); fAbsRap_sel_corr = new TH1D("rap_sel_corr", "rap_sel_corr", nbin2, 0, 132); GetOutputList()->Add(Nntuple); GetOutputList()->Add(hacc); GetOutputList()->Add(hsim); GetOutputList()->Add(haccFSR); GetOutputList()->Add(hsel); GetOutputList()->Add(hfull); GetOutputList()->Add(hacc_PU); GetOutputList()->Add(hsim_PU); GetOutputList()->Add(haccFSR_PU); GetOutputList()->Add(hsel_PU); GetOutputList()->Add(hfull_PU); GetOutputList()->Add(hacc_corr); GetOutputList()->Add(hsim_corr); GetOutputList()->Add(haccFSR_corr); GetOutputList()->Add(hsel_corr); GetOutputList()->Add(hfull_corr); GetOutputList()->Add(fAbsRap_full); GetOutputList()->Add(fAbsRap_acc); GetOutputList()->Add(fAbsRap_accFSR); GetOutputList()->Add(fAbsRap_sel); GetOutputList()->Add(fAbsRap_sim); GetOutputList()->Add(fAbsRap_full_PU); GetOutputList()->Add(fAbsRap_acc_PU); GetOutputList()->Add(fAbsRap_accFSR_PU); GetOutputList()->Add(fAbsRap_sel_PU); GetOutputList()->Add(fAbsRap_sim_PU); GetOutputList()->Add(fAbsRap_full_corr); GetOutputList()->Add(fAbsRap_acc_corr); GetOutputList()->Add(fAbsRap_accFSR_corr); GetOutputList()->Add(fAbsRap_sel_corr); GetOutputList()->Add(fAbsRap_sim_corr); ds = new TNamed(TString("outfile"),dataset); GetOutputList()->Add(ds); }
void Expectation::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); // tree tExpectation_ = new TTree("LostLeptonExpectation","a simple Tree with simple variables"); // tExpectation_->SetAutoSave(10000000000); // tExpectation_->SetAutoFlush(1000000); tExpectation_->Branch("EvtNum",&event,"EvtNum/i"); tExpectation_->Branch("HT",&ht30,"HT/F"); tExpectation_->Branch("MHT",&mht30,"MHT/F"); tExpectation_->Branch("NJets",&num_jets_pt30,"NJets/s"); tExpectation_->Branch("BTags",&num_csvm_jets30,"BTags/s"); tExpectation_->Branch("Bin",&Bin_,"Bin/s"); tExpectation_->Branch("NVtx",&num_primary_vertices,"NVtx/s"); tExpectation_->Branch("minDeltaPhiN",&min_delta_phi_met_N,"minDeltaPhiN/F"); tExpectation_->Branch("Weight", &weightppb, "Weight/F"); tExpectation_->Branch("MET",&met,"MET/F"); tExpectation_->Branch("METPhi",&met_phi,"METPhi/F"); tExpectation_->Branch("MTW",&MTW,"MTW/F"); tExpectation_->Branch("selectedIDIsoElectronsNum", &num_veto_els, "selectedIDIsoElectronsNum/s"); tExpectation_->Branch("selectedIDIsoMuonsNum", &num_veto_mus, "selectedIDIsoMuonsNum/s"); tExpectation_->Branch("GenElecNum", &num_true_els, "GenElecNum/s"); tExpectation_->Branch("GenMuNum", &num_true_mus, "GenMuNum/s"); tExpectation_->Branch("Expectation",&Expectation_,"Expectation/s"); tExpectation_->Branch("ExpectationDiLep",&ExpectationDiLep_,"ExpectationDiLep/s"); tExpectation_->Branch("MuDiLepControlSample",&MuDiLepControlSample_,"MuDiLepControlSample/s"); tExpectation_->Branch("ElecDiLepControlSample",&ElecDiLepControlSample_,"ElecDiLepControlSample/s"); // tExpectation_->Branch("muMTW",&muMTW,"muMTW/s"); tExpectation_->Branch("muAcc",&muAcc,"muAcc/s"); tExpectation_->Branch("muReco",&muReco,"muReco/s"); tExpectation_->Branch("muIso",&muIso,"muIso/s"); tExpectation_->Branch("MuPurity",&MuPurity_,"MuPurity/s"); // tExpectation_->Branch("elecMTW",&elecMTW,"elecMTW/s"); tExpectation_->Branch("elecAcc",&elecAcc,"elecAcc/s"); tExpectation_->Branch("elecReco",&elecReco,"elecReco/s"); tExpectation_->Branch("elecIso",&elecIso,"elecIso/s"); tExpectation_->Branch("ElecPurity",&ElecPurity_,"ElecPurity/s"); tExpectation_->Branch("mu_pt",&mu_pt); tExpectation_->Branch("mu_veto",&mu_veto); tExpectation_->Branch("mu_mT",&mu_mT); tExpectation_->Branch("mu_tm",&mu_tm); tExpectation_->Branch("mu_activity_mu",&mu_activity_mu); tExpectation_->Branch("mu_activity_el",&mu_activity_el); tExpectation_->Branch("true_mu_pt",&true_mu_pt); tExpectation_->Branch("true_mu_activity_mu",&true_mu_activity_mu); tExpectation_->Branch("true_mu_activity_el",&true_mu_activity_el); tExpectation_->Branch("el_pt",&el_pt); tExpectation_->Branch("el_veto",&el_veto); tExpectation_->Branch("el_mT",&el_mT); tExpectation_->Branch("el_tm",&el_tm); tExpectation_->Branch("el_activity_mu",&el_activity_mu); tExpectation_->Branch("el_activity_el",&el_activity_el); tExpectation_->Branch("true_el_pt",&true_el_pt); tExpectation_->Branch("true_el_activity_mu",&true_el_activity_mu); tExpectation_->Branch("true_el_activity_el",&true_el_activity_el); GetOutputList()->Add(tExpectation_); SearchBins_ = new SearchBins(); std::cout<<"Applying filters: "<<applyFilters_<<std::endl; }