ATLAS Offline Software
Functions | Variables
MDT_ResponseTest.cxx File Reference
#include "MDT_Response/MDT_Response.h"
#include "CLHEP/Random/RandomEngine.h"
#include "CLHEP/Random/RanluxEngine.h"
#include "CLHEP/Random/RandPoisson.h"
#include "CLHEP/Random/RandFlat.h"
#include "TH1.h"
#include "TFile.h"
#include <cerrno>
#include <climits>
#include <cstdlib>
#include <iostream>
#include "CxxUtils/checker_macros.h"

Go to the source code of this file.

Functions

CLHEP::RandFlat ranFlat (ranEngine)
 
double generateFlat ()
 
double generateRadius ()
 
double generatePositionAlongTube ()
 
void generateEvents (int eventMax)
 
int main (int argc, char *argv[])
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 
CLHEP::RanluxEngine ranEngine
 
MDT_Response response
 
double tubeMax = 14.7
 
double tubeLength = 5000.
 

Function Documentation

◆ generateEvents()

void generateEvents ( int  eventMax)

Definition at line 46 of file MDT_ResponseTest.cxx.

46  {
47  TH1* adcHist = new TH1F("adc","adc",400,0,200);
48  TH1* driftHist = new TH1F("driftTime","driftTime",1000,0,1000);
49  TH1* radiusHit = new TH1F("radiusHit","radiusHit",100,0,tubeMax);
50  TH1* radiusNoHit = new TH1F("radiusNoHit","radiusNoHit",100,0,tubeMax);
51  TH1* posLengthHit = new TH1F("posLengthHit","posLengthHit",100,0,tubeLength);
52  TH1* posLengthNoHit = new TH1F("posLengthNoHit","posLengthNoHit",100,0,tubeLength);
53  for( int i=0;i<eventMax; ++i ){
54 
55  // generate drift radius + position along tube
56  double radius = generateRadius();
57  double positionAlongTube = generatePositionAlongTube();
58  response.SetSegment(radius,positionAlongTube);
59 
60  // check whether tube fired as we also simulate tube inefficiency
61  bool hasHit = response.GetSignal(&ranEngine);
62  if( hasHit ){
63  // get the drift time (TDC count) and ADC
64  double driftTime = response.DriftTime();
65  double adc = response.AdcResponse();
66  adcHist->Fill(adc);
67  driftHist->Fill(driftTime);
68  radiusHit->Fill(radius);
69  posLengthHit->Fill(positionAlongTube);
70  }else{
71  radiusNoHit->Fill(radius);
72  posLengthNoHit->Fill(positionAlongTube);
73  }
74 
75  }
76 
77 }

◆ generateFlat()

double generateFlat ( )

Definition at line 34 of file MDT_ResponseTest.cxx.

34  {
35  return ranFlat.fire();
36 }

◆ generatePositionAlongTube()

double generatePositionAlongTube ( )

Definition at line 42 of file MDT_ResponseTest.cxx.

42  {
43  return tubeLength*generateFlat();
44 }

◆ generateRadius()

double generateRadius ( )

Definition at line 38 of file MDT_ResponseTest.cxx.

38  {
39  return tubeMax*generateFlat();
40 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 79 of file MDT_ResponseTest.cxx.

79  {
80 
81  int eventMax = 20000;
82  if( argc > 1 ) {
83  char *endptr;
84  errno = 0;
85  long convArg = strtol(argv[1], &endptr, 0);
86  if(errno == ERANGE || *endptr != '\0' || argv[1] == endptr) {
87  std::cout<<"Invalid parameter! Quit now!"<<std::endl;
88  exit(1);
89  }
90  // Only needed if sizeof(int) < sizeof(long)
91  if(convArg < INT_MIN || convArg > INT_MAX) {
92  std::cout<<"Invalid parameter! Quit now!"<<std::endl;
93  exit(1);
94  }
95  int tempMax = (int) convArg;
96  if (tempMax > 0) eventMax = tempMax;
97  }
98 
99  std::cout << " Starting simulation of MDT_response, events " << eventMax << std::endl;
100 
101  TFile* outputFile = new TFile("MDT_ResponseTest.root","RECREATE");
102 
103  // simulate long chamber
104  tubeLength = 5000.;
105  TDirectory* dir = outputFile->mkdir("LongTubes");
106  dir->cd();
107  generateEvents(eventMax);
108 
109  // simulate short chamber
110  tubeLength = 500.;
111  dir = outputFile->mkdir("ShortTubes");
112  dir->cd();
113  generateEvents(eventMax);
114 
115  // simulate short chamber, large incident angle
116  double increasedPathLength = 0.25; // here one could use the angle
117  response.SetClusterDensity(8.5*increasedPathLength);
118  dir = outputFile->mkdir("ShortTubesMediumAngle");
119  dir->cd();
120  generateEvents(eventMax);
121 
122 // // simulate short chamber, large incident angle
123 // increasedPathLength = 4; // here one could use the angle
124 // response.SetClusterDensity(8.5*increasedPathLength);
125 // dir = outputFile->mkdir("ShortTubesLargeAngle");
126 // dir->cd();
127 // generateEvents(eventMax);
128 
129  outputFile->Write();
130  outputFile->Close();
131 
132  return 0;
133 }

◆ ranFlat()

CLHEP::RandFlat ranFlat ( ranEngine  )

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 21 of file MDT_ResponseTest.cxx.

◆ ranEngine

CLHEP::RanluxEngine ranEngine

Definition at line 24 of file MDT_ResponseTest.cxx.

◆ response

MDT_Response response

Definition at line 28 of file MDT_ResponseTest.cxx.

◆ tubeLength

double tubeLength = 5000.

Definition at line 32 of file MDT_ResponseTest.cxx.

◆ tubeMax

double tubeMax = 14.7

Definition at line 31 of file MDT_ResponseTest.cxx.

MDT_Response::DriftTime
double DriftTime() const
Definition: MDT_Response.h:179
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
response
MDT_Response response
Definition: MDT_ResponseTest.cxx:28
generateEvents
void generateEvents(int eventMax)
Definition: MDT_ResponseTest.cxx:46
generateFlat
double generateFlat()
Definition: MDT_ResponseTest.cxx:34
generateRadius
double generateRadius()
Definition: MDT_ResponseTest.cxx:38
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
tubeMax
double tubeMax
Definition: MDT_ResponseTest.cxx:31
TRT::Hit::driftTime
@ driftTime
Definition: HitInfo.h:43
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
generatePositionAlongTube
double generatePositionAlongTube()
Definition: MDT_ResponseTest.cxx:42
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
calibdata.exit
exit
Definition: calibdata.py:236
beamspotman.dir
string dir
Definition: beamspotman.py:623
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MDT_Response::AdcResponse
double AdcResponse() const
Definition: MDT_Response.h:191
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
MDT_Response::SetClusterDensity
void SetClusterDensity(double dens)
Definition: MDT_Response.h:201
ranFlat
CLHEP::RandFlat ranFlat(ranEngine)
ranEngine
CLHEP::RanluxEngine ranEngine
Definition: MDT_ResponseTest.cxx:24
tubeLength
double tubeLength
Definition: MDT_ResponseTest.cxx:32
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
MDT_Response::SetSegment
void SetSegment(double r, double x)
Definition: MDT_Response.h:105
MDT_Response::GetSignal
bool GetSignal(CLHEP::HepRandomEngine *rndmEngine)
Definition: MDT_Response.cxx:254