Commit 6fe0c726 authored by Frank Gaede's avatar Frank Gaede
Browse files

example root macro for plots

parent afaa5c28
// draw sim hits
/** Helper function for radius
*/
float r(float x,float y) { return sqrt(x*x+y*y) ; }
/** helper function for layer number
*/
int layer(int cellid){
// so far only layer used in cellid
return ( cellid ) ;
}
//------------------------------------------------------
void draw_simhits( const char* FILEN ) {
auto* f = new TFile(FILEN) ;
auto* events = (TTree*) f->Get("events") ;
// define some aliases for simpler plotting
events->SetAlias("x","SimCalorimeterHits.position.x");
events->SetAlias("y","SimCalorimeterHits.position.y");
events->SetAlias("z","SimCalorimeterHits.position.z");
events->SetAlias("l","SimCalorimeterHits.cellID");
events->SetAlias("e","SimCalorimeterHits.energy");
auto c1 = new TCanvas("C1","Some example plots for sim calo hits",1000 , 1000 );
c1->Divide(2,2);
c1->cd(1) ;
// hit energy spectrum
events->Draw("e") ;
c1->cd(2) ;
// hits scatter plot in x-y
events->Draw("x:y","abs(x)<50&abs(y)<50");
c1->cd(3) ;
// longitudenal profile
events->Draw("l","e") ;
c1->cd(4) ;
// radial profile
events->Draw("sqrt(x*x+y*y)","(sqrt(x*x+y*y)<50)*e") ;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment