Restore run folder.
This commit is contained in:
1021
run/macros/Beam.old.C
Normal file
1021
run/macros/Beam.old.C
Normal file
File diff suppressed because it is too large
Load Diff
227
run/macros/BeamEnv.C
Normal file
227
run/macros/BeamEnv.C
Normal file
@ -0,0 +1,227 @@
|
||||
#include <TH2.h>
|
||||
#include <TStyle.h>
|
||||
#include <TCanvas.h>
|
||||
#include <string>
|
||||
|
||||
void EnvatZ(Int_t fnumber, char* fname, TCanvas* c1)
|
||||
{
|
||||
// For old lem4 simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH3F* hBeamSpot = new TH3F("hBeamSpot", " x,y,z", 64, -40., 40., 64, -40., 40.,2900,-900,2000);
|
||||
// TH1F* hPosZ = new TH1F("hPosZ", "z",1600,-800.,800.);
|
||||
|
||||
// hBeamSpot->Fill(muTargetPosX[0], muTargetPosY[0]);
|
||||
// hPosZ->Fill(muTargetPosZ[0]);
|
||||
|
||||
// TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
// hPosZ->Draw();
|
||||
|
||||
// gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
// c1->cd(1);
|
||||
t1->Draw("muTargetPosZ[0]:muTargetPosY[0]:muTargetPosX[0]>>hBeamSpot");
|
||||
// hBeamSpot->Draw("lego");
|
||||
// hBeamSpot->Draw();
|
||||
hBeamSpot->DrawCopy("cont0 same");
|
||||
|
||||
Double_t Xrms=hBeamSpot->GetRMS(1);
|
||||
Double_t Yrms=hBeamSpot->GetRMS(2);
|
||||
Double_t Zrms=hBeamSpot->GetRMS(3);
|
||||
|
||||
Double_t Xavg=hBeamSpot->GetMean(1);
|
||||
Double_t Yavg=hBeamSpot->GetMean(2);
|
||||
Double_t Zavg=hBeamSpot->GetMean(3);
|
||||
|
||||
Double_t Nbins=hBeamSpot->Integral();
|
||||
// Long64_t Nbins=t1.save_x->GetEntries();
|
||||
if (Xrms != 0) {
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",fnumber,Zavg,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
// delete c1;
|
||||
delete f1;
|
||||
|
||||
|
||||
// hPosZ->Draw();
|
||||
|
||||
// sprintf(filenamePrint,"musrSrClass_%s.ps",fileNr);
|
||||
// c1->Print(filenamePrint);
|
||||
}
|
||||
|
||||
void BeamSlice(char* fname,Int_t SaveID)
|
||||
{
|
||||
|
||||
Double_t zSlice,Xrms,Yrms,Zrms,Xavg,Yavg,Zavg,Nbins;
|
||||
// For new musrSim simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist",Cond);
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,100,-600,6000,100,-2600,1300)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
gStyle->SetPalette(1,0);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
Zrms=bspot_hist->GetRMS(3);
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
Zavg=bspot_hist->GetMean(3);
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n",SaveID,zSlice,Xrms,Yrms,Zrms,Xavg,Yavg,Zavg,Nbins);
|
||||
|
||||
f1->Close();
|
||||
}
|
||||
|
||||
void Slice(char* fname,Int_t SaveID)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Slice Properties",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(1);
|
||||
t1->Draw("muIniPosY[0]:muIniPosZ[0]>>ini_hist");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Beam spot at slice
|
||||
c1->cd(2);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
// Initial x polarization
|
||||
c1->cd(3);
|
||||
t1->Draw("muIniPolX >> ipol_x(128, -1.1, 1.1)"); //0, 2
|
||||
ipol_x->SetTitle("Polarization X");
|
||||
ipol_x->GetXaxis()->SetNdivisions(405);
|
||||
ipol_x->GetYaxis()->SetNdivisions(406);
|
||||
ipol_x->GetXaxis()->SetTickLength(0.018);
|
||||
ipol_x->GetYaxis()->SetTickLength(0.018);
|
||||
ipol_x->Draw("F");
|
||||
ipol_x->SetFillStyle(1001);
|
||||
ipol_x->SetFillColor(kGreen-5);
|
||||
ipol_x->Draw();
|
||||
|
||||
|
||||
// x polarization at slice
|
||||
c1->cd(4);
|
||||
t1->Draw("save_polx >> pol_x(128, -1.1, 1.1)",Cond); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Initial z polarization
|
||||
c1->cd(5);
|
||||
t1->Draw("muIniPolZ >> ipol_z(128, -1.1, 1.1)"); //0, 2
|
||||
ipol_z->SetTitle("Polarization Z");
|
||||
ipol_z->GetXaxis()->SetNdivisions(405);
|
||||
ipol_z->GetYaxis()->SetNdivisions(406);
|
||||
ipol_z->GetXaxis()->SetTickLength(0.018);
|
||||
ipol_z->GetYaxis()->SetTickLength(0.018);
|
||||
ipol_z->Draw("F");
|
||||
ipol_z->SetFillStyle(1001);
|
||||
ipol_z->SetFillColor(kGreen-5);
|
||||
ipol_z->Draw();
|
||||
|
||||
// z polarization at slice
|
||||
c1->cd(6);
|
||||
t1->Draw("save_polz >> pol_z(128, -1.1, 1.1)",Cond); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
// f1->Close();
|
||||
}
|
||||
|
||||
void BeamSlices(char* fname,Int_t SaveIDi, Int_t SaveIDf)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TString Cond;
|
||||
Int_t i;
|
||||
|
||||
printf("SliceID \t Z \t Xrms \t Yrms \t Zrms \t Xavg \t Yavg \t Zavg \t N\n");
|
||||
for (i=SaveIDi; i<=SaveIDf; i++) {
|
||||
|
||||
BeamSlice(fname,i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NatSlice(char* fname,Int_t SaveID)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TString Cond;
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
Int_t i;
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
gStyle->SetPalette(1,0);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
// printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",i,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
printf("%d\t",Nbins);
|
||||
f1->Close();
|
||||
|
||||
}
|
||||
|
||||
void ToF(char* fname,Int_t SaveID)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
|
||||
Cond.Form("save_detID== %03d&&save_particleID==-13",SaveID);
|
||||
t1->Draw("save_time>>tof",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
// f1->Close();
|
||||
|
||||
}
|
304
run/macros/BeamEnv.h
Normal file
304
run/macros/BeamEnv.h
Normal file
@ -0,0 +1,304 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// This class has been automatically generated on
|
||||
// Fri Oct 26 16:55:39 2007 by ROOT version 5.08/00
|
||||
// from TTree t1/a simple Tree with simple variables
|
||||
// found on file: musr_200003.root
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BeamEnv_h
|
||||
#define BeamEnv_h
|
||||
|
||||
#include <TROOT.h>
|
||||
#include <TChain.h>
|
||||
#include <TFile.h>
|
||||
|
||||
class BeamEnv {
|
||||
public :
|
||||
TTree *fChain; //!pointer to the analyzed TTree or TChain
|
||||
Int_t fCurrent; //!current Tree number in a TChain
|
||||
|
||||
// Declaration of leave types
|
||||
Int_t runID;
|
||||
Int_t eventID;
|
||||
Double_t BFieldAtDecay_Bx;
|
||||
Double_t BFieldAtDecay_By;
|
||||
Double_t BFieldAtDecay_Bz;
|
||||
Double_t BFieldAtDecay_B3;
|
||||
Double_t BFieldAtDecay_B4;
|
||||
Double_t BFieldAtDecay_B5;
|
||||
Double_t muIniPosX;
|
||||
Double_t muIniPosY;
|
||||
Double_t muIniPosZ;
|
||||
Double_t muIniMomX;
|
||||
Double_t muIniMomY;
|
||||
Double_t muIniMomZ;
|
||||
Double_t muIniPolX;
|
||||
Double_t muIniPolY;
|
||||
Double_t muIniPolZ;
|
||||
Int_t muDecayDetID;
|
||||
Double_t muDecayPosX;
|
||||
Double_t muDecayPosY;
|
||||
Double_t muDecayPosZ;
|
||||
Double_t muDecayTime;
|
||||
Double_t muDecayPolX;
|
||||
Double_t muDecayPolY;
|
||||
Double_t muDecayPolZ;
|
||||
Double_t muTargetTime;
|
||||
Double_t muTargetPolX;
|
||||
Double_t muTargetPolY;
|
||||
Double_t muTargetPolZ;
|
||||
Double_t fieldValue;
|
||||
Int_t det_n;
|
||||
Int_t det_ID[50]; //[det_n]
|
||||
Double_t det_edep[50]; //[det_n]
|
||||
Int_t det_nsteps[50]; //[det_n]
|
||||
Double_t det_length[50]; //[det_n]
|
||||
Double_t det_time_start[50]; //[det_n]
|
||||
Double_t det_time_end[50]; //[det_n]
|
||||
Double_t det_x[50]; //[det_n]
|
||||
Double_t det_y[50]; //[det_n]
|
||||
Double_t det_z[50]; //[det_n]
|
||||
Int_t save_n;
|
||||
Int_t save_detID[10]; //[save_n]
|
||||
Int_t save_particleID[10]; //[save_n]
|
||||
Double_t save_ke[10]; //[save_n]
|
||||
Double_t save_x[10]; //[save_n]
|
||||
Double_t save_y[10]; //[save_n]
|
||||
Double_t save_z[10]; //[save_n]
|
||||
Double_t save_px[10]; //[save_n]
|
||||
Double_t save_py[10]; //[save_n]
|
||||
Double_t save_pz[10]; //[save_n]
|
||||
|
||||
|
||||
// List of branches
|
||||
TBranch *b_runID; //!
|
||||
TBranch *b_eventID; //!
|
||||
TBranch *b_BFieldAtDecay; //!
|
||||
TBranch *b_muIniPosX; //!
|
||||
TBranch *b_muIniPosY; //!
|
||||
TBranch *b_muIniPosZ; //!
|
||||
TBranch *b_muIniMomX; //!
|
||||
TBranch *b_muIniMomY; //!
|
||||
TBranch *b_muIniMomZ; //!
|
||||
TBranch *b_muIniPolX; //!
|
||||
TBranch *b_muIniPolY; //!
|
||||
TBranch *b_muIniPolZ; //!
|
||||
TBranch *b_muDecayDetID; //!
|
||||
TBranch *b_muDecayPosX; //!
|
||||
TBranch *b_muDecayPosY; //!
|
||||
TBranch *b_muDecayPosZ; //!
|
||||
TBranch *b_muDecayTime; //!
|
||||
TBranch *b_muDecayPolX; //!
|
||||
TBranch *b_muDecayPolY; //!
|
||||
TBranch *b_muDecayPolZ; //!
|
||||
TBranch *b_muTargetTime; //!
|
||||
TBranch *b_muTargetPolX; //!
|
||||
TBranch *b_muTargetPolY; //!
|
||||
TBranch *b_muTargetPolZ; //!
|
||||
TBranch *b_fieldValue; //!
|
||||
TBranch *b_det_n; //!
|
||||
TBranch *b_det_ID; //!
|
||||
TBranch *b_det_edep; //!
|
||||
TBranch *b_det_nsteps; //!
|
||||
TBranch *b_det_length; //!
|
||||
TBranch *b_det_time_start; //!
|
||||
TBranch *b_det_time_end; //!
|
||||
TBranch *b_det_x; //!
|
||||
TBranch *b_det_y; //!
|
||||
TBranch *b_det_z; //!
|
||||
TBranch *b_save_n; //!
|
||||
TBranch *b_save_detID; //!
|
||||
TBranch *b_save_particleID; //!
|
||||
TBranch *b_save_ke; //!
|
||||
TBranch *b_save_x; //!
|
||||
TBranch *b_save_y; //!
|
||||
TBranch *b_save_z; //!
|
||||
TBranch *b_save_px; //!
|
||||
TBranch *b_save_py; //!
|
||||
TBranch *b_save_pz; //!
|
||||
|
||||
|
||||
BeamEnv(TTree *tree=0);
|
||||
virtual ~BeamEnv();
|
||||
virtual Int_t Cut(Long64_t entry);
|
||||
virtual Int_t GetEntry(Long64_t entry);
|
||||
virtual Long64_t LoadTree(Long64_t entry);
|
||||
virtual void Init(TTree *tree);
|
||||
virtual void Loop();
|
||||
virtual Bool_t Notify();
|
||||
virtual void Show(Long64_t entry = -1);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BeamEnv_cxx
|
||||
BeamEnv::BeamEnv(TTree *tree)
|
||||
{
|
||||
// if parameter tree is not specified (or zero), connect the file
|
||||
// used to generate this class and read the Tree.
|
||||
if (tree == 0) {
|
||||
//TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("data/lem4_1049.root");
|
||||
//if (!f) {
|
||||
//f = new TFile("musr_200003.root");
|
||||
// f = new TFile("data/lem4_1051.root"); //1049
|
||||
//}
|
||||
tree = (TTree*)gDirectory->Get("t1");
|
||||
|
||||
}
|
||||
Init(tree);
|
||||
}
|
||||
|
||||
BeamEnv::~BeamEnv()
|
||||
{
|
||||
if (!fChain) return;
|
||||
delete fChain->GetCurrentFile();
|
||||
}
|
||||
|
||||
Int_t BeamEnv::GetEntry(Long64_t entry)
|
||||
{
|
||||
// Read contents of entry.
|
||||
if (!fChain) return 0;
|
||||
return fChain->GetEntry(entry);
|
||||
}
|
||||
Long64_t BeamEnv::LoadTree(Long64_t entry)
|
||||
{
|
||||
// Set the environment to read one entry
|
||||
if (!fChain) return -5;
|
||||
Long64_t centry = fChain->LoadTree(entry);
|
||||
if (centry < 0) return centry;
|
||||
if (fChain->IsA() != TChain::Class()) return centry;
|
||||
TChain *chain = (TChain*)fChain;
|
||||
if (chain->GetTreeNumber() != fCurrent) {
|
||||
fCurrent = chain->GetTreeNumber();
|
||||
Notify();
|
||||
}
|
||||
return centry;
|
||||
}
|
||||
|
||||
void BeamEnv::Init(TTree *tree)
|
||||
{
|
||||
// The Init() function is called when the selector needs to initialize
|
||||
// a new tree or chain. Typically here the branch addresses of the tree
|
||||
// will be set. It is normaly not necessary to make changes to the
|
||||
// generated code, but the routine can be extended by the user if needed.
|
||||
// Init() will be called many times when running with PROOF.
|
||||
|
||||
// Set branch addresses
|
||||
if (tree == 0) return;
|
||||
fChain = tree;
|
||||
fCurrent = -1;
|
||||
fChain->SetMakeClass(1);
|
||||
|
||||
fChain->SetBranchAddress("runID",&runID);
|
||||
fChain->SetBranchAddress("eventID",&eventID);
|
||||
fChain->SetBranchAddress("BFieldAtDecay",&BFieldAtDecay_Bx);
|
||||
fChain->SetBranchAddress("muIniPosX",&muIniPosX);
|
||||
fChain->SetBranchAddress("muIniPosY",&muIniPosY);
|
||||
fChain->SetBranchAddress("muIniPosZ",&muIniPosZ);
|
||||
fChain->SetBranchAddress("muIniMomX",&muIniMomX);
|
||||
fChain->SetBranchAddress("muIniMomY",&muIniMomY);
|
||||
fChain->SetBranchAddress("muIniMomZ",&muIniMomZ);
|
||||
fChain->SetBranchAddress("muIniPolX",&muIniPolX);
|
||||
fChain->SetBranchAddress("muIniPolY",&muIniPolY);
|
||||
fChain->SetBranchAddress("muIniPolZ",&muIniPolZ);
|
||||
fChain->SetBranchAddress("muDecayDetID",&muDecayDetID);
|
||||
fChain->SetBranchAddress("muDecayPosX",&muDecayPosX);
|
||||
fChain->SetBranchAddress("muDecayPosY",&muDecayPosY);
|
||||
fChain->SetBranchAddress("muDecayPosZ",&muDecayPosZ);
|
||||
fChain->SetBranchAddress("muDecayTime",&muDecayTime);
|
||||
fChain->SetBranchAddress("muDecayPolX",&muDecayPolX);
|
||||
fChain->SetBranchAddress("muDecayPolY",&muDecayPolY);
|
||||
fChain->SetBranchAddress("muDecayPolZ",&muDecayPolZ);
|
||||
fChain->SetBranchAddress("muTargetTime",&muTargetTime);
|
||||
fChain->SetBranchAddress("muTargetPolX",&muTargetPolX);
|
||||
fChain->SetBranchAddress("muTargetPolY",&muTargetPolY);
|
||||
fChain->SetBranchAddress("muTargetPolZ",&muTargetPolZ);
|
||||
fChain->SetBranchAddress("fieldValue",&fieldValue);
|
||||
fChain->SetBranchAddress("det_n",&det_n);
|
||||
fChain->SetBranchAddress("det_ID",det_ID);
|
||||
fChain->SetBranchAddress("det_edep",det_edep);
|
||||
fChain->SetBranchAddress("det_nsteps",det_nsteps);
|
||||
fChain->SetBranchAddress("det_length",det_length);
|
||||
fChain->SetBranchAddress("det_time_start",det_time_start);
|
||||
fChain->SetBranchAddress("det_time_end",det_time_end);
|
||||
fChain->SetBranchAddress("det_x",det_x);
|
||||
fChain->SetBranchAddress("det_y",det_y);
|
||||
fChain->SetBranchAddress("det_z",det_z);
|
||||
fChain->SetBranchAddress("save_n", &save_n, &b_save_n);
|
||||
fChain->SetBranchAddress("save_detID", save_detID, &b_save_detID);
|
||||
fChain->SetBranchAddress("save_particleID", save_particleID, &b_save_particleID);
|
||||
fChain->SetBranchAddress("save_ke", save_ke, &b_save_ke);
|
||||
fChain->SetBranchAddress("save_x", save_x, &b_save_x);
|
||||
fChain->SetBranchAddress("save_y", save_y, &b_save_y);
|
||||
fChain->SetBranchAddress("save_z", save_z, &b_save_z);
|
||||
fChain->SetBranchAddress("save_px", save_px, &b_save_px);
|
||||
fChain->SetBranchAddress("save_py", save_py, &b_save_py);
|
||||
fChain->SetBranchAddress("save_pz", save_pz, &b_save_pz);
|
||||
|
||||
Notify();
|
||||
}
|
||||
|
||||
Bool_t BeamEnv::Notify()
|
||||
{
|
||||
// The Notify() function is called when a new file is opened. This
|
||||
// can be either for a new TTree in a TChain or when when a new TTree
|
||||
// is started when using PROOF. Typically here the branch pointers
|
||||
// will be retrieved. It is normaly not necessary to make changes
|
||||
// to the generated code, but the routine can be extended by the
|
||||
// user if needed.
|
||||
|
||||
// Get branch pointers
|
||||
b_runID = fChain->GetBranch("runID");
|
||||
b_eventID = fChain->GetBranch("eventID");
|
||||
b_BFieldAtDecay = fChain->GetBranch("BFieldAtDecay");
|
||||
b_muIniPosX = fChain->GetBranch("muIniPosX");
|
||||
b_muIniPosY = fChain->GetBranch("muIniPosY");
|
||||
b_muIniPosZ = fChain->GetBranch("muIniPosZ");
|
||||
b_muIniMomX = fChain->GetBranch("muIniMomX");
|
||||
b_muIniMomY = fChain->GetBranch("muIniMomY");
|
||||
b_muIniMomZ = fChain->GetBranch("muIniMomZ");
|
||||
b_muIniPolX = fChain->GetBranch("muIniPolX");
|
||||
b_muIniPolY = fChain->GetBranch("muIniPolY");
|
||||
b_muIniPolZ = fChain->GetBranch("muIniPolZ");
|
||||
b_muDecayDetID = fChain->GetBranch("muDecayDetID");
|
||||
b_muDecayPosX = fChain->GetBranch("muDecayPosX");
|
||||
b_muDecayPosY = fChain->GetBranch("muDecayPosY");
|
||||
b_muDecayPosZ = fChain->GetBranch("muDecayPosZ");
|
||||
b_muDecayTime = fChain->GetBranch("muDecayTime");
|
||||
b_muDecayPolX = fChain->GetBranch("muDecayPolX");
|
||||
b_muDecayPolY = fChain->GetBranch("muDecayPolY");
|
||||
b_muDecayPolZ = fChain->GetBranch("muDecayPolZ");
|
||||
b_muTargetTime = fChain->GetBranch("muTargetTime");
|
||||
b_muTargetPolX = fChain->GetBranch("muTargetPolX");
|
||||
b_muTargetPolY = fChain->GetBranch("muTargetPolY");
|
||||
b_muTargetPolZ = fChain->GetBranch("muTargetPolZ");
|
||||
b_fieldValue = fChain->GetBranch("fieldValue");
|
||||
b_det_n = fChain->GetBranch("det_n");
|
||||
b_det_ID = fChain->GetBranch("det_ID");
|
||||
b_det_edep = fChain->GetBranch("det_edep");
|
||||
b_det_nsteps = fChain->GetBranch("det_nsteps");
|
||||
b_det_length = fChain->GetBranch("det_length");
|
||||
b_det_time_start = fChain->GetBranch("det_time_start");
|
||||
b_det_time_end = fChain->GetBranch("det_time_end");
|
||||
b_det_x = fChain->GetBranch("det_x");
|
||||
b_det_y = fChain->GetBranch("det_y");
|
||||
b_det_z = fChain->GetBranch("det_z");
|
||||
|
||||
return kTRUE;
|
||||
}
|
||||
|
||||
void BeamEnv::Show(Long64_t entry)
|
||||
{
|
||||
// Print contents of entry.
|
||||
// If entry is not specified, print current entry
|
||||
if (!fChain) return;
|
||||
fChain->Show(entry);
|
||||
}
|
||||
Int_t BeamEnv::Cut(Long64_t entry)
|
||||
{
|
||||
// This function may be called from Loop.
|
||||
// returns 1 if entry is accepted.
|
||||
// returns -1 otherwise.
|
||||
return 1;
|
||||
}
|
||||
#endif // #ifdef BeamEnv_cxx
|
24
run/macros/BeamEnvLoop.C
Normal file
24
run/macros/BeamEnvLoop.C
Normal file
@ -0,0 +1,24 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber;
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
// gROOT->ProcessLine(".L sr_tr.C");
|
||||
|
||||
fileDir = "./data/";
|
||||
printf("Run \t Z \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
|
||||
for (fileNumber=52421; fileNumber<=52424; fileNumber++)
|
||||
{
|
||||
file.Form("musr_%04d.root",fileNumber);
|
||||
fileName= fileDir + file;
|
||||
EnvatZ(fileNumber,fileName,c1);
|
||||
}
|
||||
}
|
||||
|
21
run/macros/Coincedence.C
Normal file
21
run/macros/Coincedence.C
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hDettUp = new TH1F("hDettUp", "Muon arrival times Up (#mus)", 130,0.,13.);
|
||||
TH1F* hDettDown = new TH1F("hDettDown", "Muon arrival times Down (#mus)", 130,0.,13.);
|
||||
TH1F* hDettRight = new TH1F("hDettRight", "Muon arrival times Right (#mus)", 130,0.,13.);
|
||||
TH1F* hDettLeft = new TH1F("hDettLeft", "Muon arrival times Left (#mus)", 130,0.,13.);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
|
||||
for (Int_t i=0; i<100; i++) {
|
||||
hDettLeft->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
}
|
||||
}
|
||||
|
6
run/macros/Commands.C
Normal file
6
run/macros/Commands.C
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
TFile* f1 = new TFile("lem4_5000.root");
|
||||
gROOT->ProcessLine(".L NewAnalysis.C");
|
||||
NewSpec t ;
|
||||
t.Coincidence(1,2);
|
||||
}
|
39
run/macros/ExportAscii.C
Normal file
39
run/macros/ExportAscii.C
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* \brief Export Single Histogram into ASCII file
|
||||
*/
|
||||
Bool_t SingleExportAscii(TH1* hist, TString &filename, TString folder="", TString separator="\t")
|
||||
{
|
||||
Int_t i,j;
|
||||
Double_t xcenter, xwidth;
|
||||
Bool_t success=kFALSE;
|
||||
filename = folder + hist->GetName() + ".dat";
|
||||
ofstream file_out(filename);
|
||||
file_out << "# Output " << hist->ClassName() << ": " << hist->GetName() << " (" << hist->GetTitle() << ")\n";
|
||||
if (hist->GetDimension()==1)
|
||||
{
|
||||
file_out << "# BinCenter" << separator << "Content" << separator << "BinHalfWidth" << separator << "Error\n";
|
||||
for (i=1; i<=hist->GetNbinsX(); i++)
|
||||
file_out << hist->GetBinCenter(i) << separator << hist->GetBinContent(i) << separator << hist->GetBinWidth(i)/2 << separator << hist->GetBinError(i) << endl;
|
||||
if (i>1)
|
||||
success=kTRUE;
|
||||
}
|
||||
else if (hist->GetDimension()==2)
|
||||
{
|
||||
file_out << "# xBinCenter" << separator << "yBinCenter" << separator << "Content" << separator << "xBinHalfWidth" << separator << "yBinHalfWidth" << separator << "Error" << endl;
|
||||
for (i=1; i <= hist->GetNbinsX(); i++)
|
||||
{
|
||||
xcenter = hist->GetXaxis()->GetBinCenter(i);
|
||||
xwidth = hist->GetXaxis()->GetBinWidth(i)/2;
|
||||
for (j=1; j <= hist->GetNbinsY(); j++)
|
||||
file_out << xcenter << separator << hist->GetYaxis()->GetBinCenter(j) << separator << hist->GetBinContent(i,j) << separator << xwidth << separator << hist->GetYaxis()->GetBinWidth(j)/2 << separator << hist->GetBinError(i,j) << endl;
|
||||
if (j>1)
|
||||
file_out << endl; // produce a blank line after each set of Ybins for a certain Xbin. Gnuplot likes this.
|
||||
}
|
||||
if (i>1)
|
||||
success=kTRUE;
|
||||
}
|
||||
file_out.close();
|
||||
if (success == kTRUE)
|
||||
cout << "*** TRemiHistExport: Histogram " << hist->GetName() << " written to " << filename << endl;
|
||||
return success;
|
||||
}
|
253
run/macros/HiFiSim.C
Normal file
253
run/macros/HiFiSim.C
Normal file
@ -0,0 +1,253 @@
|
||||
#include <TH2.h>
|
||||
#include <TStyle.h>
|
||||
#include <TCanvas.h>
|
||||
#include <string>
|
||||
|
||||
void EnvatZ(Int_t fnumber, char* fname, TCanvas* c1)
|
||||
{
|
||||
// For old lem4 simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH3F* hBeamSpot = new TH3F("hBeamSpot", " x,y,z", 32, -100., 100., 32, -100., 100.,2900,-900,2000);
|
||||
// TH1F* hPosZ = new TH1F("hPosZ", "z",1600,-800.,800.);
|
||||
|
||||
// hBeamSpot->Fill(muTargetPosX[0], muTargetPosY[0]);
|
||||
// hPosZ->Fill(muTargetPosZ[0]);
|
||||
|
||||
// TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
// hPosZ->Draw();
|
||||
|
||||
// gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
// c1->cd(1);
|
||||
t1->Draw("muTargetPosZ[0]:muTargetPosY[0]:muTargetPosX[0]>>hBeamSpot");
|
||||
// hBeamSpot->Draw("lego");
|
||||
// hBeamSpot->Draw();
|
||||
hBeamSpot->DrawCopy("cont0 same");
|
||||
|
||||
Double_t Xrms=hBeamSpot->GetRMS(1);
|
||||
Double_t Yrms=hBeamSpot->GetRMS(2);
|
||||
Double_t Zrms=hBeamSpot->GetRMS(3);
|
||||
|
||||
Double_t Xavg=hBeamSpot->GetMean(1);
|
||||
Double_t Yavg=hBeamSpot->GetMean(2);
|
||||
Double_t Zavg=hBeamSpot->GetMean(3);
|
||||
|
||||
Double_t Nbins=hBeamSpot->Integral();
|
||||
// Long64_t Nbins=t1.save_x->GetEntries();
|
||||
if (Xrms != 0) {
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",fnumber,Zavg,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
// delete c1;
|
||||
delete f1;
|
||||
|
||||
|
||||
// hPosZ->Draw();
|
||||
|
||||
// sprintf(filenamePrint,"musrSrClass_%s.ps",fileNr);
|
||||
// c1->Print(filenamePrint);
|
||||
}
|
||||
|
||||
void BeamSlice(char* fname,Int_t SaveID)
|
||||
{
|
||||
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
// For new musrSim simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(32,-100,100,32,-100,100,100,-2600,1300)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
gStyle->SetPalette(1,0);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",SaveID,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
|
||||
f1->Close();
|
||||
}
|
||||
|
||||
void Slice(char* fname,Int_t SaveID)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Slice Properties",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(1);
|
||||
t1->Draw("muIniPosY[0]:muIniPosX[0]>>ini_hist(32,-100,100,32,-100,100)");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Beam spot at slice
|
||||
c1->cd(2);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(32,-100,100,32,-100,100)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
// Initial x polarization
|
||||
c1->cd(3);
|
||||
t1->Draw("muIniPolX >> ipol_x(128, -1.1, 1.1)"); //0, 2
|
||||
ipol_x->SetTitle("Polarization X");
|
||||
ipol_x->GetXaxis()->SetNdivisions(405);
|
||||
ipol_x->GetYaxis()->SetNdivisions(406);
|
||||
ipol_x->GetXaxis()->SetTickLength(0.018);
|
||||
ipol_x->GetYaxis()->SetTickLength(0.018);
|
||||
ipol_x->Draw("F");
|
||||
ipol_x->SetFillStyle(1001);
|
||||
ipol_x->SetFillColor(kGreen-5);
|
||||
ipol_x->Draw();
|
||||
|
||||
|
||||
// x polarization at slice
|
||||
c1->cd(4);
|
||||
t1->Draw("save_polx >> pol_x(128, -1.1, 1.1)",Cond); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Initial z polarization
|
||||
c1->cd(5);
|
||||
t1->Draw("muIniPolZ >> ipol_z(128, -1.1, 1.1)"); //0, 2
|
||||
ipol_z->SetTitle("Polarization Z");
|
||||
ipol_z->GetXaxis()->SetNdivisions(405);
|
||||
ipol_z->GetYaxis()->SetNdivisions(406);
|
||||
ipol_z->GetXaxis()->SetTickLength(0.018);
|
||||
ipol_z->GetYaxis()->SetTickLength(0.018);
|
||||
ipol_z->Draw("F");
|
||||
ipol_z->SetFillStyle(1001);
|
||||
ipol_z->SetFillColor(kGreen-5);
|
||||
ipol_z->Draw();
|
||||
|
||||
// z polarization at slice
|
||||
c1->cd(6);
|
||||
t1->Draw("save_polz >> pol_z(128, -1.1, 1.1)",Cond); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
// f1->Close();
|
||||
}
|
||||
|
||||
void CompSlice(Int_t ifnamei, Int_t ifnamef, Int_t SaveID)
|
||||
{
|
||||
TString fname;
|
||||
TString title;
|
||||
TString Cond;
|
||||
Double_t B,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13&&save_n==1",SaveID);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Slice Properties",60,40,600,800);
|
||||
c1->Divide(4,4);
|
||||
|
||||
Int_t ifname;
|
||||
Int_t counter=0;
|
||||
|
||||
printf("B \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
for (ifname=ifnamei; ifname<=ifnamef; ifname++) {
|
||||
counter++;
|
||||
fname.Form("data/musr_%d.root",ifname);
|
||||
TFile* f1 = new TFile(fname);
|
||||
// Initial beam spot
|
||||
c1->cd(counter);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(32,-100,100,32,-100,100)",Cond);
|
||||
B=(ifname-ifnamei)*0.05+0.6;
|
||||
title.Form("B=%f Tesla",B);
|
||||
bspot_hist->SetTitle(title);
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%g\t%g\t%g\t%g\t%g\t%g\n",B,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
|
||||
// f1->Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BeamSlices(char* fname,Int_t SaveIDi, Int_t SaveIDf)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TString Cond;
|
||||
Int_t i;
|
||||
|
||||
printf("SliceID \t Z \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
for (i=SaveIDi; i<=SaveIDf; i++) {
|
||||
|
||||
BeamSlice(fname,i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NatSlice(char* fname,Int_t SaveID)
|
||||
{
|
||||
// For new musrSim simulation files
|
||||
TString Cond;
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
Int_t i;
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond;
|
||||
|
||||
// Define an array with save volume IDs
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",SaveID);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(32,-100,100,32,-100,100,100,-2600,1300)",Cond);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
gStyle->SetPalette(1,0);
|
||||
bspot_hist->SetTitle("Beam Cross Section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
// printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",i,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
printf("%d\t",Nbins);
|
||||
f1->Close();
|
||||
|
||||
}
|
24
run/macros/LoopFiles.C
Normal file
24
run/macros/LoopFiles.C
Normal file
@ -0,0 +1,24 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber,L1,L3;
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
|
||||
fileDir = "data/";
|
||||
//printf("Run \t Asy \t dAsy \t Chi2 \t N\n");
|
||||
|
||||
fileNumber=0;
|
||||
for (L3=0; L3<=16 ; L3++) {
|
||||
for (L1=0; L1<=16 ; L1++) {
|
||||
fileNumber++;
|
||||
file.Form("musr_142%02d.root",fileNumber);
|
||||
fileName= fileDir + file;
|
||||
// printf("File is : %s\n", (char*) fileName);
|
||||
NatSlice(fileName,901);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
24
run/macros/LoopFiles1.C
Normal file
24
run/macros/LoopFiles1.C
Normal file
@ -0,0 +1,24 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber,L1,L3;
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
|
||||
fileDir = "data/";
|
||||
//printf("Run \t Asy \t dAsy \t Chi2 \t N\n");
|
||||
|
||||
fileNumber=0;
|
||||
for (L3=0; L3<=16 ; L3++) {
|
||||
for (L1=0; L1<=16 ; L1++) {
|
||||
fileNumber++;
|
||||
file.Form("musr_142%02d.root",fileNumber);
|
||||
fileName= fileDir + file;
|
||||
// printf("File is : %s\n", (char*) fileName);
|
||||
NatSlice(fileName,901);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
24
run/macros/LoopFilesOne.C
Normal file
24
run/macros/LoopFilesOne.C
Normal file
@ -0,0 +1,24 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber,CR;
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
|
||||
fileDir = "data/";
|
||||
//printf("Run \t Asy \t dAsy \t Chi2 \t N\n");
|
||||
|
||||
fileNumber=0;
|
||||
for (CR=0; CR<=16 ; CR++) {
|
||||
fileNumber++;
|
||||
file.Form("musr_101%02d.root",fileNumber);
|
||||
fileName= fileDir + file;
|
||||
// printf("File is : %s\n", (char*) fileName);
|
||||
// NatSlice(fileName,901);
|
||||
printf("%d\t",CR);
|
||||
BeamSlice(fileName,901);
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
|
26
run/macros/LoopFilesThree.C
Normal file
26
run/macros/LoopFilesThree.C
Normal file
@ -0,0 +1,26 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber,L1,L3;
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
|
||||
fileDir = "data/";
|
||||
//printf("Run \t Asy \t dAsy \t Chi2 \t N\n");
|
||||
|
||||
fileNumber=0;
|
||||
for (L3=0; L3<=10 ; L3++) {
|
||||
for (L1=0; L1<=10 ; L1++) {
|
||||
for (CR=0; CR<=16; CR++) {
|
||||
fileNumber++;
|
||||
file.Form("musr_115%02d.root",fileNumber);
|
||||
fileName= fileDir + file;
|
||||
// printf("File is : %s\n", (char*) fileName);
|
||||
NatSlice(fileName,901);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
169
run/macros/NewAnalysis.C
Normal file
169
run/macros/NewAnalysis.C
Normal file
@ -0,0 +1,169 @@
|
||||
#define analysis_cxx
|
||||
#include "analysis.h"
|
||||
#include <TH2.h>
|
||||
#include <TStyle.h>
|
||||
#include <TCanvas.h>
|
||||
|
||||
void analysis::Loop()
|
||||
{
|
||||
Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hDettUp = new TH1F("hDettUp", "Muon arrival times Up (#mus)", 130,0.,13.);
|
||||
TH1F* hDettDown = new TH1F("hDettDown", "Muon arrival times Down (#mus)", 130,0.,13.);
|
||||
TH1F* hDettRight = new TH1F("hDettRight", "Muon arrival times Right (#mus)", 130,0.,13.);
|
||||
TH1F* hDettLeft = new TH1F("hDettLeft", "Muon arrival times Left (#mus)", 130,0.,13.);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Coincidence between 1 and 33 scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==1) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==36) {
|
||||
printf("Found coincedence\n");
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettUp->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coincidence between 17 and 49 scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==17) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==49){
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettDown->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coincidence between 9 and 42 scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==9) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==42) {
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettRight->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coincidence between 25 and 57 scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==25) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==57){
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettLeft->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PLOT HISTOGRAMS
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
|
||||
// hEdeposited->Scale(1/(number_of_generated_events*hEdeposited->GetBinWidth(1)));
|
||||
TH1F *htemp1 = (TH1F*) hDettUp->Clone(); htemp1->SetName("htemp1");
|
||||
TH1F *htemp2 = (TH1F*) hDettUp->Clone(); htemp2->SetName("htemp2");
|
||||
|
||||
TH1F *htemp3 = (TH1F*) hDettUp->Clone(); htemp3->SetName("htemp3");
|
||||
TH1F *htemp4 = (TH1F*) hDettUp->Clone(); htemp4->SetName("htemp4");
|
||||
|
||||
TH1F *htemp5 = (TH1F*) hDettUp->Clone(); htemp5->SetName("htemp5");
|
||||
htemp5->SetTitle("Muon decay asymmetry U-D; Time (#mus); Asymmetry");
|
||||
htemp5->Sumw2();
|
||||
|
||||
TH1F *htemp6 = (TH1F*) hDettUp->Clone(); htemp6->SetName("htemp6");
|
||||
htemp6->SetTitle("Muon decay asymmetry L-R; Time (#mus); Asymmetry");
|
||||
htemp6->Sumw2();
|
||||
|
||||
htemp1->Add(hDettUp,hDettDown,1.,-1.);
|
||||
htemp2->Add(hDettUp,hDettDown,1., 1.);
|
||||
htemp5->Divide(htemp1,htemp2,1.,1.);
|
||||
|
||||
htemp3->Add(hDettLeft,hDettRight,1.,-1.);
|
||||
htemp4->Add(hDettLeft,hDettRight,1., 1.);
|
||||
htemp6->Divide(htemp3,htemp4,1.,1.);
|
||||
|
||||
htemp5->SetLineWidth(2);
|
||||
htemp5->SetLineColor(2);
|
||||
htemp5->SetAxisRange(-0.8,0.8,"Y");
|
||||
htemp5->Draw("hist");
|
||||
|
||||
htemp6->SetLineWidth(2);
|
||||
htemp6->SetLineColor(4);
|
||||
htemp6->SetAxisRange(-0.8,0.8,"Y");
|
||||
htemp6->Draw("same");
|
||||
|
||||
hEdepositCF->SetLineWidth(2);
|
||||
hEdepositCF->SetLineColor(2);
|
||||
hEdepositCF->Draw("hist");
|
||||
//hEdepositCF->Fit("gaus");
|
||||
|
||||
TCanvas* c2= new TCanvas("c2","canvas 2");
|
||||
hEdeposited->Draw();
|
||||
|
||||
// sprintf(filenamePrint,"musrSrClass_%s.ps",fileNr);
|
||||
// c1->Print(filenamePrint);
|
||||
}
|
1332
run/macros/NewSpec.C
Normal file
1332
run/macros/NewSpec.C
Normal file
File diff suppressed because it is too large
Load Diff
312
run/macros/NewSpec.h
Normal file
312
run/macros/NewSpec.h
Normal file
@ -0,0 +1,312 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// This class has been automatically generated on
|
||||
// Fri Oct 26 16:55:39 2007 by ROOT version 5.08/00
|
||||
// from TTree t1/a simple Tree with simple variables
|
||||
// found on file: musr_200003.root
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef NewSpec_h
|
||||
#define NewSpec_h
|
||||
|
||||
#include <TROOT.h>
|
||||
#include <TChain.h>
|
||||
#include <TFile.h>
|
||||
|
||||
class NewSpec {
|
||||
public :
|
||||
TTree *fChain; //!pointer to the analyzed TTree or TChain
|
||||
Int_t fCurrent; //!current Tree number in a TChain
|
||||
|
||||
// Declaration of leave types
|
||||
Int_t runID;
|
||||
Int_t eventID;
|
||||
Double_t BFieldAtDecay_Bx;
|
||||
Double_t BFieldAtDecay_By;
|
||||
Double_t BFieldAtDecay_Bz;
|
||||
Double_t BFieldAtDecay_B3;
|
||||
Double_t BFieldAtDecay_B4;
|
||||
Double_t BFieldAtDecay_B5;
|
||||
Double_t muIniPosX;
|
||||
Double_t muIniPosY;
|
||||
Double_t muIniPosZ;
|
||||
Double_t muIniMomX;
|
||||
Double_t muIniMomY;
|
||||
Double_t muIniMomZ;
|
||||
Double_t muIniPolX;
|
||||
Double_t muIniPolY;
|
||||
Double_t muIniPolZ;
|
||||
Int_t muDecayDetID;
|
||||
Double_t muDecayPosX;
|
||||
Double_t muDecayPosY;
|
||||
Double_t muDecayPosZ;
|
||||
Double_t muDecayTime;
|
||||
Double_t muDecayPolX;
|
||||
Double_t muDecayPolY;
|
||||
Double_t muDecayPolZ;
|
||||
Double_t muTargetTime;
|
||||
Double_t muTargetPolX;
|
||||
Double_t muTargetPolY;
|
||||
Double_t muTargetPolZ;
|
||||
Double_t fieldNomVal;
|
||||
Int_t det_n;
|
||||
Int_t det_ID[100]; //[det_n]
|
||||
Double_t det_edep[100]; //[det_n]
|
||||
Int_t det_nsteps[100]; //[det_n]
|
||||
Double_t det_length[100]; //[det_n]
|
||||
Double_t det_time_start[100]; //[det_n]
|
||||
Double_t det_time_end[100]; //[det_n]
|
||||
Double_t det_x[100]; //[det_n]
|
||||
Double_t det_y[100]; //[det_n]
|
||||
Double_t det_z[100]; //[det_n]
|
||||
Int_t save_n;
|
||||
Int_t save_detID[100]; //[save_n]
|
||||
Int_t save_particleID[100]; //[save_n]
|
||||
Double_t save_ke[100]; //[save_n]
|
||||
Double_t save_x[100]; //[save_n]
|
||||
Double_t save_y[100]; //[save_n]
|
||||
Double_t save_z[100]; //[save_n]
|
||||
Double_t save_px[100]; //[save_n]
|
||||
Double_t save_py[100]; //[save_n]
|
||||
Double_t save_pz[100]; //[save_n]
|
||||
|
||||
|
||||
// List of branches
|
||||
TBranch *b_runID; //!
|
||||
TBranch *b_eventID; //!
|
||||
TBranch *b_BFieldAtDecay; //!
|
||||
TBranch *b_muIniPosX; //!
|
||||
TBranch *b_muIniPosY; //!
|
||||
TBranch *b_muIniPosZ; //!
|
||||
TBranch *b_muIniMomX; //!
|
||||
TBranch *b_muIniMomY; //!
|
||||
TBranch *b_muIniMomZ; //!
|
||||
TBranch *b_muIniPolX; //!
|
||||
TBranch *b_muIniPolY; //!
|
||||
TBranch *b_muIniPolZ; //!
|
||||
TBranch *b_muDecayDetID; //!
|
||||
TBranch *b_muDecayPosX; //!
|
||||
TBranch *b_muDecayPosY; //!
|
||||
TBranch *b_muDecayPosZ; //!
|
||||
TBranch *b_muDecayTime; //!
|
||||
TBranch *b_muDecayPolX; //!
|
||||
TBranch *b_muDecayPolY; //!
|
||||
TBranch *b_muDecayPolZ; //!
|
||||
TBranch *b_muTargetTime; //!
|
||||
TBranch *b_muTargetPolX; //!
|
||||
TBranch *b_muTargetPolY; //!
|
||||
TBranch *b_muTargetPolZ; //!
|
||||
TBranch *b_fieldNomVal; //!
|
||||
TBranch *b_det_n; //!
|
||||
TBranch *b_det_ID; //!
|
||||
TBranch *b_det_edep; //!
|
||||
TBranch *b_det_nsteps; //!
|
||||
TBranch *b_det_length; //!
|
||||
TBranch *b_det_time_start; //!
|
||||
TBranch *b_det_time_end; //!
|
||||
TBranch *b_det_x; //!
|
||||
TBranch *b_det_y; //!
|
||||
TBranch *b_det_z; //!
|
||||
TBranch *b_save_n; //!
|
||||
TBranch *b_save_detID; //!
|
||||
TBranch *b_save_particleID; //!
|
||||
TBranch *b_save_ke; //!
|
||||
TBranch *b_save_x; //!
|
||||
TBranch *b_save_y; //!
|
||||
TBranch *b_save_z; //!
|
||||
TBranch *b_save_px; //!
|
||||
TBranch *b_save_py; //!
|
||||
TBranch *b_save_pz; //!
|
||||
|
||||
|
||||
NewSpec(TTree *tree=0);
|
||||
virtual ~NewSpec();
|
||||
virtual Int_t Cut(Long64_t entry);
|
||||
virtual Int_t GetEntry(Long64_t entry);
|
||||
virtual Long64_t LoadTree(Long64_t entry);
|
||||
virtual void Init(TTree *tree);
|
||||
virtual void Loop();
|
||||
virtual Bool_t Notify();
|
||||
virtual void Show(Long64_t entry = -1);
|
||||
virtual void CreateIO(Bool_t FigFlag, Double_t eCut);
|
||||
virtual void CoinIO(Bool_t FigFlag, Double_t eCut);
|
||||
virtual void CoinIOUD(Bool_t FigFlag, Double_t eCut);
|
||||
virtual void TBLRCoinIO(Bool_t FigFlag, Double_t eCut, Bool_t MDecayNotInSample);
|
||||
virtual void TBLRCoinDown(Bool_t FigFlag, Double_t eCut);
|
||||
virtual void TBLRCoinUp(Bool_t FigFlag, Double_t eCut);
|
||||
virtual void SCoinIO(Bool_t FigFlag, Double_t eCut);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef NewSpec_cxx
|
||||
NewSpec::NewSpec(TTree *tree)
|
||||
{
|
||||
// if parameter tree is not specified (or zero), connect the file
|
||||
// used to generate this class and read the Tree.
|
||||
if (tree == 0) {
|
||||
//TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("data/lem4_1049.root");
|
||||
//if (!f) {
|
||||
//f = new TFile("musr_200003.root");
|
||||
// f = new TFile("data/lem4_1051.root"); //1049
|
||||
//}
|
||||
tree = (TTree*)gDirectory->Get("t1");
|
||||
|
||||
}
|
||||
Init(tree);
|
||||
}
|
||||
|
||||
NewSpec::~NewSpec()
|
||||
{
|
||||
if (!fChain) return;
|
||||
delete fChain->GetCurrentFile();
|
||||
}
|
||||
|
||||
Int_t NewSpec::GetEntry(Long64_t entry)
|
||||
{
|
||||
// Read contents of entry.
|
||||
if (!fChain) return 0;
|
||||
return fChain->GetEntry(entry);
|
||||
}
|
||||
Long64_t NewSpec::LoadTree(Long64_t entry)
|
||||
{
|
||||
// Set the environment to read one entry
|
||||
if (!fChain) return -5;
|
||||
Long64_t centry = fChain->LoadTree(entry);
|
||||
if (centry < 0) return centry;
|
||||
if (fChain->IsA() != TChain::Class()) return centry;
|
||||
TChain *chain = (TChain*)fChain;
|
||||
if (chain->GetTreeNumber() != fCurrent) {
|
||||
fCurrent = chain->GetTreeNumber();
|
||||
Notify();
|
||||
}
|
||||
return centry;
|
||||
}
|
||||
|
||||
void NewSpec::Init(TTree *tree)
|
||||
{
|
||||
// The Init() function is called when the selector needs to initialize
|
||||
// a new tree or chain. Typically here the branch addresses of the tree
|
||||
// will be set. It is normaly not necessary to make changes to the
|
||||
// generated code, but the routine can be extended by the user if needed.
|
||||
// Init() will be called many times when running with PROOF.
|
||||
|
||||
// Set branch addresses
|
||||
if (tree == 0) return;
|
||||
fChain = tree;
|
||||
fCurrent = -1;
|
||||
fChain->SetMakeClass(1);
|
||||
|
||||
fChain->SetBranchAddress("runID",&runID);
|
||||
fChain->SetBranchAddress("eventID",&eventID);
|
||||
fChain->SetBranchAddress("BFieldAtDecay",&BFieldAtDecay_Bx);
|
||||
fChain->SetBranchAddress("muIniPosX",&muIniPosX);
|
||||
fChain->SetBranchAddress("muIniPosY",&muIniPosY);
|
||||
fChain->SetBranchAddress("muIniPosZ",&muIniPosZ);
|
||||
fChain->SetBranchAddress("muIniMomX",&muIniMomX);
|
||||
fChain->SetBranchAddress("muIniMomY",&muIniMomY);
|
||||
fChain->SetBranchAddress("muIniMomZ",&muIniMomZ);
|
||||
fChain->SetBranchAddress("muIniPolX",&muIniPolX);
|
||||
fChain->SetBranchAddress("muIniPolY",&muIniPolY);
|
||||
fChain->SetBranchAddress("muIniPolZ",&muIniPolZ);
|
||||
fChain->SetBranchAddress("muDecayDetID",&muDecayDetID);
|
||||
fChain->SetBranchAddress("muDecayPosX",&muDecayPosX);
|
||||
fChain->SetBranchAddress("muDecayPosY",&muDecayPosY);
|
||||
fChain->SetBranchAddress("muDecayPosZ",&muDecayPosZ);
|
||||
fChain->SetBranchAddress("muDecayTime",&muDecayTime);
|
||||
fChain->SetBranchAddress("muDecayPolX",&muDecayPolX);
|
||||
fChain->SetBranchAddress("muDecayPolY",&muDecayPolY);
|
||||
fChain->SetBranchAddress("muDecayPolZ",&muDecayPolZ);
|
||||
fChain->SetBranchAddress("muTargetTime",&muTargetTime);
|
||||
fChain->SetBranchAddress("muTargetPolX",&muTargetPolX);
|
||||
fChain->SetBranchAddress("muTargetPolY",&muTargetPolY);
|
||||
fChain->SetBranchAddress("muTargetPolZ",&muTargetPolZ);
|
||||
fChain->SetBranchAddress("fieldNomVal",&fieldNomVal);
|
||||
fChain->SetBranchAddress("det_n",&det_n);
|
||||
fChain->SetBranchAddress("det_ID",det_ID);
|
||||
fChain->SetBranchAddress("det_edep",det_edep);
|
||||
fChain->SetBranchAddress("det_nsteps",det_nsteps);
|
||||
fChain->SetBranchAddress("det_length",det_length);
|
||||
fChain->SetBranchAddress("det_time_start",det_time_start);
|
||||
fChain->SetBranchAddress("det_time_end",det_time_end);
|
||||
fChain->SetBranchAddress("det_x",det_x);
|
||||
fChain->SetBranchAddress("det_y",det_y);
|
||||
fChain->SetBranchAddress("det_z",det_z);
|
||||
fChain->SetBranchAddress("save_n", &save_n, &b_save_n);
|
||||
fChain->SetBranchAddress("save_detID", save_detID, &b_save_detID);
|
||||
fChain->SetBranchAddress("save_particleID", save_particleID, &b_save_particleID);
|
||||
fChain->SetBranchAddress("save_ke", save_ke, &b_save_ke);
|
||||
fChain->SetBranchAddress("save_x", save_x, &b_save_x);
|
||||
fChain->SetBranchAddress("save_y", save_y, &b_save_y);
|
||||
fChain->SetBranchAddress("save_z", save_z, &b_save_z);
|
||||
fChain->SetBranchAddress("save_px", save_px, &b_save_px);
|
||||
fChain->SetBranchAddress("save_py", save_py, &b_save_py);
|
||||
fChain->SetBranchAddress("save_pz", save_pz, &b_save_pz);
|
||||
|
||||
Notify();
|
||||
}
|
||||
|
||||
Bool_t NewSpec::Notify()
|
||||
{
|
||||
// The Notify() function is called when a new file is opened. This
|
||||
// can be either for a new TTree in a TChain or when when a new TTree
|
||||
// is started when using PROOF. Typically here the branch pointers
|
||||
// will be retrieved. It is normaly not necessary to make changes
|
||||
// to the generated code, but the routine can be extended by the
|
||||
// user if needed.
|
||||
|
||||
// Get branch pointers
|
||||
b_runID = fChain->GetBranch("runID");
|
||||
b_eventID = fChain->GetBranch("eventID");
|
||||
b_BFieldAtDecay = fChain->GetBranch("BFieldAtDecay");
|
||||
b_muIniPosX = fChain->GetBranch("muIniPosX");
|
||||
b_muIniPosY = fChain->GetBranch("muIniPosY");
|
||||
b_muIniPosZ = fChain->GetBranch("muIniPosZ");
|
||||
b_muIniMomX = fChain->GetBranch("muIniMomX");
|
||||
b_muIniMomY = fChain->GetBranch("muIniMomY");
|
||||
b_muIniMomZ = fChain->GetBranch("muIniMomZ");
|
||||
b_muIniPolX = fChain->GetBranch("muIniPolX");
|
||||
b_muIniPolY = fChain->GetBranch("muIniPolY");
|
||||
b_muIniPolZ = fChain->GetBranch("muIniPolZ");
|
||||
b_muDecayDetID = fChain->GetBranch("muDecayDetID");
|
||||
b_muDecayPosX = fChain->GetBranch("muDecayPosX");
|
||||
b_muDecayPosY = fChain->GetBranch("muDecayPosY");
|
||||
b_muDecayPosZ = fChain->GetBranch("muDecayPosZ");
|
||||
b_muDecayTime = fChain->GetBranch("muDecayTime");
|
||||
b_muDecayPolX = fChain->GetBranch("muDecayPolX");
|
||||
b_muDecayPolY = fChain->GetBranch("muDecayPolY");
|
||||
b_muDecayPolZ = fChain->GetBranch("muDecayPolZ");
|
||||
b_muTargetTime = fChain->GetBranch("muTargetTime");
|
||||
b_muTargetPolX = fChain->GetBranch("muTargetPolX");
|
||||
b_muTargetPolY = fChain->GetBranch("muTargetPolY");
|
||||
b_muTargetPolZ = fChain->GetBranch("muTargetPolZ");
|
||||
b_fieldNomVal = fChain->GetBranch("fieldNomVal");
|
||||
b_det_n = fChain->GetBranch("det_n");
|
||||
b_det_ID = fChain->GetBranch("det_ID");
|
||||
b_det_edep = fChain->GetBranch("det_edep");
|
||||
b_det_nsteps = fChain->GetBranch("det_nsteps");
|
||||
b_det_length = fChain->GetBranch("det_length");
|
||||
b_det_time_start = fChain->GetBranch("det_time_start");
|
||||
b_det_time_end = fChain->GetBranch("det_time_end");
|
||||
b_det_x = fChain->GetBranch("det_x");
|
||||
b_det_y = fChain->GetBranch("det_y");
|
||||
b_det_z = fChain->GetBranch("det_z");
|
||||
|
||||
return kTRUE;
|
||||
}
|
||||
|
||||
void NewSpec::Show(Long64_t entry)
|
||||
{
|
||||
// Print contents of entry.
|
||||
// If entry is not specified, print current entry
|
||||
if (!fChain) return;
|
||||
fChain->Show(entry);
|
||||
}
|
||||
Int_t NewSpec::Cut(Long64_t entry)
|
||||
{
|
||||
// This function may be called from Loop.
|
||||
// returns 1 if entry is accepted.
|
||||
// returns -1 otherwise.
|
||||
return 1;
|
||||
}
|
||||
#endif // #ifdef NewSpec_cxx
|
648
run/macros/NewSpeccp.C
Normal file
648
run/macros/NewSpeccp.C
Normal file
@ -0,0 +1,648 @@
|
||||
#define NewSpec_cxx
|
||||
#include "NewSpec.h"
|
||||
#include <TH2.h>
|
||||
#include <TStyle.h>
|
||||
#include <TCanvas.h>
|
||||
#include <string>
|
||||
#include <TROOT.h>
|
||||
#include <TKey.h>
|
||||
#include <TFile.h>
|
||||
#include <TSystem.h>
|
||||
#include <TTree.h>
|
||||
|
||||
void NewSpec::CreateIO( Bool_t FigFlag, Double_t eCut )
|
||||
{
|
||||
// Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
|
||||
// Back inner histogram, i.e. all counts in segments 1-16
|
||||
TH1F* hBackI = new TH1F("hBackI","Muon arrival times Back I (#mus)",1300,0.,13.);
|
||||
// Forward inner histogram, i.e. all counts in segments 17-32
|
||||
TH1F* hForwI = new TH1F("hForwI","Muon arrival times Forw I (#mus)",1300,0.,13.);
|
||||
// Back outer histogram, i.e. all counts in segments 33-48
|
||||
TH1F* hBackO = new TH1F("hBackO","Muon arrival times Back O (#mus)",1300,0.,13.);
|
||||
// Forward outer histogram, i.e. all counts in segments 49-64
|
||||
TH1F* hForwO = new TH1F("hForwO","Muon arrival times Forw O (#mus)",1300,0.,13.);
|
||||
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Hist in Back I detector (1-16)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]<=16 && det_ID[i] >=1) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
hBackI->Fill(det_time_start[i]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Forw I detector (17-32)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]>=17 && det_ID[i]<=32) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
hForwI->Fill(det_time_start[i]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Back O detector (33-48)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]<=48 && det_ID[i] >=33) {
|
||||
// hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
hBackO->Fill(det_time_start[i]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Forw O detector (49-64)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]>=49 && det_ID[i]<=64) {
|
||||
// hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
hForwO->Fill(det_time_start[i]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate Asymmetry
|
||||
// Temporary F and B histograms
|
||||
TH1F *hFtemp = (TH1F*) hForwI->Clone(); hFtemp->SetName("hFtemp");
|
||||
TH1F *hBtemp = (TH1F*) hBackI->Clone(); hBtemp->SetName("hBtemp");
|
||||
|
||||
// Sum and difference F and B
|
||||
TH1F *hSumFB = (TH1F*) hForwI->Clone(); hSumFB->SetName("hSumFB");
|
||||
hSumFB->Sumw2();
|
||||
TH1F *hDifFB = (TH1F*) hForwI->Clone(); hDifFB->SetName("hDifFB");
|
||||
hDifFB->Sumw2();
|
||||
|
||||
// Asymmetry histograms!
|
||||
TH1F *hAsyFB = (TH1F*) hForwI->Clone(); hAsyFB->SetName("hAsyFB");
|
||||
hAsyFB->SetTitle("Muon decay asymmetry F-B; Time (#mus); Asymmetry");
|
||||
hAsyFB->Sumw2();
|
||||
|
||||
// Calculate difference and sum, then divide
|
||||
hDifFB->Add(hFtemp,hBtemp,1.,-1.);
|
||||
hSumFB->Add(hFtemp,hBtemp,1., 1.);
|
||||
hAsyFB->Divide(hDifFB,hSumFB,1.,1.);
|
||||
|
||||
if (FigFlag) {
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
c1->Divide(2,3);
|
||||
c1->cd(1);
|
||||
hBackI->Draw();
|
||||
c1->cd(2);
|
||||
hForwI->Draw();
|
||||
c1->cd(3);
|
||||
hBackO->Draw();
|
||||
c1->cd(4);
|
||||
hForwO->Draw();
|
||||
c1->cd(5);
|
||||
hAsyFB->Draw();
|
||||
hAsyFB -> Fit("pol0","Q");
|
||||
gStyle->SetOptStat(1001111);
|
||||
gStyle->SetOptFit(0001);
|
||||
gStyle->SetLineColor(2);
|
||||
c1->cd(6);
|
||||
hDetz->Draw();
|
||||
} else {
|
||||
hAsyFB -> Fit("pol0","NQ");
|
||||
}
|
||||
Double_t chi2=pol0->GetChisquare();
|
||||
Double_t p1=pol0->GetParameter(0);
|
||||
Double_t e1=pol0->GetParError(0);
|
||||
|
||||
// printf("Chi=%g\tP1=%g +/- %g\n",chi2,p1,e1);
|
||||
printf("%g\t%g\t%g\n",p1,e1,chi2);
|
||||
}
|
||||
|
||||
void NewSpec::CoinIO( Bool_t FigFlag, Double_t eCut )
|
||||
{
|
||||
// Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
|
||||
// Back inner histogram, i.e. all counts in segments 1-16
|
||||
TH1F* hBack = new TH1F("hBack","Muon arrival times Back (#mus)",1300,0.,13.);
|
||||
// Forward inner histogram, i.e. all counts in segments 17-32
|
||||
TH1F* hForw = new TH1F("hForw","Muon arrival times Forw (#mus)",1300,0.,13.);
|
||||
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Hist in Back detector (1-16) coincidence (33-48)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]<=16 && det_ID[i] >=1) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]<=48 && det_ID[j] >=33) {
|
||||
if (det_edep[j]>eCut){
|
||||
hBack->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Forw I detector (17-32) coincidence (49-64)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]>=17 && det_ID[i]<=32) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]<=64 && det_ID[j] >=49) {
|
||||
if (det_edep[j]>eCut){
|
||||
hForw->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Calculate Asymmetry
|
||||
// Temporary F and B histograms
|
||||
TH1F *hFtemp = (TH1F*) hForw->Clone(); hFtemp->SetName("hFtemp");
|
||||
TH1F *hBtemp = (TH1F*) hBack->Clone(); hBtemp->SetName("hBtemp");
|
||||
|
||||
// Sum and difference F and B
|
||||
TH1F *hSumFB = (TH1F*) hForw->Clone(); hSumFB->SetName("hSumFB");
|
||||
hSumFB->Sumw2();
|
||||
TH1F *hDifFB = (TH1F*) hForw->Clone(); hDifFB->SetName("hDifFB");
|
||||
hDifFB->Sumw2();
|
||||
|
||||
// Asymmetry histograms!
|
||||
TH1F *hAsyFB = (TH1F*) hForw->Clone(); hAsyFB->SetName("hAsyFB");
|
||||
hAsyFB->SetTitle("Muon decay asymmetry F-B; Time (#mus); Asymmetry");
|
||||
hAsyFB->Sumw2();
|
||||
|
||||
// Calculate difference and sum, then divide
|
||||
hDifFB->Add(hFtemp,hBtemp,1.,-1.);
|
||||
hSumFB->Add(hFtemp,hBtemp,1., 1.);
|
||||
hAsyFB->Divide(hDifFB,hSumFB,1.,1.);
|
||||
|
||||
if (FigFlag) {
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
c1->Divide(2,2);
|
||||
c1->cd(1);
|
||||
hBack->Draw();
|
||||
c1->cd(2);
|
||||
hForw->Draw();
|
||||
c1->cd(3);
|
||||
hAsyFB->Draw();
|
||||
hAsyFB -> Fit("pol0","Q");
|
||||
gStyle->SetOptStat(1001111);
|
||||
gStyle->SetOptFit(0001);
|
||||
gStyle->SetLineColor(2);
|
||||
c1->cd(4);
|
||||
hDetz->Draw();
|
||||
} else {
|
||||
hAsyFB -> Fit("pol0","NQ");
|
||||
}
|
||||
Double_t chi2=pol0->GetChisquare();
|
||||
Double_t p1=pol0->GetParameter(0);
|
||||
Double_t e1=pol0->GetParError(0);
|
||||
Double_t NDet=hDetz->GetSum();
|
||||
|
||||
// printf("Chi=%g\tP1=%g +/- %g\n",chi2,p1,e1);
|
||||
printf("%g\t%g\t%g\t%g\n",p1,e1,chi2,NDet);
|
||||
}
|
||||
|
||||
|
||||
void NewSpec::TBLRCoinIO( Bool_t FigFlag, Double_t eCut )
|
||||
{
|
||||
// Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
|
||||
// Top, Bottom, Left and Right histograms
|
||||
TH1F* hT = new TH1F("hT","Muon arrival times Top (#mus)",1300,0.,13.);
|
||||
TH1F* hB = new TH1F("hB","Muon arrival times Bottom (#mus)",1300,0.,13.);
|
||||
TH1F* hL = new TH1F("hL","Muon arrival times Left (#mus)",1300,0.,13.);
|
||||
TH1F* hR = new TH1F("hR","Muon arrival times Right (#mus)",1300,0.,13.);
|
||||
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Hist in Top detector (11-14)+(27-30) coincidence (43-46)+(59-62)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if ((det_ID[i]<=14 && det_ID[i] >=11) || (det_ID[i]<=30 && det_ID[i] >=27)) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if ((det_ID[j]<=46 && det_ID[j] >=43) || (det_ID[j]<=62 && det_ID[j] >=59)) {
|
||||
if (det_edep[j]>eCut){
|
||||
hT->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Bottom detector (3-6)+(19-22) coincidence (35-38)+(51-54)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if ((det_ID[i]<=6 && det_ID[i] >=3) || (det_ID[i]<=22 && det_ID[i] >=19)) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if ((det_ID[j]<=38 && det_ID[j] >=35) || (det_ID[j]<=54 && det_ID[j] >=51)) {
|
||||
if (det_edep[j]>eCut){
|
||||
hB->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Left detector (7-10)+(23-26) coincidence (39-42)+(55-58)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if ((det_ID[i]<=10 && det_ID[i] >=7) || (det_ID[i]<=26 && det_ID[i] >=23)) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if ((det_ID[j]<=42 && det_ID[j] >=39) || (det_ID[j]<=58 && det_ID[j] >=55)) {
|
||||
if (det_edep[j]>eCut){
|
||||
hL->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hist in Right detector (1,2,15,16)+(17,18,31,32) coincidence (33,34,47,48)+(49,50,63,64)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if ((det_ID[i]<=18 && det_ID[i] >=15) || (det_ID[i]<=2 && det_ID[i] >=1) || (det_ID[i]<=32 && det_ID[i] >=31)) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if ((det_ID[j]<=50 && det_ID[j] >=47) || (det_ID[j]<=34 && det_ID[j] >=33) || (det_ID[j]<=64 && det_ID[j] >=63)) {
|
||||
if (det_edep[j]>eCut){
|
||||
hR->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Calculate T-B Asymmetry
|
||||
// Temporary T and B histograms
|
||||
TH1F *hTtemp = (TH1F*) hT->Clone(); hTtemp->SetName("hTtemp");
|
||||
TH1F *hBtemp = (TH1F*) hB->Clone(); hBtemp->SetName("hBtemp");
|
||||
|
||||
// Sum and difference T and B
|
||||
TH1F *hSumTB = (TH1F*) hT->Clone(); hSumTB->SetName("hSumTB");
|
||||
hSumTB->Sumw2();
|
||||
TH1F *hDifTB = (TH1F*) hT->Clone(); hDifTB->SetName("hDifTB");
|
||||
hDifTB->Sumw2();
|
||||
|
||||
// Asymmetry histograms!
|
||||
TH1F *hAsyTB = (TH1F*) hT->Clone(); hAsyTB->SetName("hAsyTB");
|
||||
hAsyTB->SetTitle("Muon decay asymmetry T-B; Time (#mus); Asymmetry");
|
||||
hAsyTB->Sumw2();
|
||||
|
||||
// Calculate difference and sum, then divide
|
||||
hDifTB->Add(hTtemp,hBtemp,1.,-1.);
|
||||
hSumTB->Add(hTtemp,hBtemp,1., 1.);
|
||||
hAsyTB->Divide(hDifTB,hSumTB,1.,1.);
|
||||
|
||||
// Calculate L-R Asymmetry
|
||||
// Temporary L and R histograms
|
||||
TH1F *hLtemp = (TH1F*) hL->Clone(); hLtemp->SetName("hLtemp");
|
||||
TH1F *hRtemp = (TH1F*) hR->Clone(); hRtemp->SetName("hRtemp");
|
||||
|
||||
// Sum and difference L and R
|
||||
TH1F *hSumLR = (TH1F*) hL->Clone(); hSumLR->SetName("hSumLR");
|
||||
hSumLR->Sumw2();
|
||||
TH1F *hDifLR = (TH1F*) hL->Clone(); hDifLR->SetName("hDifLR");
|
||||
hDifLR->Sumw2();
|
||||
|
||||
// Asymmetry histograms!
|
||||
TH1F *hAsyLR = (TH1F*) hL->Clone(); hAsyLR->SetName("hAsyLR");
|
||||
hAsyLR->SetTitle("Muon decay asymmetry L-R; Time (#mus); Asymmetry");
|
||||
hAsyLR->Sumw2();
|
||||
|
||||
// Calculate difference and sum, then divide
|
||||
hDifLR->Add(hLtemp,hRtemp,1.,-1.);
|
||||
hSumLR->Add(hLtemp,hRtemp,1., 1.);
|
||||
hAsyLR->Divide(hDifLR,hSumLR,1.,1.);
|
||||
|
||||
if (FigFlag) {
|
||||
// Top - Bottom
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
c1->Divide(2,2);
|
||||
c1->cd(1);
|
||||
hT->Draw();
|
||||
c1->cd(2);
|
||||
hB->Draw();
|
||||
c1->cd(3);
|
||||
hAsyTB->Draw();
|
||||
hAsyTB -> Fit("pol0","Q");
|
||||
// Top - Bottom
|
||||
Double_t TBchi2=pol0->GetChisquare();
|
||||
Double_t TBp1=pol0->GetParameter(0);
|
||||
Double_t TBe1=pol0->GetParError(0);
|
||||
gStyle->SetOptStat(1001111);
|
||||
gStyle->SetOptFit(0001);
|
||||
gStyle->SetLineColor(2);
|
||||
c1->cd(4);
|
||||
hDetz->Draw();
|
||||
|
||||
// Left - Right
|
||||
TCanvas* c2= new TCanvas("c2","canvas 2");
|
||||
c2->Divide(2,2);
|
||||
c2->cd(1);
|
||||
hL->Draw();
|
||||
c2->cd(2);
|
||||
hR->Draw();
|
||||
c2->cd(3);
|
||||
hAsyLR->Draw();
|
||||
hAsyLR -> Fit("pol0","Q");
|
||||
// Left - Right
|
||||
Double_t LRchi2=pol0->GetChisquare();
|
||||
Double_t LRp1=pol0->GetParameter(0);
|
||||
Double_t LRe1=pol0->GetParError(0);
|
||||
gStyle->SetOptStat(1001111);
|
||||
gStyle->SetOptFit(0001);
|
||||
gStyle->SetLineColor(2);
|
||||
c2->cd(4);
|
||||
hDetz->Draw();
|
||||
} else {
|
||||
hAsyTB -> Fit("pol0","NQ");
|
||||
// Top - Bottom
|
||||
Double_t TBchi2=pol0->GetChisquare();
|
||||
Double_t TBp1=pol0->GetParameter(0);
|
||||
Double_t TBe1=pol0->GetParError(0);
|
||||
|
||||
hAsyLR -> Fit("pol0","NQ");
|
||||
// Left - Right
|
||||
Double_t LRchi2=pol0->GetChisquare();
|
||||
Double_t LRp1=pol0->GetParameter(0);
|
||||
Double_t LRe1=pol0->GetParError(0);
|
||||
}
|
||||
|
||||
Double_t NDet=hDetz->GetSum();
|
||||
|
||||
// printf("Chi=%g\tP1=%g +/- %g\n",chi2,p1,e1);
|
||||
printf("%g\t%g\t%g\t%g\t%g\n",TBp1,TBe1,LRp1,LRe1,NDet);
|
||||
}
|
||||
|
||||
|
||||
void NewSpec::SCoinIO( Bool_t FigFlag, Double_t eCut )
|
||||
{
|
||||
// Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
|
||||
// Sigmenets histograms 1-32
|
||||
TH1F* h1 = new TH1F("h1","Muon arrival times in 1 (#mus)",1300,0.,13.);
|
||||
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Segments (1-16) coincidence (33-48)
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==1) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
if (det_edep[i]>eCut){
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==33) {
|
||||
if (det_edep[j]>eCut){
|
||||
h1->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[j]);
|
||||
hEventID->Fill(eventID);
|
||||
break; //fill only once
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Calculate Asymmetry
|
||||
// Temporary F and B histograms
|
||||
TH1F *hFtemp = (TH1F*) hForw->Clone(); hFtemp->SetName("hFtemp");
|
||||
TH1F *hBtemp = (TH1F*) hBack->Clone(); hBtemp->SetName("hBtemp");
|
||||
|
||||
// Sum and difference F and B
|
||||
TH1F *hSumFB = (TH1F*) hForw->Clone(); hSumFB->SetName("hSumFB");
|
||||
hSumFB->Sumw2();
|
||||
TH1F *hDifFB = (TH1F*) hForw->Clone(); hDifFB->SetName("hDifFB");
|
||||
hDifFB->Sumw2();
|
||||
|
||||
// Asymmetry histograms!
|
||||
TH1F *hAsyFB = (TH1F*) hForw->Clone(); hAsyFB->SetName("hAsyFB");
|
||||
hAsyFB->SetTitle("Muon decay asymmetry F-B; Time (#mus); Asymmetry");
|
||||
hAsyFB->Sumw2();
|
||||
|
||||
// Calculate difference and sum, then divide
|
||||
hDifFB->Add(hFtemp,hBtemp,1.,-1.);
|
||||
hSumFB->Add(hFtemp,hBtemp,1., 1.);
|
||||
hAsyFB->Divide(hDifFB,hSumFB,1.,1.);
|
||||
|
||||
if (FigFlag) {
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
c1->Divide(2,2);
|
||||
c1->cd(1);
|
||||
hBack->Draw();
|
||||
c1->cd(2);
|
||||
hForw->Draw();
|
||||
c1->cd(3);
|
||||
hAsyFB->Draw();
|
||||
hAsyFB -> Fit("pol0","Q");
|
||||
gStyle->SetOptStat(1001111);
|
||||
gStyle->SetOptFit(0001);
|
||||
gStyle->SetLineColor(2);
|
||||
c1->cd(4);
|
||||
hDetz->Draw();
|
||||
} else {
|
||||
hAsyFB -> Fit("pol0","NQ");
|
||||
}
|
||||
Double_t chi2=pol0->GetChisquare();
|
||||
Double_t p1=pol0->GetParameter(0);
|
||||
Double_t e1=pol0->GetParError(0);
|
||||
Double_t NDet=hDetz->GetSum();
|
||||
|
||||
// printf("Chi=%g\tP1=%g +/- %g\n",chi2,p1,e1);
|
||||
printf("%g\t%g\t%g\t%g\n",p1,e1,chi2,NDet);
|
||||
}
|
366
run/macros/SpinRotAna.C
Normal file
366
run/macros/SpinRotAna.C
Normal file
@ -0,0 +1,366 @@
|
||||
char popis[100];
|
||||
|
||||
void SpinRotAna(){
|
||||
cout<<"Syntax: root[]> SpinRotAna.C(\"20021\")"<<endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void SpinRotAna(char* runID) {
|
||||
cout<<"runID="<<runID<<endl;
|
||||
char inputFileName[1000]="data/musr_"; strcat(inputFileName,runID); strcat(inputFileName,".root");
|
||||
cout<<"Opening file "<<inputFileName<<endl;
|
||||
TFile* f1=new TFile(inputFileName);
|
||||
// TFile* f1=new TFile("data/musr_20021.root");
|
||||
// PlotOneSaveVolume();
|
||||
|
||||
strcpy(popis,"undefined");
|
||||
if (strcmp(runID,"20053")==0) {strcpy(popis,"#splitline{Run 20053: E_{const}=2.43 kV/mm; v04=0.03 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20063")==0) {strcpy(popis,"#splitline{Run 20063: e01=2.55 kV/mm; v04=0.03 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20064")==0) {strcpy(popis,"#splitline{Run 20064: e01=2.57 kV/mm; v04=0.03 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20073")==0) {strcpy(popis,"#splitline{Run 20073: e01=2.90 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20074")==0) {strcpy(popis,"#splitline{Run 20074: e01=2.95 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20075")==0) {strcpy(popis,"#splitline{Run 20075: e01=3.00 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20076")==0) {strcpy(popis,"#splitline{Run 20076: e01=3.05 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20081")==0) {strcpy(popis,"#splitline{Run 20081: e01=3.00 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20082")==0) {strcpy(popis,"#splitline{Run 20082: e01=3.00 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20111")==0) {strcpy(popis,"#splitline{Run 20111: e01=3.00 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20116")==0) {strcpy(popis,"#splitline{Run 20116: e01=3.00 kV/mm; v04=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20121")==0) {strcpy(popis,"#splitline{Run 20121: e01=3.00 kV/mm; b05c=0.0339 T}{pie3\_HiField\_d05\_x30\_z-15111}");}
|
||||
if (strcmp(runID,"20131")==0) {strcpy(popis,"#splitline{Run 20131: e01=3.00 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20132")==0) {strcpy(popis,"#splitline{Run 20132: e01=3.03 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20133")==0) {strcpy(popis,"#splitline{Run 20133: e01=3.06 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20134")==0) {strcpy(popis,"#splitline{Run 20134: e01=2.97 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20135")==0) {strcpy(popis,"#splitline{Run 20135: e01=2.94 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20141")==0) {strcpy(popis,"#splitline{Run 20141: e01=3.00 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20142")==0) {strcpy(popis,"#splitline{Run 20142: e01=3.03 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20143")==0) {strcpy(popis,"#splitline{Run 20143: e01=3.06 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20144")==0) {strcpy(popis,"#splitline{Run 20144: e01=2.97 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20145")==0) {strcpy(popis,"#splitline{Run 20145: e01=2.94 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20181")==0) {strcpy(popis,"#splitline{Run 20181: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20191")==0) {strcpy(popis,"#splitline{Run 20191: e01=3.09 kV/mm; v04=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20201")==0) {strcpy(popis,"#splitline{Run 20201: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032, y-x}");}
|
||||
if (strcmp(runID,"20201")==0) {strcpy(popis,"#splitline{Run 20201: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032, y-x}");}
|
||||
if (strcmp(runID,"20202")==0) {strcpy(popis,"#splitline{Run 20202: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032, -yx}");}
|
||||
if (strcmp(runID,"20203")==0) {strcpy(popis,"#splitline{Run 20203: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20211")==0) {strcpy(popis,"#splitline{Run 20211: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032, y-x}");}
|
||||
if (strcmp(runID,"20212")==0) {strcpy(popis,"#splitline{Run 20212: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032, -yx}");}
|
||||
if (strcmp(runID,"20213")==0) {strcpy(popis,"#splitline{Run 20213: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032}");}
|
||||
if (strcmp(runID,"20221")==0) {strcpy(popis,"#splitline{Run 20221: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032\_NEW, y-x}");}
|
||||
if (strcmp(runID,"20222")==0) {strcpy(popis,"#splitline{Run 20222: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032\_NEW, -yx}");}
|
||||
if (strcmp(runID,"20223")==0) {strcpy(popis,"#splitline{Run 20223: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032\_NEW}");}
|
||||
if (strcmp(runID,"20231")==0) {strcpy(popis,"#splitline{Run 20231: e01=3.09 kV/mm; b05c=0.0339 T}{reggiani\_Jan2010\_z-12032\_NEW}");}
|
||||
if (strcmp(runID,"20301")==0) {strcpy(popis,"#splitline{Run 20301: e01=3.09 kV/mm; b05c=0.0339 T}{like 20181 with Geant4.9.3}");}
|
||||
if (strcmp(runID,"20302")==0) {strcpy(popis,"#splitline{Run 20302: e01=3.09 kV/mm; b05c=0.0339 T}{like 20181}");}
|
||||
if (strcmp(runID,"20303")==0) {strcpy(popis,"#splitline{Run 20303: e01=3.09 kV/mm; b05c=0.0339 T}{like 20181 with Geant4.9.3 new}");}
|
||||
if (strcmp(runID,"20311")==0) {strcpy(popis,"#splitline{Run 20311: e01=3.09 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20312")==0) {strcpy(popis,"#splitline{Run 20312: e01=3.00 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20313")==0) {strcpy(popis,"#splitline{Run 20313: e01=3.03 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20314")==0) {strcpy(popis,"#splitline{Run 20314: e01=3.06 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20315")==0) {strcpy(popis,"#splitline{Run 20315: e01=3.12 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20316")==0) {strcpy(popis,"#splitline{Run 20316: e01=3.15 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20321")==0) {strcpy(popis,"#splitline{Run 20321: e01=3.03 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20331")==0) {strcpy(popis,"#splitline{Run 20331: E_{unif}=3.03 kV/mm; B_{unif}=0.0392 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20332")==0) {strcpy(popis,"#splitline{Run 20332: E_{unif}=3.00 kV/mm; B_{unif}=0.0392 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20333")==0) {strcpy(popis,"#splitline{Run 20333: E_{unif}=3.06 kV/mm; B_{unif}=0.0392 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20334")==0) {strcpy(popis,"#splitline{Run 20334: E_{unif}=3.09 kV/mm; B_{unif}=0.0392 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20335")==0) {strcpy(popis,"#splitline{Run 20335: E_{unif}=2.97 kV/mm; B_{unif}=0.0392 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20351")==0) {strcpy(popis,"#splitline{Run 20351: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{Feb Turtle}");}
|
||||
if (strcmp(runID,"20361")==0) {strcpy(popis,"#splitline{Run 20361: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4 MeV/c, x=y=0}");}
|
||||
if (strcmp(runID,"20362")==0) {strcpy(popis,"#splitline{Run 20362: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4+/-0.81 MeV/c, x=y=0}");}
|
||||
if (strcmp(runID,"20363")==0) {strcpy(popis,"#splitline{Run 20363: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4 MeV/c, x,y=Gaussian}");}
|
||||
if (strcmp(runID,"20371")==0) {strcpy(popis,"#splitline{Run 20371: e01=3.03 kV/mm; b05c=0.0339 T}{Feb Turtle, Geant4.9.3}");}
|
||||
if (strcmp(runID,"20381")==0) {strcpy(popis,"#splitline{Run 20381: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{Feb Turtle, #mu does not decay}");}
|
||||
if (strcmp(runID,"20391")==0) {strcpy(popis,"#splitline{Run 20391: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4 MeV/c, x=y=0, #mu does not decay}");}
|
||||
if (strcmp(runID,"20392")==0) {strcpy(popis,"#splitline{Run 20392: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4+/-0.81 MeV/c, x=y=0, #mu does not decay}");}
|
||||
if (strcmp(runID,"20393")==0) {strcpy(popis,"#splitline{Run 20393: E_{unif}=3.08544 kV/mm; B_{unif}=0.041 T}{p=27.4 MeV/c, x,y=Gaussian, #mu does not decay}");}
|
||||
|
||||
|
||||
TCanvas* cR1IN = PlotOneSaveVolume ("R1IN", "save_detID==1010&&save_particleID==-13");
|
||||
TCanvas* cR1IN2= PlotOneSaveVolumeTwo("R1IN2","save_detID==1010&&save_particleID==-13");
|
||||
char outputFileName_cR1IN[1000]; sprintf(outputFileName_cR1IN,"pict/SpinRotAna_R1IN_%s.ps",runID);
|
||||
cR1IN->Print(outputFileName_cR1IN);
|
||||
char outputFileName_cR1IN2[1000]; sprintf(outputFileName_cR1IN2,"pict/SpinRotAna_R1IN_two_%s.ps",runID);
|
||||
cR1IN2->Print(outputFileName_cR1IN2);
|
||||
|
||||
TCanvas* cR1OU = PlotOneSaveVolume ("R1OU", "save_detID==1020&&save_particleID==-13");
|
||||
TCanvas* cR1OU2= PlotOneSaveVolumeTwo("R1OU2","save_detID==1020&&save_particleID==-13");
|
||||
char outputFileName_cR1OU[1000]; sprintf(outputFileName_cR1OU,"pict/SpinRotAna_R1OU_%s.ps",runID);
|
||||
cR1OU->Print(outputFileName_cR1OU);
|
||||
char outputFileName_cR1OU2[1000]; sprintf(outputFileName_cR1OU2,"pict/SpinRotAna_R1OU_two_%s.ps",runID);
|
||||
cR1OU2->Print(outputFileName_cR1OU2);
|
||||
|
||||
TCanvas* cR2IN = PlotOneSaveVolume ("R2IN", "save_detID==1050&&save_particleID==-13");
|
||||
TCanvas* cR2IN2= PlotOneSaveVolumeTwo("R2IN2","save_detID==1050&&save_particleID==-13");
|
||||
char outputFileName_cR2IN[1000]; sprintf(outputFileName_cR2IN,"pict/SpinRotAna_R2IN_%s.ps",runID);
|
||||
cR2IN->Print(outputFileName_cR2IN);
|
||||
char outputFileName_cR2IN2[1000]; sprintf(outputFileName_cR2IN2,"pict/SpinRotAna_R2IN_two_%s.ps",runID);
|
||||
cR2IN2->Print(outputFileName_cR2IN2);
|
||||
|
||||
TCanvas* cR2OU = PlotOneSaveVolume ("R2OU", "save_detID==1060&&save_particleID==-13");
|
||||
TCanvas* cR2OU2= PlotOneSaveVolumeTwo("R2OU2","save_detID==1060&&save_particleID==-13");
|
||||
char outputFileName_cR2OU[1000]; sprintf(outputFileName_cR2OU,"pict/SpinRotAna_R2OU_%s.ps",runID);
|
||||
cR2OU->Print(outputFileName_cR2OU);
|
||||
char outputFileName_cR2OU2[1000]; sprintf(outputFileName_cR2OU2,"pict/SpinRotAna_R2OU_two_%s.ps",runID);
|
||||
cR2OU2->Print(outputFileName_cR2OU2);
|
||||
|
||||
|
||||
|
||||
TCanvas* cEnvelope = new TCanvas("cEnvelope","cEnvelope");
|
||||
// TH1D* hisEnvelopeX = new TH1D("hisEnvelopeX","Beam envelope; z (cm); 2*RMS of x and -y (cm)",1200,-1700,-500);
|
||||
// TH1D* hisEnvelopeY = new TH1D("hisEnvelopeY","Beam envelope; z (cm); 2*RMS of x and -y (cm)",1200,-1700,-500);
|
||||
TH1D* hisEnvelopeX = new TH1D("hisEnvelopeX","Beam envelope; z (cm); #pm 2*RMS of x and y (cm)",1200,-1400,-200);
|
||||
TH1D* hisEnvelopeY = new TH1D("hisEnvelopeY","Beam envelope; z (cm); #pm 2*RMS of x and y (cm)",1200,-1400,-200);
|
||||
Double_t fRunID=atof(runID);
|
||||
std::cout<<"fRunID="<<fRunID<<std::endl;
|
||||
if (fRunID<20130) {
|
||||
FillEnvelope(hisEnvelopeX,-1511.15,"save_x/10>>hh","save_detID==1010&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1241.0,"save_x/10>>hh","save_detID==1020&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1200,"save_x/10>>hh","save_detID==1025&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1160,"save_x/10>>hh","save_detID==1028&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1146.6,"save_x/10>>hh","save_detID==1030&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1086.6,"save_x/10>>hh","save_detID==1033&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-1026.6,"save_x/10>>hh","save_detID==1036&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-972.15,"save_x/10>>hh","save_detID==1040&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-962.15,"save_x/10>>hh","save_detID==1041&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-952.15,"save_x/10>>hh","save_detID==1042&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-942.15,"save_x/10>>hh","save_detID==1043&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-932.15,"save_x/10>>hh","save_detID==1044&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-922.15,"save_x/10>>hh","save_detID==1045&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-912.15,"save_x/10>>hh","save_detID==1046&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-902.15,"save_x/10>>hh","save_detID==1047&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-892.15,"save_x/10>>hh","save_detID==1048&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-882.15,"save_x/10>>hh","save_detID==1049&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-872.15,"save_x/10>>hh","save_detID==1050&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-602.0 ,"save_x/10>>hh","save_detID==1060&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-592.0 ,"save_x/10>>hh","save_detID==1061&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-582.0 ,"save_x/10>>hh","save_detID==1062&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-572.0 ,"save_x/10>>hh","save_detID==1063&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-562.0 ,"save_x/10>>hh","save_detID==1064&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-552.0 ,"save_x/10>>hh","save_detID==1065&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-542.0 ,"save_x/10>>hh","save_detID==1066&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-532.0 ,"save_x/10>>hh","save_detID==1067&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-522.0 ,"save_x/10>>hh","save_detID==1068&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-512.0 ,"save_x/10>>hh","save_detID==1069&&save_particleID==-13");
|
||||
|
||||
FillEnvelope(hisEnvelopeY,-1511.15,"save_y/10>>hh","save_detID==1010&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1241.0,"save_y/10>>hh","save_detID==1020&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1200,"save_y/10>>hh","save_detID==1025&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1160,"save_y/10>>hh","save_detID==1028&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1146.6,"save_y/10>>hh","save_detID==1030&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1086.6,"save_y/10>>hh","save_detID==1033&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-1026.6,"save_y/10>>hh","save_detID==1036&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-972.15,"save_y/10>>hh","save_detID==1040&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-962.15,"save_y/10>>hh","save_detID==1041&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-952.15,"save_y/10>>hh","save_detID==1042&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-942.15,"save_y/10>>hh","save_detID==1043&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-932.15,"save_y/10>>hh","save_detID==1044&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-922.15,"save_y/10>>hh","save_detID==1045&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-912.15,"save_y/10>>hh","save_detID==1046&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-902.15,"save_y/10>>hh","save_detID==1047&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-892.15,"save_y/10>>hh","save_detID==1048&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-882.15,"save_y/10>>hh","save_detID==1049&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-872.15,"save_y/10>>hh","save_detID==1050&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-602.0 ,"save_y/10>>hh","save_detID==1060&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-592.0 ,"save_y/10>>hh","save_detID==1061&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-582.0 ,"save_y/10>>hh","save_detID==1062&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-572.0 ,"save_y/10>>hh","save_detID==1063&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-562.0 ,"save_y/10>>hh","save_detID==1064&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-552.0 ,"save_y/10>>hh","save_detID==1065&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-542.0 ,"save_y/10>>hh","save_detID==1066&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-532.0 ,"save_y/10>>hh","save_detID==1067&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-522.0 ,"save_y/10>>hh","save_detID==1068&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-512.0 ,"save_y/10>>hh","save_detID==1069&&save_particleID==-13");
|
||||
}
|
||||
else {
|
||||
FillEnvelope(hisEnvelopeX,-1183.3,"save_x/10>>hh","save_detID==1010&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-913.1,"save_x/10>>hh","save_detID==1020&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-903.1,"save_x/10>>hh","save_detID==1025&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-893.1,"save_x/10>>hh","save_detID==1026&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-880.0,"save_x/10>>hh","save_detID==1028&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-870.0,"save_x/10>>hh","save_detID==1030&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-820.0,"save_x/10>>hh","save_detID==1033&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-759.0,"save_x/10>>hh","save_detID==1036&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-710.0,"save_x/10>>hh","save_detID==1045&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-707.0,"save_x/10>>hh","save_detID==1046&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-697.0,"save_x/10>>hh","save_detID==1047&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-687.0,"save_x/10>>hh","save_detID==1048&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-677.0,"save_x/10>>hh","save_detID==1049&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-667.0,"save_x/10>>hh","save_detID==1050&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-395.0,"save_x/10>>hh","save_detID==1060&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-385.0,"save_x/10>>hh","save_detID==1061&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-375.0,"save_x/10>>hh","save_detID==1062&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-365.0,"save_x/10>>hh","save_detID==1063&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-355.0,"save_x/10>>hh","save_detID==1064&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-345.0,"save_x/10>>hh","save_detID==1065&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-335.0,"save_x/10>>hh","save_detID==1066&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-325.0,"save_x/10>>hh","save_detID==1067&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-315.0,"save_x/10>>hh","save_detID==1068&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeX,-305.0,"save_x/10>>hh","save_detID==1069&&save_particleID==-13");
|
||||
|
||||
FillEnvelope(hisEnvelopeY,-1183.3,"save_y/10>>hh","save_detID==1010&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-913.1,"save_y/10>>hh","save_detID==1020&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-903.1,"save_y/10>>hh","save_detID==1025&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-893.1,"save_y/10>>hh","save_detID==1026&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-880.0,"save_y/10>>hh","save_detID==1028&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-870.0,"save_y/10>>hh","save_detID==1030&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-820.0,"save_y/10>>hh","save_detID==1033&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-759.0,"save_y/10>>hh","save_detID==1036&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-710.0,"save_y/10>>hh","save_detID==1045&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-707.0,"save_y/10>>hh","save_detID==1046&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-697.0,"save_y/10>>hh","save_detID==1047&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-687.0,"save_y/10>>hh","save_detID==1048&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-677.0,"save_y/10>>hh","save_detID==1049&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-667.0,"save_y/10>>hh","save_detID==1050&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-395.0,"save_y/10>>hh","save_detID==1060&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-385.0,"save_y/10>>hh","save_detID==1061&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-375.0,"save_y/10>>hh","save_detID==1062&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-365.0,"save_y/10>>hh","save_detID==1063&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-355.0,"save_y/10>>hh","save_detID==1064&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-345.0,"save_y/10>>hh","save_detID==1065&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-335.0,"save_y/10>>hh","save_detID==1066&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-325.0,"save_y/10>>hh","save_detID==1067&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-315.0,"save_y/10>>hh","save_detID==1068&&save_particleID==-13");
|
||||
FillEnvelope(hisEnvelopeY,-305.0,"save_y/10>>hh","save_detID==1069&&save_particleID==-13");
|
||||
}
|
||||
|
||||
|
||||
hisEnvelopeX->SetMaximum(19);
|
||||
hisEnvelopeX->SetMinimum(-19);
|
||||
hisEnvelopeX->SetMarkerStyle(20);
|
||||
hisEnvelopeX->Draw("P");
|
||||
hisEnvelopeY->SetMarkerStyle(20);
|
||||
hisEnvelopeY->Draw("Psame");
|
||||
Vysvetlivka(popis,0.15,0.14,90,0.025);
|
||||
char outputFileName_cR2OU[1000]; sprintf(outputFileName_cR2OU,"pict/SpinRotAna_Envelope_%s.ps",runID);
|
||||
gPad->SetGrid();
|
||||
cEnvelope->Print(outputFileName_cR2OU);
|
||||
|
||||
}
|
||||
|
||||
TCanvas* PlotOneSaveVolume(char* name, char* condition) {
|
||||
cout<<"PlotOneSaveVolume called"<<endl;
|
||||
char cName[100]; strcpy(cName,"c"); strcat(cName,name);
|
||||
TCanvas* c1= new TCanvas(cName,cName,700,900);
|
||||
c1->Divide(2,3);
|
||||
|
||||
c1->cd(1);
|
||||
char hNameX[200]; strcpy(hNameX,"h"); strcat(hNameX,name); strcat(hNameX,"x");
|
||||
TH1D* hisX = new TH1D(hNameX,hNameX,100,-25,25);
|
||||
hisX->GetXaxis()->SetTitle("x (cm)");
|
||||
char whatToPlotX[200]; strcpy(whatToPlotX,"save_x/10>>"); strcat(whatToPlotX,hNameX);
|
||||
t1->Draw(whatToPlotX,condition);
|
||||
if (strcmp(popis,"undefined")) {
|
||||
Vysvetlivka(popis,0.2,0.14,90);
|
||||
}
|
||||
char chTransmission[200];
|
||||
Double_t transmission = (hisX->GetEntries())/(t1->GetEntries())*100;
|
||||
sprintf(chTransmission,"Transmission: %.1f %%",transmission);
|
||||
Vysvetlivka(chTransmission,0.8,0.14,90);
|
||||
|
||||
c1->cd(2);
|
||||
char hNameY[200]; strcpy(hNameY,"h"); strcat(hNameY,name); strcat(hNameY,"y");
|
||||
cout<<hNameY<<endl;
|
||||
TH1D* hisY = new TH1D(hNameY,hNameY,100,-25,25);
|
||||
hisY->GetXaxis()->SetTitle("y (cm)");
|
||||
char whatToPlotY[200]; strcpy(whatToPlotY,"save_y/10>>"); strcat(whatToPlotY,hNameY);
|
||||
t1->Draw(whatToPlotY,condition);
|
||||
|
||||
c1->cd(3);
|
||||
char hNameXX[200]; strcpy(hNameXX,"h"); strcat(hNameXX,name); strcat(hNameXX,"Xprime");
|
||||
cout<<hNameXX<<endl;
|
||||
TH1D* hisXX = new TH1D(hNameXX,hNameXX,100,-100,100);
|
||||
hisXX->GetXaxis()->SetTitle("x_{angle} (mrad)");
|
||||
char whatToPlotXX[200]; strcpy(whatToPlotXX,"atan2(save_px,save_pz)*1000>>"); strcat(whatToPlotXX,hNameXX);
|
||||
cout<<whatToPlotXX<<endl;
|
||||
t1->Draw(whatToPlotXX,condition);
|
||||
|
||||
c1->cd(4);
|
||||
char hNameYY[200]; strcpy(hNameYY,"h"); strcat(hNameYY,name); strcat(hNameYY,"Yprime");
|
||||
cout<<hNameYY<<endl;
|
||||
TH1D* hisYY = new TH1D(hNameYY,hNameYY,100,-100,100);
|
||||
hisYY->GetXaxis()->SetTitle("y_{angle} (mrad)");
|
||||
char whatToPlotYY[200]; strcpy(whatToPlotYY,"atan2(save_py,save_pz)*1000>>"); strcat(whatToPlotYY,hNameYY);
|
||||
cout<<whatToPlotYY<<endl;
|
||||
t1->Draw(whatToPlotYY,condition);
|
||||
|
||||
// c1->cd(5);
|
||||
// char hNamePolT[200]; strcpy(hNamePolT,"h"); strcat(hNamePolT,name); strcat(hNamePolT,"PolT");
|
||||
// cout<<hNamePolT<<endl;
|
||||
// TH1D* hisPolT = new TH1D(hNamePolT,hNamePolT,102,-1.02,1.02);
|
||||
// hisPolT->GetXaxis()->SetTitle("#sqrt{(P_{x}^{2}+P_{y}^{2})}");
|
||||
// char whatToPlotPolT[200]; strcpy(whatToPlotPolT,"sqrt(save_polx*save_polx+save_poly*save_poly)>>"); strcat(whatToPlotPolT,hNamePolT);
|
||||
// cout<<whatToPlotPolT<<endl;
|
||||
// t1->Draw(whatToPlotPolT,condition);
|
||||
|
||||
c1->cd(5);
|
||||
char hNameThetaPol[200]; strcpy(hNameThetaPol,"h"); strcat(hNameThetaPol,name); strcat(hNameThetaPol,"ThetaPol");
|
||||
cout<<hNameThetaPol<<endl;
|
||||
TH1D* hisThetaPol = new TH1D(hNameThetaPol,hNameThetaPol,90,-90.,90);
|
||||
hisThetaPol->GetXaxis()->SetTitle("#theta(P)-90\,deg");
|
||||
// char whatToPlotPolT[200]; strcpy(whatToPlotPolT,"180/3.14159*atan(sqrt(save_polx*save_polx+save_poly*save_poly)/save_polz)>>"); strcat(whatToPlotPolT,hNameThetaPol);
|
||||
char whatToPlotPolT[200]; strcpy(whatToPlotPolT,"180/3.14159*atan(save_polz/sqrt(save_polx*save_polx+save_poly*save_poly))>>"); strcat(whatToPlotPolT,hNameThetaPol);
|
||||
cout<<whatToPlotPolT<<endl;
|
||||
t1->Draw(whatToPlotPolT,condition);
|
||||
|
||||
c1->cd(6);
|
||||
char hNamePz[200]; strcpy(hNamePz,"h"); strcat(hNamePz,name); strcat(hNamePz,"pz");
|
||||
TH1D* hisPz = new TH1D(hNamePz,hNamePz,100,-50,50);
|
||||
hisPz->GetXaxis()->SetTitle("(p-p0)/p0 (%)");
|
||||
char whatToPlotPz[200]; strcpy(whatToPlotPz,"(save_pz-27.4)/27.4*100>>"); strcat(whatToPlotPz,hNamePz);
|
||||
t1->Draw(whatToPlotPz,condition);
|
||||
|
||||
return c1;
|
||||
}
|
||||
|
||||
TCanvas* PlotOneSaveVolumeTwo(char* name, char* condition) {
|
||||
cout<<"PlotOneSaveVolume called"<<endl;
|
||||
char cName[100]; strcpy(cName,"c"); strcat(cName,name);
|
||||
TCanvas* c1= new TCanvas(cName,cName,700,900);
|
||||
c1->Divide(2,3);
|
||||
|
||||
c1->cd(1);
|
||||
char hName1[200]; strcpy(hName1,"h"); strcat(hName1,name); strcat(hName1,"xXxprime");
|
||||
TH2D* his1 = new TH2D(hName1,hName1,40,-25,25,40,-25,25);
|
||||
his1->GetXaxis()->SetTitle("x (cm)");
|
||||
his1->GetYaxis()->SetTitle("y (cm)");
|
||||
char whatToPlotX[200]; strcpy(whatToPlotX,"save_y/10:save_x/10>>"); strcat(whatToPlotX,hName1);
|
||||
t1->Draw(whatToPlotX,condition,"box");
|
||||
if (strcmp(popis,"undefined")) {
|
||||
Vysvetlivka(popis,0.2,0.14,90);
|
||||
}
|
||||
|
||||
c1->cd(2);
|
||||
char hName2[200]; strcpy(hName2,"h"); strcat(hName2,name); strcat(hName2,"xXxprime");
|
||||
TH2D* his2 = new TH2D(hName2,hName2,40,-25,25,40,-100,100);
|
||||
his2->GetXaxis()->SetTitle("x (cm)");
|
||||
his2->GetYaxis()->SetTitle("x_{angle} (mrad)");
|
||||
char whatToPlotX[200]; strcpy(whatToPlotX,"(atan2(save_px,save_pz)*1000):save_x/10>>"); strcat(whatToPlotX,hName2);
|
||||
t1->Draw(whatToPlotX,condition,"box");
|
||||
|
||||
c1->cd(3);
|
||||
char hName3[200]; strcpy(hName3,"h"); strcat(hName3,name); strcat(hName3,"xXp");
|
||||
TH2D* his3 = new TH2D(hName3,hName3,40,-25,25,40,-50,50);
|
||||
his3->GetXaxis()->SetTitle("x (cm)");
|
||||
his3->GetYaxis()->SetTitle("(p-p0)/p0 (%)");
|
||||
char whatToPlotX[200]; strcpy(whatToPlotX,"((save_pz-27.4)/27.4*100):(save_x/10)>>"); strcat(whatToPlotX,hName3);
|
||||
t1->Draw(whatToPlotX,condition,"box");
|
||||
|
||||
return c1;
|
||||
}
|
||||
|
||||
void FillEnvelope(TH1D* hist, const Double_t z, char* velicina, char* condition) {
|
||||
TH1D hh = TH1D("hh","hh",1000,-50.,50.);
|
||||
t1->Draw(velicina,condition);
|
||||
Double_t RMS2 = 2*(hh.GetRMS());
|
||||
if (strcmp(velicina,"save_y/10>>hh")==0) {RMS2 *=-1;}
|
||||
std::cout<<"z="<<z<<" RMS2="<<RMS2<<std::endl;
|
||||
hist->Fill(z,RMS2);
|
||||
}
|
||||
|
||||
void Vysvetlivka(char* textik, Double_t x, Double_t y, Double_t uhel=270, Double_t textSize=0.04) {
|
||||
TLatex latex;
|
||||
latex.SetNDC();
|
||||
latex.SetTextAngle(uhel);
|
||||
latex.SetTextSize(textSize);
|
||||
latex.DrawLatex(x,y,textik);
|
||||
}
|
4
run/macros/TFrame.C
Normal file
4
run/macros/TFrame.C
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
//========= Macro generated from object: TFrame/Pad graphics frame
|
||||
//========= by ROOT version5.24/00
|
||||
}
|
228
run/macros/analysis.C
Normal file
228
run/macros/analysis.C
Normal file
@ -0,0 +1,228 @@
|
||||
#define analysis_cxx
|
||||
#include "analysis.h"
|
||||
#include <TH2.h>
|
||||
#include <TStyle.h>
|
||||
#include <TCanvas.h>
|
||||
|
||||
void analysis::Loop()
|
||||
{
|
||||
// In a ROOT session, you can do:
|
||||
// Root > .L analysis.C
|
||||
// Root > analysis t
|
||||
// Root > t.GetEntry(12); // Fill t data members with entry number 12
|
||||
// Root > t.Show(); // Show values of entry 12
|
||||
// Root > t.Show(16); // Read and show values of entry 16
|
||||
// Root > t.Loop(); // Loop on all entries <- Very Important!
|
||||
// Root > .ls // Shows what histos are available for plotting
|
||||
//
|
||||
// This is the loop skeleton where:
|
||||
// jentry is the global entry number in the chain
|
||||
// ientry is the entry number in the current Tree
|
||||
// Note that the argument to GetEntry must be:
|
||||
// jentry for TChain::GetEntry
|
||||
// ientry for TTree::GetEntry and TBranch::GetEntry
|
||||
//
|
||||
// To read only selected branches, insert statements as:
|
||||
// METHOD1:
|
||||
// fChain->SetBranchStatus("*",0); // disable all branches
|
||||
// fChain->SetBranchStatus("branchname",1); // activate branchname
|
||||
// METHOD2: replace line
|
||||
// fChain->GetEntry(jentry); //read all branches
|
||||
// b_branchname->GetEntry(ientry); //read only this branch
|
||||
//
|
||||
//
|
||||
// To create TEMPLATE files for analysis proceed as follows:
|
||||
// 1. Load the root file containing all the variables, e.g.:
|
||||
// TFile* f=new TFile("data/lem4_1049.root");
|
||||
// 2. Quickly check the Tree and Variable names:
|
||||
// f->ls(); // Shows tree name (i.e. t1)
|
||||
// t1->Print(); // Shows variable names
|
||||
// 3. Create the template files .C and .h (t1 is the Tree name)
|
||||
// t1->MakeClass("myAnalysis")
|
||||
//
|
||||
//
|
||||
// How to write data to an EXTERNAL file (use cout instead of outdata for printing on screen):
|
||||
// See also: www.bgsu.edu/departments/compsci/docs/index.html
|
||||
//
|
||||
// ofstream outdata;
|
||||
// outdata.open("export.dat");
|
||||
// for (Int_t i=0; i<hEdepositCF->GetNbinsX(); i++) {outdata<<hEdepositCF->GetBinContent(i)<<endl;}
|
||||
// outdata.close();
|
||||
//
|
||||
|
||||
Double_t eCut = 0.7; //minimum energy deposition in scintillators [MeV]
|
||||
Bool_t tofFlag = 0;
|
||||
if (fChain == 0) return;
|
||||
|
||||
|
||||
//DEFINE HISTOGRAMS
|
||||
TH1F* hEdeposited = new TH1F("hEdeposited","Energy spectrum; E [MeV]", 250,0.,2.5);
|
||||
TH1F* hEdepositCF = new TH1F("hEdepositCF","Energy spectrum; E [keV]", 500,0.,20.0);
|
||||
TH1F* hEdepTrig = new TH1F("hEdepTrig", "Radioactive electron kin. energy",250,0.,2.5);
|
||||
TH1F* hDettUp = new TH1F("hDettUp", "Muon arrival times Up (#mus)", 1300,0.,13.);
|
||||
TH1F* hDettDown = new TH1F("hDettDown", "Muon arrival times Down (#mus)", 1300,0.,13.);
|
||||
TH1F* hDettRight = new TH1F("hDettRight", "Muon arrival times Right (#mus)", 1300,0.,13.);
|
||||
TH1F* hDettLeft = new TH1F("hDettLeft", "Muon arrival times Left (#mus)", 1300,0.,13.);
|
||||
TH1F* hEdepoTest = new TH1F("hEdepoTest", "Number of events in coincidence", 100,0.,1.);
|
||||
TH1F* hTof = new TH1F("hTof", "time-of-flight (#mus)", 1000, 0., 1.);
|
||||
TH2F* hBeamSpot = new TH2F("hBeamSpot", " x,y", 40, -40., 40., 40, -40., 40.);
|
||||
TH1F* hDetz = new TH1F("hDetz", "z detector [mm]", 140, -140., 140.);
|
||||
TH1F* hEventID = new TH1F("hEventID", "Event ID", 10001, -0.5, 10000.5);
|
||||
hEdeposited->Sumw2();
|
||||
hEdepositCF->Sumw2();
|
||||
hEdepTrig->Sumw2();
|
||||
|
||||
Long64_t nentries = fChain->GetEntriesFast();
|
||||
//nentries=1000;
|
||||
|
||||
Long64_t nbytes = 0, nb = 0;
|
||||
for (Long64_t jentry=0; jentry<nentries;jentry++) {
|
||||
tofFlag = 0;
|
||||
Long64_t ientry = LoadTree(jentry);
|
||||
if (ientry < 0) break;
|
||||
nb = fChain->GetEntry(jentry); nbytes += nb;
|
||||
|
||||
// FILL IN HISTOGRAMS
|
||||
hEdepositCF->Fill(save_ke[0]/1000.);
|
||||
hBeamSpot->Fill(save_x[0], save_y[0]);
|
||||
|
||||
//for (Int_t i=0; i<det_n; i++)
|
||||
// { if (det_ID[i]==623) { hEdeposited->Fill(save_ke[i]);}
|
||||
// }
|
||||
|
||||
hTof->Fill(muTargetTime);
|
||||
if (muTargetTime>0.23) tofFlag = 1;
|
||||
//tofFlag = 1.;
|
||||
|
||||
// Coincidence between Up scintillators
|
||||
// for (Int_t i=0; i<det_n; i++) {
|
||||
// if (det_ID[i]==21) {
|
||||
// hEdeposited->Fill(det_edep[i]);
|
||||
// for (Int_t j=0; j<det_n; j++){
|
||||
// if (det_ID[j]==11) {
|
||||
// if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
// hDettUp->Fill(det_time_start[j]);
|
||||
// hDetz->Fill(det_z[i]);
|
||||
// hEventID->Fill(eventID);
|
||||
// break; //fill only once
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// Coincidence between Down scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==23) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==13){
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettDown->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coincidence between Right scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==22) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==12) {
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettRight->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coincidence between Left scintillators
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if (det_ID[i]==24) {
|
||||
hEdeposited->Fill(det_edep[i]);
|
||||
for (Int_t j=0; j<det_n; j++){
|
||||
if (det_ID[j]==14){
|
||||
if (det_edep[i]>eCut && det_edep[j]>eCut && tofFlag){
|
||||
hDettLeft->Fill(det_time_start[j]);
|
||||
hDetz->Fill(det_z[i]);
|
||||
hEventID->Fill(eventID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Testing event coincidence with SciFi
|
||||
Bool_t twentyone= false;
|
||||
Bool_t twozero7 = false;
|
||||
Bool_t twozero8 = false;
|
||||
Int_t ikk=0;
|
||||
for (Int_t i=0; i<det_n; i++) {
|
||||
if ((det_ID[i]== 21)&&(det_edep[i]>0.0)) {twentyone = true; ikk = i;}
|
||||
if ((det_ID[i]==207)&&(det_edep[i]>0.0)) twozero7 = true;
|
||||
if ((det_ID[i]==208)&&(det_edep[i]>0.0)) twozero8 = true;
|
||||
}
|
||||
//if (twentyone) hEdepoTest->Fill(det_edep[ikk]); // Fiber hits
|
||||
//if (twozero7&& twozero8) hEdepoTest->Fill(det_edep[ikk]); // Coincidence
|
||||
if (twentyone&&twozero7&& twozero8) hEdepoTest->Fill(det_edep[ikk]); // Fibre hits + coincidence
|
||||
|
||||
}
|
||||
|
||||
// PLOT HISTOGRAMS
|
||||
TCanvas* c1= new TCanvas("c1","canvas 1");
|
||||
|
||||
// hEdeposited->Scale(1/(number_of_generated_events*hEdeposited->GetBinWidth(1)));
|
||||
TH1F *htemp1 = (TH1F*) hDettUp->Clone(); htemp1->SetName("htemp1");
|
||||
TH1F *htemp2 = (TH1F*) hDettUp->Clone(); htemp2->SetName("htemp2");
|
||||
|
||||
TH1F *htemp3 = (TH1F*) hDettUp->Clone(); htemp3->SetName("htemp3");
|
||||
TH1F *htemp4 = (TH1F*) hDettUp->Clone(); htemp4->SetName("htemp4");
|
||||
|
||||
TH1F *htemp5 = (TH1F*) hDettUp->Clone(); htemp5->SetName("htemp5");
|
||||
htemp5->SetTitle("Muon decay asymmetry U-D; Time (#mus); Asymmetry");
|
||||
htemp5->Sumw2();
|
||||
|
||||
TH1F *htemp6 = (TH1F*) hDettUp->Clone(); htemp6->SetName("htemp6");
|
||||
htemp6->SetTitle("Muon decay asymmetry L-R; Time (#mus); Asymmetry");
|
||||
htemp6->Sumw2();
|
||||
|
||||
htemp1->Add(hDettUp,hDettDown,1.,-1.);
|
||||
htemp2->Add(hDettUp,hDettDown,1., 1.);
|
||||
htemp5->Divide(htemp1,htemp2,1.,1.);
|
||||
|
||||
htemp3->Add(hDettLeft,hDettRight,1.,-1.);
|
||||
htemp4->Add(hDettLeft,hDettRight,1., 1.);
|
||||
htemp6->Divide(htemp3,htemp4,1.,1.);
|
||||
|
||||
htemp5->SetLineWidth(2);
|
||||
htemp5->SetLineColor(2);
|
||||
htemp5->SetAxisRange(-0.8,0.8,"Y");
|
||||
htemp5->Draw("hist");
|
||||
|
||||
htemp6->SetLineWidth(2);
|
||||
htemp6->SetLineColor(4);
|
||||
htemp6->SetAxisRange(-0.8,0.8,"Y");
|
||||
htemp6->Draw("same");
|
||||
|
||||
hEdepositCF->SetLineWidth(2);
|
||||
hEdepositCF->SetLineColor(2);
|
||||
hEdepositCF->Draw("hist");
|
||||
//hEdepositCF->Fit("gaus");
|
||||
|
||||
TCanvas* c2= new TCanvas("c2","canvas 2");
|
||||
hEdeposited->Draw();
|
||||
|
||||
// sprintf(filenamePrint,"musrSrClass_%s.ps",fileNr);
|
||||
// c1->Print(filenamePrint);
|
||||
}
|
304
run/macros/analysis.h
Normal file
304
run/macros/analysis.h
Normal file
@ -0,0 +1,304 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// This class has been automatically generated on
|
||||
// Fri Oct 26 16:55:39 2007 by ROOT version 5.08/00
|
||||
// from TTree t1/a simple Tree with simple variables
|
||||
// found on file: musr_200003.root
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef analysis_h
|
||||
#define analysis_h
|
||||
|
||||
#include <TROOT.h>
|
||||
#include <TChain.h>
|
||||
#include <TFile.h>
|
||||
|
||||
class analysis {
|
||||
public :
|
||||
TTree *fChain; //!pointer to the analyzed TTree or TChain
|
||||
Int_t fCurrent; //!current Tree number in a TChain
|
||||
|
||||
// Declaration of leave types
|
||||
Int_t runID;
|
||||
Int_t eventID;
|
||||
Double_t BFieldAtDecay_Bx;
|
||||
Double_t BFieldAtDecay_By;
|
||||
Double_t BFieldAtDecay_Bz;
|
||||
Double_t BFieldAtDecay_B3;
|
||||
Double_t BFieldAtDecay_B4;
|
||||
Double_t BFieldAtDecay_B5;
|
||||
Double_t muIniPosX;
|
||||
Double_t muIniPosY;
|
||||
Double_t muIniPosZ;
|
||||
Double_t muIniMomX;
|
||||
Double_t muIniMomY;
|
||||
Double_t muIniMomZ;
|
||||
Double_t muIniPolX;
|
||||
Double_t muIniPolY;
|
||||
Double_t muIniPolZ;
|
||||
Int_t muDecayDetID;
|
||||
Double_t muDecayPosX;
|
||||
Double_t muDecayPosY;
|
||||
Double_t muDecayPosZ;
|
||||
Double_t muDecayTime;
|
||||
Double_t muDecayPolX;
|
||||
Double_t muDecayPolY;
|
||||
Double_t muDecayPolZ;
|
||||
Double_t muTargetTime;
|
||||
Double_t muTargetPolX;
|
||||
Double_t muTargetPolY;
|
||||
Double_t muTargetPolZ;
|
||||
Double_t fieldValue;
|
||||
Int_t det_n;
|
||||
Int_t det_ID[50]; //[det_n]
|
||||
Double_t det_edep[50]; //[det_n]
|
||||
Int_t det_nsteps[50]; //[det_n]
|
||||
Double_t det_length[50]; //[det_n]
|
||||
Double_t det_time_start[50]; //[det_n]
|
||||
Double_t det_time_end[50]; //[det_n]
|
||||
Double_t det_x[50]; //[det_n]
|
||||
Double_t det_y[50]; //[det_n]
|
||||
Double_t det_z[50]; //[det_n]
|
||||
Int_t save_n;
|
||||
Int_t save_detID[10]; //[save_n]
|
||||
Int_t save_particleID[10]; //[save_n]
|
||||
Double_t save_ke[10]; //[save_n]
|
||||
Double_t save_x[10]; //[save_n]
|
||||
Double_t save_y[10]; //[save_n]
|
||||
Double_t save_z[10]; //[save_n]
|
||||
Double_t save_px[10]; //[save_n]
|
||||
Double_t save_py[10]; //[save_n]
|
||||
Double_t save_pz[10]; //[save_n]
|
||||
|
||||
|
||||
// List of branches
|
||||
TBranch *b_runID; //!
|
||||
TBranch *b_eventID; //!
|
||||
TBranch *b_BFieldAtDecay; //!
|
||||
TBranch *b_muIniPosX; //!
|
||||
TBranch *b_muIniPosY; //!
|
||||
TBranch *b_muIniPosZ; //!
|
||||
TBranch *b_muIniMomX; //!
|
||||
TBranch *b_muIniMomY; //!
|
||||
TBranch *b_muIniMomZ; //!
|
||||
TBranch *b_muIniPolX; //!
|
||||
TBranch *b_muIniPolY; //!
|
||||
TBranch *b_muIniPolZ; //!
|
||||
TBranch *b_muDecayDetID; //!
|
||||
TBranch *b_muDecayPosX; //!
|
||||
TBranch *b_muDecayPosY; //!
|
||||
TBranch *b_muDecayPosZ; //!
|
||||
TBranch *b_muDecayTime; //!
|
||||
TBranch *b_muDecayPolX; //!
|
||||
TBranch *b_muDecayPolY; //!
|
||||
TBranch *b_muDecayPolZ; //!
|
||||
TBranch *b_muTargetTime; //!
|
||||
TBranch *b_muTargetPolX; //!
|
||||
TBranch *b_muTargetPolY; //!
|
||||
TBranch *b_muTargetPolZ; //!
|
||||
TBranch *b_fieldValue; //!
|
||||
TBranch *b_det_n; //!
|
||||
TBranch *b_det_ID; //!
|
||||
TBranch *b_det_edep; //!
|
||||
TBranch *b_det_nsteps; //!
|
||||
TBranch *b_det_length; //!
|
||||
TBranch *b_det_time_start; //!
|
||||
TBranch *b_det_time_end; //!
|
||||
TBranch *b_det_x; //!
|
||||
TBranch *b_det_y; //!
|
||||
TBranch *b_det_z; //!
|
||||
TBranch *b_save_n; //!
|
||||
TBranch *b_save_detID; //!
|
||||
TBranch *b_save_particleID; //!
|
||||
TBranch *b_save_ke; //!
|
||||
TBranch *b_save_x; //!
|
||||
TBranch *b_save_y; //!
|
||||
TBranch *b_save_z; //!
|
||||
TBranch *b_save_px; //!
|
||||
TBranch *b_save_py; //!
|
||||
TBranch *b_save_pz; //!
|
||||
|
||||
|
||||
analysis(TTree *tree=0);
|
||||
virtual ~analysis();
|
||||
virtual Int_t Cut(Long64_t entry);
|
||||
virtual Int_t GetEntry(Long64_t entry);
|
||||
virtual Long64_t LoadTree(Long64_t entry);
|
||||
virtual void Init(TTree *tree);
|
||||
virtual void Loop();
|
||||
virtual Bool_t Notify();
|
||||
virtual void Show(Long64_t entry = -1);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef analysis_cxx
|
||||
analysis::analysis(TTree *tree)
|
||||
{
|
||||
// if parameter tree is not specified (or zero), connect the file
|
||||
// used to generate this class and read the Tree.
|
||||
if (tree == 0) {
|
||||
//TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("data/lem4_1049.root");
|
||||
//if (!f) {
|
||||
//f = new TFile("musr_200003.root");
|
||||
// f = new TFile("data/lem4_1051.root"); //1049
|
||||
//}
|
||||
tree = (TTree*)gDirectory->Get("t1");
|
||||
|
||||
}
|
||||
Init(tree);
|
||||
}
|
||||
|
||||
analysis::~analysis()
|
||||
{
|
||||
if (!fChain) return;
|
||||
delete fChain->GetCurrentFile();
|
||||
}
|
||||
|
||||
Int_t analysis::GetEntry(Long64_t entry)
|
||||
{
|
||||
// Read contents of entry.
|
||||
if (!fChain) return 0;
|
||||
return fChain->GetEntry(entry);
|
||||
}
|
||||
Long64_t analysis::LoadTree(Long64_t entry)
|
||||
{
|
||||
// Set the environment to read one entry
|
||||
if (!fChain) return -5;
|
||||
Long64_t centry = fChain->LoadTree(entry);
|
||||
if (centry < 0) return centry;
|
||||
if (fChain->IsA() != TChain::Class()) return centry;
|
||||
TChain *chain = (TChain*)fChain;
|
||||
if (chain->GetTreeNumber() != fCurrent) {
|
||||
fCurrent = chain->GetTreeNumber();
|
||||
Notify();
|
||||
}
|
||||
return centry;
|
||||
}
|
||||
|
||||
void analysis::Init(TTree *tree)
|
||||
{
|
||||
// The Init() function is called when the selector needs to initialize
|
||||
// a new tree or chain. Typically here the branch addresses of the tree
|
||||
// will be set. It is normaly not necessary to make changes to the
|
||||
// generated code, but the routine can be extended by the user if needed.
|
||||
// Init() will be called many times when running with PROOF.
|
||||
|
||||
// Set branch addresses
|
||||
if (tree == 0) return;
|
||||
fChain = tree;
|
||||
fCurrent = -1;
|
||||
fChain->SetMakeClass(1);
|
||||
|
||||
fChain->SetBranchAddress("runID",&runID);
|
||||
fChain->SetBranchAddress("eventID",&eventID);
|
||||
fChain->SetBranchAddress("BFieldAtDecay",&BFieldAtDecay_Bx);
|
||||
fChain->SetBranchAddress("muIniPosX",&muIniPosX);
|
||||
fChain->SetBranchAddress("muIniPosY",&muIniPosY);
|
||||
fChain->SetBranchAddress("muIniPosZ",&muIniPosZ);
|
||||
fChain->SetBranchAddress("muIniMomX",&muIniMomX);
|
||||
fChain->SetBranchAddress("muIniMomY",&muIniMomY);
|
||||
fChain->SetBranchAddress("muIniMomZ",&muIniMomZ);
|
||||
fChain->SetBranchAddress("muIniPolX",&muIniPolX);
|
||||
fChain->SetBranchAddress("muIniPolY",&muIniPolY);
|
||||
fChain->SetBranchAddress("muIniPolZ",&muIniPolZ);
|
||||
fChain->SetBranchAddress("muDecayDetID",&muDecayDetID);
|
||||
fChain->SetBranchAddress("muDecayPosX",&muDecayPosX);
|
||||
fChain->SetBranchAddress("muDecayPosY",&muDecayPosY);
|
||||
fChain->SetBranchAddress("muDecayPosZ",&muDecayPosZ);
|
||||
fChain->SetBranchAddress("muDecayTime",&muDecayTime);
|
||||
fChain->SetBranchAddress("muDecayPolX",&muDecayPolX);
|
||||
fChain->SetBranchAddress("muDecayPolY",&muDecayPolY);
|
||||
fChain->SetBranchAddress("muDecayPolZ",&muDecayPolZ);
|
||||
fChain->SetBranchAddress("muTargetTime",&muTargetTime);
|
||||
fChain->SetBranchAddress("muTargetPolX",&muTargetPolX);
|
||||
fChain->SetBranchAddress("muTargetPolY",&muTargetPolY);
|
||||
fChain->SetBranchAddress("muTargetPolZ",&muTargetPolZ);
|
||||
fChain->SetBranchAddress("fieldValue",&fieldValue);
|
||||
fChain->SetBranchAddress("det_n",&det_n);
|
||||
fChain->SetBranchAddress("det_ID",det_ID);
|
||||
fChain->SetBranchAddress("det_edep",det_edep);
|
||||
fChain->SetBranchAddress("det_nsteps",det_nsteps);
|
||||
fChain->SetBranchAddress("det_length",det_length);
|
||||
fChain->SetBranchAddress("det_time_start",det_time_start);
|
||||
fChain->SetBranchAddress("det_time_end",det_time_end);
|
||||
fChain->SetBranchAddress("det_x",det_x);
|
||||
fChain->SetBranchAddress("det_y",det_y);
|
||||
fChain->SetBranchAddress("det_z",det_z);
|
||||
fChain->SetBranchAddress("save_n", &save_n, &b_save_n);
|
||||
fChain->SetBranchAddress("save_detID", save_detID, &b_save_detID);
|
||||
fChain->SetBranchAddress("save_particleID", save_particleID, &b_save_particleID);
|
||||
fChain->SetBranchAddress("save_ke", save_ke, &b_save_ke);
|
||||
fChain->SetBranchAddress("save_x", save_x, &b_save_x);
|
||||
fChain->SetBranchAddress("save_y", save_y, &b_save_y);
|
||||
fChain->SetBranchAddress("save_z", save_z, &b_save_z);
|
||||
fChain->SetBranchAddress("save_px", save_px, &b_save_px);
|
||||
fChain->SetBranchAddress("save_py", save_py, &b_save_py);
|
||||
fChain->SetBranchAddress("save_pz", save_pz, &b_save_pz);
|
||||
|
||||
Notify();
|
||||
}
|
||||
|
||||
Bool_t analysis::Notify()
|
||||
{
|
||||
// The Notify() function is called when a new file is opened. This
|
||||
// can be either for a new TTree in a TChain or when when a new TTree
|
||||
// is started when using PROOF. Typically here the branch pointers
|
||||
// will be retrieved. It is normaly not necessary to make changes
|
||||
// to the generated code, but the routine can be extended by the
|
||||
// user if needed.
|
||||
|
||||
// Get branch pointers
|
||||
b_runID = fChain->GetBranch("runID");
|
||||
b_eventID = fChain->GetBranch("eventID");
|
||||
b_BFieldAtDecay = fChain->GetBranch("BFieldAtDecay");
|
||||
b_muIniPosX = fChain->GetBranch("muIniPosX");
|
||||
b_muIniPosY = fChain->GetBranch("muIniPosY");
|
||||
b_muIniPosZ = fChain->GetBranch("muIniPosZ");
|
||||
b_muIniMomX = fChain->GetBranch("muIniMomX");
|
||||
b_muIniMomY = fChain->GetBranch("muIniMomY");
|
||||
b_muIniMomZ = fChain->GetBranch("muIniMomZ");
|
||||
b_muIniPolX = fChain->GetBranch("muIniPolX");
|
||||
b_muIniPolY = fChain->GetBranch("muIniPolY");
|
||||
b_muIniPolZ = fChain->GetBranch("muIniPolZ");
|
||||
b_muDecayDetID = fChain->GetBranch("muDecayDetID");
|
||||
b_muDecayPosX = fChain->GetBranch("muDecayPosX");
|
||||
b_muDecayPosY = fChain->GetBranch("muDecayPosY");
|
||||
b_muDecayPosZ = fChain->GetBranch("muDecayPosZ");
|
||||
b_muDecayTime = fChain->GetBranch("muDecayTime");
|
||||
b_muDecayPolX = fChain->GetBranch("muDecayPolX");
|
||||
b_muDecayPolY = fChain->GetBranch("muDecayPolY");
|
||||
b_muDecayPolZ = fChain->GetBranch("muDecayPolZ");
|
||||
b_muTargetTime = fChain->GetBranch("muTargetTime");
|
||||
b_muTargetPolX = fChain->GetBranch("muTargetPolX");
|
||||
b_muTargetPolY = fChain->GetBranch("muTargetPolY");
|
||||
b_muTargetPolZ = fChain->GetBranch("muTargetPolZ");
|
||||
b_fieldValue = fChain->GetBranch("fieldValue");
|
||||
b_det_n = fChain->GetBranch("det_n");
|
||||
b_det_ID = fChain->GetBranch("det_ID");
|
||||
b_det_edep = fChain->GetBranch("det_edep");
|
||||
b_det_nsteps = fChain->GetBranch("det_nsteps");
|
||||
b_det_length = fChain->GetBranch("det_length");
|
||||
b_det_time_start = fChain->GetBranch("det_time_start");
|
||||
b_det_time_end = fChain->GetBranch("det_time_end");
|
||||
b_det_x = fChain->GetBranch("det_x");
|
||||
b_det_y = fChain->GetBranch("det_y");
|
||||
b_det_z = fChain->GetBranch("det_z");
|
||||
|
||||
return kTRUE;
|
||||
}
|
||||
|
||||
void analysis::Show(Long64_t entry)
|
||||
{
|
||||
// Print contents of entry.
|
||||
// If entry is not specified, print current entry
|
||||
if (!fChain) return;
|
||||
fChain->Show(entry);
|
||||
}
|
||||
Int_t analysis::Cut(Long64_t entry)
|
||||
{
|
||||
// This function may be called from Loop.
|
||||
// returns 1 if entry is accepted.
|
||||
// returns -1 otherwise.
|
||||
return 1;
|
||||
}
|
||||
#endif // #ifdef analysis_cxx
|
89
run/macros/beamSpotWithCut.C
Normal file
89
run/macros/beamSpotWithCut.C
Normal file
@ -0,0 +1,89 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L beamSpotWithCut.C
|
||||
// beamSpotWithCut("data/sr1_1100.root", 10)
|
||||
|
||||
#include <string>
|
||||
#define NSIZE 100000
|
||||
void beamSpotWithCut(char* fname, Double_t cut)
|
||||
{
|
||||
Double_t *pTDx, *pTDy, *pSamplex, *pSampley, *pEventIDTD, *pEventIDSample;
|
||||
Double_t TDx[NSIZE], TDy[NSIZE], Samplex[NSIZE], Sampley[NSIZE], EventIDTD[NSIZE], EventIDSample[NSIZE];
|
||||
Long64_t i, j, k, nEventsTD, nEventsSample;
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
// muon beam spot at TD
|
||||
t1->Draw("eventID:save_y:save_x","save_detID==890&&save_particleID==-13"); //0, 2
|
||||
nEventsTD = t1->GetSelectedRows();
|
||||
pTDx = t1->GetV3();
|
||||
pTDy = t1->GetV2();
|
||||
pEventIDTD = t1->GetV1();
|
||||
|
||||
for (i = 0; i<nEventsTD; i++){
|
||||
EventIDTD[i] = pEventIDTD[i];
|
||||
TDx[i] = pTDx[i];
|
||||
TDy[i] = pTDy[i];
|
||||
}
|
||||
|
||||
// muon beam spot at Sample
|
||||
t1->Draw("eventID:save_y:save_x","save_detID==902&&save_particleID==-13"); //0, 2
|
||||
nEventsSample = t1->GetSelectedRows();
|
||||
pSamplex = t1->GetV3();
|
||||
pSampley = t1->GetV2();
|
||||
pEventIDSample = t1->GetV1();
|
||||
|
||||
for (i = 0; i<nEventsSample; i++){
|
||||
EventIDSample[i] = pEventIDSample[i];
|
||||
Samplex[i] = pSamplex[i];
|
||||
Sampley[i] = pSampley[i];
|
||||
}
|
||||
|
||||
// muon beam spot at Sample with cut
|
||||
TH2D *hBeamSpot = new TH2D("beam spot with cut", "beam spot with cut", 60, -30., 30., 60, -30., 30);
|
||||
k = 0;
|
||||
for (i = 0; i<nEventsSample; i++){
|
||||
for (j = k; j<nEventsTD; j++){
|
||||
// cout << i << ", " << j << ", " << k << ", " << EventIDSample[i] << ", " << EventIDTD[j] << ", " << Samplex[i] << ", " << sqrt(TDx[j]*TDx[j]+TDy[j]*TDy[j]) << endl;
|
||||
if (EventIDSample[i] == EventIDTD[j]){
|
||||
if (sqrt(TDx[j]*TDx[j]+TDy[j]*TDy[j])<=cut) hBeamSpot->Fill(Samplex[i], Sampley[i]);
|
||||
k = j + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// gStyle->SetName(fname);
|
||||
gStyle->SetOptTitle(1);
|
||||
TCanvas* c1 = new TCanvas("Beam Spot","Beam Spot",60,40,600,800);
|
||||
c1->Divide(1,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// beam spot at TD
|
||||
c1->cd(1);
|
||||
t1->Draw("save_y:save_x >> beamtd(60, -30., 30., 60, -30., 30.)","save_detID==890&&save_particleID==-13&&sqrt(save_x*save_x+save_y*save_y)<=40.");
|
||||
beamtd->SetTitle("Beam Spot at TD");
|
||||
beamtd->GetXaxis()->SetTitle("x (mm)");
|
||||
beamtd->GetYaxis()->SetTitle("y (mm)");
|
||||
beamtd->Draw();
|
||||
beamtd->Draw("cont0 same");
|
||||
|
||||
// beam spot at sample
|
||||
c1->cd(2);
|
||||
t1->Draw("save_y:save_x >> beamsample(60, -30., 30., 60, -30., 30.)","save_detID==902&&save_particleID==-13");
|
||||
beamsample->SetTitle("Beam Spot at Sample");
|
||||
beamsample->GetXaxis()->SetTitle("x (mm)");
|
||||
beamsample->GetYaxis()->SetTitle("y (mm)");
|
||||
beamsample->Draw();
|
||||
beamsample->Draw("cont0 same");
|
||||
|
||||
c1->cd(3);
|
||||
hBeamSpot->SetTitle("Beam Spot at Sample with Cut");
|
||||
hBeamSpot->GetXaxis()->SetTitle("x (mm)");
|
||||
hBeamSpot->GetYaxis()->SetTitle("y (mm)");
|
||||
hBeamSpot->Draw();
|
||||
hBeamSpot->Draw("cont0 same");
|
||||
}
|
||||
|
||||
|
44
run/macros/invertZ.C
Normal file
44
run/macros/invertZ.C
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
TString fileIn, fileOut;
|
||||
Double_t *r, *z, *Er, *Ez;
|
||||
Int_t fileSize, rValues, zValues, index;
|
||||
|
||||
fileIn = "NosePlate_2DE.map";
|
||||
fileOut = "NosePlate_rawscaled_2DE.map";
|
||||
|
||||
TGraphErrors *fileGraph = new TGraphErrors(fileIn);
|
||||
if ( fileGraph->IsZombie() ){
|
||||
cout << endl;
|
||||
cout << "File " << fileIn << " does not exist!!!" << endl << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
r = fileGraph->GetX();
|
||||
z = fileGraph->GetY();
|
||||
Er = fileGraph->GetEX();
|
||||
Ez = fileGraph->GetEY();
|
||||
fileSize = fileGraph->GetN();
|
||||
|
||||
rValues = r[0];
|
||||
zValues = z[0];
|
||||
Double_t zScale[fileSize];
|
||||
Double_t EzScale[fileSize];
|
||||
|
||||
zScale[0] = z[0];
|
||||
EzScale[0] = Ez[0];
|
||||
for (Int_t i=1; i<fileSize; i++){
|
||||
zScale[i] = z[i]*-1;
|
||||
EzScale[i] = Ez[i]*-1.;
|
||||
}
|
||||
|
||||
FILE *fp = fopen(fileOut, "w");
|
||||
|
||||
fprintf(fp,"%4.0f\t%4.0f\t mm\t0.00001000\n",rValues, zValues);
|
||||
for (Int_t j=0; j<rValues; j++){
|
||||
for (i=zValues; i>0; i--){
|
||||
index = j*zValues + i;
|
||||
fprintf(fp,"%4.0f\t%4.0f\t%10.3f\t%10.3f\n",r[index], zScale[index], Er[index], EzScale[index]);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
44
run/macros/makeDecayHists.C
Normal file
44
run/macros/makeDecayHists.C
Normal file
@ -0,0 +1,44 @@
|
||||
// makeDecayHists.C
|
||||
//
|
||||
// Simple root macro to generate positron decay histograms from musrSim data
|
||||
|
||||
// #include "NewSpec.h"
|
||||
//
|
||||
// void makeDecayHists(const char* musrSimFileName)
|
||||
// {
|
||||
// gROOT->ProcessLine(".L NewSpec.C");
|
||||
// TFile *fout = new TFile(musrSimFileName, "UPDATE");
|
||||
// if (fout == 0) {
|
||||
// cout << endl << "**ERROR** Couldn't open file" << musrSimFileName;
|
||||
// cout << endl << endl;
|
||||
// return;
|
||||
// }
|
||||
// fout->cd();
|
||||
//
|
||||
// // TFile::Open(musrSimFileName, "update");
|
||||
// NewSpec spec;
|
||||
// spec.TBLRCoinIO(1,0.5,0); //all muon decays
|
||||
//
|
||||
// // hT->Write();hB->Write();hL->Write();hR->Write();hAsyLR->Write();hAsyTB->Write();
|
||||
// // hEdeposited->Write();hTof->Write();hDetz->Write();hBeamSpot->Write();
|
||||
//
|
||||
// fout->Close();
|
||||
// return;
|
||||
// }
|
||||
{
|
||||
// gROOT->ProcessLine(".L NewSpec.C");
|
||||
TH1F *hT, *hB, *hL, *hR, *hAsyLR, *hAsyTB, *hEdeposited, *hTof, *hDetz, *hBeamSpot;
|
||||
TFile::Open("data/musr_13047.root", "update");
|
||||
NewSpec spec;
|
||||
spec.TBLRCoinIO(1,0.5,1); //0: all muon decays, 1: muons decaying outside sample plate
|
||||
hT = (TH1F*)gDirectory->FindObjectAny("hT"); hB = (TH1F*)gDirectory->FindObjectAny("hB");
|
||||
hL = (TH1F*)gDirectory->FindObjectAny("hL"); hR = (TH1F*)gDirectory->FindObjectAny("hR");
|
||||
hAsyLR = (TH1F*)gDirectory->FindObjectAny("hAsyLR"); hAsyTB = (TH1F*)gDirectory->FindObjectAny("hAsyTB");
|
||||
hEdeposited = (TH1F*)gDirectory->FindObjectAny("hEdeposited");
|
||||
hTof = (TH1F*)gDirectory->FindObjectAny("hTof");
|
||||
hDetz = (TH1F*)gDirectory->FindObjectAny("hDetz");
|
||||
hBeamSpot = (TH1F*)gDirectory->FindObjectAny("hBeamSpot");
|
||||
|
||||
hT->Write();hB->Write();hL->Write();hR->Write();hAsyLR->Write();hAsyTB->Write();
|
||||
hEdeposited->Write();hTof->Write();hDetz->Write();hBeamSpot->Write();
|
||||
}
|
309
run/macros/sr_tr.C
Normal file
309
run/macros/sr_tr.C
Normal file
@ -0,0 +1,309 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L sr_tr.C
|
||||
// sr_transm("data/sr1_1100.root")
|
||||
|
||||
#include <string>
|
||||
void sr_transm(char* fname)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
t1->Draw("save_polx >> pol_x(128, -1, 1)","save_detID==902&&save_particleID==-13"); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(128, -1, 1)","save_detID==902&&save_particleID==-13"); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosZ[0]:muIniPosY[0]>>ini_hist(64,-40,40,64,-1710,-1646)","muIniPolZ > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)","save_detID==902&&save_particleID==-13");
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)","save_detID==902&&save_particleID==-13&&sqrt(save_x**2+save_y**2)<35");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
/* bspot_hist->GetXaxis()->SetTitle("x at z=16 [mm]")
|
||||
bspot_hist->GetYaxis()->SetTitle("y at z=16 [mm]")*/
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
/* c1->cd(6)->SetGridx();c1->cd(6)->SetGridy();
|
||||
t1->Draw("save_y:save_x>>bspot_hist1(64,-40,40,64,-40,40)","save_detID==901&&save_particleID==-13&&sqrt(save_x**2+save_y**2)<=15");
|
||||
bspot_hist1->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist1->GetXaxis()->SetTitle("x at z=0 (mm)")
|
||||
bspot_hist1->GetYaxis()->SetTitle("y at z=0 (mm)")
|
||||
bspot_hist1->Draw();
|
||||
bspot_hist1->Draw("cont0 same");*/
|
||||
xfsect->SetTitle("x cross section [mm]");
|
||||
xfsect->SetFillStyle(1001);
|
||||
xfsect->SetFillColor(45);
|
||||
xfsect->Draw();
|
||||
}
|
||||
|
||||
void phase_space(char* fname)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Phase Space",60,40,600,800);
|
||||
c1->Divide(2,2);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting phase space px,py
|
||||
c1->cd(1);
|
||||
t1->Draw("muIniMomY[0]:muIniMomX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam phase space []");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
}
|
||||
|
||||
void Slice(char* fname, Int_t Slice)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
t1->Draw("save_polx >> pol_x(64,-1,1)",Cond); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(64,-1,1)",Cond); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosZ[0]:muIniPosY[0]>>ini_hist(64,-40,40,64,-1710,-1646)","muIniPolZ > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("save_z>>zhist",Cond);
|
||||
zSlice=zhist->GetMean(1);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
Title.Form("Muon beam cross section [mm], z=%g [mm]",zSlice);
|
||||
bspot_hist->SetTitle(Title);
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
xfsect->SetTitle("x cross section [mm]");
|
||||
xfsect->SetFillStyle(1001);
|
||||
xfsect->SetFillColor(45);
|
||||
xfsect->Draw();
|
||||
}
|
||||
|
||||
|
||||
void VarSlice(char* fname, char* Var, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1 = new TCanvas("c1",Var);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s >> histo",Var);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Var);
|
||||
histo->Draw("F");
|
||||
histo->SetFillStyle(1001);
|
||||
histo->SetFillColor(kGreen-5);
|
||||
histo->Draw();
|
||||
}
|
||||
|
||||
void VarxySlice(char* fname, char* Varx, char* Vary, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1 = new TCanvas("c1",Var);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s:%s >> histo",Vary,Varx);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Histo);
|
||||
histo->Draw();
|
||||
histo->Draw("cont0 same");
|
||||
}
|
||||
|
||||
void Beam_Env(char* fname, Int_t iSlice, Int_t fSlice)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
Int_t i;
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission");
|
||||
|
||||
// Initial beam spot
|
||||
// t1->Draw("muIniPosZ[0]:muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
// ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
// ini_hist->Draw();
|
||||
// ini_hist->Draw("cont0 same");
|
||||
// ini_hist->ProjectionX("xisect",31,33);
|
||||
// ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
printf("SliceID \t Z \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
for (i=iSlice; i<=fSlice; i++)
|
||||
{
|
||||
// Resulting beam spot
|
||||
Cond.Form("save_detID==%d&&save_particleID==-13",i);
|
||||
// Cond.Form("save_detID==%d&& (save_particleID!=22) ",i);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)",Cond);
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)",Cond);
|
||||
|
||||
// Get properties of slice
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",i,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
// delete bspot_hist;
|
||||
}
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)","save_particleID==-13");
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)","save_particleID==-13");
|
||||
// bspot_hist->Draw("Iso");
|
||||
}
|
||||
|
301
run/macros/sr_tr_cp.C
Normal file
301
run/macros/sr_tr_cp.C
Normal file
@ -0,0 +1,301 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L sr_tr.C
|
||||
// sr_transm("data/sr1_1100.root")
|
||||
|
||||
#include <string>
|
||||
void sr_transm(char* fname)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
t1->Draw("save_polx >> pol_x(128, -1, 1)","save_detID==902&&save_particleID==-13"); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(128, -1, 1)","save_detID==902&&save_particleID==-13"); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosZ[0]:muIniPosY[0]>>ini_hist(64,-40,40,64,-1710,-1646)","muIniPolZ > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)","save_detID==902&&save_particleID==-13");
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)","save_detID==902&&save_particleID==-13&&sqrt(save_x**2+save_y**2)<20");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
xfsect->SetTitle("x cross section [mm]");
|
||||
xfsect->SetFillStyle(1001);
|
||||
xfsect->SetFillColor(45);
|
||||
xfsect->Draw();
|
||||
}
|
||||
|
||||
void phase_space(char* fname)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Phase Space",60,40,600,800);
|
||||
c1->Divide(2,2);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting phase space px,py
|
||||
c1->cd(1);
|
||||
t1->Draw("muIniMomY[0]:muIniMomX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam phase space []");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
}
|
||||
|
||||
void Slice(char* fname, Int_t Slice)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
t1->Draw("save_polx >> pol_x(64,-1,1)",Cond); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(64,-1,1)",Cond); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosZ[0]:muIniPosY[0]>>ini_hist(64,-40,40,64,-1710,-1646)","muIniPolZ > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("save_z>>zhist",Cond);
|
||||
zSlice=zhist->GetMean(1);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
Title.Form("Muon beam cross section [mm], z=%g [mm]",zSlice);
|
||||
bspot_hist->SetTitle(Title);
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
xfsect->SetTitle("x cross section [mm]");
|
||||
xfsect->SetFillStyle(1001);
|
||||
xfsect->SetFillColor(45);
|
||||
xfsect->Draw();
|
||||
}
|
||||
|
||||
|
||||
void VarSlice(char* fname, char* Var, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1 = new TCanvas("c1",Var);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s >> histo",Var);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Var);
|
||||
histo->Draw("F");
|
||||
histo->SetFillStyle(1001);
|
||||
histo->SetFillColor(kGreen-5);
|
||||
histo->Draw();
|
||||
}
|
||||
|
||||
void VarxySlice(char* fname, char* Varx, char* Vary, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// TCanvas* c1 = new TCanvas("c1",Var);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s:%s >> histo",Vary,Varx);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Histo);
|
||||
histo->Draw();
|
||||
histo->Draw("cont0 same");
|
||||
}
|
||||
|
||||
void Beam_Env(char* fname, Int_t iSlice, Int_t fSlice)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
Int_t i;
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission");
|
||||
|
||||
// Initial beam spot
|
||||
// t1->Draw("muIniPosZ[0]:muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
// ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
// ini_hist->Draw();
|
||||
// ini_hist->Draw("cont0 same");
|
||||
// ini_hist->ProjectionX("xisect",31,33);
|
||||
// ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
printf("SliceID \t Z \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
for (i=iSlice; i<=fSlice; i++)
|
||||
{
|
||||
// Resulting beam spot
|
||||
Cond.Form("save_detID==%d&&save_particleID==-13",i);
|
||||
// Cond.Form("save_detID==%d&& (save_particleID!=22) ",i);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)",Cond);
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)",Cond);
|
||||
|
||||
// Get properties of slice
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%d\t%g\t%g\t%g\t%g\t%g\t%g\n",i,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
// delete bspot_hist;
|
||||
}
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)","save_particleID==-13");
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)","save_particleID==-13");
|
||||
// bspot_hist->Draw("Iso");
|
||||
}
|
||||
|
197
run/macros/sr_transm.C
Normal file
197
run/macros/sr_transm.C
Normal file
@ -0,0 +1,197 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L sr_transm.C
|
||||
// sr_transm("data/sr1_1100.root")
|
||||
|
||||
#include <string>
|
||||
void sr_transm(char* fname)
|
||||
{
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
|
||||
//TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,800,800);
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,800,800);
|
||||
c1->Divide(2,2);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
//c1->cd(1)->SetGridx();c1->cd(1)->SetGridy();
|
||||
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
//t1->Draw("det_y:det_x>>bspot_hist(64,-80,80,64,-80,80)"); //t1->Draw("mcpHit.positiony*10:mcpHit.positionx*10>>bspot_hist(64,-40,40,64,-40,40)","mcpHit.positionz==2&&mcpHit.ID==0");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
//bspot_hist->Draw("cont0");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
// t1->Draw("mcpHit.positionx*10:mcpHit.positiony*10>>bspot_hist(128,-12,12,128,-12,12)","","goff");
|
||||
bspot_hist->ProjectionX("xsect",31,33);
|
||||
bspot_hist->ProjectionY("ysect",31,33);
|
||||
|
||||
// TText *pt = new TText(-36., 33., "L1 = 11.0 kV");
|
||||
|
||||
// pt->SetTextSize(0.05);
|
||||
// pt->Draw();
|
||||
|
||||
|
||||
//pl=new TPaveLabel(2, 155, 16, 175, "RA_Up = 11 kV");
|
||||
//pl=new TPaveLabel(-75, 60, -15, 75, "#splitline{RA_Up = 8.6 kV}{L3 = 6.78 kV}");
|
||||
//pl->SetBorderSize(1);
|
||||
//pl->SetTextSize(0.43);
|
||||
//pl->Draw();
|
||||
|
||||
|
||||
|
||||
c1->cd(3);
|
||||
xsect->SetTitle("x cross section [mm]");
|
||||
xsect->SetFillStyle(1001);
|
||||
//xsect->Draw("F");
|
||||
xsect->SetFillColor(45);
|
||||
xsect->Draw();
|
||||
|
||||
c1->cd(2);
|
||||
t1->Draw("muTargetPolZ >> pol_z(128, -1, -0.95)","(muTargetPolZ > -2)"); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
c1->cd(1);
|
||||
//Energy loss in CFoil
|
||||
//t1->Draw("10-det_edep_mup*1000","(det_n==1)&&(det_edep<0.1)&&(det_edep_mup*1000>0.1)");
|
||||
t1->Draw("muTargetPolX >> pol_x(128, -0.4, 0)","(muTargetPolX > -2)"); //0, 2
|
||||
//t1->Draw("det_edep_mup*1000","(det_n==1)&&(det_edep<0.1)");
|
||||
//t1->Draw("det_edep_mup*1000>>tmp_hist(64,-80,80)","(det_n==1)&&(det_edep<0.1)");
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
//pol_x->SetFillColor(kBlue-5);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
/*
|
||||
TAxis* yax = ang_hist->GetYaxis();
|
||||
yax->SetNdivisions(206); // N2*100 + N1 (N2 = secondary, N1 = primary) //yax->SetNdivisions(410);
|
||||
yax->SetTickLength(0.018);
|
||||
yax->SetLabelSize(0.04);
|
||||
yax->SetTitleSize(0.045);
|
||||
yax->SetTitleOffset(1.3);
|
||||
yax->SetTitle("Counts (arb. units)");
|
||||
*/
|
||||
|
||||
c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/// Plot of muon beam angular dispersion after lens 1:
|
||||
|
||||
TCanvas* c2 = new TCanvas("c2","Angular Dispersion",60,40,800,800);
|
||||
//gStyle->SetPalette(1,0);
|
||||
//c1->Divide(2,2);
|
||||
c2->SetGridx();
|
||||
c2->SetGridy();
|
||||
//c2->SetFillColor(kWhite); // Fill background with white for printing
|
||||
|
||||
//c2->cd(1);
|
||||
t1->Draw("save_pz","(save_detID==800)"); //xsect->SetTitle("x cross section [mm]");
|
||||
htemp->SetTitle("Position 1 [mm]");
|
||||
htemp->Draw("F");
|
||||
htemp->SetFillStyle(1001);
|
||||
htemp->SetFillColor(38);
|
||||
htemp->Draw();
|
||||
|
||||
//t1->Draw("atan2(mcpHit.posyini,mcpHit.posxini)*57.29577951308:atan2(mcpHit.positiony,mcpHit.positionx)*57.29577951308>
|
||||
|
||||
// Double_t Pi = TMath::Pi(); // 180/Pi
|
||||
//c2->cd(2)->SetGridx(); c1->cd(2)->SetGridy();
|
||||
//t1->Draw("atan2(save_py,save_px)*57.29577951308:atan2(mcpHit.positiony,mcpHit.positionx)*57.29577951308>>bspot_hist3(64,-180,180,64,-180,180)","mcpHit.ID==0");
|
||||
///t1->Draw("atan2(save_py,save_px)*57.29577951308");
|
||||
|
||||
//t1->Draw("det_y[0]:det_x[0]>>bspot_hist(64,-40,40,64,-40,40)");
|
||||
t1->Draw("90-atan2(save_pz,sqrt(save_px^2 + save_py^2))*57.29577951308>>ang_hist(64,0,5)","(save_detID==900)");
|
||||
//t1->Draw("90-atan2(save_pz,sqrt(save_px^2 + save_py^2))*57.29577951308");
|
||||
//htemp->SetTitle("Correlation angle for L1 (8.7 kV, 15 keV); Final angle [deg.]; Inital angle [deg.]");
|
||||
ang_hist->GetXaxis()->SetRangeUser(-5., 5.);
|
||||
ang_hist->Draw("F");
|
||||
ang_hist->SetFillStyle(1001);
|
||||
ang_hist->SetFillColor(805);
|
||||
|
||||
ang_hist->SetTitleSize(0.025);
|
||||
ang_hist->SetTitle("Muon angular distribution after L1");
|
||||
|
||||
ang_hist->GetXaxis()->SetNdivisions(206);
|
||||
ang_hist->GetXaxis()->SetTickLength(0.018);
|
||||
ang_hist->GetXaxis()->SetLabelSize(0.04);
|
||||
ang_hist->GetXaxis()->SetTitleSize(0.045);
|
||||
ang_hist->GetYaxis()->SetTitleOffset(1.0);
|
||||
ang_hist->GetXaxis()->SetTitle("Angle (deg.)");
|
||||
|
||||
TAxis* yax = ang_hist->GetYaxis();
|
||||
yax->SetNdivisions(206); // N2*100 + N1 (N2 = secondary, N1 = primary) //yax->SetNdivisions(410);
|
||||
yax->SetTickLength(0.018);
|
||||
yax->SetLabelSize(0.04);
|
||||
yax->SetTitleSize(0.045);
|
||||
yax->SetTitleOffset(1.3);
|
||||
yax->SetTitle("Counts (arb. units)");
|
||||
|
||||
ang_hist->Draw();
|
||||
|
||||
TText *pt = new TText(3.2, 200., "Plane at -300 mm");
|
||||
pt->SetTextSize(0.03);
|
||||
pt->Draw();
|
||||
|
||||
//TPaveText *pt = new TPaveText(0.6,0.4,0.89, 0.45,"trNDC");
|
||||
//pt->SetTextSize(0.03);
|
||||
//pt->SetFillColor(0); //pt->SetFillColor(390);
|
||||
//pt->SetBorderSize(0);
|
||||
//pt->SetTextAlign(12);
|
||||
//pte = pt->AddText("Plane at z = -300 mm");
|
||||
//pt->Draw();
|
||||
|
||||
|
||||
//c2->SaveAs("data/sr1_ang_dist_300.eps");
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/// Insert simple text directly from command line
|
||||
// TText text(3, 300, "Plane at -380 mm");
|
||||
// text.SetTextSize(0.03);
|
||||
// text.Draw();
|
||||
|
||||
|
||||
/// Optional changes of statistics
|
||||
// TPaveStats* sb2=(TPaveStats *)(ang_hist->GetListOfFunctions()->FindObject("stats"));
|
||||
// sb2->SetTextSize(0.025);
|
||||
// sb2->SetFillColor(390);
|
||||
|
||||
|
||||
/// An easy way to plot functions
|
||||
// (new TF1("fun1","(1-x)*sqrt(1-x*x)",-1,1))->Draw();
|
||||
// (new TF2("fun2","(175/80)**2*(1-y)*(1-x**2)+(1+y)*(1-x)**2",-1,1,-1,1))->Draw("lego")
|
||||
|
||||
|
||||
// From: www-pnp.physics.ox.ac.uk/~west/root/plotting_with_style.html#demo_background
|
||||
/// For publishing (insert these lines in rootlogon.C):
|
||||
// gStyle->SetLineWidth(2.);
|
||||
// gStyle->SetTextSize(1.1);
|
||||
// gStyle->SetLabelSize(0.06,"xy");
|
||||
// gStyle->SetTitleSize(0.06,"xy");
|
||||
// gStyle->SetTitleOffset(1.2,"x");
|
||||
// gStyle->SetTitleOffset(1.0,"y");
|
||||
// gStyle->SetPadTopMargin(0.1);
|
||||
// gStyle->SetPadRightMargin(0.1);
|
||||
// gStyle->SetPadBottomMargin(0.16);
|
||||
// gStyle->SetPadLeftMargin(0.12);
|
||||
|
105
run/macros/td_mcp2_tof.C
Normal file
105
run/macros/td_mcp2_tof.C
Normal file
@ -0,0 +1,105 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L td_mcp2_tof.C
|
||||
// td_mcp2_tof("data/sr1_1100.root")
|
||||
|
||||
#include <string>
|
||||
#define NSIZE 100000
|
||||
void td_mcp2_tof(const char* fname)
|
||||
{
|
||||
Double_t *ptofTD, *ptofMCP2, *pEventIDTD, *pEventIDMCP2;
|
||||
Double_t tofTD[NSIZE], tofMCP2[NSIZE], EventIDTD[NSIZE], EventIDMCP2[NSIZE];
|
||||
Long64_t i, j, k, nEventsTD, nEventsMCP2;
|
||||
TTree *t1;
|
||||
TH1D *htof, *tof_mcp2_plane, *tof_td;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
// muon time-of-flight to TD
|
||||
t1->Draw("eventID:1000*save_time","save_detID==890&&((save_particleID==-13)||(save_particleID==-1313))"); //0, 2
|
||||
// t1->Draw("eventID:1000*save_time","save_detID==890&&save_particleID==-1313"); //0, 2
|
||||
nEventsTD = t1->GetSelectedRows();
|
||||
ptofTD = t1->GetV2();
|
||||
pEventIDTD = t1->GetV1();
|
||||
|
||||
for (i = 0; i<nEventsTD; i++){
|
||||
EventIDTD[i] = pEventIDTD[i];
|
||||
tofTD[i] = ptofTD[i];
|
||||
}
|
||||
|
||||
// muon time-of-flight to MCP2, mu+ or Mu
|
||||
t1->Draw("eventID:1000*save_time","save_detID==902&&((save_particleID==-13)||(save_particleID==-1313))&&sqrt(save_x**2+save_y**2)<=20"); //0, 2
|
||||
// t1->Draw("eventID:1000*save_time","save_detID==902&&save_particleID==-1313"); //0, 2
|
||||
nEventsMCP2 = t1->GetSelectedRows();
|
||||
ptofMCP2 = t1->GetV2();
|
||||
pEventIDMCP2 = t1->GetV1();
|
||||
// cout << "nEventsMCP2 = " << nEventsMCP2 << endl;
|
||||
|
||||
for (i = 0; i<nEventsMCP2; i++){
|
||||
EventIDMCP2[i] = pEventIDMCP2[i];
|
||||
tofMCP2[i] = ptofMCP2[i];
|
||||
}
|
||||
|
||||
// TOF TD-MCP2
|
||||
htof = new TH1D("tof_TDMCP2", "Time-of-flight TD-MCP2", 1000, 0.25, 500.25);
|
||||
k = 0;
|
||||
for (i = 0; i<nEventsMCP2; i++){
|
||||
for (j = k; j<nEventsTD; j++){
|
||||
// cout << i << ", " << j << ", " << EventIDMCP2[i] << ", " << EventIDTD[j] << ", " << tofMCP2[i] << ", " << tofTD[j] << endl;
|
||||
if (EventIDMCP2[i] == EventIDTD[j]){
|
||||
htof->Fill(tofMCP2[i] - tofTD[j]);
|
||||
k = j + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
// gStyle->SetName(fname);
|
||||
gStyle->SetOptTitle(1);
|
||||
TCanvas* c1 = new TCanvas("Time of Flight","Time of Flight",60,40,600,800);
|
||||
c1->Divide(1,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// muon time-of-flight to TD
|
||||
c1->cd(1);
|
||||
t1->Draw("1000*save_time >> tof_td(2000, 0.25, 1000.25)","save_detID==890&&save_particleID==-13"); //0, 2
|
||||
tof_td = (TH1D*) gDirectory->Get("tof_td");
|
||||
tof_td->SetTitle("Time-of-flight to TD");
|
||||
tof_td->GetXaxis()->SetTitle("TD time of flight (ns)");
|
||||
// tof_td->GetXaxis()->SetNdivisions(405);
|
||||
tof_td->GetYaxis()->SetNdivisions(406);
|
||||
// tof_td->GetXaxis()->SetTickLength(0.018);
|
||||
tof_td->GetYaxis()->SetTickLength(0.018);
|
||||
tof_td->Draw("F");
|
||||
tof_td->SetFillStyle(1001);
|
||||
tof_td->SetFillColor(kGreen-5);
|
||||
tof_td->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// muon time-of-flight to MCP2
|
||||
c1->cd(2);
|
||||
t1->Draw("1000*save_time >> tof_mcp2_plane(2000, 0.25, 1000.25)","save_detID==902&&((save_particleID==-13)||(save_particleID==-1313))"); //0, 2
|
||||
tof_mcp2_plane = (TH1D*) gDirectory->Get("tof_mcp2_plane");
|
||||
tof_mcp2_plane->SetTitle("Time-of-flight to plane of MCP2 (including muons missing MCP2)");
|
||||
tof_mcp2_plane->GetXaxis()->SetTitle("MCP2 time of flight (ns)");
|
||||
// tof_mcp2->GetXaxis()->SetNdivisions(405);
|
||||
tof_mcp2_plane->GetYaxis()->SetNdivisions(406);
|
||||
// tof_mcp2->GetXaxis()->SetTickLength(0.018);
|
||||
tof_mcp2_plane->GetYaxis()->SetTickLength(0.018);
|
||||
tof_mcp2_plane->Draw("F");
|
||||
tof_mcp2_plane->SetFillStyle(1001);
|
||||
tof_mcp2_plane->Draw();
|
||||
|
||||
c1->cd(3);
|
||||
htof->SetTitle("Time-of-flight TD-MCP2");
|
||||
htof->GetXaxis()->SetTitle("TD-MCP2 time of flight (ns)");
|
||||
htof->GetYaxis()->SetNdivisions(406);
|
||||
htof->GetYaxis()->SetTickLength(0.018);
|
||||
htof->Draw("F");
|
||||
htof->Draw();
|
||||
}
|
||||
|
||||
|
356
run/macros/test1_tr.C
Normal file
356
run/macros/test1_tr.C
Normal file
@ -0,0 +1,356 @@
|
||||
// To run root without logon screen and script use: root -l -n
|
||||
// To run a named macro in root use:
|
||||
//.L test1_tr.C
|
||||
// sr_transm("data/musr_1100.root", 868)
|
||||
|
||||
#include <string>
|
||||
void sr_transm(const char* fname, int saveID)
|
||||
{
|
||||
char cutStr[128];
|
||||
TH1D *pol_x, *pol_z, *xisect, *yisect, *xfsect, *yfsect;
|
||||
TH2D *ini_hist, *bspot_hist, *bspot_hist1;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
if (saveID < 868)
|
||||
sprintf(cutStr,"save_detID== %3i &&save_particleID==-13",saveID);
|
||||
else
|
||||
sprintf(cutStr,"save_detID== %3i &&save_particleID==-13 && save_pz>0",saveID);
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
t1->Draw("save_polx >> pol_x(128,-1,1)",cutStr); //0, 2
|
||||
pol_x = (TH1D*) gDirectory->Get("pol_x");
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(128, -1, 1)",cutStr); //-1., 1
|
||||
pol_z = (TH1D*) gDirectory->Get("pol_z");
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
// t1->Draw("muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40, 40,64,-40,40)");
|
||||
t1->Draw("muIniPosY[0]:muIniPosZ[0]>>ini_hist(64,-1710,-1646,64,-40,40)","muIniPolZ > -2");
|
||||
ini_hist = (TH2D*) gDirectory->Get("ini_hist");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
// t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)","save_detID==902&&save_particleID==-13");
|
||||
if (saveID < 868)
|
||||
t1->Draw("save_y:(save_z+1678.)>>bspot_hist(80,-40,40,80,-40,40)",cutStr);
|
||||
else
|
||||
t1->Draw("save_y:save_x>>bspot_hist(80,-40,40,80,-40,40)",cutStr);
|
||||
|
||||
bspot_hist = (TH2D*) gDirectory->Get("bspot_hist");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
/* bspot_hist->GetXaxis()->SetTitle("x at z=16 [mm]")
|
||||
bspot_hist->GetYaxis()->SetTitle("y at z=16 [mm]")*/
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect = (TH1D*) gDirectory->Get("xisect");
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
c1->cd(6)->SetGridx();c1->cd(6)->SetGridy();
|
||||
if (saveID < 868)
|
||||
t1->Draw("save_y:(save_z+1678.)>>bspot_hist1(80,-20,20,80,-20,20)",cutStr);
|
||||
else
|
||||
t1->Draw("save_y:save_x>>bspot_hist1(80,-20,20,80,-20,20)",cutStr);
|
||||
bspot_hist1 = (TH2D*) gDirectory->Get("bspot_hist1");
|
||||
bspot_hist1->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist1->GetXaxis()->SetTitle("x (mm)");
|
||||
bspot_hist1->GetYaxis()->SetTitle("y (mm)");
|
||||
bspot_hist1->Draw();
|
||||
bspot_hist1->Draw("cont0 same");
|
||||
cout << "Mean x, Mean y, RMS x, RMS y: " << bspot_hist1->GetMean(1) << ", " << bspot_hist1->GetMean(2) << ", " << bspot_hist1->GetRMS(1) << ", " << bspot_hist1->GetRMS(2) << ", " << endl;
|
||||
cout << "Fraction in [ -5.,15.]: " << bspot_hist1->Integral(31,70,31,70)/bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
cout << "Fraction in [-10.,10.]: " << bspot_hist1->Integral(21,60,21,60)/bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
cout << "Fraction in [-12.5,12.5]: " << bspot_hist1->Integral(16,65,16,65)/bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
cout << "Fraction in [-5.0,5.0]: " << bspot_hist1->Integral(31,50,31,50)/bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
|
||||
cout << "Fraction in [-2.5,2.5]: " << bspot_hist1->Integral(36,45,36,45)/bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
cout << "N[-20,20]: " << bspot_hist1->Integral(1,80,1,80) << endl;
|
||||
}
|
||||
|
||||
void phase_space(const char* fname)
|
||||
{
|
||||
TH1D *pol_x, *pol_z, *xisect, *yisect, *xfsect, *yfsect;
|
||||
TH2D *ini_hist, *bspot_hist, *bspot_hist1;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Phase Space",60,40,600,800);
|
||||
c1->Divide(2,2);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting phase space px,py
|
||||
c1->cd(1);
|
||||
t1->Draw("muIniMomY[0]:muIniMomX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam phase space []");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("muTargetPosY[0]:muTargetPosX[0]>>bspot_hist(64,-40,40,64,-40,40)","muTargetPolX > -2");
|
||||
bspot_hist->SetTitle("Muon beam cross section [mm]");
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
}
|
||||
|
||||
void Slice(const char* fname, Int_t Slice)
|
||||
{
|
||||
TH1D *pol_x, *pol_z, *xisect, *yisect, *xfsect, *yfsect, *zhist;
|
||||
TH2D *ini_hist, *bspot_hist;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice;
|
||||
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission",60,40,600,800);
|
||||
c1->Divide(2,3);
|
||||
c1->SetGridx();
|
||||
c1->SetGridy();
|
||||
|
||||
// Resulting polarization in the x direction
|
||||
c1->cd(1);
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
t1->Draw("save_polx >> pol_x(64,-1,1)",Cond); //0, 2
|
||||
pol_x->SetTitle("Polarization X");
|
||||
pol_x->GetXaxis()->SetNdivisions(405);
|
||||
pol_x->GetYaxis()->SetNdivisions(406);
|
||||
pol_x->GetXaxis()->SetTickLength(0.018);
|
||||
pol_x->GetYaxis()->SetTickLength(0.018);
|
||||
pol_x->Draw("F");
|
||||
pol_x->SetFillStyle(1001);
|
||||
pol_x->SetFillColor(kGreen-5);
|
||||
pol_x->Draw();
|
||||
//c1->SaveAs("data/sr_bspot_0.eps");
|
||||
|
||||
// Resulting polarization in the z direction
|
||||
c1->cd(2);
|
||||
t1->Draw("save_polz >> pol_z(64,-1,1)",Cond); //-1., 1
|
||||
pol_z->SetTitle("Polarization Z");
|
||||
pol_z->GetXaxis()->SetNdivisions(405);
|
||||
pol_z->GetYaxis()->SetNdivisions(406);
|
||||
pol_z->GetXaxis()->SetTickLength(0.018);
|
||||
pol_z->GetYaxis()->SetTickLength(0.018);
|
||||
pol_z->Draw("F");
|
||||
pol_z->SetFillStyle(1001);
|
||||
pol_z->SetFillColor(38);
|
||||
pol_z->Draw();
|
||||
|
||||
|
||||
// Initial beam spot
|
||||
c1->cd(3)->SetGridx();c1->cd(3)->SetGridy(); // c2->cd(3);
|
||||
t1->Draw("muIniPosZ[0]:muIniPosY[0]>>ini_hist(64,-40,40,64,-1710,-1646)","muIniPolZ > -2");
|
||||
ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
ini_hist->Draw();
|
||||
ini_hist->Draw("cont0 same");
|
||||
ini_hist->ProjectionX("xisect",31,33);
|
||||
ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
// Resulting beam spot
|
||||
c1->cd(4)->SetGridx();c1->cd(4)->SetGridy(); // c1->cd(3);
|
||||
t1->Draw("save_z>>zhist",Cond);
|
||||
zSlice=zhist->GetMean(1);
|
||||
t1->Draw("save_y:save_x>>bspot_hist(64,-40,40,64,-40,40)",Cond);
|
||||
Title.Form("Muon beam cross section [mm], z=%g [mm]",zSlice);
|
||||
bspot_hist->SetTitle(Title);
|
||||
bspot_hist->Draw();
|
||||
bspot_hist->Draw("cont0 same");
|
||||
bspot_hist->ProjectionX("xfsect",31,33);
|
||||
bspot_hist->ProjectionY("yfsect",31,33);
|
||||
|
||||
// Initial beam spot cross section
|
||||
c1->cd(5);
|
||||
xisect->SetTitle("x initial cross section [mm]");
|
||||
xisect->SetFillStyle(1001);
|
||||
xisect->SetFillColor(45);
|
||||
xisect->Draw();
|
||||
|
||||
|
||||
// Resulting beam spot cross section
|
||||
c1->cd(6);
|
||||
xfsect->SetTitle("x cross section [mm]");
|
||||
xfsect->SetFillStyle(1001);
|
||||
xfsect->SetFillColor(45);
|
||||
xfsect->Draw();
|
||||
}
|
||||
|
||||
|
||||
void VarSlice(const char* fname, char* Var, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
TH1D *histo;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1", Var);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s >> histo",Var);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Var);
|
||||
histo->Draw("F");
|
||||
histo->SetFillStyle(1001);
|
||||
histo->SetFillColor(kGreen-5);
|
||||
histo->Draw();
|
||||
}
|
||||
|
||||
void VarxySlice(const char* fname, char* Varx, char* Vary, Int_t Slice, Int_t SubPlot)
|
||||
{
|
||||
TH1D *histo;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title,Histo;
|
||||
Double_t zSlice;
|
||||
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1", Varx);
|
||||
// c1->Divide(3,5);
|
||||
c1->cd(SubPlot);
|
||||
|
||||
Cond.Form("save_detID== %04d&&save_particleID==-13",Slice);
|
||||
Histo.Form("%s:%s >> histo",Vary,Varx);
|
||||
t1->Draw(Histo,Cond);
|
||||
histo->SetTitle(Histo);
|
||||
histo->Draw();
|
||||
histo->Draw("cont0 same");
|
||||
}
|
||||
|
||||
void Beam_Env(const char* fname, Int_t iSlice, Int_t fSlice)
|
||||
{
|
||||
TH2D *bspot_hist;
|
||||
TTree *t1;
|
||||
|
||||
TFile* f1 = new TFile(fname);
|
||||
TString Cond,Title;
|
||||
Double_t zSlice,Xrms,Yrms,Xavg,Yavg,Nbins;
|
||||
Int_t i;
|
||||
|
||||
t1 = (TTree*) gDirectory->FindObjectAny("t1");
|
||||
|
||||
gStyle->SetPalette(1,0);
|
||||
TCanvas* c1 = new TCanvas("c1","Polarization and Transmission");
|
||||
|
||||
// Initial beam spot
|
||||
// t1->Draw("muIniPosZ[0]:muIniPosY[0]:muIniPosX[0]>>ini_hist(64,-40,40,64,-40,40)","muIniPolX > -2");
|
||||
// ini_hist->SetTitle("Muon initial beam cross section [mm]");
|
||||
// ini_hist->Draw();
|
||||
// ini_hist->Draw("cont0 same");
|
||||
// ini_hist->ProjectionX("xisect",31,33);
|
||||
// ini_hist->ProjectionY("yisect",31,33);
|
||||
|
||||
printf("SliceID \t Z \t Xrms \t Yrms \t Xavg \t Yavg \t N\n");
|
||||
for (i=iSlice; i<=fSlice; i++)
|
||||
{
|
||||
// Resulting beam spot
|
||||
Cond.Form("save_detID==%d&&save_particleID==-13",i);
|
||||
// Cond.Form("save_detID==%d&& (save_particleID!=22) ",i);
|
||||
t1->Draw("save_z:save_y:save_x>>bspot_hist(100,-100,100,100,-100,100,100,-2600,300)",Cond);
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)",Cond);
|
||||
bspot_hist = (TH2D*) gDirectory->Get("bspot_hist");
|
||||
// Get properties of slice
|
||||
zSlice=bspot_hist->GetMean(3);
|
||||
|
||||
Xrms=bspot_hist->GetRMS(1);
|
||||
Yrms=bspot_hist->GetRMS(2);
|
||||
|
||||
Xavg=bspot_hist->GetMean(1);
|
||||
Yavg=bspot_hist->GetMean(2);
|
||||
|
||||
Nbins=bspot_hist->Integral();
|
||||
|
||||
printf("%d\t%10.1f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%g\n",i,zSlice,Xrms,Yrms,Xavg,Yavg,Nbins);
|
||||
// delete bspot_hist;
|
||||
}
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-290,290)","save_particleID==-13");
|
||||
// t1->Draw("save_z:save_y:save_x>>bspot_hist(64,-40,40,64,-40,40,100,-2600,300)","save_particleID==-13");
|
||||
// bspot_hist->Draw("Iso");
|
||||
}
|
||||
|
9
run/macros/tmp.C
Normal file
9
run/macros/tmp.C
Normal file
@ -0,0 +1,9 @@
|
||||
// To run: root -b LoopFiles.C
|
||||
|
||||
{
|
||||
TString fileDir,fileName,file;
|
||||
Int_t fileNumber,L1,L3;
|
||||
|
||||
gROOT->ProcessLine(".L BeamEnv.C");
|
||||
BeamSlices("data/musr_142180.root",851,904);
|
||||
}
|
70
run/macros/treeviewer.C
Normal file
70
run/macros/treeviewer.C
Normal file
@ -0,0 +1,70 @@
|
||||
void treeviewer() {
|
||||
//=========Macro generated by ROOT version5.32/00
|
||||
//=========for tree "t1" (Sat May 5 17:31:13 2012)
|
||||
//===This macro can be opened from a TreeViewer session after loading
|
||||
//===the corresponding tree, or by running root with the macro name argument
|
||||
|
||||
open_session();
|
||||
}
|
||||
|
||||
open_session(void *p = 0) {
|
||||
gSystem->Load("libTreeViewer");
|
||||
TTreeViewer *treeview = (TTreeViewer *) p;
|
||||
if (!treeview) treeview = new TTreeViewer();
|
||||
TTree *tv_tree = (TTree*)gROOT->FindObject("t1");
|
||||
TFile *tv_file = (TFile*)gROOT->GetListOfFiles()->FindObject("data/musr_50703.root");
|
||||
if (!tv_tree) {
|
||||
if (!tv_file) tv_file = new TFile("data/musr_50703.root");
|
||||
if (tv_file) tv_tree = (TTree*)tv_file->Get("t1");
|
||||
if(!tv_tree) {
|
||||
printf("Tree %s not found", fTree->GetName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
treeview->SetTreeName("t1");
|
||||
treeview->SetNexpressions(10);
|
||||
// Set expressions on axis and cut
|
||||
TTVLVEntry *item;
|
||||
// X expression
|
||||
item = treeview->ExpressionItem(0);
|
||||
item->SetExpression("save_z", "~save_z");
|
||||
// Y expression
|
||||
item = treeview->ExpressionItem(1);
|
||||
item->SetExpression("save_ke", "~save_ke");
|
||||
// Z expression
|
||||
item = treeview->ExpressionItem(2);
|
||||
item->SetExpression("", "-empty-");
|
||||
// Cut expression
|
||||
item = treeview->ExpressionItem(3);
|
||||
item->SetExpression("save_detID>870&&save_particleID==-13", "~ScanAlongZ");
|
||||
// Scan list
|
||||
item = treeview->ExpressionItem(4);
|
||||
item->SetExpression("", "Scan box");
|
||||
// User defined expressions
|
||||
item = treeview->ExpressionItem(5);
|
||||
item->SetExpression("save_detID==902&&save_particleID==-13", "~SamplePosition", kTRUE);
|
||||
item = treeview->ExpressionItem(6);
|
||||
item->SetExpression("save_detID>870&&save_particleID==-13", "~ScanAlongZ", kTRUE);
|
||||
item = treeview->ExpressionItem(7);
|
||||
item->SetExpression("save_detID==890&&save_particleID==-13", "~TDAfterFoil", kTRUE);
|
||||
item = treeview->ExpressionItem(8);
|
||||
item->SetExpression("acos(save_pz/sqrt(save_px^2+save_py^2+save_pz^2))*180/3.14", "~AcosTheta", kFALSE);
|
||||
item = treeview->ExpressionItem(9);
|
||||
item->SetExpression("save_time-0.3152", "~TOFTDSample", kFALSE);
|
||||
item = treeview->ExpressionItem(10);
|
||||
item->SetExpression("", "-empty-", kFALSE);
|
||||
item = treeview->ExpressionItem(11);
|
||||
item->SetExpression("", "-empty-", kFALSE);
|
||||
item = treeview->ExpressionItem(12);
|
||||
item->SetExpression("", "-empty-", kFALSE);
|
||||
item = treeview->ExpressionItem(13);
|
||||
item->SetExpression("", "-empty-", kFALSE);
|
||||
item = treeview->ExpressionItem(14);
|
||||
item->SetExpression("", "-empty-", kFALSE);
|
||||
//--- session object
|
||||
tv_session = new TTVSession(treeview);
|
||||
treeview->SetSession(tv_session);
|
||||
//--- Connect first record
|
||||
tv_session->First();
|
||||
}
|
192
run/macros/writeMusrRoot.C
Normal file
192
run/macros/writeMusrRoot.C
Normal file
@ -0,0 +1,192 @@
|
||||
/***************************************************************************
|
||||
|
||||
writeMusrRoot.C
|
||||
|
||||
Author: Thomas Prokscha
|
||||
Date: 29-Nov-2017
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2017 by Thomas Prokscha, Paul Scherrer Institut *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
//
|
||||
|
||||
#include "TMusrRunHeader.h"
|
||||
|
||||
void writeMusrRoot(Int_t runNo, Double_t B, Double_t ModHV, Double_t SampleHV, Double_t ImpEnergy, Double_t TimeZero)
|
||||
{
|
||||
// load libraries during root startup, defined in rootlogon.C
|
||||
|
||||
// gSystem->Load("$ROOTSYS/lib/libPSimulateMuTransition");
|
||||
// gSystem->Load("$ROOTSYS/lib/libTMusrRunHeader.so");
|
||||
|
||||
TH1F *hDecay001, *hDecay002, *hDecay003, *hDecay004;
|
||||
char titleStr[256];
|
||||
TFolder *histosFolder;
|
||||
TFolder *decayAnaModule, *scAnaModule;
|
||||
TFolder *gRunHeader;
|
||||
TString runTitle;
|
||||
TString histogramFileName;
|
||||
TObjArray Slist(0);
|
||||
TMusrRunPhysicalQuantity prop;
|
||||
|
||||
// Int_t runNo = 13031;
|
||||
// Double_t B = 1500.; //field in G
|
||||
// Double_t ModHV = 12.0; //kV
|
||||
// Double_t SampleHV = 10.0; //kV
|
||||
// Double_t ImpEnergy = 1.1; //keV
|
||||
// Double_t TimeZero = 550.;
|
||||
|
||||
Int_t Nmuons = 2000000; //number of muons started in simulation
|
||||
Double_t SpinRot = -10.0; //degree
|
||||
Double_t Bvar = 0.1; //field variation in G
|
||||
|
||||
// histogramFileName = TString("0");
|
||||
histogramFileName += runNo;
|
||||
histogramFileName += TString("_his.root");
|
||||
sprintf(titleStr,"musrSim, WEW=%5.1f G, Mod=%5.1f kV, Sample=%5.1f kV, E=%5.1f keV, SR=%5.1f deg.", B, ModHV, SampleHV, ImpEnergy, SpinRot);
|
||||
// runTitle = TString("0");
|
||||
runTitle += runNo;
|
||||
runTitle += TString(", ");
|
||||
runTitle += TString(titleStr);
|
||||
|
||||
// feed run info header
|
||||
gRunHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "MuTransition Simulation Header Info");
|
||||
gROOT->GetListOfBrowsables()->Add(gRunHeader, "RunHeader");
|
||||
TMusrRunHeader *header = new TMusrRunHeader(true);
|
||||
|
||||
header->Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
|
||||
header->Set("RunInfo/Specific Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRootLEM.xsd");
|
||||
header->Set("RunInfo/Generator", "runMuSimulation");
|
||||
|
||||
header->Set("RunInfo/File Name", histogramFileName.Data());
|
||||
header->Set("RunInfo/Run Title", runTitle.Data());
|
||||
header->Set("RunInfo/Run Number", (Int_t) runNo);
|
||||
header->Set("RunInfo/Run Start Time", "2016-03-01 06:20:00");
|
||||
header->Set("RunInfo/Run Stop Time", "2016-03-01 06:20:11");
|
||||
|
||||
prop.Set("Run Duration", 11.0, "sec");
|
||||
header->Set("RunInfo/Run Duration", prop);
|
||||
|
||||
header->Set("RunInfo/Laboratory", "PSI");
|
||||
|
||||
header->Set("RunInfo/Instrument", "musrSim LEM");
|
||||
prop.Set("Muon Beam Momentum", 0.0, "MeV/c");
|
||||
|
||||
header->Set("RunInfo/Muon Beam Momentum", prop);
|
||||
header->Set("RunInfo/Muon Species", "positive muon and muonium");
|
||||
header->Set("RunInfo/Muon Source", "Simulation");
|
||||
header->Set("RunInfo/Setup", "LEM setup");
|
||||
header->Set("RunInfo/Comment", "musrSim/Geant4.10.3 beam transport simulation");
|
||||
header->Set("RunInfo/Sample Name", "Sample Plate");
|
||||
|
||||
prop.Set("Sample Temperature", MRH_UNDEFINED, 300, 0.01, "K");
|
||||
header->Set("RunInfo/Sample Temperature", prop);
|
||||
|
||||
prop.Set("Sample Magnetic Field", MRH_UNDEFINED, B, Bvar, "G");
|
||||
header->Set("RunInfo/Sample Magnetic Field", prop);
|
||||
|
||||
header->Set("RunInfo/No of Histos", 4);
|
||||
|
||||
prop.Set("Time Resolution", 1.0, "ns", "Simulation");
|
||||
header->Set("RunInfo/Time Resolution", prop);
|
||||
|
||||
prop.Set("Implantation Energy", ImpEnergy, "keV");
|
||||
header->Set("RunInfo/Implantation Energy", prop);
|
||||
|
||||
prop.Set("Muon Spin Angle", SpinRot, "degree along x");
|
||||
header->Set("RunInfo/Muon Spin Angle", prop);
|
||||
|
||||
header->Set("DetectorInfo/Detector001/Name", "e+ Left");
|
||||
header->Set("DetectorInfo/Detector001/Histo Number", 1);
|
||||
header->Set("DetectorInfo/Detector001/Histo Length", 13000);
|
||||
header->Set("DetectorInfo/Detector001/Time Zero Bin", TimeZero);
|
||||
header->Set("DetectorInfo/Detector001/First Good Bin", TimeZero+50);
|
||||
header->Set("DetectorInfo/Detector001/Last Good Bin", 13000);
|
||||
|
||||
header->Set("DetectorInfo/Detector002/Name", "e+ Top");
|
||||
header->Set("DetectorInfo/Detector002/Histo Number", 2);
|
||||
header->Set("DetectorInfo/Detector002/Histo Length", 13000);
|
||||
header->Set("DetectorInfo/Detector002/Time Zero Bin", TimeZero);
|
||||
header->Set("DetectorInfo/Detector002/First Good Bin", TimeZero+50);
|
||||
header->Set("DetectorInfo/Detector002/Last Good Bin", 13000);
|
||||
|
||||
header->Set("DetectorInfo/Detector003/Name", "e+ Right");
|
||||
header->Set("DetectorInfo/Detector003/Histo Number", 3);
|
||||
header->Set("DetectorInfo/Detector003/Histo Length", 13000);
|
||||
header->Set("DetectorInfo/Detector003/Time Zero Bin", TimeZero);
|
||||
header->Set("DetectorInfo/Detector003/First Good Bin", TimeZero+50);
|
||||
header->Set("DetectorInfo/Detector003/Last Good Bin", 13000);
|
||||
|
||||
header->Set("DetectorInfo/Detector004/Name", "e+ Bottom");
|
||||
header->Set("DetectorInfo/Detector004/Histo Number", 4);
|
||||
header->Set("DetectorInfo/Detector004/Histo Length", 13000);
|
||||
header->Set("DetectorInfo/Detector004/Time Zero Bin", TimeZero);
|
||||
header->Set("DetectorInfo/Detector004/First Good Bin", TimeZero+50);
|
||||
header->Set("DetectorInfo/Detector004/Last Good Bin", 13000);
|
||||
|
||||
// simulation parameters
|
||||
header->Set("Simulation/Number of Muons", Nmuons);
|
||||
|
||||
header->Set("SampleEnvironmentInfo/Cryo", "no cryostat");
|
||||
header->Set("MagneticFieldEnvironmentInfo/Magnet Name", "Field along z");
|
||||
header->Set("BeamlineInfo/Name", "musrSim LEM setup");
|
||||
|
||||
histosFolder = gROOT->GetRootFolder()->AddFolder("histos", "Histograms");
|
||||
gROOT->GetListOfBrowsables()->Add(histosFolder, "histos");
|
||||
decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms");
|
||||
scAnaModule = histosFolder->AddFolder("SCAnaModule", "SlowControl histograms");
|
||||
|
||||
gDirectory->ls();
|
||||
if (gDirectory->FindObjectAny("hL;1")) cout << "Histo found" << endl;
|
||||
hDecay001 = (TH1F*)gDirectory->FindObjectAny("hL;1"); hDecay002 = (TH1F*)gDirectory->FindObjectAny("hT;1");
|
||||
hDecay003 = (TH1F*)gDirectory->FindObjectAny("hR;1"); hDecay004 = (TH1F*)gDirectory->FindObjectAny("hB;1");
|
||||
|
||||
hDecay001->SetNameTitle("hDecay001", "hDecay001");
|
||||
hDecay002->SetNameTitle("hDecay002", "hDecay002");
|
||||
hDecay003->SetNameTitle("hDecay003", "hDecay003");
|
||||
hDecay004->SetNameTitle("hDecay004", "hDecay004");
|
||||
|
||||
decayAnaModule->Add(hDecay001);decayAnaModule->Add(hDecay002);decayAnaModule->Add(hDecay003);decayAnaModule->Add(hDecay004);
|
||||
|
||||
// write file
|
||||
TFile *fout = new TFile(histogramFileName.Data(), "RECREATE", "Midas musrSim Histograms");
|
||||
if (fout == 0) {
|
||||
cout << endl << "**ERROR** Couldn't create ROOT file";
|
||||
cout << endl << endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fout->cd();
|
||||
|
||||
header->FillFolder(gRunHeader);
|
||||
gRunHeader->Add(&Slist);
|
||||
Slist.SetName("RunSummary");
|
||||
histosFolder->Write();
|
||||
gRunHeader->Write();
|
||||
fout->Close();
|
||||
cout << "Histograms written to " << histogramFileName.Data() << endl;
|
||||
|
||||
// delete fout;
|
||||
// delete header;
|
||||
// delete histo[0];
|
||||
// delete histo[1];
|
||||
// delete gRunHeader;
|
||||
}
|
Reference in New Issue
Block a user