Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/plugins/Analysis/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@ Import('*')
subdirs = ['ReactionFilter', 'b1pi_hists', 'ReactionEfficiency']
subdirs.extend(['DAQTree', 'DAQTreeBCAL'])
subdirs.extend(['monitoring_hists'])
subdirs.extend(['p2pi_hists','p3pi_hists','p4pi_hists','p2k_hists'])
subdirs.extend(['p2gamma_hists','ppi0gamma_hists','p2pi0_hists'])
subdirs.extend(['npp_hists','cpp_hists'])
subdirs.extend(['p2pi_hists','p3pi_hists','ppi0gamma_hists'])
subdirs.extend(['fcal_charged','TPOL_tree','mcthrown_tree'])
subdirs.extend(['trackeff_hists','imaging'])
subdirs.extend(['pid_dirc','truth_dirc', 'lut_dirc', 'dirc_hists', 'dirc_reactions', 'dirc_tree', 'TRD_hists'])
subdirs.extend(['B3pi_eff_missgamma','B3pi_eff_misspip','B3pi_eff_misspim','B3pi_eff_missprot', 'mcthrown_hists'])
subdirs.extend(['compton'])
subdirs.extend(['src-ct'])
subdirs.extend(['trackeff_hists','imaging','dirc_reactions','TRD_hists'])
SConscript(dirs=subdirs, exports='env osname', duplicate=0)


# Optional targets
optdirs = ['phys_tree', 'pedestals','bcal_calib','bcal_calib_cosmic_cdc', 'CPPMVAtree']

optdirs.extend(['acceptance_hists', 'mcthrown_hists', 'cdc_hists', 'fcal_hists'])
optdirs.extend(['dc_alignment','p2pi_trees','Z2pi_trees','ccal_hits','ccal_display','fcal_led','F250_mode10_pedestal','Z2pi0_trees'])

optdirs = ['pedestals','bcal_calib','bcal_calib_cosmic_cdc', 'CPPMVAtree']

optdirs.extend(['mcthrown_hists', 'cdc_hists', 'fcal_hists'])
optdirs.extend(['p4pi_hists','p2k_hists','p2gamma_hists','p2pi0_hists'])
optdirs.extend(['B3pi_eff_missgamma','B3pi_eff_misspip','B3pi_eff_misspim','B3pi_eff_missprot'])
subdirs.extend(['pid_dirc','truth_dirc', 'lut_dirc', 'dirc_hists', 'dirc_tree'])
optdirs.extend(['dc_alignment','p2pi_trees','fcal_led','F250_mode10_pedestal'])
optdirs.extend(['npp_hists','cpp_hists'])
optdirs.extend(['Z2pi0_trees','Z2pi_trees','ccal_hits','ccal_display'])
optdirs.extend(['compton','src-ct'])

optdirs.extend(['retired'])

sbms.OptionallyBuild(env, optdirs)

7 changes: 5 additions & 2 deletions src/plugins/Calibration/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ Import('*')

# update this when plugins are added

subdirs = ['BCAL_SiPM_saturation','BCAL_attenlength_gainratio','BCAL_gainmatrix','BCAL_point_time','BCAL_point_calib','BCAL_saturation','BCAL_TDC_Timing','CDC_amp','HLDetectorTiming','TAGH_timewalk','CDC_TimeToDistance','PS_timing','PSC_TW','PS_E_calib','st_tw_corr_auto','ST_Propagation_Time','ST_Tresolution','TAGM_TW','TOF_calib','FCALLEDTree','FCAL_LED_shifts','FCAL_TimingOffsets_Primex']
subdirs = ['BCAL_attenlength_gainratio','BCAL_gainmatrix','BCAL_TDC_Timing','CDC_amp','HLDetectorTiming','TAGH_timewalk','CDC_TimeToDistance','PS_timing','PSC_TW','PS_E_calib','st_tw_corr_auto','ST_Propagation_Time','ST_Tresolution','TAGM_TW','TOF_calib','FCALLEDTree','FCAL_TimingOffsets_Primex']

SConscript(dirs=subdirs, exports='env osname', duplicate=0)

sbms.OptionallyBuild(env, ['FCALgains','FCALpedestals','FCALpulsepeak','FCAL_TimingOffsets','FCAL_Pi0HFA','FCAL_Pi0TOF'])
optdirs = ['FCALpedestals','FCALpulsepeak','FCAL_TimingOffsets','FCAL_Pi0TOF']
optdirs.extend(['BCAL_saturation','BCAL_SiPM_saturation','FCAL_LED_shifts'])

sbms.OptionallyBuild(env, optdirs)
4 changes: 3 additions & 1 deletion src/plugins/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Import('*')

Import('env osname')

