Skip to content

Commit

Permalink
Merge pull request #143 from nukazuka/main
Browse files Browse the repository at this point in the history
Updates on FELIX viewer.
  • Loading branch information
nukazuka authored Aug 18, 2024
2 parents 188dbc3 + 8d06894 commit f9dd165
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 33 deletions.
2 changes: 1 addition & 1 deletion felix/FelixQuickViewer/ver3/HistMaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void HistMaker::Init()
hist_adc_[i][j]->SetFillColorAlpha( kAzure + 1, 0.3 );

hist_bco_[i][j] = new TH1D( Form("hist_bco_module%d_chip%d", i, j ),
Form("hist_bco_module%d_chip%d;BCO full&0x7f - FPHX BCO;Entries", i, j ),
Form("hist_bco_module%d_chip%d;FPHX BCO;Entries", i, j ),
128, 0, 128 );

hist_bco_[i][j]->SetLineColor( kLadder_colors[i] );
Expand Down
131 changes: 105 additions & 26 deletions felix/FelixQuickViewer/ver3/Homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,21 @@ def ProcessRunPage( self ) :
# Make directory for the run if it's not found
if self.RUN_DIR.exists() is False :
self.RUN_DIR.mkdir()


elif os.access( self.RUN_DIR, os.W_OK ) is False :
print( self.RUN_DIR, "is not writable for you. Ask the owner")
print( "\t", self.RUN_DIR.owner())
print( "to change the access mode. Maybe" )
print( "\t chmod g+w", self.RUN_DIR)
print( "is OK to try." )
return None

elif self.info.homepage_run_clean is True :
shutil.rmtree( self.RUN_DIR )
try :
shutil.rmtree( self.RUN_DIR )
except PermissionError:
print( self.RUN_DIR, "cannot be deleted. The directory is not cleaned, and go on!" )

os.mkdir( self.RUN_DIR )

# Copy the template of index.html
Expand Down Expand Up @@ -203,10 +215,14 @@ def WriteRawHitSection( self ) :
contents = "<h3>INTTRAWHIT </h3>\n"
html_detail = "<details>\n" \
" <summary>Hide/Show</summary>\n"


for plot in self.info.raw_hit_plots :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

print( self.RUN_DIR/ plot.name )
contents += "<h4>" + plot.name + "</h4>\n"
contents += html_detail + \
Expand All @@ -232,7 +248,12 @@ def WriteTrkrHitSection( self ) :


for plot in self.info.trkr_hit_plots :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

print( self.RUN_DIR/ plot.name )
contents += "<h4>" + plot.name + "</h4>\n"
contents += html_detail + \
Expand All @@ -255,9 +276,14 @@ def WriteHotChannelSection( self ) :
html_detail = "<details>\n" \
" <summary>Hide/Show</summary>\n"

