AliRoot Core  edcc906 (edcc906)
MakeFakeHits.C
Go to the documentation of this file.
1 #include <iomanip>
2 void
4 {
5  if (!gAlice) {
6  std::cerr << "This script must be run in AliROOT" <<std::edl;
7  return;
8  }
9 
10  // Initialize
11  gAlice->InitMC("$ALICE_ROOT/FMD/Config.C");
12 
13  // Get our detector
14  AliFMD* fmd = gAlice->GetDetector("FMD");
15  if (!fmd) {
16  std::cerr << "FMD object not defined" << std::endl;
17  return;
18  }
19  // Get the runloader
20  AliRunLoader* runLoader = gAlice->GetRunLoader();
21  if (!runLoader) {
22  std::cerr << "No run loader defined" << std::end;
23  // return;
24  }
25 
26  // OCDB manager
28  cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB")
29  cdb->SetRunNumber(0)
30 
31  // Geometry database
33  geom->Init();
34  geom->InitTransformations();
35 
36  // Parameter database
37  // AliFMDParameters* param = AliFMDParameters::Instance();
38  // param->Init(kFALSE, AliFMDParameters::kAltroMap);
40 
41  // Monte-carlo application
42  AliMC* mc = gAlice->GetMCApp();
43  if (!mc) {
44  std::cerr << "No MC application defined" << std::endl;
45  return;
46  }
47 
48  // Make primaries - one for each strip
49  mc->BeginEvent();
50  Int_t ntr = 0;
51  for (size_t i = 0; i < 51200; i++) {
52  mc->PushTrack(1, -1, 211,
53  0, 0, 0, 0,
54  0, 0, 0, 0,
55  0, 0, 0,
56  kPPrimary, ntr);
57  // std::cout << "Made track # " << ntr << std::endl;
58  }
59 
60  // Make hits
61  ntr = 0;
62  for (UShort_t d = 1; d <= 3; d++) {
63  UShort_t nrng = (d == 1 ? 1 : 2);
64  for (UShort_t ir = 0; ir < nrng; ir++) {
65  Char_t r = (ir == 0 ? 'I' : 'O');
66  UShort_t nsec = (ir == 0 ? 20 : 40);
67  UShort_t nstr = (ir == 0 ? 512 : 256);
68  for (UShort_t s = 0; s < nsec; s++) {
69  for (UShort_t t = 0; t < nstr; t++) {
70  mc->BeginPrimary();
71 
72  Double_t x, y, z;
73  geom->Detector2XYZ(d, r, s, t, x, y, z);
74  UInt_t ddl, board, altro, channel;
75  UShort_t timebin;
76  map.Detector2Hardware(d, r, s, t, 0, 0, 1,
77  ddl, board, altro, channel, timebin);
78  Float_t e = Float_t(s) / nsec + Float_t(t)/(100*nstr);
79  e = Float_t(timebin % 64) / 64 * 1.5;
80 
81  std::cout << "FMD" << d << r << "[" << std::setfill('0')
82  << std::setw(2) << s << "," << std::setw(3) << t
83  << "] " << std::setfill(' ')
84  << std::setw(4) << timebin << " ("
85  << std::setw(10) << x << ","
86  << std::setw(10) << y << ","
87  << std::setw(10) << z << ") -> "
88  << std::setw(10) << e << "\t\r"
89  << std::flush;
90  fmd->AddHitByFields(ntr, // Int_t track,
91  d, // UShort_t detector,
92  r, // Char_t ring,
93  s, // UShort_t sector,
94  t, // UShort_t strip,
95  x, // Float_t x=0,
96  y, // Float_t y=0,
97  z, // Float_t z=0,
98  0, // Float_t px=0,
99  0, // Float_t py=0,
100  0, // Float_t pz=0,
101  e, // Float_t edep=0,
102  211, // Int_t pdg=0,
103  0, // Float_t t=0,
104  0.03); // Float_t len=0,
105  mc->FinishPrimary();
106  ntr++;
107  } // Strip
108  } // Sector
109  std::cout << std::endl;
110  } // Ring
111  } // Detector
112 
113  // End of event.
114  mc->FinishEvent();
115 
116  // End of run
117  gAlice->FinishRun();
118  gGeoManager->Export("geometry.root");
119 
120 }
121 
122 
123 
124 
125 
virtual void FinishEvent()
Definition: AliMC.cxx:1553
virtual void InitTransformations(Bool_t force=kFALSE)
virtual void BeginPrimary()
Definition: AliMC.cxx:1169
Forward Multiplicity Detector based on Silicon wafers. This class is the driver for especially simula...
Definition: AliFMD.h:306
virtual void FinishPrimary()
Definition: AliMC.cxx:1484
Singleton object of FMD geometry descriptions and parameters. This class is a singleton that handles ...
Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam, UShort_t preSamples, UShort_t sampleRate, UShort_t &ddl, UShort_t &board, UShort_t &altro, UShort_t &channel, UShort_t &timebin) const
TGeoManager * gGeoManager
Class that encodes a map to/from ALTRO hardware address to FMD detector coordinates.
AliRun * gAlice
Definition: AliRun.cxx:62
void Detector2XYZ(UShort_t detector, Char_t ring, UShort_t sector, UShort_t strip, Double_t &x, Double_t &y, Double_t &z) const
virtual void Init()
virtual void PushTrack(Int_t done, Int_t parent, Int_t pdg, const Float_t *pmom, const Float_t *vpos, const Float_t *polar, Float_t tof, TMCProcess mech, Int_t &ntr, Float_t weight=1, Int_t is=0) const
Definition: AliMC.cxx:1925
void SetDefaultStorage(const char *dbString)
Definition: AliMC.h:30
virtual AliFMDHit * AddHitByFields(Int_t track, UShort_t detector, Char_t ring, UShort_t sector, UShort_t strip, Float_t x=0, Float_t y=0, Float_t z=0, Float_t px=0, Float_t py=0, Float_t pz=0, Float_t edep=0, Int_t pdg=0, Float_t t=0, Float_t len=0, Bool_t stopped=kFALSE)
Definition: AliFMD.cxx:668
virtual void BeginEvent()
Definition: AliMC.cxx:1328
void MakeFakeHits()
Definition: MakeFakeHits.C:3
AliDetector * GetDetector(const char *name) const
Definition: AliRun.cxx:200
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
TEveGeoShape * geom
Definition: tpc_tracks.C:10
static AliFMDGeometry * Instance()
AliMC * GetMCApp() const
Definition: AliRun.h:53