2 #ifndef TrackerAlignment_TkAlCaSkimTreeMerger_H 3 #define TrackerAlignment_TkAlCaSkimTreeMerger_H 23 #include "TStopwatch.h" 67 maxhits_(iConfig.getParameter<int32_t>(
"NhitsMaxLimit")),
100 std::cout<<
"The chain contains "<<
ch_->GetNtrees()<<
" trees"<<std::endl;
110 if(filename.empty())
continue;
112 ch_->Add(filename.c_str());
119 std::cout<<
"Now the chain contains "<<
ch_->GetNtrees()<<
" trees ("<<
ch_->GetEntries()<<
" entries)"<<std::endl;
122 unsigned int id_ch=0;
123 uint32_t nhits_ch=0,noverlaps_ch=0;
124 ch_->SetBranchAddress(
"DetId", &id_ch);
125 ch_->SetBranchAddress(
"Nhits", &nhits_ch);
126 ch_->SetBranchAddress(
"Noverlaps",&noverlaps_ch);
128 ch_->SetBranchStatus(
"SubDet",0);
129 ch_->SetBranchStatus(
"Layer",0);
130 ch_->SetBranchStatus(
"is2D",0);
131 ch_->SetBranchStatus(
"isStereo",0);
132 ch_->SetBranchStatus(
"posX",0);
133 ch_->SetBranchStatus(
"posY",0);
134 ch_->SetBranchStatus(
"posZ",0);
135 ch_->SetBranchStatus(
"posR",0);
136 ch_->SetBranchStatus(
"posEta",0);
137 ch_->SetBranchStatus(
"posPhi",0);
140 int totnhits(0),totnoverlaps(0);
144 DetHitMap::iterator mapiter;
145 DetHitMap::iterator overlapiter;
147 for(
int ent=0;ent<
ch_->GetEntries();++ent){
151 totnoverlaps+=noverlaps_ch;
158 hitmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, nhits_ch));
166 overlapmap_.insert(std::pair<uint32_t, uint32_t>(id_ch, noverlaps_ch));
172 std::cout<<
"Nhits in the chain: "<<totnhits<<std::endl;
173 std::cout<<
"NOverlaps in the chain: "<<totnoverlaps<<std::endl;
177 std::cout<<
"Finished beginJob after "<<
myclock.RealTime()<<
" s (real time) / "<<
myclock.CpuTime()<<
" s (cpu time)"<<std::endl;
194 std::cout<<
"the first tree has "<<firsttree_->GetEntries() <<
" entries"<<std::endl;
196 uint32_t
nhits=0,noverlaps=0;
197 float posX(-99999.0),
posY(-77777.0),posZ(-88888.0);
198 float posEta(-6666.0),posPhi(-5555.0),posR(-4444.0);
200 unsigned int layer=0;
202 firsttree_->SetBranchAddress(
"DetId", &
id);
203 firsttree_->SetBranchAddress(
"Nhits", &nhits);
204 firsttree_->SetBranchAddress(
"Noverlaps",&noverlaps);
205 firsttree_->SetBranchAddress(
"SubDet", &subdet);
206 firsttree_->SetBranchAddress(
"Layer", &layer);
209 firsttree_->SetBranchAddress(
"posX", &
posX);
210 firsttree_->SetBranchAddress(
"posY", &
posY);
211 firsttree_->SetBranchAddress(
"posZ", &posZ);
212 firsttree_->SetBranchAddress(
"posR", &posR);
213 firsttree_->SetBranchAddress(
"posEta", &posEta);
214 firsttree_->SetBranchAddress(
"posPhi", &posPhi);
222 unsigned int id_out=0;
223 uint32_t nhits_out=0,noverlaps_out=0;
224 float posX_out(-99999.0),posY_out(-77777.0),posZ_out(-88888.0);
225 float posEta_out(-6666.0),posPhi_out(-5555.0),posR_out(-4444.0);
227 unsigned int layer_out=0;
228 bool is2D_out=
false,isStereo_out=
false;
229 float prescfact_out=1.0;
230 float prescfact_overlap_out=1.0;
232 out_->Branch(
"DetId", &id_out ,
"DetId/i");
233 out_->Branch(
"Nhits", &nhits_out ,
"Nhits/i");
234 out_->Branch(
"Noverlaps",&noverlaps_out,
"Noverlaps/i");
235 out_->Branch(
"SubDet", &subdet_out,
"SubDet/I");
236 out_->Branch(
"Layer", &layer_out,
"Layer/i");
237 out_->Branch(
"is2D" , &is2D_out,
"is2D/B");
238 out_->Branch(
"isStereo", &isStereo_out,
"isStereo/B");
239 out_->Branch(
"posX", &posX_out,
"posX/F");
240 out_->Branch(
"posY", &posY_out,
"posY/F");
241 out_->Branch(
"posZ", &posZ_out,
"posZ/F");
242 out_->Branch(
"posR", &posR_out,
"posR/F");
243 out_->Branch(
"posEta", &posEta_out,
"posEta/F");
244 out_->Branch(
"posPhi", &posPhi_out,
"posPhi/F");
245 out_->Branch(
"PrescaleFactor",&prescfact_out,
"PrescaleFact/F");
246 out_->Branch(
"PrescaleFactorOverlap",&prescfact_overlap_out,
"PrescaleFactOverlap/F");
250 DetHitMap::iterator mapiter;
252 for(
int mod=0;
mod<firsttree_->GetEntries();
mod++){
257 firsttree_->GetEntry(
mod);
279 else subdetmax=-9999;
289 else if(subdetmax>0){
290 if(
int(nhits_out)>subdetmax){
291 prescfact_out=
float(subdetmax/nhits_out);
293 if(
int(noverlaps_out)>subdetmax){
294 prescfact_overlap_out=
float(subdetmax)/
float(noverlaps_out);
299 prescfact_overlap_out=1.0;
307 std::cout<<
"Finished endJob after "<<
myclock.RealTime()<<
" s (real time) / "<<
myclock.CpuTime()<<
" s (cpu time)"<<std::endl;
308 std::cout<<
"Ending the tree merging."<<std::endl;
void analyze(const edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
std::string firstfilename_
#define DEFINE_FWK_MODULE(type)
std::map< uint32_t, uint32_t > DetHitMap
TkAlCaSkimTreeMerger(const edm::ParameterSet &iConfig)
edm::ParameterSet maxhitsSet_
T mod(const T &a, const T &b)