subdirs = ['Analysis', 'Utilities', 'monitoring', 'Calibration', 'include', 'Alignment']
subdirs = ['Analysis', 'Utilities', 'monitoring', 'Calibration', 'include']
sbms.OptionallyBuild(env, ['Alignment'])

SConscript(dirs=subdirs, exports='env osname', duplicate=0)

14 changes: 9 additions & 5 deletions src/plugins/Utilities/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Import('*')

# Default targets (always built)
subdirs = ['danarest', 'evio_writer', 'evio-hddm']
subdirs.extend(['2trackskim', 'pi0bcalskim', 'pi0fcalskim', 'twogamma_fcal_skim', 'run_summary', 'track_skimmer', 'trackeff_missing','ps_skim', 'trigger_skims', 'bigevents_skim', 'coherent_peak_skim','exclusivepi0skim','randomtrigger_skim','pi0fcaltofskim','single_neutral_skim','compton_neutral_skim','eta2g_primexd_skim','eta6g_primexd_skim','etapi0_primexd_skim', 'cdcbcal_skim', 'cdc_goodtrack_skim'])

subdirs.extend(['Pi0Finder', 'EventTagPi0','es_test','omega_skim','cal_high_energy_skim', 'syncskim', 'dedx_tree', 'phi_skim', 'npp_skim', 'cpp_skim'])
subdirs.extend(['pi0bcalskim', 'trackeff_missing','ps_skim', 'trigger_skims', 'exclusivepi0skim', 'randomtrigger_skim', 'pi0fcaltofskim' ])
subdirs.extend(['omega_skim', 'syncskim'])

SConscript(dirs=subdirs, exports='env osname', duplicate=0)

# Optional targets
optdirs = ['danahddm', 'dumpcandidates', 'dumpthrowns', 'l3bdt']
optdirs.extend(['merge_rawevents', 'syncskim', 'DAQ', 'TTab', 'rawevent'])
optdirs = [ '2trackskim', 'bigevents_skim', 'coherent_peak_skim' , 'twogamma_fcal_skim' ]
optdirs.extend(['pi0fcalskim', 'single_neutral_skim','compton_neutral_skim' ])
optdirs.extend(['eta2g_primexd_skim','eta6g_primexd_skim','etapi0_primexd_skim' ])
optdirs.extend(['cdcbcal_skim', 'cdc_goodtrack_skim'])
optdirs.extend(['run_summary', 'track_skimmer' ])
optdirs.extend(['merge_rawevents', 'syncskim'])
optdirs.extend(['Pi0Finder', 'EventTagPi0','cal_high_energy_skim', 'phi_skim', 'npp_skim', 'cpp_skim'])
optdirs.extend(['cdc_amp_t','cdc_echo','cdc_emu','cdc_scan', 'fmwpc_scan', 'epem_ml_skim'])
sbms.OptionallyBuild(env, optdirs)
199 changes: 199 additions & 0 deletions src/plugins/Utilities/retired/dedx_tree/JEventProcessor_dedx_tree.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// $Id$
//
// File: JEventProcessor_dedx_tree.cc
// Created: Wed Aug 28 14:48:25 EDT 2019
// Creator: njarvis (on Linux albert.phys.cmu.edu 3.10.0-693.5.2.el7.x86_64 x86_64)
//

#include "JEventProcessor_dedx_tree.h"


// Routine used to create our JEventProcessor
#include <JANA/JApplication.h>
#include <JANA/JFactory.h>

extern "C"{
void InitPlugin(JApplication *app){
InitJANAPlugin(app);
app->Add(new JEventProcessor_dedx_tree());
}
} // "C"

//define static local variable //declared in header file
thread_local DTreeFillData JEventProcessor_dedx_tree::dTreeFillData;

//------------------
// JEventProcessor_dedx_tree (Constructor)
//------------------
JEventProcessor_dedx_tree::JEventProcessor_dedx_tree()
{
SetTypeName("JEventProcessor_dedx_tree");
}

//------------------
// ~JEventProcessor_dedx_tree (Destructor)
//------------------
JEventProcessor_dedx_tree::~JEventProcessor_dedx_tree()
{

}

