BeWork.h 5.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
/*
 * BeWork.h
 *
 *  Created on: 2.2.2010
 *      Author: Vratislav
 */

//#ifndef BEWORK_H_
//#define BEWORK_H_

#pragma once

#include <TObject.h>
#include <TString.h>
#include <TFile.h>
#include <TTree.h>
#include <TChain.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include <TGeoBBox.h>
#include <TGeoTube.h>
#include <TGeoTrd1.h>
#include <TGeoBoolNode.h>
#include <TGeoCompositeShape.h>
#include <TLorentzVector.h>
#include <TUnixSystem.h>

//#include <TMemFile.h>

#include "BeEvent.h"
#include "BeReaction.h"
#include "BePureEvent.h"
#include "../AculData/AculCalibration.h"
#include "../AculData/ConfigDictionary.h"
#include "../TELoss/TELoss.h"

#ifndef __CINT__
#endif  /* __CINT __ */

#include <stdarg.h>

using std::flush;

class BeWork {

private:
//public:

//	TELosses:
	TELoss *fSiAlpha;			//!
	TELoss *fSiP;				//!

	TELoss *fCsIAlpha;			//!
	TELoss *fCsIP;				//!

	TELoss *fTargetAlpha;		//!
	TELoss *fTargetP;			//!
	TELoss *fTargetLi;			//!

	TELoss *fTargetWinAlpha;	//!
	TELoss *fTargetWinP;		//!
	TELoss *fTargetWinLi;		//!

	//configuration and parameter files
	TString fConfigFile;			//!
	TString fWorkDir;				//!
	TString fRawFilePath;			//!
//	TString fCutFile;				//!
	Bool_t fBeOnly;
	//parameter used for choice of generator
	Double_t fsRatioMin;		//!
	Double_t fsRatioMax;		//!

	//parameters
	//detectors resolution used in simulation
	Double_t fSiRes;		//!	in MeV, sigma in Si detectors
	Double_t fCsIResP;		//!	in %, FWHM in CsI for protons
	Double_t fCsIBestResP;	//! in MeV, the best absolute resolution in CsI for protons
	Double_t fCsIResA;		//!	in %, FWHM in CsI for alphas
	Double_t fCsIBestResA;	//! in MeV, the best absolute resolution in CsI for alphas

	//beam characteristics, used in MC
	Double_t fTBeamMC;			//!	in AMeV		//where is it? in the centre? on the target window?
	Double_t fTBeamResMC;		//!	in MeV, sigma for gaus
	Double_t fBeamX_MC;			//!	in cm, x position of beam at target
	Double_t fBeamY_MC;			//!	in cm, x position of beam at target
	Double_t fBeamX_sigma_MC;		//!	in cm; x position sigma of beam at target
	Double_t fBeamY_sigma_MC;		//!	in cm; x position sigma of beam at target

	Double_t fT1SimPosition;	//!	position of the first telescope in cm; used in MC
	Double_t fT2SimPosition;	//!	position of the second telescope in cm; used in MC

	//detector thicknesses in mcm
	Double_t fX11_FD;		//!
	Double_t fX11;			//!
	Double_t fX11_BD;		//!

	Double_t fX12_FD;		//!
	Double_t fX12;			//!
	Double_t fX12_BD;		//!

	//#define	XD13F	14.	//fixme original value		probably in Si equivalent
	Double_t fX13_FD;		//!

	Double_t fX21_FD;		//!
	Double_t fX21;			//!
	Double_t fX21_BD;		//!

	Double_t fX22_FD;		//!
	Double_t fX22;			//!
	Double_t fX22_BD;		//!
	//#define	XD23F	14.		//fixme original value		probably in Si equivalent
	Double_t fX23_FD;		//!

private:
//	static TRandom3 ranPosition;
	static void printProgBar(Int_t percent);
	static void printProgBar(Int_t i, Int_t inputs);
	void CreateTELosses();
	void SetWorkDir();

public:
	BeWork();
	BeWork(const char* configfile);
	BeWork(BeWork &);
	virtual ~BeWork();
	ClassDef(BeWork, 1);

	void ReadConfigFile();
	const char* GetWorkDir();

	//experimental data analysis
//	Int_t FillExpRun();
	Int_t FillExpFile(const char* inputrawfile, const char* outputfile,
			Long64_t noevents = 0, Option_t *opt = ""); //experimental data processing
	Int_t FillBeExpFile(const char *inputfile, const char* outputfile, Long64_t noevents = 0);


	//simulations
	void FillSimFile(const char* outputfile, const Int_t noevents,
			const char* generator = "", Option_t *opt = "CREATE",
			Double_t beThetaMin = 0., Double_t beThetaMax = TMath::Pi(),
			UInt_t gseed = 0/*, const char* cutfile = ""*/);	//simulation of measured variables using BinaryReaction class
	Int_t FillBeSimFile(const char *inputfile, const char* outputfile, Long64_t noevents = 0);
	static void MixSimBeFiles(const Int_t infiles, const char* treename, ...);

	TGeoManager* BuildGeometry();	//using cm size unit
	static TGeoVolume* MakeAnnularDetector(Int_t nosec, Int_t norings,
			Double_t siThickness, Double_t frontdl, Double_t backdl);
	static TGeoVolume* MakeCsIDetector();
	static TGeoVolume* MakeCsIDetectorMS(TString name);
	static TGeoVolume* MakeTarget();
	void ParticleTracking(const TLorentzVector *particle, const Int_t pID,
			TGeoManager *geom, BeEvent *event = 0, TRandom3 *detres = 0,
			Double_t beamX = 0., Double_t beamY = 0., Double_t beamZ = 0.);
	void MonteCarloState(const Int_t noevents, const char* generator,
			TTree *writetree, BeEvent *besimevent, TGeoManager *geometry,
			TTree* beampos, Double_t reactionAngleMin,
			Double_t reactionAngleMax, UInt_t gseed);

	//could be one function, just using the switch between the sources of simulated events
	//fill the file with kinematical information only by simulated events
	void FillSimKinFile(Int_t INPUTS = 0,
			Double_t beamtheta = 0., Double_t beamphi = 0.,
			const char* outputfile = "collision.root",
			Option_t *opt = "CREATE"); //simulation of kinematic variables using BinaryReaction class; opt: file access option
	void FillSimKinFile(const char* generator, Int_t INPUTS = 0,
			Double_t beamtheta = 0., Double_t beamphi = 0.,
			const char* outputfile = "collision_g.root",
			Option_t *opt = "CREATE"); //simulation of kinematic variables using G. generator; opt: file access option

	//general functions
	Int_t FillBeFile(const char* inputfile, Long64_t noevents,
			const char* rtree, const char* rbranch, const char* outputfile,
			const char* wtree, const char* wbranch, Option_t *opt = ""); //file with Be event only data processing
	static TTree* OpenTree(const char* inputfile, const char* treename,
			const Color_t col = 1, const char* friendtreename = "");
	static TChain* OpenChain(const char* inputfile, int first, int last,
			const char* treename, const Color_t color = 1, const char* friendtreename = "", Option_t* option = "");
	static Double_t CmToMic() { return 10000.; };
	static Double_t MicToCm() { return 0.0001; };
	static Int_t CountLines(const char* file, Int_t maxlinelength = 1000);





};


//#endif /* BEWORK_H_ */