Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • maxt/CEPCSW
  • zyjonah/CEPCSW
  • wanjw03/CEPCSW
  • yudian2002/CEPCSW
  • starr136a/CEPCSW
  • fucd/CEPCSW
  • shuohan/CEPCSW
  • glliu/CEPCSW
  • zhangjinxian/CEPCSW_20250110
  • zhangyz/CEPCSW
  • shuxian/CEPCSW
  • lihp29/CEPCSW
  • zhangkl/CEPCSW
  • laipz/CEPCSW
  • lizhihao/CEPCSW
  • yudian2002/cepcsw-otk-endcap-update-01
  • xuchj7/CEPCSW
  • wuchonghao9612/CEPCSW
  • chenye/CEPCSW
  • zhangxm/CEPCSW
  • mengwq/CEPCSW
  • yudian2002/cepcsw-geo-upgrade-v-2
  • fangwx/CEPCSW
  • yudian2002/cepcsw-geo-upgrade
  • jiangxj/CEPCSW
  • yudian2002/cepcsw-otk-end-cap-development
  • guolei/CEPCSW
  • chenbp/CEPCSW
  • dhb112358/CEPCSW
  • tangyb/CEPCSW
  • luhc/CEPCSW
  • songwz/cepcsw-tdr
  • yudian2002/cepcsw-ote-development
  • yudian2002/cepcsw-otb-development
  • dudejing/CEPCSW
  • shexin/CEPCSW
  • sunwy/CEPCSW
  • 1810337/CEPCSW
  • cepcsw/CEPCSW
  • tyzhang/CEPCSW
  • fucd/CEPCSW1
  • xiaolin.wang/CEPCSW
  • wangchu/CEPCSW
  • 201840277/CEPCSW
  • zhaog/CEPCSW
  • shihy/cepcsw-dose
  • myliu/CEPCSW
  • thinking/CEPCSW
  • lihn/CEPCSW
  • 221840222/CEPCSW
  • gongjd1119/CEPCSW
  • tanggy/CEPCSW
  • lintao/CEPCSW
  • guofangyi/cepcsw-release
  • shihy/CEPCSW
  • 1365447033/CEPCSW
  • lizhan/CEPCSW
  • shixin/CEPCSW
  • cepc/CEPCSW