//------------------
// init
//------------------
void JEventProcessor_dedx_tree::Init()
{
// This is called once at program startup.

//TTREE INTERFACE
//MUST DELETE WHEN FINISHED: OR ELSE DATA WON'T BE SAVED!!!
dTreeInterface = DTreeInterface::Create_DTreeInterface("dedx_tree", "dedx_tree.root");

//TTREE BRANCHES
DTreeBranchRegister locTreeBranchRegister;

locTreeBranchRegister.Register_Single<ULong64_t>("eventnumber");
locTreeBranchRegister.Register_Single<UInt_t>("ctracks");

locTreeBranchRegister.Register_Single<UInt_t>("ndedxhits");

locTreeBranchRegister.Register_Single<Double_t>("x");
locTreeBranchRegister.Register_Single<Double_t>("y");
locTreeBranchRegister.Register_Single<Double_t>("z");
locTreeBranchRegister.Register_Single<Double_t>("r");

locTreeBranchRegister.Register_Single<Double_t>("phi");
locTreeBranchRegister.Register_Single<Double_t>("theta");

locTreeBranchRegister.Register_Single<Int_t>("charge");
locTreeBranchRegister.Register_Single<Double_t>("p");
locTreeBranchRegister.Register_Single<Double_t>("dedx");
locTreeBranchRegister.Register_Single<Double_t>("dedx_int");
locTreeBranchRegister.Register_Single<Double_t>("dedx_corr");
locTreeBranchRegister.Register_Single<Double_t>("dedx_int_corr");

//REGISTER BRANCHES
dTreeInterface->Create_Branches(locTreeBranchRegister);
}

//------------------
// brun
//------------------
void JEventProcessor_dedx_tree::BeginRun(const std::shared_ptr<const JEvent> &event)
{
// This is called whenever the run number changes
}

//------------------
// evnt
//------------------
void JEventProcessor_dedx_tree::Process(const std::shared_ptr<const JEvent> &event)
{
// This is called for every event. Use of common resources like writing
// to a file or filling a histogram should be mutex protected. Using
// event->Get(...) to get reconstructed objects (and thereby activating the
// reconstruction algorithm) should be done outside of any mutex lock
// since multiple threads may call this method at the same time.
// Here's an example:
//
// vector<const MyDataClass*> mydataclasses;
// event->Get(mydataclasses);
//
// japp->RootFillLock(this);
// ... fill historgrams or trees ...
// japp->RootFillUnLock(this);

auto eventnumber = event->GetEventNumber();

// select events with physics events, i.e., not LED and other front panel triggers
const DTrigger* locTrigger = NULL;
event->GetSingle(locTrigger);
if(locTrigger->Get_L1FrontPanelTriggerBits() != 0) return;

const DVertex* locVertex = NULL;
event->GetSingle(locVertex);
double z = locVertex->dSpacetimeVertex.Z();
if ((z < 45.0) || (z > 85.0)) return;

double x = locVertex->dSpacetimeVertex.X();
double y = locVertex->dSpacetimeVertex.Y();
double r = sqrt (x*x + y*y);


vector<const DChargedTrack*> ctracks;
event->Get(ctracks);

if ((int)ctracks.size() ==0) return;

dTreeFillData.Fill_Single<ULong64_t>("eventnumber",(ULong64_t)eventnumber);

dTreeFillData.Fill_Single<UInt_t>("ctracks",(UInt_t)ctracks.size());


for (uint32_t i=0; i<ctracks.size(); i++) {

const DChargedTrackHypothesis *hyp=ctracks[i]->Get_BestFOM();

if (hyp != NULL) {

const DTrackTimeBased *track = hyp->Get_TrackTimeBased();

int nhits = (int)track->dNumHitsUsedFordEdx_CDC;

if (nhits==0) continue;

dTreeFillData.Fill_Single<UInt_t>("ndedxhits",(UInt_t)nhits);

double charge = track->charge();
DVector3 mom = track->momentum();
double p = mom.Mag();

double theta_degrees = mom.Theta() * 180.0/3.14159;
double phi_degrees = mom.Phi() * 180.0/3.14159;

double dedx = 1.0e6*track->ddEdx_CDC_amp;
double dedxfromintegral = 1.0e6*track->ddEdx_CDC;
double dedx_corr = 1.0e6*hyp->Get_dEdx_CDC_amp();
double dedxfromintegral_corr = 1.0e6*hyp->Get_dEdx_CDC_int();

dTreeFillData.Fill_Single<Double_t>("x",x);
dTreeFillData.Fill_Single<Double_t>("y",y);
dTreeFillData.Fill_Single<Double_t>("z",z);
dTreeFillData.Fill_Single<Double_t>("r",r);
dTreeFillData.Fill_Single<Double_t>("phi",phi_degrees);
dTreeFillData.Fill_Single<Double_t>("theta",theta_degrees);

dTreeFillData.Fill_Single<Int_t>("charge",(Int_t)charge);
dTreeFillData.Fill_Single<Double_t>("p",p);
dTreeFillData.Fill_Single<Double_t>("dedx",dedx);
dTreeFillData.Fill_Single<Double_t>("dedx_int",dedxfromintegral);
dTreeFillData.Fill_Single<Double_t>("dedx_corr",dedx_corr);
dTreeFillData.Fill_Single<Double_t>("dedx_int_corr",dedxfromintegral_corr);

//FILL TTREE
dTreeInterface->Fill(dTreeFillData);
}

}
}