contents_parts = ""
for txt in self.info.hot_channel_txt :
print( txt )
shutil.copy( str( txt ), self.RUN_DIR/ txt.name )
try :
shutil.copy( str( txt ), self.RUN_DIR/ txt.name )
except PermissionError :
print( txt, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

hot_num = 0;

Expand All @@ -271,21 +297,46 @@ def WriteHotChannelSection( self ) :
"#hot channels: " + str( hot_num ) + "\n"

for plot in self.info.hot_channel_plots :
print( "- ", plot )
if plot.name.split( '.' )[0] != txt.name.split( '.' )[0] :
continue

contents_parts = ""
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

print( self.RUN_DIR/ plot.name )
if ".pdf" in plot.name :
contents_parts += \
"<div class=\"center\">\n" \
" <object data=\"" + plot.name + "\"" \
"type=\"application/pdf\">\n" \
" Your browser cannot show PDF. Why don't you use new one?\n"\
" </object>\n" \
"</div>\n"

for plot in self.info.hot_channel_plots :
if ".png" in plot.name :
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

print( self.RUN_DIR/ plot.name )
contents_parts += \
"<div class=\"center\">\n" \
" <object data=\"" + plot.name + "\"" \
"type=\"application/pdf\">\n" \
" Your browser cannot show PDF. Why don't you use new one?\n"\
" </object>\n" \
"</div>\n"

contents += "<details>\n" \
" <figure>\n" \
" <a href=\"" + plot.name + "\" data-lightbox=\"images\" data-title=\"" + plot.name + "\">\n" \
" <img " + "src=\"" + plot.name + "\" " + "alt=\"" + plot.name + "\"\>\n" \
" </a>\n" \
" <a href=\"" + plot.name + "\" download=\"" + plot.name + "\">\n" \
" <figcaption>" + plot.name + "</figcaption>\n" \
" </a>\n" \
" </figure>\n"

contents += "<details>\n" \
" <summary>Hide/Show</summary>\n" \
+ contents_parts \
+ "</details>\n\n"
Expand All @@ -304,15 +355,31 @@ def WriteBcoDiffCutSection( self ) :
" <summary>Hide/Show</summary>\n"

for plot in self.info.bco_diff_plots :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

print( self.RUN_DIR/ plot.name )
contents += \
"<div class=\"center\">\n" \
" <object data=\"" + plot.name + "\"" \
"type=\"application/pdf\">\n" \
" Your browser cannot show PDF. Why don't you use new one?\n"\
" </object>\n" \
"</div>\n" \
if ".pdf" in plot.name :
contents += \
"<div class=\"center\">\n" \
" <object data=\"" + plot.name + "\"" \
"type=\"application/pdf\">\n" \
" Your browser cannot show PDF. Why don't you use new one?\n"\
" </object>\n" \
"</div>\n"
elif ".png" in plot.name :
contents += \
" <figure>\n" \
" <a href=\"" + plot.name + "\" data-lightbox=\"images\" data-title=\"" + plot.name + "\">\n" \
" <img " + "src=\"" + plot.name + "\" " + "alt=\"" + plot.name + "\"\>\n" \
" </a>\n" \
" <a href=\"" + plot.name + "\" download=\"" + plot.name + "\">\n" \
" <figcaption>" + plot.name + "</figcaption>\n" \
" </a>\n" \
" </figure>\n"

contents += "</details>\n"
file.write( contents )
Expand All @@ -329,7 +396,12 @@ def WriteCosmicSection( self ) :
" <summary>Hide/Show</summary>\n"

for plot in self.info.cosmic_plots :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
try :
shutil.copy( str(plot), self.RUN_DIR/ plot.name )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

suffix = str(plot).split( "." )[1]

if suffix == "pdf" :
Expand Down Expand Up @@ -380,7 +452,14 @@ def WriteFelixSection( self, felix ) :

caption = run_type + "<br> " + plot_title + "<br> chunk " + chunk

shutil.copy( plot, self.RUN_DIR / image )
print( "in:", plot )
print( "out:", self.RUN_DIR / image )
try :
shutil.copy( plot, self.RUN_DIR / image )
except PermissionError:
print( plot, "cannot be copied due to permission. Check the owner of the file and ask the person to add write permission to the file" )
continue

contents += \
" <figure>\n" \
" <a href=\"" + image + "\" data-lightbox=\"images\" data-title=\"" + image + "\">\n" \
Expand Down
10 changes: 8 additions & 2 deletions felix/FelixQuickViewer/ver3/Information.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__( self, args ) :
self.HITMAP_DIR = self.QA_DIR / "hitmap"
self.HOTMAP_DIR = self.QA_DIR / "hotdeadmap"
self.BCODIFF_DIR = self.QA_DIR / "bco_bcofull_difference"
self.BCODIFF_DIR = self.QA_DIR / "bco_bcofull_difference"
self.BCODIFF_NEW_DIR = self.QA_DIR / "bco_bcofull_difference"
self.RAWHIT_DIR = self.QA_DIR / "raw_hit" / str( self.year )
self.TRKRHIT_DIR = self.QA_DIR / "trkr_hit" / str( self.year )
self.TRKRCLUSTER_DIR = self.QA_DIR / "cluster_hit" / str( self.year )
Expand Down Expand Up @@ -206,6 +206,9 @@ def GetHotChannelPlots( self ) :
path = self.HOTMAP_DIR / "plots" / str( self.year )
self.hot_channel_plots = sorted( list( path.glob( "*" + str(self.run) + "*.pdf" ) ) )

for plot in list( path.glob( "*" + str(self.run) + "*.png" ) ) :
self.hot_channel_plots.append( plot )

path = self.HOTMAP_DIR / "txt" / str( self.year )
self.hot_channel_txt = sorted( list( path.glob( "*" + str(self.run) + "*.txt" ) ) )

Expand All @@ -216,7 +219,10 @@ def GetCosmicPlots( self ) :

def GetBcoDiffPlots( self ) :
self.bco_diff_plots = self.GetPlots( self.BCODIFF_DIR / "plots" / str(self.year) )

#self.bco_diff_plots.append( self.GetPlots( self.BCODIFF_DIR / "plots" / str(self.year), suffix=".png" ) )
for plot in self.GetPlots( self.BCODIFF_DIR / "plots" / str(self.year), suffix=".png" ) :
self.bco_diff_plots.append( plot )

def GetRawHitPlots( self ) :
print( "Raw hit plot" )
self.raw_hit_plots = self.GetPlots( self.RAWHIT_DIR / "plots" )
Expand Down
13 changes: 9 additions & 4 deletions felix/FelixQuickViewer/ver3/Viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,14 @@ int Viewer::Draw()
}
else // for junk data
{
this->Draw_Channel();
//this->Draw_Channel();
this->Draw_AdcChannel();
this->Draw_BcoDiff();
this->Draw_Bco();

//this->Draw_HitDist();
this->Draw_HitDist( 0, kLadder_num_/2); // 0 - 14/2 --> 0 - 7
this->Draw_HitDist( kLadder_num_/2, kLadder_num_); //
this->Draw_HitDist();
//this->Draw_HitDist( 0, kLadder_num_/2); // 0 - 14/2 --> 0 - 7
//this->Draw_HitDist( kLadder_num_/2, kLadder_num_); //

}

Expand Down Expand Up @@ -904,8 +905,12 @@ int Viewer::Draw_Bco( int ladder_min, int ladder_max, int chip_min, int chip_max
option = "HIST";

hist_bco_ladder[i]->Draw( option.c_str() );
hist_bco_ladder[i]->GetXaxis()->SetNdivisions( 21010 );
hist_bco_ladder[i]->GetYaxis()->SetNdivisions( 21010 );

this->SetStyle();
gPad->SetLogy( true );
//gPad->SetLogy( false );

leg->AddEntry( hist_bco_ladder[i], ( "FELIX CH" + to_string(i) ).c_str() );
if( i == 6 || i == ladder_max-1 )
Expand Down

0 comments on commit f9dd165

Please sign in to comment.