59 results
Show changes
Showing
with 1259 additions and 252 deletions
#ifndef BackgroundBatch_hh
#define BackgroundBatch_hh
#include <cstdint>
#include <vector>
#include "TTimeStamp.h"
class BackgroundBatch {
public:
double start_time; // ns, the start time of the batch, relative to signal event
double duration; // the duration of the batch
int num_events; // the number of events in the batch
// below are the metadata of each type of backgrouds in the batch
std::vector<int> event_numbers_groupby_type; // the number of events for each type
// below are the metadata of each event in the batch
std::vector<size_t> event_types; // the event types in the batch
std::vector<double> event_times; // the relative event times in the batch (in ns)
};
#endif
#ifndef BackgroundLoader_hh
#define BackgroundLoader_hh
#include "IBackgroundLoader.hh"
#include <iostream>
#include <vector>
#include <string>
#include <podio/Frame.h>
#include <podio/ROOTFrameReader.h>
class BackgroundLoader: public IBackgroundLoader {
public:
BackgroundLoader(const std::vector<std::string>& filenames) {
m_reader.openFiles(filenames);
m_max_evt = m_reader.getEntries(podio::Category::Event);
}
virtual ~BackgroundLoader() = default;
bool fill(BackgroundEvent& evt, const double current_time_in_ns) override {
// before load the next event, check whether end or not.
// if reach the end, then go back to the first event.
if (m_current_evt >= m_max_evt) {
m_current_evt = 0;
}
// get the frame of the current event
auto frame = podio::Frame(m_reader.readEntry(podio::Category::Event, m_current_evt));
// before unpack the hits, check the collections name to index map.
if (evt.collection_index.empty()) {
size_t idx = 0;
for (auto col_name: frame.getAvailableCollections()) {
// std::cout << "available collection: " << col_name << std::endl;
evt.collection_index[col_name] = idx;
++idx;
// find the corresponding subdetector type.
for (size_t subdet = 0; subdet < BackgroundEvent::kNSubDetType; ++subdet) {
for (auto key: evt.subdet2colnames[subdet]) {
if (col_name.find(key) != std::string::npos) {
evt.collection_subdet[col_name] = subdet;
break;
}
}
}
}
}
for (auto [name, colidx]: evt.collection_index) {
auto col_ = frame.get(name);
// check whether the collection has a valid subdetector type.
if (evt.collection_subdet.find(name) == evt.collection_subdet.end()) {
continue;
}
auto time_window = evt.subdet2twindow[evt.collection_subdet[name]];
// if the current time is out of the time window, then skip this collection.
if (current_time_in_ns < -time_window || current_time_in_ns > time_window) {
continue;
}
std::cout << "Collection: " << name
<< ", index: " << colidx
<< ", time window: " << time_window << " ns"
<< ", current time: " << current_time_in_ns;
// debug only. don't create any hits.
// conclusion: no memory leakage in the above code.
// continue;
int counter = 0;
if (auto col = dynamic_cast<const edm4hep::SimTrackerHitCollection*>(col_)) {
auto& trk_col = evt.tracker_hits[colidx];
for (auto oldhit: *col) {
auto t = oldhit.getTime() + current_time_in_ns;
if (t < -time_window || t > time_window) {
// if the hit is not in the time window, skip.
continue;
}
auto newhit = trk_col.create();
newhit.setCellID(oldhit.getCellID());
newhit.setEDep(oldhit.getEDep());
newhit.setTime(t); // new
newhit.setPathLength(oldhit.getPathLength());
newhit.setQuality(oldhit.getQuality());
newhit.setPosition(oldhit.getPosition());
newhit.setMomentum(oldhit.getMomentum());
// extra
newhit.setOverlay(true);
++counter;
}
} else if (auto col = dynamic_cast<const edm4hep::SimCalorimeterHitCollection*>(col_)) {
auto& calo_col = evt.calorimeter_hits[colidx];
auto& calo_contrib_col = evt.calo_contribs[colidx];
for (auto oldhit: *col) {
// check whether the hit is in the time window.
bool is_in_window = false;
for (auto contrib: oldhit.getContributions()) {
auto t = contrib.getTime() + current_time_in_ns;
if (t < -time_window || t > time_window) {
continue;
}
is_in_window = true;
break;
}
if (not is_in_window) {
continue;
}
auto newhit = calo_col.create();
newhit.setCellID(oldhit.getCellID());
newhit.setEnergy(oldhit.getEnergy());
newhit.setPosition(oldhit.getPosition());
// todo: fixme
// loop all the contributions and add the time.
for (auto contrib: oldhit.getContributions()) {
auto newcontrib = calo_contrib_col.create();
newcontrib.setPDG(contrib.getPDG());
newcontrib.setEnergy(contrib.getEnergy());
newcontrib.setStepPosition(contrib.getStepPosition());
newcontrib.setTime(contrib.getTime() + current_time_in_ns);
newhit.addToContributions(newcontrib);
}
++counter;
}
} else {
continue;
}
std::cout << ", counter: " << counter << std::endl;
}
++m_current_evt;
return true;
}
private:
podio::ROOTFrameReader m_reader;
unsigned int m_current_evt{0};
unsigned int m_max_evt{0};
};
#endif
\ No newline at end of file
#include "DetSimMixingAlg.hh"
#include "GaudiKernel/IEventProcessor.h"
#include "GaudiKernel/IAppMgrUI.h"
#include "GaudiKernel/GaudiException.h"
#include "GaudiKernel/IRndmEngine.h"
#include <CLHEP/Random/RandExponential.h>
#include <CLHEP/Random/RandFlat.h>
#include <CLHEP/Random/RandPoisson.h>
#include "BackgroundLoader.hh"
DECLARE_COMPONENT(DetSimMixingAlg)
DetSimMixingAlg::DetSimMixingAlg(const std::string& name, ISvcLocator* pSvcLocator)
: Algorithm(name, pSvcLocator) {
}
StatusCode DetSimMixingAlg::initialize() {
StatusCode sc;
info() << "Initialize DetSimMixingAlg... " << endmsg;
// preparation according to user properties
if (m_background_rates.value().size() != m_background_filelists.value().size()) {
error() << "The size of the background rates and filelists should be the same." << endmsg;
return StatusCode::FAILURE;
}
for (auto [type, rate]: m_background_rates.value()) {
if (m_background_filelists.value().find(type) == m_background_filelists.value().end()) {
error() << "The input file lists for the background type " << type << " is not provided." << endmsg;
return StatusCode::FAILURE;
}
m_event_types.push_back(type);
m_event_rates.push_back(rate);
m_input_lists.push_back(m_background_filelists.value()[type]);
}
// prepare the loaders
for (size_t i = 0; i < m_event_types.size(); ++i) {
// only the positive rates are considered into total rates
if (m_event_rates[i] > 0) {
m_total_rates += m_event_rates[i];
}
m_event_loaders.push_back(new BackgroundLoader(m_input_lists[i]));
}
if (m_total_rates < 0) {
error() << "The total rate of the background events should be >= 0." << endmsg;
return StatusCode::FAILURE;
} else if (m_total_rates == 0) {
info() << "All background events will be loaded in fixed time window mode." << endmsg;
} else {
m_total_tau = 1.0 / m_total_rates;
}
info() << "Summary of the background events: " << endmsg;
for (size_t i = 0; i < m_event_types.size(); ++i) {
if (m_event_rates[i] > 0) {
info() << " Event type: " << m_event_types[i] << ", rate: " << m_event_rates[i] << " Hz" << endmsg;
} else {
info() << " Event type: " << m_event_types[i] << ", time window: " << fabs(m_event_rates[i]) << " ns" << endmsg;
}
}
// prepare for the output
// for simplicity, the collection names are with prefix. the key in the map is without prefix, so it is same to the original input.
std::string prefix = "Mixed";
// SimTrackerHitCollections
for (const auto& name : m_trackerColNames) {
std::string name_col = name + "Collection";
auto col = new DataHandle<edm4hep::SimTrackerHitCollection>(prefix + name_col, Gaudi::DataHandle::Writer, this);
m_trackerColMap[name_col] = col;
auto sig_col = new DataHandle<edm4hep::SimTrackerHitCollection>(name_col, Gaudi::DataHandle::Reader, this);
m_sig_trackerColMap[name_col] = col;
}
// SimCalorimeterHitCollections
for (const auto& name : m_calorimeterColNames) {
std::string name_col = name + "Collection";
std::string name_contrib_col = name + "ContributionCollection";
auto col = new DataHandle<edm4hep::SimCalorimeterHitCollection>(prefix + name_col, Gaudi::DataHandle::Writer, this);
m_calorimeterColMap[name_col] = col;
auto col_contrib = new DataHandle<edm4hep::CaloHitContributionCollection>(prefix + name_contrib_col, Gaudi::DataHandle::Writer, this);
m_caloContribColMap[name_col] = col_contrib;
auto sig_col = new DataHandle<edm4hep::SimCalorimeterHitCollection>(name_col, Gaudi::DataHandle::Reader, this);
m_sig_calorimeterColMap[name_col] = sig_col;
auto sig_col_contrib = new DataHandle<edm4hep::CaloHitContributionCollection>(name_contrib_col, Gaudi::DataHandle::Reader, this);
m_sig_caloContribColMap[name_col] = sig_col_contrib;
}
return sc;
}
StatusCode DetSimMixingAlg::execute() {
StatusCode sc;
info() << "Execute DetSimMixingAlg... " << endmsg;
// ========================================================================
// Reset
// ========================================================================
double start_time{0.0}; // ns, the start time of the event, always align to the signal
// ========================================================================
// Prepare the batches
// ========================================================================
std::vector<BackgroundBatch> batches;
int nbatches = 10; // the total number of batches will be 2*nbatches, [-nbatches, nbatches)
double duration = 3460; // duration of each batch (ns): Nbunch x TBunchSpacing = 10 x 346 ns = 3460 ns
for (int i = -nbatches; i < nbatches; ++i) {
BackgroundBatch batch;
batch.start_time = start_time + i*duration;
batch.duration = duration;
// todo: need to sample according to the rate
batch.num_events = 0;
for (size_t evttype = 0; evttype < m_event_types.size(); ++evttype) {
batch.event_numbers_groupby_type.push_back(0);
}
double current_time = 0;
// =======================================================================
// fixed time window mode
// =======================================================================
// insert at beginning, align to the begin of batch
for (size_t evttype = 0; evttype < m_event_types.size(); ++evttype) {
// skip the sampled mode type
if (m_event_rates[evttype] > 0) {
continue;
}
double time_window_event = fabs(m_event_rates[evttype]);
int n_events = std::max(1, static_cast<int>(batch.duration/time_window_event)); // ns
for (size_t j = 0; j < n_events; ++j) {
double this_current_time = j * time_window_event; // ns
++batch.num_events;
batch.event_types.push_back(evttype);
batch.event_times.push_back(this_current_time);
batch.event_numbers_groupby_type[evttype] += 1;
}
}
// =======================================================================
// sampled mode
// =======================================================================
while (m_total_tau>0) {
// sampling and get an event
size_t selected_evttype = 0;
double r = CLHEP::RandFlat::shoot(m_total_rates);
double accumulated = 0;
for (size_t evttype = 0; evttype < m_event_types.size(); ++evttype) {
// skip the fixed time mode type
if (m_event_rates[evttype] <= 0) {
continue;
}
accumulated += m_event_rates[evttype];
if (r < accumulated) {
selected_evttype = evttype;
break;
}
}
// sampling the time
current_time += CLHEP::RandExponential::shoot(m_total_tau)*1e9; // ns
if (current_time > duration) {
break;
}
// add the event to Batch.
++batch.num_events;
batch.event_types.push_back(selected_evttype);
batch.event_times.push_back(current_time);
batch.event_numbers_groupby_type[selected_evttype] += 1;
}
batches.push_back(batch);
}
// ========================================================================
// Unpack the hits from Loader and fill the existing hits into collections
// of BackgroundEvent.
// ========================================================================
BackgroundEvent bkg_evt;
info() << "Creating a BackgroundEvent..." << endmsg;
for (size_t i = 0; i < batches.size(); ++i) {
info() << " Batch " << i << ": " << endmsg;
const BackgroundBatch& batch = batches[i];
for (size_t j = 0; j < batch.num_events; ++j) {
size_t evttype = batch.event_types[j];
double evttime = batch.start_time + batch.event_times[j];
info() << " Event type: " << m_event_types[evttype] << ", time: " << evttime << " ns" << endmsg;
IBackgroundLoader* loader = m_event_loaders[evttype];
if (not loader->fill(bkg_evt, evttime)) {
error() << "Failed to load the next event." << endmsg;
return StatusCode::FAILURE;
}
}
}
info() << "BackgroundEvent created." << endmsg;
info() << "Summary: " << endmsg;
// dump the information
for (auto [name, idx]: bkg_evt.collection_index) {
info() << "- Collection: " << name << ", index: " << idx;
if (bkg_evt.tracker_hits.count(idx)) {
info() << " Tracker hits: " << bkg_evt.tracker_hits[idx].size() << endmsg;
} else if (bkg_evt.calorimeter_hits.count(idx)) {
info() << " Calorimeter hits: " << bkg_evt.calorimeter_hits[idx].size() << endmsg;
} else {
info() << endmsg;
}
}
// ========================================================================
// Put the BackgroundEvent into the event store
// ========================================================================
// add prefix 'Mixed'.
for (auto [col_name, colidx]: bkg_evt.collection_index) {
if (bkg_evt.tracker_hits.count(colidx)) {
auto& col = bkg_evt.tracker_hits[colidx];
auto newcol = m_trackerColMap[col_name]->createAndPut();
// background
for (auto oldhit: col) {
auto newhit = newcol->create();
newhit.setCellID(oldhit.getCellID());
newhit.setEDep(oldhit.getEDep());
newhit.setTime(oldhit.getTime()); // new
newhit.setPathLength(oldhit.getPathLength());
newhit.setQuality(oldhit.getQuality());
newhit.setPosition(oldhit.getPosition());
newhit.setMomentum(oldhit.getMomentum());
}
// signal
auto sig_col = m_sig_trackerColMap[col_name]->get();
if (!sig_col) {
continue;
}
for (auto oldhit: *sig_col) {
auto newhit = newcol->create();
newhit.setCellID(oldhit.getCellID());
newhit.setEDep(oldhit.getEDep());
newhit.setTime(oldhit.getTime()); // new
newhit.setPathLength(oldhit.getPathLength());
newhit.setQuality(oldhit.getQuality());
newhit.setPosition(oldhit.getPosition());
newhit.setMomentum(oldhit.getMomentum());
}
} else if (bkg_evt.calorimeter_hits.count(colidx)) {
auto& col = bkg_evt.calorimeter_hits[colidx];
auto& col_contrib = bkg_evt.calo_contribs[colidx];
auto newcol = m_calorimeterColMap[col_name]->createAndPut();
auto newcol_contrib = m_caloContribColMap[col_name]->createAndPut();
for (auto oldhit: col) {
auto newhit = newcol->create();
newhit.setCellID(oldhit.getCellID());
newhit.setEnergy(oldhit.getEnergy());
newhit.setPosition(oldhit.getPosition());
// todo: fixme
// loop all the contributions and add the time.
for (auto contrib: oldhit.getContributions()) {
auto newcontrib = newcol_contrib->create();
newcontrib.setPDG(contrib.getPDG());
newcontrib.setEnergy(contrib.getEnergy());
newcontrib.setStepPosition(contrib.getStepPosition());
newcontrib.setTime(contrib.getTime());
newhit.addToContributions(newcontrib);
}
}
// signal
auto sig_col = m_sig_calorimeterColMap[col_name]->get();
auto sig_col_contrib = m_sig_caloContribColMap[col_name]->get();
if (!sig_col || !sig_col_contrib) {
continue;
}
for (auto oldhit: *sig_col) {
auto newhit = newcol->create();
newhit.setCellID(oldhit.getCellID());
newhit.setEnergy(oldhit.getEnergy());
newhit.setPosition(oldhit.getPosition());
// todo: fixme
// loop all the contributions and add the time.
for (auto contrib: oldhit.getContributions()) {
auto newcontrib = newcol_contrib->create();
newcontrib.setPDG(contrib.getPDG());
newcontrib.setEnergy(contrib.getEnergy());
newcontrib.setStepPosition(contrib.getStepPosition());
newcontrib.setTime(contrib.getTime());
newhit.addToContributions(newcontrib);
}
}
} else {
error() << "The collection " << col_name
<< " with idx" << colidx
<< " is not found." << endmsg;
continue;
}
}
return sc;
}
StatusCode DetSimMixingAlg::finalize() {
StatusCode sc;
info() << "Finalize DetSimMixingAlg... " << endmsg;
return sc;
}
#ifndef DetSimMixingAlg_hh
#define DetSimMixingAlg_hh
/*
* Description:
* This algorithm is used to generate a mixing event.
* Assume there will be one physics event and multiple background events.
*
* The main algorithm first creates enough BackgroundBatch instances.
* All the metadata will be prepared into the batch.
* Then, the main algorithm will start the mixing and load the real hits.
* The reason to unpack the hits in main algorithm is to reduce the data copy.
*
* About the BackgroundBatch:
*
* -----------------------------------------------> time
* | o x o o x |
* | | |
* | | \-> group by event type 'x', num of events = 2
* | -> group by event type 'o', num of events = 3
* \-> start time
*
* For each event, it consists of several collections. For one batch:
*
* | EventType | Collection 1 | Collection 2 | ... | Collection N |
* | o | | | ... | |
* | x | | | ... | |
* | o | | | ... | |
* | o | | | ... | |
* | x | | | ... | |
*
* The main algorithm needs to loop BackgroundLoader and unpack the collections.
* For each iteration in the loop of the above table, a current event could be accessed.
* According to the current event, the main algorithm could unpack the collections.
*
* Authors:
* Tao Lin <lintao AT ihep.ac.cn>
*/
#include <string>
#include <vector>
#include <map>
#include <GaudiKernel/Algorithm.h>
#include <Gaudi/Property.h>
#include <GaudiKernel/ToolHandle.h>
#include "k4FWCore/DataHandle.h"
#include "BackgroundBatch.hh"
#include "IBackgroundLoader.hh"
class DetSimMixingAlg: public Algorithm {
public:
DetSimMixingAlg(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;
private:
double m_total_rates{0}; // Hz.
double m_total_tau{0}; // s.
private:
std::vector<std::string> m_event_types; // the event types of the background events
std::vector<double> m_event_rates; // the rates of the background events
std::vector<IBackgroundLoader*> m_event_loaders; // the loaders of the background events
std::vector<std::vector<std::string>> m_input_lists; // input files for each backgroud
// following maps are used to load signal collections from memory
std::map<std::string, DataHandle<edm4hep::SimTrackerHitCollection>*> m_sig_trackerColMap;
std::map<std::string, DataHandle<edm4hep::SimCalorimeterHitCollection>*> m_sig_calorimeterColMap;
std::map<std::string, DataHandle<edm4hep::CaloHitContributionCollection>*> m_sig_caloContribColMap;
private:
// following maps are used to put collections into memory
std::map<std::string, DataHandle<edm4hep::SimTrackerHitCollection>*> m_trackerColMap;
std::map<std::string, DataHandle<edm4hep::SimCalorimeterHitCollection>*> m_calorimeterColMap;
std::map<std::string, DataHandle<edm4hep::CaloHitContributionCollection>*> m_caloContribColMap;
// the name here is without suffix "Collection"
Gaudi::Property<std::vector<std::string>> m_trackerColNames{this,
"TrackerCollections",
{"VXD", "ITKBarrel", "ITKEndcap", "TPC", "TPCLowPt", "TPCSpacePoint",
"OTKBarrel", "OTKEndcap", "MuonBarrel", "MuonEndcap"},
"Names of the Tracker collections (without suffix Collection)"};
Gaudi::Property<std::vector<std::string>> m_calorimeterColNames{this,
"CalorimeterCollections",
{"EcalBarrel", "EcalEndcaps", "EcalEndcapRing",
"HcalBarrel", "HcalEndcaps", "HcalEndcapRing"},
"Names of the Calorimeter collections (without suffix Collection)"};
private:
// Following properties are used to configure different types of background events.
// * Key: label of one type
// * Value:
// * rate:
// * FixedTimeWindow: if the rate is less than 0, then always mix the background events. fabs(rate) is the time window of the background events.
// * Sampled: if the rate is larger than 0, then the background events will be sampled according to the rate.
// * filelist: the input file list for this type of background events.
Gaudi::Property<std::map<std::string, double>> m_background_rates{this, "BackgroundRates", {}, "The rates (positive, Hz) or time windows (negative, ns) of the background events"};
Gaudi::Property<std::map<std::string, std::vector<std::string>>> m_background_filelists{this, "BackgroundFileLists", {}, "The input file lists for the background events"};
};
#endif
#ifndef IBackgroundLoader_hh
#define IBackgroundLoader_hh
#include "BackgroundBatch.hh"
#include <map>
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/CaloHitContributionCollection.h"
/*
* Description:
* As there are multiple collections for one event, this BackgrounEvent
* is used to organize these collections.
*
* The key is the index of collection.
*
* BackgroundLoader is resposible to fill its hit collections into the
* BackgroundEvent.
*/
struct BackgroundEvent {
std::map<size_t, edm4hep::SimTrackerHitCollection> tracker_hits;
std::map<size_t, edm4hep::SimCalorimeterHitCollection> calorimeter_hits;
std::map<size_t, edm4hep::CaloHitContributionCollection> calo_contribs;
std::map<std::string, size_t> collection_index; // key is collection name, value is index.
std::map<std::string, size_t> collection_subdet; // key is collection name, value is subdetector type.
// in order to reduce the memory usage, need additional filter setup here.
// for example, for TPC, we need to load all the hits.
// however, for the tracker/calo, we only need to load the hits which are
// in an interested event time window.
enum SubDetType {
kVXD = 0, // 200 ns
kITK = 1, // 200 ns
kTPC = 2, // 34 us
kOTK = 3, // 1 us
kECAL = 4, // 150 ns
kHCAL = 5, // 1 us
kMUON = 6, // 1 us // todo
kNSubDetType
};
std::vector<double> subdet2twindow = {200, 200, 34000, 1000, 150, 1000, 1000}; // key is subdet, value is time window.
std::vector<std::vector<std::string>> subdet2colnames = {
{"VXD"},
{"ITK"},
{"TPC"},
{"OTK"},
{"Ecal"},
{"Hcal"},
{"Muon"}
};
};
class IBackgroundLoader {
public:
virtual ~IBackgroundLoader() = default;
// the loader is responsible to unpack the hits into background event.
// if failed, then return false.
virtual bool fill(BackgroundEvent& bkg_event, const double current_time_in_ns) = 0;
};
#endif
\ No newline at end of file
...@@ -33,6 +33,10 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) { ...@@ -33,6 +33,10 @@ CaloSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
// std::cout << "CaloSensitiveDetector::ProcessHits" << std::endl; // std::cout << "CaloSensitiveDetector::ProcessHits" << std::endl;
dd4hep::sim::Geant4StepHandler h(step); dd4hep::sim::Geant4StepHandler h(step);
// if there is no deposit energy, don't create hit object
if (h.deposit() <= 0) return true;
if(m_applyBirksLaw) h.doApplyBirksLaw(); if(m_applyBirksLaw) h.doApplyBirksLaw();
dd4hep::Position pos = 0.5 * (h.prePos() + h.postPos()); dd4hep::Position pos = 0.5 * (h.prePos() + h.postPos());
HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step); HitContribution contrib = dd4hep::sim::Geant4Hit::extractContribution(step);
......
...@@ -23,10 +23,9 @@ void MuonBarrelSensitiveDetector::Initialize(G4HCofThisEvent* HCE){ ...@@ -23,10 +23,9 @@ void MuonBarrelSensitiveDetector::Initialize(G4HCofThisEvent* HCE){
} }
G4bool MuonBarrelSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){ G4bool MuonBarrelSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){
G4TouchableHandle touchPost = step->GetPostStepPoint()->GetTouchableHandle();
G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle();
dd4hep::sim::Geant4StepHandler h(step); dd4hep::sim::Geant4StepHandler h(step);
//if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; //if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true;
if (h.deposit() <= 0 && !Geant4Hit::isGeantino(step->GetTrack())) return true;
dd4hep::Position prePos = h.prePos(); dd4hep::Position prePos = h.prePos();
dd4hep::Position postPos = h.postPos(); dd4hep::Position postPos = h.postPos();
......
...@@ -24,10 +24,9 @@ void MuonEndcapSensitiveDetector::Initialize(G4HCofThisEvent* HCE){ ...@@ -24,10 +24,9 @@ void MuonEndcapSensitiveDetector::Initialize(G4HCofThisEvent* HCE){
} }
G4bool MuonEndcapSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){ G4bool MuonEndcapSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){
G4TouchableHandle touchPost = step->GetPostStepPoint()->GetTouchableHandle();
G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle();
dd4hep::sim::Geant4StepHandler h(step); dd4hep::sim::Geant4StepHandler h(step);
//if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; //if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true;
if (h.deposit() <= 0 && !Geant4Hit::isGeantino(step->GetTrack())) return true;
dd4hep::Position prePos = h.prePos(); dd4hep::Position prePos = h.prePos();
dd4hep::Position postPos = h.postPos(); dd4hep::Position postPos = h.postPos();
......
...@@ -35,6 +35,10 @@ private: ...@@ -35,6 +35,10 @@ private:
double _relative_position_of_measurement_surface; double _relative_position_of_measurement_surface;
double _shellInnerR;
double _shellOuterR;
double _shellHalfZ;
struct VXD_Layer { struct VXD_Layer {
int nLadders; int nLadders;
double phi0; double phi0;
......
...@@ -207,7 +207,8 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -207,7 +207,8 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
double eps3 = 1.0e-06 ; // layer in disk double eps3 = 1.0e-06 ; // layer in disk
double eps4 = 1.0e-08 ; // forward or backwards double eps4 = 1.0e-08 ; // forward or backwards
double sort_policy = rInner+height + eps1 * idisk + eps3 * 1; //double sort_policy = rInner+height + eps1 * idisk + eps3 * 1;
double sort_policy = fabs(z) + eps1 * idisk + eps3 * 1;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
// if this is the negative z disk add epsilon to the policy // if this is the negative z disk add epsilon to the policy
...@@ -228,7 +229,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -228,7 +229,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// measurement plane // measurement plane
z += zsign*0.5*senThickness; z += zsign*0.5*senThickness;
//sort_policy = fabs(z) ; //sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 2 ; sort_policy = fabs(z) + eps1 * idisk + eps3 * 2 ;
if (z < 0) sort_policy += eps4 ; if (z < 0) sort_policy += eps4 ;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
...@@ -266,7 +267,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -266,7 +267,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// interface between sensitive and support // interface between sensitive and support
z += zsign*0.5*senThickness; z += zsign*0.5*senThickness;
// sort_policy = fabs(z) ; // sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 3; sort_policy = fabs(z) + eps1 * idisk + eps3 * 3;
if (z < 0) sort_policy += eps4; if (z < 0) sort_policy += eps4;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
...@@ -289,7 +290,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -289,7 +290,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// interface between support and sensitive // interface between support and sensitive
z += zsign*supThickness; z += zsign*supThickness;
// sort_policy = fabs(z) ; // sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 4; sort_policy = fabs(z) + eps1 * idisk + eps3 * 4;
if (z < 0) sort_policy += eps4; if (z < 0) sort_policy += eps4;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
...@@ -309,7 +310,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -309,7 +310,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// measurement plane at the back // measurement plane at the back
z += zsign*0.5*senThickness; z += zsign*0.5*senThickness;
// sort_policy = fabs(z) ; // sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 5; sort_policy = fabs(z) + eps1 * idisk + eps3 * 5;
if (z < 0) sort_policy += eps4; if (z < 0) sort_policy += eps4;
if (!even_petals) { if (!even_petals) {
sort_policy += eps2; sort_policy += eps2;
...@@ -349,7 +350,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -349,7 +350,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// rear face of sensitive // rear face of sensitive
z += zsign*0.5*senThickness; z += zsign*0.5*senThickness;
// sort_policy = fabs(z) ; // sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 6; sort_policy = fabs(z) + eps1 * idisk + eps3 * 6;
if (z < 0) sort_policy += eps4; if (z < 0) sort_policy += eps4;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
...@@ -371,7 +372,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm ...@@ -371,7 +372,7 @@ void CEPCOTKEndcapKalDetector::create_segmented_disk_layers(int idisk, int nsegm
// rear face of support // rear face of support
z += zsign*supThickness; z += zsign*supThickness;
// sort_policy = fabs(z) ; // sort_policy = fabs(z) ;
sort_policy = rInner+height + eps1 * idisk + eps3 * 4; sort_policy = fabs(z) + eps1 * idisk + eps3 * 4;
if (z < 0) sort_policy += eps4; if (z < 0) sort_policy += eps4;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "kaldet/ILDSegmentedDiscMeasLayer.h" #include "kaldet/ILDSegmentedDiscMeasLayer.h"
#include "kaldet/ILDDiscMeasLayer.h" #include "kaldet/ILDDiscMeasLayer.h"
#include "kaldet/ILDCylinderMeasLayer.h"
#include "streamlog/streamlog.h" #include "streamlog/streamlog.h"
#include "CLHEP/Units/SystemOfUnits.h" #include "CLHEP/Units/SystemOfUnits.h"
...@@ -43,6 +44,11 @@ void CEPCITKEndcapKalDetector::build() { ...@@ -43,6 +44,11 @@ void CEPCITKEndcapKalDetector::build() {
streamlog_out(DEBUG) << "CEPCITKEndcapKalDetector::build " << std::endl; streamlog_out(DEBUG) << "CEPCITKEndcapKalDetector::build " << std::endl;
double eps = 1e-9; double eps = 1e-9;
double eps1 = 1.0e-04; // disk
double eps2 = 1.0e-05; // odd or even
double eps3 = 1.0e-06; // layer in disk
//double eps4 = 1.0e-07; // ring
double eps5 = 1.0e-08; // forward or backwards
int ndisks = _disksData.layers.size(); int ndisks = _disksData.layers.size();
for (int idisk = 0; idisk < ndisks; idisk++) { for (int idisk = 0; idisk < ndisks; idisk++) {
...@@ -58,6 +64,7 @@ void CEPCITKEndcapKalDetector::build() { ...@@ -58,6 +64,7 @@ void CEPCITKEndcapKalDetector::build() {
double rmaxSupport = disk.rmaxSupport; double rmaxSupport = disk.rmaxSupport;
double thicknessSupport = disk.thicknessSupport; double thicknessSupport = disk.thicknessSupport;
int nrings = rings.size(); int nrings = rings.size();
double thicknessTotal = 0;
for (int iring = 0; iring < nrings; iring++) { for (int iring = 0; iring < nrings; iring++) {
auto& ring = rings[iring]; auto& ring = rings[iring];
...@@ -67,6 +74,11 @@ void CEPCITKEndcapKalDetector::build() { ...@@ -67,6 +74,11 @@ void CEPCITKEndcapKalDetector::build() {
double widthInner = ring.widthInner; double widthInner = ring.widthInner;
double widthOuter = ring.widthOuter; double widthOuter = ring.widthOuter;
double length = ring.length; double length = ring.length;
double tSensitive = ring.thicknessSensitive;
double tGlue = ring.thicknessGlue;
double tService = ring.thicknessService;
double thickness = tSensitive + tGlue + tService;
if (thickness > thicknessTotal) thicknessTotal = thickness;
int nsegments = npetals/2; int nsegments = npetals/2;
this->create_segmented_disk_layers(idisk, iring, nsegments, true, phi0, zPosition); this->create_segmented_disk_layers(idisk, iring, nsegments, true, phi0, zPosition);
...@@ -74,7 +86,7 @@ void CEPCITKEndcapKalDetector::build() { ...@@ -74,7 +86,7 @@ void CEPCITKEndcapKalDetector::build() {
// odd segements // odd segements
// update phi0 by the angular distance of one petal // update phi0 by the angular distance of one petal
phi0 -= 2.0 * M_PI / npetals; phi0 += 2.0 * M_PI / npetals;
this->create_segmented_disk_layers(idisk, iring, nsegments, false, phi0, zPosition); this->create_segmented_disk_layers(idisk, iring, nsegments, false, phi0, zPosition);
this->create_segmented_disk_layers(idisk, iring, nsegments, false, phi0, -zPosition); this->create_segmented_disk_layers(idisk, iring, nsegments, false, phi0, -zPosition);
} }
...@@ -84,33 +96,53 @@ void CEPCITKEndcapKalDetector::build() { ...@@ -84,33 +96,53 @@ void CEPCITKEndcapKalDetector::build() {
Bool_t dummy = false; Bool_t dummy = false;
double z0 = zPosition - 0.5*thicknessSupport + eps; double z_front = zPosition - 0.5*thicknessSupport + eps;
streamlog_out(DEBUG) << "CEPCITKEndcapKalDetector::create air support disk at " << z0 << " sort_policy = " << fabs(z0) << std::endl; double sort_policy = rmaxSupport + idisk * eps1 + 6 * eps3;
streamlog_out(DEBUG) << "CEPCITKEndcapKalDetector::create air support disk at " << z_front << " sort_policy = " << sort_policy << std::endl;
TVector3 xc0_fwd(0.0, 0.0, z0);
TVector3 normal0_fwd(xc0_fwd); TVector3 normal_fwd(0, 0, 1);
normal0_fwd.SetMag(1.0); TVector3 normal_bwd(0, 0,-1);
Add(new ILDDiscMeasLayer(air, support, xc0_fwd, normal0_fwd, _bZ, fabs(z0), rminSupport, rmaxSupport, dummy, -1, "ITKEAirSupportDiscPositiveZ"));
TVector3 xc_front_fwd(0.0, 0.0, z_front);
TVector3 xc0_bwd(0.0, 0.0, -z0); Add(new ILDDiscMeasLayer(air, support, xc_front_fwd, normal_fwd, _bZ, sort_policy, rminSupport, rmaxSupport, dummy, -1, "ITKEAirSupportDiscPositiveZ"));
TVector3 normal0_bwd(xc0_bwd);
normal0_bwd.SetMag(1.0); TVector3 xc_front_bwd(0.0, 0.0, -z_front);
Add(new ILDDiscMeasLayer(support, air, xc0_bwd, normal0_bwd, _bZ, fabs(z0), rminSupport, rmaxSupport, dummy, -1, "ITKEAirSupportDiscNegativeZ")); Add(new ILDDiscMeasLayer(air, support, xc_front_bwd, normal_bwd, _bZ, sort_policy+eps5, rminSupport, rmaxSupport, dummy, -1, "ITKEAirSupportDiscNegativeZ"));
double z1 = zPosition + 0.5*thicknessSupport - eps; double z_rear = zPosition + 0.5*thicknessSupport - eps;
TVector3 xc1_fwd(0.0, 0.0, z1); TVector3 xc_rear_fwd(0.0, 0.0, z_rear);
TVector3 normal1_fwd(xc1_fwd); Add(new ILDDiscMeasLayer(support, air, xc_rear_fwd, normal_fwd, _bZ, sort_policy+eps3, rminSupport, rmaxSupport, dummy, -1, "ITKESupportAirDiscPositiveZ"));
normal1_fwd.SetMag(1.0);
Add(new ILDDiscMeasLayer(air, support, xc1_fwd, normal1_fwd, _bZ, fabs(z1), rminSupport, rmaxSupport, dummy, -1, "ITKESupportAirDiscPositiveZ")); TVector3 xc_rear_bwd(0.0, 0.0, -z_rear);
Add(new ILDDiscMeasLayer(support, air, xc_rear_bwd, normal_bwd, _bZ, sort_policy+eps3+eps5, rminSupport, rmaxSupport, dummy, -1, "ITKESupportAirDiscNegativeZ"));
TVector3 xc1_bwd(0.0, 0.0, -z1);
TVector3 normal1_bwd(xc1_bwd); double inner_radius = rminSupport - idisk * eps1;
normal1_bwd.SetMag(1.0); double outer_radius = rmaxSupport + idisk * eps1 + 2 * eps2;
Add(new ILDDiscMeasLayer(support, air, xc1_bwd, normal1_bwd, _bZ, fabs(z1), rminSupport, rmaxSupport, dummy, -1, "ITKESupportAirDiscNegativeZ"));
Add(new ILDCylinderMeasLayer(air, air, inner_radius, 0.5*thicknessSupport+thicknessTotal+eps, 0, 0, zPosition, _bZ, dummy, -1, "ITKEInnerEdgePositiveZ"));
Add(new ILDCylinderMeasLayer(air, air, inner_radius, 0.5*thicknessSupport+thicknessTotal+eps, 0, 0, -zPosition, _bZ, dummy, -1, "ITKEInnerEdgeNegativeZ"));
sort_policy = rmaxSupport + idisk * eps1;
TVector3 xc_front_edge_fwd(0.0, 0.0, zPosition - 0.5*thicknessSupport - thicknessTotal - eps);
Add(new ILDDiscMeasLayer(air, air, xc_front_edge_fwd, normal_fwd, _bZ, sort_policy, inner_radius, outer_radius, dummy, -1, "ITKEFrontEdgePositiveZ"));
TVector3 xc_front_edge_bwd(0.0, 0.0, -zPosition + 0.5*thicknessSupport + thicknessTotal + eps);
Add(new ILDDiscMeasLayer(air, air, xc_front_edge_bwd, normal_bwd, _bZ, sort_policy+eps5, inner_radius, outer_radius, dummy, -1, "ITKEFrontEdgeNegativeZ"));
Add(new ILDCylinderMeasLayer(air, air, outer_radius, 0.5*thicknessSupport+thicknessTotal+eps, 0, 0, zPosition, _bZ, dummy, -1, "ITKEOuterEdgePositiveZ"));
Add(new ILDCylinderMeasLayer(air, air, outer_radius, 0.5*thicknessSupport+thicknessTotal+eps, 0, 0, -zPosition, _bZ, dummy, -1, "ITKEOuterEdgeNegativeZ"));
sort_policy = rmaxSupport + idisk * eps1 + 3 * eps2;
TVector3 xc_rear_edge_fwd(0.0, 0.0, zPosition + 0.5*thicknessSupport + thicknessTotal + eps);
Add(new ILDDiscMeasLayer(air, air, xc_rear_edge_fwd, normal_fwd, _bZ, sort_policy, inner_radius, outer_radius, dummy, -1, "ITKERearEdgePositiveZ"));
TVector3 xc_rear_edge_bwd(0.0, 0.0, -zPosition - 0.5*thicknessSupport - thicknessTotal - eps);
Add(new ILDDiscMeasLayer(air, air, xc_rear_edge_bwd, normal_bwd, _bZ, sort_policy+eps5, inner_radius, outer_radius, dummy, -1, "ITKERearEdgeNegativeZ"));
} }
streamlog_out(DEBUG1) << "MultiRingsZDisk based ITKEndcap MeasLayer created" << std::endl;
} }
void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring, int nsegments, bool even_petals, double phi0, double zpos) { void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring, int nsegments, bool even_petals, double phi0, double zpos) {
...@@ -141,16 +173,19 @@ void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring ...@@ -141,16 +173,19 @@ void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring
} }
// create segmented disk // create segmented disk
double rmaxSupport = _disksData.layers[idisk].rmaxSupport;
double eps1 = 1.0e-04; // ring double eps1 = 1.0e-04; // disk
double eps2 = 1.0e-05; // odd or even double eps2 = 1.0e-05; // odd or even
double eps3 = 1.0e-06; // layer in disk double eps3 = 1.0e-06; // layer in disk
double eps4 = 1.0e-08; // forward or backwards double eps4 = 1.0e-07; // ring
double eps5 = 1.0e-08; // forward or backwards
//double sort_policy = fabs(z); //double sort_policy = fabs(z);
//double sort_policy = rInner+height + eps1 * idisk + eps3 * 1 ; //double sort_policy = rInner+height + eps1 * idisk + eps3 * 1 ;
double sort_policy = eps1 * iring; //double sort_policy = eps1 * iring;
double sort_policy = rmaxSupport + eps1 * idisk + eps3 + eps4 * iring;
if (!even_petals) sort_policy += eps2; if (!even_petals) sort_policy += eps2;
if (zpos < 0) sort_policy += eps4; if (zpos < 0) sort_policy += eps5;
double tSupport = _disksData.layers[idisk].thicknessSupport; double tSupport = _disksData.layers[idisk].thicknessSupport;
double tSensitive = _disksData.layers[idisk].rings[iring].thicknessSensitive; double tSensitive = _disksData.layers[idisk].rings[iring].thicknessSensitive;
...@@ -167,26 +202,26 @@ void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring ...@@ -167,26 +202,26 @@ void CEPCITKEndcapKalDetector::create_segmented_disk_layers(int idisk, int iring
TMaterial& rear = even_petals ? glue : service; TMaterial& rear = even_petals ? glue : service;
double z = even_petals ? zpos - zsign*(0.5*tSupport + tRear + tSensitive + tFront) : zpos + zsign*(0.5*tSupport); double z = even_petals ? zpos - zsign*(0.5*tSupport + tRear + tSensitive + tFront) : zpos + zsign*(0.5*tSupport);
streamlog_out(DEBUG1) << "CEPCITKEndcapKalDetector::create_segmented_disk add front face of sensitive at " << z << " sort_policy = " << fabs(z)+sort_policy << std::endl; streamlog_out(DEBUG1) << "CEPCITKEndcapKalDetector::create_segmented_disk add front face of sensitive at " << z << " sort_policy = " << sort_policy << std::endl;
const char *name1 = z > 0 ? "ITKEFrontFacePositiveZ" : "ITKEFrontFaceNegativeZ"; const char *name1 = z > 0 ? (even_petals ? "ITKEFrontFacePositiveZ_even" : "ITKEFrontFacePositiveZ_odd") : (even_petals ? "ITKEFrontFaceNegativeZ_even" : "ITKEFrontFaceNegativeZ_odd");
Add(new ILDSegmentedDiscMeasLayer(air, front, _bZ, fabs(z)+sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name1)); Add(new ILDSegmentedDiscMeasLayer(air, front, _bZ, sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name1));
z += zsign*tFront; z += zsign*tFront;
const char *name2 = z > 0 ? "ITKEFrontPositiveZ" : "ITKEFrontNegativeZ"; const char *name2 = z > 0 ? (even_petals ? "ITKEFrontPositiveZ_even" : "ITKEFrontPositiveZ_odd") : (even_petals ? "ITKEFrontNegativeZ_even" : "ITKEFrontNegativeZ_odd");
Add(new ILDSegmentedDiscMeasLayer(front, silicon, _bZ, fabs(z)+sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name2)); Add(new ILDSegmentedDiscMeasLayer(front, silicon, _bZ, sort_policy+eps3, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name2));
z += zsign*0.5*tSensitive; z += zsign*0.5*tSensitive;
const char *name3 = z > 0 ? "ITKESenPositiveZ" : "ITKESenNegativeZ"; const char *name3 = z > 0 ? (even_petals ? "ITKESenPositiveZ_even" : "ITKESenPositiveZ_odd") : (even_petals ? "ITKESenNegativeZ_even" : "ITKESenNegativeZ_odd");
Add( new ILDSegmentedDiscMeasLayer(silicon, silicon, _bZ, fabs(z)+sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, active, module_ids, name3)); Add( new ILDSegmentedDiscMeasLayer(silicon, silicon, _bZ, sort_policy+2*eps3, nsegments, z, phi0, rInner, height, widthInner, widthOuter, active, module_ids, name3));
z += zsign*0.5*tSensitive; z += zsign*0.5*tSensitive;
const char *name4 = z > 0 ? "ITKERearPositiveZ" : "ITKERearNegativeZ"; const char *name4 = z > 0 ? (even_petals ? "ITKERearPositiveZ_even" : "ITKERearPositiveZ_odd") : (even_petals ? "ITKERearNegativeZ_even" : "ITKERearNegativeZ_odd");
Add( new ILDSegmentedDiscMeasLayer(silicon, rear, _bZ, fabs(z)+sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name4)); Add( new ILDSegmentedDiscMeasLayer(silicon, rear, _bZ, sort_policy+3*eps3, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name4));
z += zsign*tRear; z += zsign*tRear;
const char *name5 = z > 0 ? "ITKERearFacePositiveZ" : "ITKERearFaceNegativeZ"; const char *name5 = z > 0 ? (even_petals ? "ITKERearFacePositiveZ_even" : "ITKERearFacePositiveZ_odd") : (even_petals ? "ITKERearFaceNegativeZ_even" : "ITKERearFaceNegativeZ_odd");
Add(new ILDSegmentedDiscMeasLayer(rear, air, _bZ, fabs(z)+sort_policy, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name5)); Add(new ILDSegmentedDiscMeasLayer(rear, air, _bZ, sort_policy+4*eps3, nsegments, z, phi0, rInner, height, widthInner, widthOuter, dummy, name5));
} }
void CEPCITKEndcapKalDetector::setupGearGeom(const gear::GearMgr& gearMgr) { void CEPCITKEndcapKalDetector::setupGearGeom(const gear::GearMgr& gearMgr) {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "kaldet/CEPCITKKalDetector.h" #include "kaldet/CEPCITKKalDetector.h"
#include "kaldet/MaterialDataBase.h" #include "kaldet/MaterialDataBase.h"
#include "kaldet/ILDParallelPlanarStripMeasLayer.h" #include "kaldet/ILDParallelPlanarStripMeasLayer.h"
#include "kaldet/ILDCylinderMeasLayer.h"
#include <UTIL/BitField64.h> #include <UTIL/BitField64.h>
#include <UTIL/ILDConf.h> #include <UTIL/ILDConf.h>
...@@ -80,6 +81,11 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc* ...@@ -80,6 +81,11 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc*
const double width = _ITKgeo[layer].width ; const double width = _ITKgeo[layer].width ;
const double length = _ITKgeo[layer].length; const double length = _ITKgeo[layer].length;
double nonoverlap_width = width / 2.0;
double nonoverlap_offset = offset - offset/fabs(offset) * (width/2.0 - nonoverlap_width/2.0);
double overlap_width = width - nonoverlap_width;
double overlap_offset = offset + offset/fabs(offset) * (width/2.0 - overlap_width/2.0);
double currPhi; double currPhi;
const double dphi = _ITKgeo[layer].dphi ; const double dphi = _ITKgeo[layer].dphi ;
...@@ -103,63 +109,142 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc* ...@@ -103,63 +109,142 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc*
encoder[lcio::ILDCellID0::side] = 0 ; encoder[lcio::ILDCellID0::side] = 0 ;
encoder[lcio::ILDCellID0::layer] = layer ; encoder[lcio::ILDCellID0::layer] = layer ;
encoder[lcio::ILDCellID0::module] = ladder ; encoder[lcio::ILDCellID0::module] = ladder ;
int nsort = offset > 0 ? (nLadders - ladder)%nLadders : ladder;
// check if the sensitive is inside or outside for the support // check if the sensitive is inside or outside for the support
if( sensitive_distance < ladder_distance ) { if( sensitive_distance < ladder_distance ) {
double sen_front_sorting_policy = sensitive_distance + (4 * nsort + 0) * eps_layer;
double sen_front_sorting_policy = sensitive_distance + (4 * ladder+0) * eps_layer ; double sen_back_sorting_policy = sensitive_distance + (4 * nsort + 2) * eps_layer;
double sen_back_sorting_policy = sensitive_distance + (4 * ladder+2) * eps_layer ; double sup_back_sorting_policy = sensitive_distance + (4 * nsort + 3) * eps_layer;
double sup_back_sorting_policy = ladder_distance + (4 * ladder+3) * eps_layer ;
// overlap sorting policy uses nLadders as the overlapping "ladder" is the order i.e. there will now be nLadders+1
// air - sensitive boundary double overlap_front_sorting_policy = sensitive_distance + (4 * nLadders + 0) * eps_layer;
Add(new ILDParallelPlanarMeasLayer(air, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSenFront")) ; double overlap_back_sorting_policy = sensitive_distance + (4 * nLadders + 2) * eps_layer;
double overlap_sup_back_sorting_policy = sensitive_distance + (4 * nLadders + 3) * eps_layer;
// air - sensitive boundary
if (ladder == 0) {
double overlap_front_sorting_policy = sensitive_distance + (4 * nLadders + 0) * eps_layer;
Add(new ILDParallelPlanarMeasLayer(air, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSenFront_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(air, silicon, sensitive_distance, currPhi, _bZ, overlap_front_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSenFront_nonoverlap"));
}
else {
Add(new ILDParallelPlanarMeasLayer(air, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSenFront"));
}
for (int isensor=0; isensor<nsensors; ++isensor) { for (int isensor=0; isensor<nsensors; ++isensor) {
encoder[lcio::ILDCellID0::sensor] = isensor ; encoder[lcio::ILDCellID0::sensor] = isensor ;
int CellID = encoder.lowWord() ; int CellID = encoder.lowWord() ;
double measurement_plane_sorting_policy = sensitive_distance + (4 * ladder+1) * eps_layer + eps_sensor * isensor ; double measurement_plane_sorting_policy = sensitive_distance + (4 * nsort + 1) * eps_layer + eps_sensor * isensor;
double overlap_measurement_plane_sorting_policy = sensitive_distance + (4 * nLadders + 1) * eps_layer + eps_sensor * isensor;
double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor%(nsensors/nrow))*sensor_length; double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor%(nsensors/nrow))*sensor_length;
if (z_centre_sensor>0) z_centre_sensor += gap; if (z_centre_sensor>0) z_centre_sensor += gap;
if (_isStripDetector) { if (_isStripDetector) {
// measurement plane defined as the middle of the sensitive volume // measurement plane defined as the middle of the sensitive volume
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy, width, sensor_length, offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer")) ; if (ladder == 0) {
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
nonoverlap_width, sensor_length, nonoverlap_offset, z_centre_sensor, offset, stripAngle, CellID,
"ITKStripMeaslayer_nonoverlap"));
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, overlap_measurement_plane_sorting_policy,
overlap_width, sensor_length, overlap_offset, z_centre_sensor, offset, stripAngle, CellID,
"ITKStripMeaslayer_overlap"));
}
else {
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
width, sensor_length, offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer"));
}
} }
else { else {
// measurement plane defined as the middle of the sensitive volume // measurement plane defined as the middle of the sensitive volume
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy, width, sensor_length, offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer")) ; if (ladder == 0) {
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
nonoverlap_width, sensor_length, nonoverlap_offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, overlap_measurement_plane_sorting_policy,
overlap_width, sensor_length, overlap_offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer_overlap"));
}
else {
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
width, sensor_length, offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer"));
}
} }
//std::cout << "CEPCITKKalDetector add surface with CellID = " << CellID << std::endl ; //std::cout << "CEPCITKKalDetector add surface with CellID = " << CellID << std::endl ;
} }
// sensitive - support boundary // sensitive - support boundary
Add(new ILDParallelPlanarMeasLayer(silicon, carbon, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSenSupportIntf" )) ; if (ladder == 0) {
Add(new ILDParallelPlanarMeasLayer(silicon, carbon, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(silicon, carbon, sensitive_distance+sensitive_thickness, currPhi, _bZ, overlap_back_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf_overlap"));
}
else {
Add(new ILDParallelPlanarMeasLayer(silicon, carbon, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf"));
}
// support - air boundary // support - air boundary
Add(new ILDParallelPlanarMeasLayer(carbon, air, ladder_distance+ladder_thickness, currPhi, _bZ, sup_back_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSupRear" )) ; if (ladder == 0) {
Add(new ILDParallelPlanarMeasLayer(carbon, air, ladder_distance+ladder_thickness, currPhi, _bZ, sup_back_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSupRear_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(carbon, air, ladder_distance+ladder_thickness, currPhi, _bZ, overlap_sup_back_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSupRear_overlap"));
}
else {
Add(new ILDParallelPlanarMeasLayer(carbon, air, ladder_distance+ladder_thickness, currPhi, _bZ, sup_back_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSupRear"));
}
} }
else { else {
double sup_front_sorting_policy = sensitive_distance + (4 * nsort + 0) * eps_layer;
double sup_front_sorting_policy = ladder_distance + (4 * ladder+0) * eps_layer ; double sen_front_sorting_policy = sensitive_distance + (4 * nsort + 1) * eps_layer;
double sen_front_sorting_policy = sensitive_distance + (4 * ladder+1) * eps_layer ; double sen_back_sorting_policy = sensitive_distance + (4 * nsort + 3) * eps_layer;
double sen_back_sorting_policy = sensitive_distance + (4 * ladder+3) * eps_layer ; // overlap sorting policy uses nLadders as the overlapping "ladder" is the order i.e. there will now be nLadders+1
double overlap_sup_front_sorting_policy = sensitive_distance + (4 * nLadders + 0) * eps_layer;
// air - support boundary double overlap_sen_front_sorting_policy = sensitive_distance + (4 * nLadders + 1) * eps_layer;
Add(new ILDParallelPlanarMeasLayer(air, carbon, ladder_distance, currPhi, _bZ, sup_front_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSupFront")) ; double overlap_sen_back_sorting_policy = sensitive_distance + (4 * nLadders + 3) * eps_layer;
// support boundary - sensitive if (ladder == 0) {
Add(new ILDParallelPlanarMeasLayer(carbon, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSenSupportIntf" )) ; // air - support boundary
Add(new ILDParallelPlanarMeasLayer(air, carbon, ladder_distance, currPhi, _bZ, sup_front_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSupFront_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(air, carbon, ladder_distance, currPhi, _bZ, overlap_sup_front_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSupFront_overlap"));
// support boundary - sensitive
Add(new ILDParallelPlanarMeasLayer(carbon, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(carbon, silicon, sensitive_distance, currPhi, _bZ, overlap_sen_front_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf_overlap"));
// support - air boundary
Add(new ILDParallelPlanarMeasLayer(silicon, air, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy,
nonoverlap_width, length, nonoverlap_offset, z_centre_support, offset, dummy, -1, "ITKSenRear_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(silicon, air, sensitive_distance+sensitive_thickness, currPhi, _bZ, overlap_sen_back_sorting_policy,
overlap_width, length, overlap_offset, z_centre_support, offset, dummy, -1, "ITKSenRear_overlap"));
}
else {
// air - support boundary
Add(new ILDParallelPlanarMeasLayer(air, carbon, ladder_distance, currPhi, _bZ, sup_front_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSupFront"));
// support boundary - sensitive
Add(new ILDParallelPlanarMeasLayer(carbon, silicon, sensitive_distance, currPhi, _bZ, sen_front_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSenSupportIntf"));
// support - air boundary
Add(new ILDParallelPlanarMeasLayer(silicon, air, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy,
width, length, offset, z_centre_support, offset, dummy, -1, "ITKSenRear"));
}
for (int isensor=0; isensor<nsensors; ++isensor) { for (int isensor=0; isensor<nsensors; ++isensor) {
encoder[lcio::ILDCellID0::sensor] = isensor ; encoder[lcio::ILDCellID0::sensor] = isensor ;
int CellID = encoder.lowWord() ; int CellID = encoder.lowWord() ;
double measurement_plane_sorting_policy = sensitive_distance + (4 * ladder+2) * eps_layer + eps_sensor * isensor ; double measurement_plane_sorting_policy = sensitive_distance + (4 * nsort + 2) * eps_layer + eps_sensor * isensor;
double overlap_measurement_plane_sorting_policy = sensitive_distance + (4 * nLadders + 2) * eps_layer + eps_sensor * isensor;
//double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor*sensor_length) ; //double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor*sensor_length) ;
double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor%(nsensors/nrow))*sensor_length; double z_centre_sensor = -0.5*length + (0.5*sensor_length) + (isensor%(nsensors/nrow))*sensor_length;
...@@ -167,19 +252,35 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc* ...@@ -167,19 +252,35 @@ CEPCITKKalDetector::CEPCITKKalDetector( const gear::GearMgr& gearMgr, IGeomSvc*
if (_isStripDetector) { if (_isStripDetector) {
// measurement plane defined as the middle of the sensitive volume // measurement plane defined as the middle of the sensitive volume
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy, width, sensor_length, offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer")) ; if (ladder == 0) {
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
nonoverlap_width, sensor_length, nonoverlap_offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer_nonoverlap"));
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, overlap_measurement_plane_sorting_policy,
overlap_width, sensor_length, overlap_offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer_overlap"));
}
else {
Add(new ILDParallelPlanarStripMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
width, sensor_length, offset, z_centre_sensor, offset, stripAngle, CellID, "ITKStripMeaslayer"));
}
} else { } else {
// measurement plane defined as the middle of the sensitive volume // measurement plane defined as the middle of the sensitive volume
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy, width, sensor_length, offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer")) ; if (ladder == 0) {
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
nonoverlap_width, sensor_length, nonoverlap_offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer_nonoverlap"));
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, overlap_measurement_plane_sorting_policy,
overlap_width, sensor_length, overlap_offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer_overlap"));
}
else {
Add(new ILDParallelPlanarMeasLayer(silicon, silicon, sensitive_distance+sensitive_thickness*0.5, currPhi, _bZ, measurement_plane_sorting_policy,
width, sensor_length, offset, z_centre_sensor, offset, true, CellID, "ITKMeaslayer"));
}
} }
//std::cout << "CEPCITKKalDetector add surface with CellID = " << CellID << std::endl ; //std::cout << "CEPCITKKalDetector add surface with CellID = " << CellID << std::endl ;
} }
// support - air boundary
Add(new ILDParallelPlanarMeasLayer(silicon, air, sensitive_distance+sensitive_thickness, currPhi, _bZ, sen_back_sorting_policy, width, length, offset, z_centre_support, offset, dummy,-1,"ITKSenRear" )) ;
} }
} }
double redge = sqrt((ladder_distance+ladder_thickness)*(ladder_distance+ladder_thickness) + (fabs(offset)+0.5*width) * (fabs(offset)+0.5*width)) + eps_layer;
Add(new ILDCylinderMeasLayer(air, air, redge, 0.5*length, 0, 0, 0, _bZ, dummy, -1, "ITKOuterEdge"));
} }
SetOwner(); SetOwner();
......
...@@ -347,7 +347,7 @@ TVKalDetector(10) ...@@ -347,7 +347,7 @@ TVKalDetector(10)
TVector3 front_face_normal_bwd(front_face_centre_bwd); TVector3 front_face_normal_bwd(front_face_centre_bwd);
front_face_normal_bwd.SetMag(1.0); front_face_normal_bwd.SetMag(1.0);
Add (new ILDDiscMeasLayer(air, air, front_face_centre_bwd,front_face_normal_bwd, bz, -z_min_ecal_ecap, 0., r_max_ecal_ecap/cos(M_PI/8.0), true, encoder.lowWord(),"ECalEndcapFace-Z")); Add (new ILDDiscMeasLayer(air, air, front_face_centre_bwd,front_face_normal_bwd, bz, z_min_ecal_ecap+1e-8, 0., r_max_ecal_ecap/cos(M_PI/8.0), true, encoder.lowWord(),"ECalEndcapFace-Z"));
// streamlog_out( DEBUG0 ) << " *** adding ECalEndcapFace-Z Measurement layer at Zmin = " << front_face_centre_bwd.z() << " and Rmax = " << r_max_ecal_ecap/cos(M_PI/8.0) << std::endl ; // streamlog_out( DEBUG0 ) << " *** adding ECalEndcapFace-Z Measurement layer at Zmin = " << front_face_centre_bwd.z() << " and Rmax = " << r_max_ecal_ecap/cos(M_PI/8.0) << std::endl ;
......
...@@ -203,13 +203,13 @@ TVKalDetector(250) // SJA:FIXME initial size, 250 looks reasonable for ILD, thou ...@@ -203,13 +203,13 @@ TVKalDetector(250) // SJA:FIXME initial size, 250 looks reasonable for ILD, thou
Add(new ILDDiscMeasLayer(tpcgas, tpcreadout, TVector3(0,0,zminReadout), TVector3(0,0,1), bz, zminReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace+Z1")); Add(new ILDDiscMeasLayer(tpcgas, tpcreadout, TVector3(0,0,zminReadout), TVector3(0,0,1), bz, zminReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace+Z1"));
Add(new ILDDiscMeasLayer(tpcreadout, air, TVector3(0,0,zmaxReadout), TVector3(0,0,1), bz, zmaxReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace+Z2")); Add(new ILDDiscMeasLayer(tpcreadout, air, TVector3(0,0,zmaxReadout), TVector3(0,0,1), bz, zmaxReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace+Z2"));
Add(new ILDDiscMeasLayer(air, tpcendplate, TVector3(0,0,zminEndplate), TVector3(0,0,1), bz, zminEndplate, rminEndplate, rmaxEndplate, dummy, -1,"EPCEndplateFace+Z1")); Add(new ILDDiscMeasLayer(air, tpcendplate, TVector3(0,0,zminEndplate), TVector3(0,0,1), bz, zminEndplate, rtub, outerr, dummy, -1,"TPCEndplateFace+Z1"));
Add(new ILDDiscMeasLayer(tpcendplate, air, TVector3(0,0,zmaxEndplate), TVector3(0,0,1), bz, zmaxEndplate, rminEndplate, rmaxEndplate, dummy, -1,"EPCEndplateFace+Z2")); Add(new ILDDiscMeasLayer(tpcendplate, air, TVector3(0,0,zmaxEndplate), TVector3(0,0,1), bz, zmaxEndplate, rtub, outerr, dummy, -1,"TPCEndplateFace+Z2"));
Add(new ILDDiscMeasLayer(tpcgas, tpcreadout, TVector3(0,0,-zminReadout), TVector3(0,0,-1), bz, -zminReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace-Z1")); Add(new ILDDiscMeasLayer(tpcgas, tpcreadout, TVector3(0,0,-zminReadout), TVector3(0,0,-1), bz, zminReadout+1e-8, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace-Z1"));
Add(new ILDDiscMeasLayer(tpcreadout, air, TVector3(0,0,-zmaxReadout), TVector3(0,0,-1), bz, -zmaxReadout, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace-Z2")); Add(new ILDDiscMeasLayer(tpcreadout, air, TVector3(0,0,-zmaxReadout), TVector3(0,0,-1), bz, zmaxReadout+1e-8, rminReadout, rmaxReadout, dummy, -1, "TPCReadoutFace-Z2"));
Add(new ILDDiscMeasLayer(air, tpcendplate, TVector3(0,0,-zminEndplate), TVector3(0,0,-1), bz, -zminEndplate, rminEndplate, rmaxEndplate, dummy, -1,"EPCEndplateFace-Z1")); Add(new ILDDiscMeasLayer(air, tpcendplate, TVector3(0,0,-zminEndplate), TVector3(0,0,-1), bz, zminEndplate+1e-8, rtub, outerr, dummy, -1,"TPCEndplateFace-Z1"));
Add(new ILDDiscMeasLayer(tpcendplate, air, TVector3(0,0,-zmaxEndplate), TVector3(0,0,-1), bz, -zmaxEndplate, rminEndplate, rmaxEndplate, dummy, -1,"EPCEndplateFace-Z2")); Add(new ILDDiscMeasLayer(tpcendplate, air, TVector3(0,0,-zmaxEndplate), TVector3(0,0,-1), bz, zmaxEndplate+1e-8, rtub, outerr, dummy, -1,"TPCEndplateFace-Z2"));
SetOwner(); SetOwner();
} }
......
...@@ -2,19 +2,32 @@ ...@@ -2,19 +2,32 @@
# Description: # Description:
# This script is used to build the CEPCSW docs. # This script is used to build the CEPCSW docs.
function install-sphinx() {
if [ ! -d "venv" ]; then
python -m venv venv
source venv/bin/activate
# pip install -r requirements.txt
pip install sphinx-rtd-theme myst-parser
else
source venv/bin/activate
fi
}
function check-sphinx() { function check-sphinx() {
which sphinx-build >& /dev/null which sphinx-build >& /dev/null
} }
function run-build-docs() { function run-build-docs() {
pushd docs
make html make html
popd
} }
pushd docs
install-sphinx
if check-sphinx; then if check-sphinx; then
run-build-docs run-build-docs
else else
echo "Please setup sphinx before build the docs. " 1>&2 echo "Please setup sphinx before build the docs. " 1>&2
exit -1 exit -1
fi fi
popd
...@@ -94,7 +94,7 @@ endif() ...@@ -94,7 +94,7 @@ endif()
if (CEPCSW_USE_SYSTEM_EDM4CEPC) if (CEPCSW_USE_SYSTEM_EDM4CEPC)
message("Try to use an existing installation of EDM4CEPC") message("Try to use an existing installation of EDM4CEPC")
find_package(EDM4CEPC) find_package(EDM4CEPC REQUIRED)
else() else()
message("Try to use an internal installation of EDM4CEPC") message("Try to use an internal installation of EDM4CEPC")
include("${CMAKE_CURRENT_LIST_DIR}/internal_edm4cepc.cmake") include("${CMAKE_CURRENT_LIST_DIR}/internal_edm4cepc.cmake")
......
...@@ -19,23 +19,23 @@ option(CEPCSW_USE_SYSTEM_CKF_BELLE ...@@ -19,23 +19,23 @@ option(CEPCSW_USE_SYSTEM_CKF_BELLE
"Use the existing installation of CKF BELLE. Otherwise the internal version will be used." "Use the existing installation of CKF BELLE. Otherwise the internal version will be used."
FALSE) FALSE)
option(CEPCSW_USER_SYSTEM_EDM4CEPC option(CEPCSW_USE_SYSTEM_EDM4CEPC
"Use the existing installation of EDM4CEPC. Otherwise the internal version will be used." "Use the existing installation of EDM4CEPC. Otherwise the internal version will be used."
FALSE) TRUE)
option(CEPCSW_USER_SYSTEM_ILCUTIL option(CEPCSW_USE_SYSTEM_ILCUTIL
"Use the existing installation of ILCUTIL. Otherwise the internal version will be used." "Use the existing installation of ILCUTIL. Otherwise the internal version will be used."
FALSE) FALSE)
option(CEPCSW_USER_SYSTEM_AIDATT option(CEPCSW_USE_SYSTEM_AIDATT
"Use the existing installation of aidaTT. Otherwise the internal version will be used." "Use the existing installation of aidaTT. Otherwise the internal version will be used."
FALSE) FALSE)
option(CEPCSW_USER_SYSTEM_KALTEST option(CEPCSW_USE_SYSTEM_KALTEST
"Use the existing installation of KalTest. Otherwise the internal version will be used." "Use the existing installation of KalTest. Otherwise the internal version will be used."
FALSE) FALSE)
option(CEPCSW_USER_SYSTEM_DDKALTEST option(CEPCSW_USE_SYSTEM_DDKALTEST
"Use the existing installation of DDKalTest. Otherwise the internal version will be used." "Use the existing installation of DDKalTest. Otherwise the internal version will be used."
FALSE) FALSE)
......
...@@ -13,7 +13,7 @@ It consists three major parts: ...@@ -13,7 +13,7 @@ It consists three major parts:
To use CEPCSW, users can use the software release deployed at IHEP's CVMFS or build from source code. To use CEPCSW, users can use the software release deployed at IHEP's CVMFS or build from source code.
Currently, the libraries are built in `CentOS 7`. If you are using other different operating systems, you can consider to use the container technologies, such as Docker, Apptainer. Currently, the libraries are built in `AlmaLinux 9` (previously it is `CentOS 7`). If you are using other different operating systems, you can consider to use the container technologies, such as Docker, Apptainer.
### SSH login ### SSH login
If you already have an IHEP AFS account, you can first login using an SSH client, such as OpenSSH: If you already have an IHEP AFS account, you can first login using an SSH client, such as OpenSSH:
...@@ -21,8 +21,10 @@ If you already have an IHEP AFS account, you can first login using an SSH client ...@@ -21,8 +21,10 @@ If you already have an IHEP AFS account, you can first login using an SSH client
$ ssh -Y username@lxlogin.ihep.ac.cn $ ssh -Y username@lxlogin.ihep.ac.cn
``` ```
### Start CentOS 7 container ### Start container if necessary (optional)
Then, you need to **start the container** with following command: Before start the container, make sure you really need it. Since tdr25.3, the default OS is AlmaLinux 9. If you still work on an older version, then you need the CentOS 7 container.
Then, you need to **start the container** with following command if necessary:
```bash ```bash
$ /cvmfs/container.ihep.ac.cn/bin/hep_container shell CentOS7 $ /cvmfs/container.ihep.ac.cn/bin/hep_container shell CentOS7
``` ```
...@@ -51,12 +53,10 @@ REDHAT_SUPPORT_PRODUCT_VERSION="7" ...@@ -51,12 +53,10 @@ REDHAT_SUPPORT_PRODUCT_VERSION="7"
As CEPCSW is already deployed at IHEP CVMFS. You can use it as following: As CEPCSW is already deployed at IHEP CVMFS. You can use it as following:
```bash ```bash
Singularity> source /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr24.5.0/CEPCSW/setup.sh $ source /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr25.3.2/CEPCSW/setup.sh
INFO: Setup CEPCSW externals: /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/externals/103.0.2/setup-103.0.2.sh
INFO: Setup CEPCSW: /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr24.5.0/CEPCSW/InstallArea
``` ```
From the output, you will know the current version of external libraries is 103.0.2. This is based on the LCG 103. From the output, you will know the current version of external libraries is 105.0.0. This is based on the LCG 105.
To start a simulation and reconstruction with `TDR_o1_v1`: To start a simulation and reconstruction with `TDR_o1_v1`:
```bash ```bash
...@@ -129,7 +129,9 @@ There are two options: ...@@ -129,7 +129,9 @@ There are two options:
* One is that install CVMFS in your machine directly. * One is that install CVMFS in your machine directly.
* Another is that install CVMFS in the Docker container. * Another is that install CVMFS in the Docker container.
We provide two images for the two cases: We provide several images for the two cases:
* `cepc/cepcsw:el9`
* `cepc/cepcsw-cvmfs:el9`
* `cepc/cepcsw:el7` * `cepc/cepcsw:el7`
* `cepc/cepcsw-cvmfs:el7` * `cepc/cepcsw-cvmfs:el7`
...@@ -161,13 +163,13 @@ $ sudo cvmfs_config setup ...@@ -161,13 +163,13 @@ $ sudo cvmfs_config setup
After you see CVMFS is setup without issues, you can try to access the CEPCSW: After you see CVMFS is setup without issues, you can try to access the CEPCSW:
```bash ```bash
ls /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr24.5.0 ls /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr25.3.2
CEPCSW CEPCSWData CEPCSW CEPCSWData
``` ```
Now, you can start the container with following long command: Now, you can start the container with following long command:
```bash ```bash
$ docker run --privileged --rm -i -t -v /home:/home -v /cvmfs/sft.cern.ch:/cvmfs/sft.cern.ch -v /cvmfs/geant4.cern.ch:/cvmfs/geant4.cern.ch -v /cvmfs/cepcsw.ihep.ac.cn:/cvmfs/cepcsw.ihep.ac.cn -v /cvmfs/container.ihep.ac.cn:/cvmfs/container.ihep.ac.cn cepc/cepcsw:el7 /bin/bash $ docker run --privileged --rm -i -t -v /home:/home -v /cvmfs/sft.cern.ch:/cvmfs/sft.cern.ch -v /cvmfs/geant4.cern.ch:/cvmfs/geant4.cern.ch -v /cvmfs/cepcsw.ihep.ac.cn:/cvmfs/cepcsw.ihep.ac.cn -v /cvmfs/container.ihep.ac.cn:/cvmfs/container.ihep.ac.cn cepc/cepcsw:el9 /bin/bash
``` ```
The option `-v` allows the Docker container to access the directories in the local machine. The option `-v` allows the Docker container to access the directories in the local machine.
...@@ -176,7 +178,7 @@ The option `-v` allows the Docker container to access the directories in the loc ...@@ -176,7 +178,7 @@ The option `-v` allows the Docker container to access the directories in the loc
We also provide a Docker image with cvmfs client installed inside. We also provide a Docker image with cvmfs client installed inside.
```bash ```bash
$ docker run --privileged --rm -i -t -v /home:/home cepc/cepcsw-cvmfs:el7 /bin/bash $ docker run --privileged --rm -i -t -v /home:/home cepc/cepcsw-cvmfs:el9 /bin/bash
``` ```
Now, you should be in the container. However, the cvmfs is not setup automatically. You need to mount the repositories manually. Here is an example: Now, you should be in the container. However, the cvmfs is not setup automatically. You need to mount the repositories manually. Here is an example:
...@@ -190,9 +192,7 @@ Then, you should be able access the necessary CVMFS repositories. ...@@ -190,9 +192,7 @@ Then, you should be able access the necessary CVMFS repositories.
For example, setting up an existing CEPCSW: For example, setting up an existing CEPCSW:
```bash ```bash
$ source /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr24.5.0/CEPCSW/setup.sh $ source /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr25.3.2/CEPCSW/setup.sh
INFO: Setup CEPCSW externals: /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/externals/103.0.2/setup-103.0.2.sh
INFO: Setup CEPCSW: /cvmfs/cepcsw.ihep.ac.cn/prototype/releases/tdr24.5.0/CEPCSW/InstallArea
``` ```
Run a simulation: Run a simulation:
......