/*
This is a proprietary part of DataMelt package.
License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License,
or any later version.
http://creativecommons.org/licenses/by-sa/3.0/
Permission to use, copy and modify this software and its documentation for
NON-COMMERCIAL purposes is granted,
without fee, provided that an acknowledgment to the author, Dr Sergei Chekanov
appears in all copies and associated documentation or publications.
Redistributions of the source code, or parts of the source codes,
must retain the copyright notice, this list of conditions and the following disclaimer
(all at the top of each source code) and requires the written permission of Sergei Chekanov
Redistribution in binary form of all or parts of a class must reproduce the
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution and requires the written permission of Sergei Chekanov
Details about license agreement or commercial use are: http://jwork.org/jhepwork/license.php
*/
package jhpro.stat;
import java.io.Serializable;
import java.util.ArrayList;
import jhplot.H1D;
import jhplot.P1D;
/**
* This class serves as input for the Limit.ComputeLimit method. It takes the
* signal, background and data histograms to form a channel. More channels can
* be added using AddChannel(), as well as different systematics sources.
*
* @author S.Chekanov
**/
public class DataSource implements Cloneable, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
// The arrays used to store the packed inputs
private ArrayList fSignal; // packed input signal
private ArrayList fBackground; // packed input background
private ArrayList fCandidates; // packed input candidates (data)
private ArrayList fErrorOnSignal; // error source on signal
private ArrayList fErrorOnBackground; // error source for background
private ArrayList fErrorOnData; // // error source for data
private ArrayList fIds; // packed IDs for the different
// error sources
private static int chenCounter = 0;
/**
* Simplest constructor. Use addChannel to add data.
*/
public DataSource() {
chenCounter = 0;
SetOwner();
}
/**
* Allow cloning
*/
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
/**
* Adds one channel with signal, background and data given as input.
* Systematic is assumed to be zero for data, signal and background.
*
* @param s
* Signal histogram
* @param b
* Background histogram
* @param d
* Observed data histogram
*/
public DataSource(H1D s, H1D b, H1D d) {
chenCounter = 0;
SetOwner();
addChannel(s, b, d,0,0,0,"ch"+Integer.toString(chenCounter));
}
/**
* Adds one channel with signal, background and data given as input.
* Systematic is assumed to be zero for data, signal and background.
* @param s
* Signal
* @param b
* Background
* @param d
* Data
*/
public DataSource(P1D s, P1D b, P1D d) {
chenCounter = 0;
SetOwner();
addChannel(s, b, d,0,0,0,"ch"+Integer.toString(chenCounter));
}
/**
* Another constructor, directly adds one channel with signal, background
* and data given as input. One can specify systematic uncertainty for
* signal, background and data. For example, 0.05 value for signal
* means that signal should be scaled up by 5%. If it is -0.05, signal
* should be scaled down by 0.05%.
*
* @param s
* Signal histogram
* @param b
* Background histogram
* @param d
* Data histogram
* @param es
* Error on signal
* @param eb
* Error on background
* @param ed
* Error on data
*
* @param name name indicating this systematics
*/
public DataSource(H1D s, H1D b, H1D d, double es,
double eb, double ed, String name) {
chenCounter = 0;
SetOwner();
addChannel(s, b, d, es, eb, ed, name);
}
/**
* Adds a channel with signal, background and data given as input.
* All systematic errors are assumed to be 0.
*
* @param s
* Signal histogram
* @param b
* Background histogram
* @param d
* Observed data histogram
*/
public void addChannel(H1D s, H1D b, H1D d) {
chenCounter++;
DataKeeper ss = new DataKeeper(s);
DataKeeper bb = new DataKeeper(b);
DataKeeper dd = new DataKeeper(d);
addChannel(ss, bb, dd, 0, 0, 0, "ch" + Integer.toString(chenCounter));
}
/**
* Adds a channel with signal, background and data given as input.
* All systematic errors are set to zero. The name is set to the channel number.
*
* @param s
* Signal
* @param b
* Background
* @param d
* Data
*/
public void addChannel(P1D s, P1D b, P1D d) {
chenCounter++;
DataKeeper ss = new DataKeeper(s);
DataKeeper bb = new DataKeeper(b);
DataKeeper dd = new DataKeeper(d);
addChannel(ss, bb, dd, 0, 0, 0, "ch" + Integer.toString(chenCounter));
}
/**
* Adds a channel with signal, background and data given as input.
* One can specify name for this channel and systematic errors.
* This is the main constructor.
*
* @param s
* Signal expected
* @param b
* Background expected
* @param d
* Data observed
* @param es
* Systematic error on signal
* @param eb
* Systematic error on background
* @param ed
* Systematic error on data
* @param name
* Name for this data source
*
*/
public void addChannel(DataKeeper s, DataKeeper b, DataKeeper d, double es,
double eb, double ed, String name) {
chenCounter++;
fSignal.add(s);
fBackground.add(b);
fCandidates.add(d);
fErrorOnSignal.add(es);
fErrorOnBackground.add(eb);
fErrorOnData.add(ed);
fIds.add(name);
}
/**
* Adds a channel with signal, background and data given as input.
*
* @param s
* Signal expected
* @param b
* Background expected
* @param d
* Data observed
*
*/
public void addChannel(DataKeeper s, DataKeeper b, DataKeeper d) {
chenCounter++;
addChannel(s, b, d, 0, 0, 0, "ch" + Integer.toString(chenCounter));
}
/**
* Get data for signal
*
* @return
*/
public ArrayList getSignal() {
return fSignal;
}
/**
* Get data for background
*
* @return
*/
public ArrayList getBackground() {
return fBackground;
}
/**
* Get data with candidates
*
* @return
*/
public ArrayList getCandidates() {
return fCandidates;
}
/**
* Get errors on signal on all channels
*
* @return
*/
public ArrayList getErrorOnSignal() {
return fErrorOnSignal;
}
/**
* Get systematics on background for all channels
*
* @return
*/
public ArrayList getErrorOnBackground() {
return fErrorOnBackground;
}
/**
* Get systematics on data for all channels
*
* @return
*/
public ArrayList getErrorOnData() {
return fErrorOnData;
}
/**
* Get names of the errors
*
* @return
*/
public ArrayList getErrorNames() {
return fIds;
}
/**
* Adds a channel with signal, background and data given as input. In
* addition, systematic error can be set for signal, background, data.
* For example, systematic error 0.05 on background means scaling background
* by 1+0.05 factor (i.e. added 5% systematics). If it is -0.05, this
* will scale background by 1-0.05.
*
* @param s
* Signal histogram
* @param b
* Background histogram
* @param d
* Data histogram
* @param es
* Systematic on signal
* @param eb
* Systematic on background
* @param ed
* Systematic on data
* @param name
* Name for this channel
*/
public void addChannel(H1D s, H1D b, H1D d, double es,
double eb, double ed, String name) {
chenCounter++;
DataKeeper ss = new DataKeeper(s);
DataKeeper bb = new DataKeeper(b);
DataKeeper dd = new DataKeeper(d);
addChannel(ss, bb, dd, es, eb, ed, name);
}
/**
* Adds a channel with signal, background and data given as input. In
* addition, error sources are defined. TH1 are here used for convenience:
* each bin has to be seen as an error source (relative). names is an array
* of strings containing the names of the sources. Sources with the same
* name are correlated.
*
* @param s
* Expected signal P1D
* @param b
* Expected background P1D
* @param d
* Measured data P1D
* @param es
* systematic on signal
* @param eb
* systematic on background
* @param ed
* systematic on data
* @param name
* name for this channel
*/
public void addChannel(P1D s, P1D b, P1D d, double es,
double eb, double ed, String name) {
chenCounter++;
DataKeeper ss = new DataKeeper(s);
DataKeeper bb = new DataKeeper(b);
DataKeeper dd = new DataKeeper(d);
addChannel(ss, bb, dd, es, eb, ed, name);
}
/**
* Get total numberer of channels
*
* @return
*/
public int getNumberChennels() {
return chenCounter;
}
/**
* Initialize all arrays
*
* @param swtch
*/
public void SetOwner() {
fSignal = new ArrayList();
fBackground = new ArrayList();
fCandidates = new ArrayList();
fErrorOnSignal = new ArrayList();
fErrorOnBackground = new ArrayList();
fErrorOnData = new ArrayList();
fIds = new ArrayList();
}
}
Ads help maintain this website.