20 #include "TStopwatch.h" 52 : filelist_(iConfig.getParameter<
std::
string>(
"FileList")),
53 treename_(iConfig.getParameter<
std::
string>(
"TreeName")),
54 outfilename_(iConfig.getParameter<
std::
string>(
"OutputFile")),
55 maxhits_(iConfig.getParameter<int32_t>(
"NhitsMaxLimit")),
64 LogDebug(
"TkAlCaSkimTreeMerger") <<
"\n\n*** MAX N HITS = " <<
maxhits_ << std::endl << std::endl;
72 LogDebug(
"TkAlCaSkimTreeMerger") <<
"finished." << std::endl;
81 LogDebug(
"TkAlCaSkimTreeMerger") <<
"The chain contains " <<
ch_->GetNtrees() <<
" trees" << std::endl;
88 while (!flist.eof()) {
100 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Now the chain contains " <<
ch_->GetNtrees() <<
" trees (" <<
ch_->GetEntries()
101 <<
" entries)" << std::endl;
103 unsigned int id_ch = 0;
104 uint32_t nhits_ch = 0, noverlaps_ch = 0;
105 ch_->SetBranchAddress(
"DetId", &id_ch);
106 ch_->SetBranchAddress(
"Nhits", &nhits_ch);
107 ch_->SetBranchAddress(
"Noverlaps", &noverlaps_ch);
109 ch_->SetBranchStatus(
"SubDet",
false);
110 ch_->SetBranchStatus(
"Layer",
false);
111 ch_->SetBranchStatus(
"is2D",
false);
112 ch_->SetBranchStatus(
"isStereo",
false);
113 ch_->SetBranchStatus(
"posX",
false);
114 ch_->SetBranchStatus(
"posY",
false);
115 ch_->SetBranchStatus(
"posZ",
false);
116 ch_->SetBranchStatus(
"posR",
false);
117 ch_->SetBranchStatus(
"posEta",
false);
118 ch_->SetBranchStatus(
"posPhi",
false);
120 int totnhits(0), totnoverlaps(0);
123 DetHitMap::iterator mapiter;
124 DetHitMap::iterator overlapiter;
126 for (
int ent = 0; ent <
ch_->GetEntries(); ++ent) {
129 totnhits += nhits_ch;
130 totnoverlaps += noverlaps_ch;
133 if (mapiter !=
hitmap_.end()) {
136 hitmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, nhits_ch));
143 overlapmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, noverlaps_ch));
148 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Nhits in the chain: " << totnhits << std::endl;
149 LogDebug(
"TkAlCaSkimTreeMerger") <<
"NOverlaps in the chain: " << totnoverlaps << std::endl;
152 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Finished beginJob after " <<
myclock.RealTime() <<
" s (real time) / " 153 <<
myclock.CpuTime() <<
" s (cpu time)" << std::endl;
167 LogDebug(
"TkAlCaSkimTreeMerger") <<
"the first tree has " <<
firsttree_->GetEntries() <<
" entries" << std::endl;
169 uint32_t
nhits = 0, noverlaps = 0;
170 float posX(-99999.0),
posY(-77777.0), posZ(-88888.0);
171 float posEta(-6666.0), posPhi(-5555.0), posR(-4444.0);
173 unsigned int layer = 0;
177 firsttree_->SetBranchAddress(
"Noverlaps", &noverlaps);
178 firsttree_->SetBranchAddress(
"SubDet", &subdet);
186 firsttree_->SetBranchAddress(
"posEta", &posEta);
187 firsttree_->SetBranchAddress(
"posPhi", &posPhi);
192 out_ =
new TTree(
treename_.c_str(),
"AlignmentHitMapsTOTAL");
193 unsigned int id_out = 0;
194 uint32_t nhits_out = 0, noverlaps_out = 0;
195 float posX_out(-99999.0), posY_out(-77777.0), posZ_out(-88888.0);
196 float posEta_out(-6666.0), posPhi_out(-5555.0), posR_out(-4444.0);
198 unsigned int layer_out = 0;
199 bool is2D_out =
false, isStereo_out =
false;
200 float prescfact_out = 1.0;
201 float prescfact_overlap_out = 1.0;
203 out_->Branch(
"DetId", &id_out,
"DetId/i");
204 out_->Branch(
"Nhits", &nhits_out,
"Nhits/i");
205 out_->Branch(
"Noverlaps", &noverlaps_out,
"Noverlaps/i");
206 out_->Branch(
"SubDet", &subdet_out,
"SubDet/I");
207 out_->Branch(
"Layer", &layer_out,
"Layer/i");
208 out_->Branch(
"is2D", &is2D_out,
"is2D/B");
209 out_->Branch(
"isStereo", &isStereo_out,
"isStereo/B");
210 out_->Branch(
"posX", &posX_out,
"posX/F");
211 out_->Branch(
"posY", &posY_out,
"posY/F");
212 out_->Branch(
"posZ", &posZ_out,
"posZ/F");
213 out_->Branch(
"posR", &posR_out,
"posR/F");
214 out_->Branch(
"posEta", &posEta_out,
"posEta/F");
215 out_->Branch(
"posPhi", &posPhi_out,
"posPhi/F");
216 out_->Branch(
"PrescaleFactor", &prescfact_out,
"PrescaleFact/F");
217 out_->Branch(
"PrescaleFactorOverlap", &prescfact_overlap_out,
"PrescaleFactOverlap/F");
220 DetHitMap::iterator mapiter;
245 else if (subdet_out == 2)
247 else if (subdet_out == 3)
249 else if (subdet_out == 4)
251 else if (subdet_out == 5)
253 else if (subdet_out == 6)
262 if (
int(noverlaps_out) >
maxhits_) {
265 }
else if (subdetmax > 0) {
266 if (
int(nhits_out) > subdetmax) {
267 prescfact_out =
float(subdetmax / nhits_out);
269 if (
int(noverlaps_out) > subdetmax) {
270 prescfact_overlap_out =
float(subdetmax) /
float(noverlaps_out);
274 prescfact_overlap_out = 1.0;
281 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Finished endJob after " <<
myclock.RealTime() <<
" s (real time) / " 282 <<
myclock.CpuTime() <<
" s (cpu time)" << std::endl;
283 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Ending the tree merging." << std::endl;
285 LogDebug(
"TkAlCaSkimTreeMerger") <<
"Deleting..." << std::flush;
292 desc.setComment(
"Merger of TkAlCaSkim Trees");
296 desc.add<
int>(
"NhitsMaxLimit", 0);
299 std::vector<edm::ParameterSet> tkAlCaSkimDefaults(1);
300 tkAlCaSkimDefaults[0].addParameter(
"PXBmaxhits", -1);
301 tkAlCaSkimDefaults[0].addParameter(
"PXFmaxhits", -1);
302 tkAlCaSkimDefaults[0].addParameter(
"TIBmaxhits", -1);
303 tkAlCaSkimDefaults[0].addParameter(
"TIDmaxhits", -1);
304 tkAlCaSkimDefaults[0].addParameter(
"TOBmaxhits", -1);
305 tkAlCaSkimDefaults[0].addParameter(
"TECmaxhits", -1);
306 desc.addVPSet(
"NhitsMaxSet", tkAlCaSkimTreeParamsDesc, tkAlCaSkimDefaults);
void analyze(const edm::Event &, const edm::EventSetup &) override
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
std::string firstfilename_
TkAlCaSkimTreeMerger(const edm::ParameterSet &iConfig)
static void fillDescriptions(edm::ConfigurationDescriptions &)
#define DEFINE_FWK_MODULE(type)
~TkAlCaSkimTreeMerger() override
edm::ParameterSet maxhitsSet_
std::map< uint32_t, uint32_t > DetHitMap
T mod(const T &a, const T &b)