2 #ifndef TrackerAlignment_TkAlCaSkimTreeMerger_H
3 #define TrackerAlignment_TkAlCaSkimTreeMerger_H
22 #include "TStopwatch.h"
55 : filelist_(iConfig.getParameter<
std::
string>(
"FileList")),
56 treename_(iConfig.getParameter<
std::
string>(
"TreeName")),
57 outfilename_(iConfig.getParameter<
std::
string>(
"OutputFile")),
59 maxhits_(iConfig.getParameter<int32_t>(
"NhitsMaxLimit")),
89 std::cout <<
"The chain contains " <<
ch_->GetNtrees() <<
" trees" << std::endl;
96 while (!flist.eof()) {
108 std::cout <<
"Now the chain contains " <<
ch_->GetNtrees() <<
" trees (" <<
ch_->GetEntries() <<
" entries)"
111 unsigned int id_ch = 0;
112 uint32_t nhits_ch = 0, noverlaps_ch = 0;
113 ch_->SetBranchAddress(
"DetId", &id_ch);
114 ch_->SetBranchAddress(
"Nhits", &nhits_ch);
115 ch_->SetBranchAddress(
"Noverlaps", &noverlaps_ch);
117 ch_->SetBranchStatus(
"SubDet",
false);
118 ch_->SetBranchStatus(
"Layer",
false);
119 ch_->SetBranchStatus(
"is2D",
false);
120 ch_->SetBranchStatus(
"isStereo",
false);
121 ch_->SetBranchStatus(
"posX",
false);
122 ch_->SetBranchStatus(
"posY",
false);
123 ch_->SetBranchStatus(
"posZ",
false);
124 ch_->SetBranchStatus(
"posR",
false);
125 ch_->SetBranchStatus(
"posEta",
false);
126 ch_->SetBranchStatus(
"posPhi",
false);
128 int totnhits(0), totnoverlaps(0);
131 DetHitMap::iterator mapiter;
132 DetHitMap::iterator overlapiter;
134 for (
int ent = 0; ent <
ch_->GetEntries(); ++ent) {
137 totnhits += nhits_ch;
138 totnoverlaps += noverlaps_ch;
141 if (mapiter !=
hitmap_.end()) {
144 hitmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, nhits_ch));
151 overlapmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, noverlaps_ch));
156 std::cout <<
"Nhits in the chain: " << totnhits << std::endl;
157 std::cout <<
"NOverlaps in the chain: " << totnoverlaps << std::endl;
161 <<
" s (cpu time)" << std::endl;
177 uint32_t
nhits = 0, noverlaps = 0;
178 float posX(-99999.0),
posY(-77777.0), posZ(-88888.0);
179 float posEta(-6666.0), posPhi(-5555.0), posR(-4444.0);
181 unsigned int layer = 0;
185 firsttree_->SetBranchAddress(
"Noverlaps", &noverlaps);
186 firsttree_->SetBranchAddress(
"SubDet", &subdet);
187 firsttree_->SetBranchAddress(
"Layer", &layer);
194 firsttree_->SetBranchAddress(
"posEta", &posEta);
195 firsttree_->SetBranchAddress(
"posPhi", &posPhi);
200 out_ =
new TTree(
treename_.c_str(),
"AlignmentHitMapsTOTAL");
201 unsigned int id_out = 0;
202 uint32_t nhits_out = 0, noverlaps_out = 0;
203 float posX_out(-99999.0), posY_out(-77777.0), posZ_out(-88888.0);
204 float posEta_out(-6666.0), posPhi_out(-5555.0), posR_out(-4444.0);
206 unsigned int layer_out = 0;
207 bool is2D_out =
false, isStereo_out =
false;
208 float prescfact_out = 1.0;
209 float prescfact_overlap_out = 1.0;
211 out_->Branch(
"DetId", &id_out,
"DetId/i");
212 out_->Branch(
"Nhits", &nhits_out,
"Nhits/i");
213 out_->Branch(
"Noverlaps", &noverlaps_out,
"Noverlaps/i");
214 out_->Branch(
"SubDet", &subdet_out,
"SubDet/I");
215 out_->Branch(
"Layer", &layer_out,
"Layer/i");
216 out_->Branch(
"is2D", &is2D_out,
"is2D/B");
217 out_->Branch(
"isStereo", &isStereo_out,
"isStereo/B");
218 out_->Branch(
"posX", &posX_out,
"posX/F");
219 out_->Branch(
"posY", &posY_out,
"posY/F");
220 out_->Branch(
"posZ", &posZ_out,
"posZ/F");
221 out_->Branch(
"posR", &posR_out,
"posR/F");
222 out_->Branch(
"posEta", &posEta_out,
"posEta/F");
223 out_->Branch(
"posPhi", &posPhi_out,
"posPhi/F");
224 out_->Branch(
"PrescaleFactor", &prescfact_out,
"PrescaleFact/F");
225 out_->Branch(
"PrescaleFactorOverlap", &prescfact_overlap_out,
"PrescaleFactOverlap/F");
228 DetHitMap::iterator mapiter;
253 else if (subdet_out == 2)
255 else if (subdet_out == 3)
257 else if (subdet_out == 4)
259 else if (subdet_out == 5)
261 else if (subdet_out == 6)
270 if (
int(noverlaps_out) >
maxhits_) {
273 }
else if (subdetmax > 0) {
274 if (
int(nhits_out) > subdetmax) {
275 prescfact_out =
float(subdetmax / nhits_out);
277 if (
int(noverlaps_out) > subdetmax) {
278 prescfact_overlap_out =
float(subdetmax) /
float(noverlaps_out);
282 prescfact_overlap_out = 1.0;
290 <<
" s (cpu time)" << std::endl;
291 std::cout <<
"Ending the tree merging." << std::endl;
293 std::cout <<
"Deleting..." << std::flush;