ATLAS Offline Software
Loading...
Searching...
No Matches
MDT_ResponseTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "CLHEP/Random/RandomEngine.h"
8#include "CLHEP/Random/RanluxEngine.h"
9#include "CLHEP/Random/RandPoisson.h"
10#include "CLHEP/Random/RandFlat.h"
11
12#include "TH1.h"
13#include "TFile.h"
14
15#include <cerrno>
16#include <climits>
17#include <cstdlib>
18#include <iostream>
19
21ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // standalone application
22
23// random generator
24CLHEP::RanluxEngine ranEngine;
25CLHEP::RandFlat ranFlat(ranEngine);
26
27// create MDT response simulation object
29
30
31double tubeMax = 14.7;
32double tubeLength = 5000.;
33
34double generateFlat() {
35 return ranFlat.fire();
36}
37
39 return tubeMax*generateFlat();
40}
41
45
46void generateEvents( int eventMax ) {
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}
78
79int main(int argc, char* argv[] ){
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}
double generateRadius()
CLHEP::RandFlat ranFlat(ranEngine)
double tubeMax
double tubeLength
CLHEP::RanluxEngine ranEngine
double generatePositionAlongTube()
double generateFlat()
void generateEvents(int eventMax)
MDT_Response response
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
int main()
Definition hello.cxx:18