24 #include <calobase/TowerInfoContainer.h>
25 #include <calobase/TowerInfo.h>
26 #include <calobase/TowerInfoDefs.h>
35 ,cdbtreename(cdbtreename)
44 std::cout <<
"towerid::towerid(const std::string &name) Calling ctor" << std::endl;
49 std::cout <<
"towerid::~towerid() Calling dtor" << std::endl;
61 std::cout <<
"towerid::Init(PHCompositeNode *topNode) Initializing" << std::endl;
68 std::cout <<
"towerid::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
77 emcTowerContainer = findNode::getClass<TowerInfoContainer>(topNode,
"TOWERS_CEMC");
78 if(!emcTowerContainer)
80 std::cout <<
PHWHERE <<
"towerid::process_event Could not find node TOWERS_CEMC" << std::endl;
85 bool goodevent =
false;
86 int tower_range = emcTowerContainer->
size();
87 for(
int j = 0;
j < tower_range;
j++){
89 double energy = emcTowerContainer -> get_tower_at_channel(
j) -> get_energy();
123 const int nBins = 101;
127 Fspec =
new TH2F(
"Fspec",
"Fspec",
nTowers+1,-0.5,
nTowers+0.5,nBins,0.-1/(2*nBins),1+1/(2*nBins));
137 Fspeci_IB =
new TH2F(
"Fspeci_IB",
"Fspeci_IB",
nIB+1,-0.5,
nIB+0.5,nBins,0.-1/(2*nBins),1);
168 for(
int j = 0;
j<
nIB;
j++){
244 TFile *histsIn =
new TFile(Form(
"output/%d/DST_CALOR-%08d_badTowerMapTree.root",runnumber,runnumber));
253 float cutoffFreq_SG_lo;
254 float cutoffFreq_K_lo;
257 float cutoffFreq_IB_lo;
264 TH1F *dummyProj = NULL;
269 cutoffFreq_SG = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
270 cutoffFreq_SG_lo = -1*dummyProj->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
276 cutoffFreq_K = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
277 cutoffFreq_K_lo = -1*
Fspec_K->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
280 Fspec = (TH2F*)histsIn ->
Get(
"Fspec");
283 cutoffFreq = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
290 cutoffFreq_IB = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
291 cutoffFreq_IB_lo = -1*
Fspec_IB->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
307 Fspeci = (TH2F*)histsIn ->
Get(
"Fspeci");
320 TH1F *fSpecProj_SG = (TH1F*)
Fspeci_SG->ProjectionY(
"dummySG",
i+1,
i+1);
321 TH1F *fSpecProj_K = (TH1F*)
Fspeci_K->ProjectionY(
"dummyK",
i+1,
i+1);
322 TH1F *fSpecProj = (TH1F*)
Fspeci->ProjectionY(
"dummySpec",
i+1,
i+1);
324 if(
fiber_type == 0 && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) > cutoffFreq_SG){
327 else if(
fiber_type == 1 && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) > cutoffFreq_K){
330 else if(fSpecProj -> GetBinCenter(fSpecProj->GetMaximumBin()) == 0){
333 else if (
fiber_type == 0 && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) < cutoffFreq_SG_lo && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) >0 ){
336 else if (
fiber_type ==1 && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) < cutoffFreq_K_lo && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) > 0){
348 for(
int j = 0;
j <
nIB;
j++){
349 TH1F *fSpecIBProj = (TH1F*)
Fspeci_IB->ProjectionY(
"dummyIB",
j+1,
j+1);
351 if(fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin())>cutoffFreq_IB){
353 std::cout <<
"IB " <<
j <<
" is hot with ADC rate" << fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin())<<
" > "<< cutoffFreq_IB << std::endl;
361 for(
int biny = 0; biny <
Fspeci_IB->GetNbinsY(); biny++)
Fspeci_IB->SetBinContent(
j+1,biny+1,-10);
367 for(
int j = 0;
j <
nIB;
j++){
368 TH1F *fSpecIBProj = (TH1F*)
Fspeci_IB->ProjectionY(
"dummyIB",
j+1,
j+1);
370 if(fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin())<cutoffFreq_IB_lo){
372 std::cout <<
"IB " <<
j <<
" is cold with ADC rate" << fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin()) <<
" < " << cutoffFreq_IB_lo << std::endl;
435 std::cout <<
"removing hot/cold regions" << std::endl;
439 std::cout <<
"hot/cold IB or sector detected. Running another pass for hot towers" << std::endl;
488 cutoffFreq_SG = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
489 cutoffFreq_SG_lo = -1*dummyProj->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
494 cutoffFreq_K = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
495 cutoffFreq_K_lo = -1*
Fspec_K->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
499 cutoffFreq = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
503 cutoffFreq_IB = dummyProj->GetStdDev()*
sigmas_hi + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
504 cutoffFreq_IB_lo = -1*
Fspec_IB->GetStdDev()*
sigmas_lo + dummyProj->GetBinCenter(dummyProj->GetMaximumBin());
515 TH1F *fSpecProj_SG = (TH1F*)
Fspeci_SG->ProjectionY(
"dummySG",
i+1,
i+1);
516 TH1F *fSpecProj_K = (TH1F*)
Fspeci_K->ProjectionY(
"dummyK",
i+1,
i+1);
517 TH1F *fSpecProj = (TH1F*)
Fspeci->ProjectionY(
"dummySpec",
i+1,
i+1);
519 if(
fiber_type == 0 && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) > cutoffFreq_SG){
522 else if(
fiber_type == 1 && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) > cutoffFreq_K){
525 else if(fSpecProj -> GetBinCenter(fSpecProj->GetMaximumBin()) ==0){
528 else if (
fiber_type == 0 && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) < cutoffFreq_SG_lo && fSpecProj_SG->GetBinCenter(fSpecProj_SG->GetMaximumBin()) >0 ){
531 else if (
fiber_type ==1 && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) < cutoffFreq_K_lo && fSpecProj_K->GetBinCenter(fSpecProj_K->GetMaximumBin()) > 0){
541 for(
int j = 0;
j<
nIB;
j++){
542 if(
ibF[
j]==-1)
continue;
543 TH1F *fSpecIBProj = (TH1F*)
Fspeci_IB->ProjectionY(
"dummyIB",
j+1,
j+1);
545 if(fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin())>cutoffFreq_IB){
547 std::cout <<
"IB " <<
j <<
"is hot with ADC rate " << fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin()) <<
" > " << cutoffFreq_IB << std::endl;
561 for(
int j = 0;
j<
nIB;
j++){
562 if(
ibF[
j]==-1)
continue;
564 TH1F *fSpecIBProj = (TH1F*)
Fspeci_IB->ProjectionY(
"dummyIB",
j+1,
j+1);
566 if(fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin())<cutoffFreq_IB_lo){
568 std::cout <<
"IB " <<
j <<
" is cold with ADC rate " << fSpecIBProj->GetBinCenter(fSpecIBProj->GetMaximumBin()) <<
" < " << cutoffFreq_IB_lo << std::endl;
626 std::cout <<
"towerid::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
627 std::cout <<
"Saint Gobain Cutoff Frequency: " << cutoffFreq_SG << std::endl;
628 std::cout <<
"Kurary Cutoff Frequency: " << cutoffFreq_K << std::endl;
629 std::cout <<
"Overall Tower Cutoff Frequency: " << cutoffFreq << std::endl;
630 std::cout <<
"IB Cutoff hit Frequency: " << cutoffFreq_IB << std::endl;
640 TFile *cdbOut =
new TFile(Form(
"cdbMaps/%d/CEMC-%08d_badTowerMapCDBTTree.root",runnumber,runnumber),
"RECREATE");
642 T =
new TTree(
"T",
"T");
689 std::cout <<
"towerid::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
695 std::cout <<
"towerid::Print(const std::string &what) const Printing info for " << what << std::endl;
700 std::cout <<
"towerid::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
706 std::cout <<
"towerid::EndRun: this is the end of run: "<< runnumber << std::endl;