From 9cdd08c3685194fe7df82715b6e270c7bd3ab304 Mon Sep 17 00:00:00 2001 From: Sanghyun Ko Date: Wed, 23 Jun 2021 15:01:15 +0900 Subject: [PATCH] delete deprecated Podio standalone sequence, update key4hep version --- Digi/Digi.cc | 27 ---- Digi/include/DigiPodio.h | 71 ---------- Digi/include/DigiSiPM.h | 4 +- Digi/src/DigiPodio.cc | 135 ------------------ analysis/JER.cc | 289 --------------------------------------- analysis/analysis.cpp | 12 +- analysis/calib.cc | 129 ----------------- edm4dr.yaml | 17 +-- init_k4.sh | 4 +- 9 files changed, 15 insertions(+), 673 deletions(-) delete mode 100644 Digi/Digi.cc delete mode 100644 Digi/include/DigiPodio.h delete mode 100644 Digi/src/DigiPodio.cc delete mode 100644 analysis/JER.cc delete mode 100644 analysis/calib.cc diff --git a/Digi/Digi.cc b/Digi/Digi.cc deleted file mode 100644 index 6c0d19c..0000000 --- a/Digi/Digi.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "DigiPodio.h" - -#include -#include - -int main(int , char* argv[]) { - std::string filenameIn = std::string(argv[1]); - std::string filenameOut = std::string(argv[2]); - - auto digipodio = std::make_unique(filenameIn,filenameOut); - - digipodio->initialize(); - - unsigned int entries = digipodio->GetReader()->getEntries(); - for (unsigned int iEvt = 0; iEvt < entries; iEvt++) { - std::cout << "processing " << iEvt << "th event" << std::endl; - digipodio->execute(); - - digipodio->GetWriter()->writeEvent(); - digipodio->GetStore()->clear(); - digipodio->GetReader()->endOfEvent(); - } - - digipodio->finalize(); - - return 0; -} diff --git a/Digi/include/DigiPodio.h b/Digi/include/DigiPodio.h deleted file mode 100644 index 6a77705..0000000 --- a/Digi/include/DigiPodio.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef DigiPodio_h -#define DigiPodio_h 1 - -#include "edm4hep/RawCalorimeterHitCollection.h" -#include "edm4hep/SparseVectorCollection.h" -#include "edm4hep/EventHeaderCollection.h" - -#include "podio/ROOTWriter.h" -#include "podio/ROOTReader.h" - -#include "SiPMSensor.h" -#include "SiPMAdc.h" - -namespace drc { - -class DigiPodio { -public: - DigiPodio(const std::string filenameIn, const std::string filenameOut); - virtual ~DigiPodio() {}; - - void initialize(); - void execute(); - void finalize(); - - podio::ROOTReader* GetReader() { return m_reader.get(); } - podio::ROOTWriter* GetWriter() { return m_writer.get(); } - podio::EventStore* GetStore() { return m_store.get(); } - -private: - template - void create(T*& pCollection, std::string name); - - template - void registerForWrite(T*& pCollection, std::string name); - - std::unique_ptr m_reader; - std::unique_ptr m_writer; - std::unique_ptr m_store; - - edm4hep::RawCalorimeterHitCollection* m_digiHits; - edm4hep::SparseVectorCollection* m_waveforms; - - std::string m_filenameIn; - std::string m_filenameOut; - - std::unique_ptr m_sensor; - std::unique_ptr m_adc; - - // Hamamatsu S13615-1025 - double m_Dcr = 100e3; - double m_Xt = 0.01; - double m_sampling = 0.1; - double m_recovery = 20.; - - // ADC parameters - unsigned int m_bits = 16; - double m_range = std::pow(2., static_cast(m_bits)-1.); - double m_gain = 20.; // in dB i.e. gain(linear) = 10^(m_gain/20) - - // integration parameters - double m_gateStart = 10.; - double m_gateEnd = 250.; - int m_thres = static_cast( 0.5 * (std::pow(10.,m_gain/20.) * std::pow(2., static_cast(m_bits)) / m_range ) ); - - bool isFirstEvent = true; - int verbose = 0; -}; - -} // namespace drc - -#endif diff --git a/Digi/include/DigiSiPM.h b/Digi/include/DigiSiPM.h index ae4baee..6371653 100644 --- a/Digi/include/DigiSiPM.h +++ b/Digi/include/DigiSiPM.h @@ -33,8 +33,8 @@ class DigiSiPM : public GaudiAlgorithm { std::unique_ptr m_adc; // Hamamatsu S14160-1310PS - Gaudi::property m_sigLength{this, "signalLength", 200., "signal length in ns"}; - Gaudi::property m_sipmSize{this, "SiPMsize", 1.3, "width of photosensitive area in mm"}; + Gaudi::Property m_sigLength{this, "signalLength", 200., "signal length in ns"}; + Gaudi::Property m_sipmSize{this, "SiPMsize", 1.3, "width of photosensitive area in mm"}; Gaudi::Property m_Dcr{this, "DCR", 120e3, "SiPM DCR"}; Gaudi::Property m_Xt{this, "Xtalk", 0.01, "SiPM crosstalk"}; Gaudi::Property m_sampling{this, "sampling", 0.1, "SiPM sampling rate in ns"}; diff --git a/Digi/src/DigiPodio.cc b/Digi/src/DigiPodio.cc deleted file mode 100644 index e9de85b..0000000 --- a/Digi/src/DigiPodio.cc +++ /dev/null @@ -1,135 +0,0 @@ -#include "DigiPodio.h" - -#include -#include - -drc::DigiPodio::DigiPodio(const std::string filenameIn, const std::string filenameOut) { - m_filenameIn = filenameIn; - m_filenameOut = filenameOut; -} - -void drc::DigiPodio::initialize() { - m_reader = std::make_unique(); - m_reader->openFile(m_filenameIn); - - m_store = std::make_unique(); - m_store->setReader(m_reader.get()); - - m_writer = std::make_unique(m_filenameOut, m_store.get()); - - m_writer->registerForWrite("SimCalorimeterHits"); - m_writer->registerForWrite("RawCalorimeterHits"); - m_writer->registerForWrite("RawTimeStructs"); - m_writer->registerForWrite("RawWavlenStructs"); - m_writer->registerForWrite("EventHeader"); - - registerForWrite(m_digiHits,"DigiCalorimeterHits"); - registerForWrite(m_waveforms,"DigiWaveforms"); - - m_sensor = std::make_unique(); - m_sensor->properties().setDcr(m_Dcr); - m_sensor->properties().setXt(m_Xt); - m_sensor->properties().setSampling(m_sampling); - m_sensor->properties().setRecoveryTime(m_recovery); - - m_adc = std::make_unique(m_bits,m_range,m_gain); - - std::cout << "DigiPodio initialized" << std::endl; - - return; -} - -void drc::DigiPodio::execute() { - auto& inputs = m_store->get("RawTimeStructs"); - - if (!isFirstEvent) { - create(m_digiHits,"DigiCalorimeterHits"); - create(m_waveforms,"DigiWaveforms"); - } else { - isFirstEvent = false; - } - - // assume same collection (OneToOneRelation) - edm4hep::RawCalorimeterHitCollection* rawHits = nullptr; - - for (unsigned int idx = 0; idx < inputs.size(); idx++) { - const auto& input = inputs.at(idx); - - if (idx==0) { - podio::CollectionBase* collBase = nullptr; - bool isOk = m_store->get(inputs.at(idx).getAssocObj().collectionID,collBase); - - if (!isOk) - throw std::runtime_error("cannot find corresponding RawCalorimeterHitCollection for RawTimeStructs!"); - - rawHits = dynamic_cast(collBase); - } - - const auto& rawhit = rawHits->at(inputs.at(idx).getAssocObj().index); - - std::vector times; - times.reserve( rawhit.getAmplitude() ); - - for (unsigned int bin = 0; bin < input.contents_size(); bin++) { - int counts = static_cast( input.getContents(bin) ); - double timeBin = input.getCenters(bin); - - for (int num = 0; num < counts; num++) - times.emplace_back(timeBin); - } - - m_sensor->resetState(); - m_sensor->addPhotons(times); // Sets photon times (times are in ns) (not appending) - m_sensor->runEvent(); // Runs the simulation - - auto digiHit = m_digiHits->create(); - auto waveforms = m_waveforms->create(); - - sipm::SiPMAnalogSignal anaSignal = m_sensor->signal(); - sipm::SiPMDigitalSignal digiSignal = m_adc->digitize(anaSignal); - - int integral = digiSignal.integral(m_gateStart,m_gateEnd,m_thres); // (intStart, intGate, threshold) - double toa = digiSignal.toa(m_gateStart,m_gateEnd,m_thres); // (intStart, intGate, threshold) - - digiHit.setAmplitude( integral ); - digiHit.setCellID( rawhit.getCellID() ); - digiHit.setTimeStamp( static_cast(toa/m_sampling) ); - waveforms.setAssocObj( edm4hep::ObjectID( digiHit.getObjectID() ) ); - waveforms.setSampling( m_sampling ); - - std::vector waveform = digiSignal.waveform(); - - for (unsigned bin = 0; bin < waveform.size(); bin++) { - int amp = waveform.at(bin); - - if (amp < m_thres) continue; - - float tStart = static_cast(bin)*m_sampling; - float tEnd = static_cast(bin+1)*m_sampling; - - waveforms.addToContents( amp ); - waveforms.addToCenters( (tStart+tEnd)/2. ); - } - } - - return; -} - -void drc::DigiPodio::finalize() { - m_reader->closeFile(); - m_writer->finish(); - - return; -} - -template -void drc::DigiPodio::create(T*& pCollection, std::string name) { - auto& collection = m_store->create(name); - pCollection = &collection; -} - -template -void drc::DigiPodio::registerForWrite(T*& pCollection, std::string name) { - create(pCollection, name); - m_writer->registerForWrite(name); -} diff --git a/analysis/JER.cc b/analysis/JER.cc deleted file mode 100644 index 9901741..0000000 --- a/analysis/JER.cc +++ /dev/null @@ -1,289 +0,0 @@ -#include "RootInterface.h" -#include "RecoInterface.h" -#include "DRsimInterface.h" -#include "fastjetInterface.h" -#include "functions.h" - -#include "fastjet/PseudoJet.hh" - -#include "HepMC3/ReaderRootTree.h" -#include "HepMC3/GenEvent.h" -#include "HepMC3/GenParticle.h" - -#include "TROOT.h" -#include "TStyle.h" -#include "TH1.h" -#include "TCanvas.h" -#include "TF1.h" -#include "TPaveStats.h" -#include "TString.h" -#include "TLorentzVector.h" -#include "TGraph.h" - -#include -#include -#include - -int main(int argc, char* argv[]) { - TString filename = argv[1]; - float low = std::stof(argv[2]); - float high = std::stof(argv[3]); - float cen = std::stof(argv[4]); - - gStyle->SetOptFit(1); - - TH1F* tEdep = new TH1F("totEdep","Total Energy deposit;MeV;Evt",100,2.*low*1000.,2.*high*1000.); - tEdep->Sumw2(); tEdep->SetLineColor(kRed); tEdep->SetLineWidth(2); - TH1F* tE_C = new TH1F("E_C","Energy of Cerenkov ch.;GeV;Evt",100,2.*low,2.*high); - tE_C->Sumw2(); tE_C->SetLineColor(kBlue); tE_C->SetLineWidth(2); - TH1F* tE_S = new TH1F("E_S","Energy of Scintillation ch.;GeV;Evt",100,2.*low,2.*high); - tE_S->Sumw2(); tE_S->SetLineColor(kRed); tE_S->SetLineWidth(2); - TH1F* tE_DR = new TH1F("E_DR","Dual-readout corrected Energy;GeV;Evt",100,2.*low,2.*high); - tE_DR->Sumw2(); tE_DR->SetLineColor(kBlack); tE_DR->SetLineWidth(2); - TH1F* tP_leak = new TH1F("Pleak","Momentum leak;MeV;Evt",100,0.,1000.*high); - tP_leak->Sumw2(); tP_leak->SetLineWidth(2); - TH1F* tP_leak_nu = new TH1F("Pleak_nu","Neutrino energy leak;MeV;Evt",100,0.,1000.*high); - tP_leak_nu->Sumw2(); tP_leak_nu->SetLineWidth(2); - - TH1F* tE_tot = new TH1F("Etot","Total energy;GeV;Evt",100,2.*low,2.*high); - tE_tot->Sumw2(); tE_tot->SetLineWidth(2); - - TH1F* tE_Sjets = new TH1F("E_Sjets","Energy of Scint cluster;GeV;nJets",100,low,high); - tE_Sjets->Sumw2(); tE_Sjets->SetLineColor(kRed); tE_Sjets->SetLineWidth(2); - TH1F* tE_Cjets = new TH1F("E_Cjets","Energy of Cerenkov cluster;GeV;nJets",100,low,high); - tE_Cjets->Sumw2(); tE_Cjets->SetLineColor(kBlue); tE_Cjets->SetLineWidth(2); - TH1F* tE_GenJets = new TH1F("E_GenJets","Energy of GenJets;GeV;nJets",100,low,high); - tE_GenJets->Sumw2(); tE_GenJets->SetLineColor(kBlack); tE_GenJets->SetLineWidth(2); - TH1F* tE_DRjets = new TH1F("E_DRjets","Energy of DR corrected cluster;GeV;nJets",100,low,high); - tE_DRjets->Sumw2(); tE_DRjets->SetLineColor(kBlack); tE_DRjets->SetLineWidth(2); - - RootInterface* recoInterface = new RootInterface(std::string(filename)+".root"); - recoInterface->set("Reco","RecoEventData"); - - RootInterface* drInterface = new RootInterface(std::string(filename)+".root"); - drInterface->set("DRsim","DRsimEventData"); - - HepMC3::ReaderRootTree reader(std::string(filename)+".root"); - - // fastjetInterface fjTower_S; - // fjTower_S.set(recoInterface->getTree(),"RecoTowerJets_S"); - // fastjetInterface fjFiber_S; - // fjFiber_S.set(recoInterface->getTree(),"RecoFiberJets_S"); - // fastjetInterface fjFiber_C; - // fjFiber_C.set(recoInterface->getTree(),"RecoFiberJets_C"); - // fastjetInterface fjGen; - // fjGen.set(reader.m_tree,"GenJets"); - - int nLeak = 0; - std::vector E_Ss,E_Cs; - - unsigned int entries = recoInterface->entries(); - while (recoInterface->numEvt() < entries) { - if (recoInterface->numEvt() % 50 == 0) printf("Analyzing %dth event ...\n", recoInterface->numEvt()); - - RecoInterface::RecoEventData evt; - recoInterface->read(evt); - - DRsimInterface::DRsimEventData drEvt; - drInterface->read(drEvt); - - HepMC3::GenEvent genEvt; - reader.read_event(genEvt); - - std::vector fjInputs_G; - std::vector fjInputs_C; - std::vector fjInputs_S; - - float Etot = 0.; - for (auto ptc : genEvt.particles()) { - int abspid = std::abs(ptc->pid()); - if ( ptc->status() != 1 ) continue; - if ( abspid == 12 || abspid == 14 || abspid == 16 ) continue; - - auto mom = ptc->momentum(); - - Etot += mom.e(); - fjInputs_G.push_back( fastjet::PseudoJet(mom.px(),mom.py(),mom.pz(),mom.e()) ); - } - - float Pleak = 0.; - float Eleak_nu = 0.; - for (auto leak : drEvt.leaks) { - TLorentzVector leak4vec; - leak4vec.SetPxPyPzE(leak.px,leak.py,leak.pz,leak.E); - if ( std::abs(leak.pdgId)==12 || std::abs(leak.pdgId)==14 || std::abs(leak.pdgId)==16 ) { - Eleak_nu += leak4vec.P(); - } else { - Pleak += leak4vec.P(); - } - } - tP_leak->Fill(Pleak); - tP_leak_nu->Fill(Eleak_nu); - - if (Pleak > 2.*1000.*0.1*cen) { - nLeak++; - continue; - } - - // std::vector fjTS; - // fjTower_S.read(fjTS); - // - // std::vector fjFS; - // fjFiber_S.read(fjFS); - // - // std::vector fjFC; - // fjFiber_C.read(fjFC); - - // std::vector fjG; - // fjGen.read(fjG); - - float Edep = 0.; - for (auto edep : drEvt.Edeps) { - Edep += edep.Edep; - } - - for (auto tower : evt.towers) { - for (auto fiber : tower.fibers) { - TVector3 vec(std::get<0>(fiber.pos),std::get<1>(fiber.pos),std::get<2>(fiber.pos)); - TVector3 p = fiber.E*vec.Unit(); - - if (fiber.IsCerenkov) { - fjInputs_C.push_back( fastjet::PseudoJet(p.x(),p.y(),p.z(),fiber.E) ); - } else { - fjInputs_S.push_back( fastjet::PseudoJet(p.x(),p.y(),p.z(),fiber.E) ); - } - } - } - - double dR = 0.8; - auto fjG = functions::runFastjet(fjInputs_G,dR); - auto fjFS = functions::runFastjet(fjInputs_S,dR); - auto fjFC = functions::runFastjet(fjInputs_C,dR); - - tEdep->Fill(Edep); - tE_tot->Fill(Etot); - - tE_C->Fill(evt.E_C); - tE_S->Fill(evt.E_S); - tE_DR->Fill(evt.E_DR); - - auto firstS = fjFS.at(0); - auto firstC = fjFC.at(0); - auto firstG = fjG.at(0); - - TLorentzVector firstS4vec, firstC4vec, firstG4vec; - firstS4vec.SetPxPyPzE(firstS.px,firstS.py,firstS.pz,firstS.E); - firstC4vec.SetPxPyPzE(firstC.px,firstC.py,firstC.pz,firstC.E); - firstG4vec.SetPxPyPzE(firstG.px,firstG.py,firstG.pz,firstG.E); - - auto secondS = functions::findSecondary(fjFS,dR); - auto secondC = functions::findSecondary(fjFC,dR); - auto secondG = functions::findSecondary(fjG,dR); - - TLorentzVector secondS4vec, secondC4vec, secondG4vec; - secondS4vec.SetPxPyPzE(secondS.px,secondS.py,secondS.pz,secondS.E); - secondC4vec.SetPxPyPzE(secondC.px,secondC.py,secondC.pz,secondC.E); - secondG4vec.SetPxPyPzE(secondG.px,secondG.py,secondG.pz,secondG.E); - - if (firstG.E < (0.9*cen)) continue; - if (secondG.E < (0.9*cen)) continue; - - tE_Sjets->Fill(firstS.E); - tE_Cjets->Fill(firstC.E); - tE_GenJets->Fill(firstG.E); - - tE_Sjets->Fill(secondS.E); - tE_Cjets->Fill(secondC.E); - tE_GenJets->Fill(secondG.E); - - float E_DRjets1, E_DRjets2; - if ( secondS4vec.DeltaR(secondC4vec) < 0.1 && firstS4vec.DeltaR(firstC4vec) < 0.1 ) { - E_DRjets1 = functions::E_DR(firstC.E,firstS.E); - E_DRjets2 = functions::E_DR(secondC.E,secondS.E); - - tE_DRjets->Fill(E_DRjets1); - tE_DRjets->Fill(E_DRjets2); - - E_Ss.push_back(firstS.E); - E_Cs.push_back(firstC.E); - E_Ss.push_back(secondS.E); - E_Cs.push_back(secondC.E); - } else if ( secondS4vec.DeltaR(firstC4vec) < 0.1 && firstS4vec.DeltaR(secondC4vec) < 0.1 ) { - E_DRjets2 = functions::E_DR(firstC.E,secondS.E); - E_DRjets1 = functions::E_DR(secondC.E,firstS.E); - - tE_DRjets->Fill(E_DRjets1); - tE_DRjets->Fill(E_DRjets2); - - E_Ss.push_back(firstS.E); - E_Cs.push_back(firstC.E); - E_Ss.push_back(secondS.E); - E_Cs.push_back(secondC.E); - } else continue; - } // event loop - - reader.close(); - drInterface->close(); - recoInterface->close(); - - TCanvas* c = new TCanvas("c",""); - - tEdep->Draw("Hist"); c->SaveAs(filename+"_Edep.png"); - tE_tot->Draw("Hist"); c->SaveAs(filename+"_Etot.png"); - - c->cd(); - tE_S->Draw("Hist"); c->Update(); - TPaveStats* statsE_S = (TPaveStats*)c->GetPrimitive("stats"); - statsE_S->SetName("Scint"); - statsE_S->SetTextColor(kRed); - statsE_S->SetY1NDC(.6); statsE_S->SetY2NDC(.8); - - tE_C->Draw("Hist&sames"); c->Update(); - TPaveStats* statsE_C = (TPaveStats*)c->GetPrimitive("stats"); - statsE_C->SetName("Cerenkov"); - statsE_C->SetTextColor(kBlue); - statsE_C->SetY1NDC(.8); statsE_C->SetY2NDC(1.); - - c->SaveAs(filename+"_EcsHist.png"); - - TF1* grE_DR = new TF1("Efit","gaus",2.*low,2.*high); grE_DR->SetLineColor(kBlack); - tE_DR->SetOption("p"); tE_DR->Fit(grE_DR,"R+&same"); - tE_DR->Draw(""); c->SaveAs(filename+"_Ecorr.png"); - - tE_Sjets->Draw(""); c->Update(); - TPaveStats* statsE_Sjets = (TPaveStats*)c->GetPrimitive("stats"); - statsE_Sjets->SetName("Scint"); - statsE_Sjets->SetTextColor(kRed); - statsE_Sjets->SetY1NDC(.6); statsE_Sjets->SetY2NDC(.8); - - tE_Cjets->Draw("sames"); c->Update(); - TPaveStats* statsE_Cjets = (TPaveStats*)c->GetPrimitive("stats"); - statsE_Cjets->SetName("Cerenkov"); - statsE_Cjets->SetTextColor(kBlue); - statsE_Cjets->SetY1NDC(.8); statsE_Cjets->SetY2NDC(1.); - - tE_Sjets->Draw("Hist"); - tE_Cjets->Draw("Hist&sames"); - c->SaveAs(filename+"_EcsJetsHist.png"); - - tE_GenJets->Draw("Hist"); - c->SaveAs(filename+"_EGenjets.png"); - - TF1* grE_DRjets = new TF1("EjetsFit","gaus",low,high); grE_DRjets->SetLineColor(kBlack); - tE_DRjets->SetOption("p"); tE_DRjets->Fit(grE_DRjets,"R+&same"); - tE_DRjets->Draw(""); - c->SaveAs(filename+"_EDRjets.png"); - - c->SetLogy(1); - tP_leak->Draw("Hist"); c->SaveAs(filename+"_Pleak.png"); - tP_leak_nu->Draw("Hist"); c->SaveAs(filename+"_Pleak_nu.png"); - c->SetLogy(0); - - TGraph* grSvsC = new TGraph(entries-nLeak,&(E_Ss[0]),&(E_Cs[0])); - grSvsC->SetTitle("SvsC;E_S;E_C"); - grSvsC->SetMarkerSize(0.5); grSvsC->SetMarkerStyle(20); - grSvsC->GetXaxis()->SetLimits(0.,high); - grSvsC->GetYaxis()->SetRangeUser(0.,high); - grSvsC->Draw("ap"); - c->SaveAs(filename+"_SvsC.png"); -} diff --git a/analysis/analysis.cpp b/analysis/analysis.cpp index fc57d77..84de6bf 100644 --- a/analysis/analysis.cpp +++ b/analysis/analysis.cpp @@ -43,9 +43,10 @@ int main(int , char* argv[]) { functions::dualhist1D* tT_dual = new functions::dualhist1D("time","time;ns;p.e.",150,10.,70.); functions::dualhist1D* tWav_dual = new functions::dualhist1D("wavlen","wavelength;nm;p.e.",120,300.,900.); - functions::dualhist1D* tNhit_dual = new functions::dualhist1D("nHits","of Scint p.e./SiPM;p.e.;n",200,0.,200.); - functions::dualhist1D* tD_dual = new functions::dualhist1D("digi","digi waveform;ns;a.u.",300,10.,250.); + functions::dualhist1D* tNhit_dual = new functions::dualhist1D("nHits","of Scint p.e./SiPM;p.e.;n",100,0.,100.); + functions::dualhist1D* tD_dual = new functions::dualhist1D("digi","digi waveform;ns;a.u.",300,10.,100.); functions::dualhist1D* tToa_dual = new functions::dualhist1D("ToA","Time of Arrival;ns;a.u.",150,10.,70.); + functions::dualhist1D* tInt_dual = new functions::dualhist1D("Int","ADC integration;ADC counts;a.u.",400,0.,2000.); auto pReader = std::make_unique(); pReader->openFile(static_cast(filename)); @@ -90,12 +91,16 @@ int main(int , char* argv[]) { TH1F* tWav = tWav_dual->getHist(type); TH1F* tD = tD_dual->getHist(type); TH1F* tToa = tToa_dual->getHist(type); + TH1F* tInt = tInt_dual->getHist(type); (type==0) ? en_S += en : en_C += en; tNhit->Fill(nhits); tToa->Fill(caloHit.getTime()); + if ( digiHit.getAmplitude() > 0 ) + tInt->Fill(static_cast(digiHit.getAmplitude())); + for (unsigned int bin = 0; bin < timeStruct.centers_size(); bin++) { float timeBin = timeStruct.getCenters(bin); tT->Fill(timeBin,timeStruct.getContents(bin)); @@ -198,6 +203,9 @@ int main(int , char* argv[]) { tNhit_dual->getHist(1)->Draw("Hist"); c->SaveAs(filename+"_nhitC.png"); tNhit_dual->getHist(0)->Draw("Hist"); c->SaveAs(filename+"_nhitS.png"); + tInt_dual->getHist(1)->Draw("Hist"); c->SaveAs(filename+"_intC.png"); + tInt_dual->getHist(0)->Draw("Hist"); c->SaveAs(filename+"_intS.png"); + tD_dual->getHist(1)->Draw("Hist"); c->SaveAs(filename+"_dC.png"); tD_dual->getHist(0)->Draw("Hist"); c->SaveAs(filename+"_dS.png"); diff --git a/analysis/calib.cc b/analysis/calib.cc deleted file mode 100644 index 82488c3..0000000 --- a/analysis/calib.cc +++ /dev/null @@ -1,129 +0,0 @@ -#include "RootInterface.h" -#include "RecoInterface.h" -#include "DRsimInterface.h" -#include "functions.h" - -#include "TROOT.h" -#include "TStyle.h" -#include "TH1.h" -#include "TCanvas.h" -#include "TF1.h" -#include "TPaveStats.h" -#include "TString.h" - -#include -#include -#include -#include -#include -#include - - -int main(int argc, char* argv[]) { - TString filename = argv[1]; - int iEta = atoi(argv[2]); - int iPhi = 0; - float Cthres = 32.5; - - float low = 0.; - float high = 25.; - - gStyle->SetOptFit(1); - - TH1F* tEdep = new TH1F("Total_Edep","Total Energy deposit;MeV;Evt",100,low*1000.,high*1000.); - tEdep->Sumw2(); tEdep->SetLineColor(kBlack); tEdep->SetLineWidth(2); - TH1F* tCtime = new TH1F("Total_C_Time","Total timing of Cerenkov ch.;ns;Evt",600,10,70); - tCtime->Sumw2(); tCtime->SetLineColor(kBlue); tCtime->SetLineWidth(2); - TH1F* tStime = new TH1F("Total_S_Time","Total timing of Scintillation ch.;ns;Evt",600,10,70); - tStime->Sumw2(); tStime->SetLineColor(kRed); tStime->SetLineWidth(2); - TH1I* tChit = new TH1I("Total_C_Hit","Total hits of Cerenkov ch",100,0.,3000.); - tChit->Sumw2(); tChit->SetLineColor(kBlue); tChit->SetLineWidth(2); - TH1I* tShit = new TH1I("Total_S_Hit","Total hits of Scintillation ch",100,0.,40000.); - tShit->Sumw2(); tShit->SetLineColor(kRed); tShit->SetLineWidth(2); - - TH1F* Edep = new TH1F("Edep","Energy deposit;MeV;Evt",100,low*1000.,high*1000.); - Edep->Sumw2(); Edep->SetLineColor(kBlack); Edep->SetLineWidth(2); - TH1F* Ctime = new TH1F("C_Time","timing of Cerenkov ch.;ns;Evt",600,10,70); - Ctime->Sumw2(); Ctime->SetLineColor(kBlue); Ctime->SetLineWidth(2); - TH1F* Stime = new TH1F("S_Time","timing of Scintillation ch.;ns;Evt",600,10,70); - Stime->Sumw2(); Stime->SetLineColor(kRed); Stime->SetLineWidth(2); - TH1I* Chit = new TH1I("C_Hit","hits of Cerenkov ch",100,0.,3000.); - Chit->Sumw2(); Chit->SetLineColor(kBlue); Chit->SetLineWidth(2); - TH1I* Shit = new TH1I("S_Hit","hits of Scintillation ch",100,0.,40000.); - Shit->Sumw2(); Shit->SetLineColor(kRed); Shit->SetLineWidth(2); - - RootInterface* drInterface = new RootInterface(std::string(filename)+".root"); - drInterface->set("DRsim","DRsimEventData"); - - unsigned int entries = drInterface->entries(); - while (drInterface->numEvt() < entries) { - if (drInterface->numEvt() % 100 == 0) printf("Analyzing %dth event ...\n", drInterface->numEvt()); - - DRsimInterface::DRsimEventData drEvt; - drInterface->read(drEvt); - - float fEdep = 0.; float ftEdep = 0.; - int fEta = 0; int fPhi = 0; - - for (auto edepItr = drEvt.Edeps.begin(); edepItr != drEvt.Edeps.end(); ++edepItr) { - auto edep = *edepItr; - fEta = edep.iTheta; - fPhi = edep.iPhi; - ftEdep += edep.Edep; if(fEta == iEta && fPhi == iPhi) fEdep += edep.Edep; - } - - int fC_hits = 0; int fS_hits = 0; - int ftC_hits = 0; int ftS_hits = 0; - - for (auto towerItr = drEvt.towers.begin(); towerItr != drEvt.towers.end(); ++towerItr) { - auto sipmItr = *towerItr; - std::vector sipmData = sipmItr.SiPMs; - - fEta = sipmItr.towerTheta.first; - fPhi = sipmItr.towerPhi.first; - - for (int i = 0; i < sipmData.size(); i++) { - - DRsimInterface::DRsimTimeStruct timeItr = sipmData[i].timeStruct; - - for(auto TmpItr = timeItr.begin(); TmpItr != timeItr.end(); ++TmpItr) { - auto timeData = *TmpItr; - if(DRsimInterface::IsCerenkov(sipmData[i].x, sipmData[i].y)) { - tCtime->Fill((timeData.first.first + timeData.first.second)/2, timeData.second); - if(fEta == iEta && fPhi == iPhi) Ctime->Fill((timeData.first.first + timeData.first.second)/2, timeData.second); - if (timeData.first.first < Cthres) { - ftC_hits += timeData.second; if(fEta == iEta && fPhi == iPhi) fC_hits += timeData.second; - } - } else { - tStime->Fill((timeData.first.first + timeData.first.second)/2, timeData.second); - ftS_hits += timeData.second; - if(fEta == iEta && fPhi == iPhi){ - Stime->Fill((timeData.first.first + timeData.first.second)/2, timeData.second); - fS_hits += timeData.second; - } - } - } - } - } - - tEdep->Fill(ftEdep); - Edep->Fill(fEdep); - Chit->Fill(fC_hits); - Shit->Fill(fS_hits); - tChit->Fill(ftC_hits); - tShit->Fill(ftS_hits); - } - - TCanvas* c = new TCanvas("c",""); - - tEdep->Draw("Hist"); c->SaveAs(filename+"_TotalEdep.png"); - Edep->Draw("Hist"); c->SaveAs(filename+"_Edep.png"); - Chit->Draw(); c->SaveAs(filename+"_Chit.png"); - Shit->Draw(); c->SaveAs(filename+"_Shit.png"); - tChit->Draw(); c->SaveAs(filename+"_TotalChit.png"); - tShit->Draw(); c->SaveAs(filename+"_TotalShit.png"); - Ctime->Draw("Hist"); c->SaveAs(filename+"_Ctime.png"); - Stime->Draw("Hist"); c->SaveAs(filename+"_Stime.png"); - tCtime->Draw("Hist"); c->SaveAs(filename+"_TotalCtime.png"); - tStime->Draw("Hist"); c->SaveAs(filename+"_TotalStime.png"); -} diff --git a/edm4dr.yaml b/edm4dr.yaml index 0267b54..1f9b0e9 100644 --- a/edm4dr.yaml +++ b/edm4dr.yaml @@ -5,23 +5,8 @@ options: includeSubfolder: True components: - # Vector3D with floats - edm4hep::Vector3f : # FIXME already lives in edm4hep, error handling in podio should be improved - Members: - - float x - - float y - - float z - ExtraCode : - declaration: " - Vector3f() : x(0),y(0),z(0) {}\n - Vector3f(float xx, float yy, float zz) : x(xx),y(yy),z(zz) {}\n - Vector3f(const float* v) : x(v[0]),y(v[1]),z(v[2]) {}\n - bool operator==(const Vector3f& v) const { return (x==v.x&&y==v.y&&z==v.z) ; }\n - float operator[](unsigned i) const { return *( &x + i ) ; }\n - " - #------ ObjectID helper struct for references/relations - edm4hep::ObjectID: + edm4hep::ObjectID: # FIXME already lives in edm4hep, error handling in podio should be improved Members: - int index - int collectionID diff --git a/init_k4.sh b/init_k4.sh index c206bbf..818df6c 100644 --- a/init_k4.sh +++ b/init_k4.sh @@ -10,7 +10,7 @@ if [ ! -d k4FWCore ]; then # FIXME LCG100 does not support k4FWCore and HSF spackages do not support ivy-bridge :( git clone https://github.com/key4hep/k4FWCore cd k4FWCore - git checkout v01-00pre09 + git checkout 38d1f2347c36a85f75d84baff144395a553c6bbd mkdir build install cd build cmake -DCMAKE_INSTALL_PREFIX=../install .. && \ @@ -32,7 +32,7 @@ cd $SCRIPT_DIR/.. if [ ! -d k4SimGeant4 ]; then git clone https://github.com/HEP-FCC/k4SimGeant4 cd k4SimGeant4 - git checkout bb238a170a1a73bc5cffc5a861fd6a60f412cfb0 + git checkout v0.1.0pre06 mkdir build install cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_STANDARD=17