//------------------
// erun
//------------------
void JEventProcessor_dedx_tree::EndRun()
{
// This is called whenever the run number changes, before it is
// changed to give you a chance to clean up before processing
// events from the next run number.
}

//------------------
// fini
//------------------
void JEventProcessor_dedx_tree::Finish()
{
// Called before program exit after event processing is finished.

delete dTreeInterface; //saves trees to file, closes file
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// $Id$
//
// File: JEventProcessor_dedx_tree.h
// Created: Wed Aug 28 14:48:25 EDT 2019
// Creator: njarvis (on Linux albert.phys.cmu.edu 3.10.0-693.5.2.el7.x86_64 x86_64)
//

#ifndef _JEventProcessor_dedx_tree_
#define _JEventProcessor_dedx_tree_

#include <JANA/JEventProcessor.h>
#include <JANA/Services/JLockService.h>

#include "TRIGGER/DTrigger.h"
#include "TRACKING/DTrackTimeBased.h"
#include "PID/DVertex.h"
#include "PID/DChargedTrack.h"
#include "PID/DChargedTrackHypothesis.h"

#include "ANALYSIS/DTreeInterface.h"

#include <vector>


class JEventProcessor_dedx_tree:public JEventProcessor{
public:
JEventProcessor_dedx_tree();
~JEventProcessor_dedx_tree();

private:
void Init() override;
void BeginRun(const std::shared_ptr<const JEvent>& event) override;
void Process(const std::shared_ptr<const JEvent>& event) override;
void EndRun() override;
void Finish() override;

//TREE
DTreeInterface* dTreeInterface;

//thread_local: Each thread has its own object: no lock needed
//important: manages it's own data internally: don't want to call new/delete every event!

static thread_local DTreeFillData dTreeFillData;


};

#endif // _JEventProcessor_dedx_tree_

53 changes: 53 additions & 0 deletions src/plugins/Utilities/retired/dedx_tree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# CDC dE/dx correction procedure for variation with theta

The first iteration of this process is documented in [GlueX-doc-4693](https://halldweb.jlab.org/doc-private/DocDB/ShowDocument?docid=4693).
The scripts are stored in the subdirectory scripts.
The correction matrix is loaded into the CCDB table /CDC/dedx\_theta.

## Prerequisites:
* 300+ evio files processed with the dedx\_tree plugin, with dE/dx truncation and the dE/dx correction switched off ( -PPID:CDC_CORRECT_DEDX_THETA=0 and -PPID:CDC_TRUNCATE_DEDX=0 )

* Simulated data processed similarly.


## Process overview:

1. makebinnedhistos.C - create many histograms of dedx vs p, for 1 degree bins in theta

2. fitbinnedhistoslg.C - find the peak position for the proton and pion bands in each (p, theta) bin, using theta-specific functions to define the fit regions

3. makesimsinglebinnedhistos.C - as (1), with simulated data

4. fitbinnedhistoslg.C - as (2) with simulated data

5. makescalefactors.C - calculate the scale factors to match the real data to the simulated data

6. extendscalefactors.C - extrapolate the scale factors to populate the edges of a rectangular space in (dedx, theta) (root -b -q dedx_correction_factors.root extendscalefactors.C)

7. smooth_histo.C - run a smoothing algorithm over the scale factors and write the matrix of scale factors into a text file which can be used in the reconstruction code. (root extended_dedx_correction_factors.root smooth_histo.C)

8. checkmatrix.C - use the matrix contained in the text file to correct the data in the root trees and create a set of corrected binned histograms, which can be fitted as before to verify that the correction process produced acceptable results.


## Plotting scripts
* drawdedxcuts.C - plots functions on top of specified dEdx vs p histogram from histogram file
* drawalldedxcuts.C - loops through all histograms in histo file, saves 2x2 canvases of dedx functions over data
* plotdata.C - reads in fitresults.root or fittedsimresults.root, plots coloured bands of dedx peak position for one particle type
* plotf.C - reads in dedx_correction_factors.root, plots coloured bands of correction factors for one particle type
* plotfdedx.C - reads in dedx_correction_factors.root, plots dedx vs theta for the data used for the correction factors
* plot_cf_vs_dedx.C - reads in dedx_correction_factors.root, makes plots cf vs theta for 5 degree steps in theta
* dots.C - reads in dedx_correction_factors.root - makes a selection of plots of cf, dedx, theta including a 3D dot plot
* drawsurf2.C - use this with the tree file open, works with dedx_correction_factors.root or extended_dedx_correction_factors.root - draws surfaces, dots and surface+dots


## Other scripts
* make_histo_into_text_file.C - writes the histogram into a text file without smoothing



A quick 3D plot of plot correction factors vs dedx, theta in colour scale can be made from the open root tree using
```sh
t->Draw("f:dedx:theta:f","","cont4 col")
```


Loading