]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TFluka/TFlukaScoringOption.cxx
Example macros for using AliAODv0 class
[u/mrichter/AliRoot.git] / TFluka / TFlukaScoringOption.cxx
CommitLineData
f0d336ab 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$*/
17
18#include "TFlukaScoringOption.h"
f450e9d0 19#include "TFlukaMCGeometry.h"
20#include <TGeoManager.h>
21#include <TGeoVolume.h>
22
8be76537 23ClassImp(TFlukaScoringOption)
f0d336ab 24
f450e9d0 25FILE* TFlukaScoringOption::fgFile(0x0);
26TFlukaMCGeometry* TFlukaScoringOption::fgGeom(0x0);
f0d336ab 27
28TFlukaScoringOption::TFlukaScoringOption()
29{
30 // Default constructor
31}
32
f450e9d0 33TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what)
34 : TNamed(name, sdum)
35{
36 // Constructor
37 fNopfl = nopfl;
38 fOutFile = outfile;
39 Int_t npar = (nopfl == 0)? 6 : 12;
40 for (Int_t i = 0; i < npar; i++) fWhat[i] = what[i];
41}
f0d336ab 42
f450e9d0 43TFlukaScoringOption::TFlukaScoringOption(const char* name, const char* sdum, Int_t nopfl, char* outfile, Float_t* what,
44 const char* det1, const char* det2, const char* det3)
f0d336ab 45 : TNamed(name, sdum)
46{
47 // Constructor
f450e9d0 48 fNopfl = nopfl + 2;
49 fOutFile = outfile;
50 Int_t npar = (nopfl == 0)? 6 : 12;
51 for (Int_t i = 0; i < npar; i++) fWhat[i] = what[i];
52
53 fName[0] = det1;
54 fName[1] = det2;
55 fName[2] = det3;
56}
57
58
59//--- GET METHODS
60//______________________________________________
61const char* TFlukaScoringOption::GetRegName(Int_t ndet)
62{
63 // Return ndet'th region name
64 return fName[ndet - 1];
65}
66
67//
68// Write Fluka Input Cards
69//
70void TFlukaScoringOption::WriteOpenFlukaFile()
71{
72 //
73 // Write Fluka input card for output file opening
74 //
75 fprintf(fgFile, "OPEN %10.1f %s\n",
76 GetLun(), "NEW");
77 fprintf(fgFile, "%s\n", GetFileName());
f0d336ab 78}
f450e9d0 79
80
81void TFlukaScoringOption::WriteFlukaInputCards()
82{
83 //
84 // Write the Fluka Input Cards for this scoring option
85 //
86
87 const char* cont_line = "&";
88
89//***************************************************************************
90//* Par()==0 only 6 parameter && regions by float *
91//* Par()==1 only 6 parameter && regions by Name *
92//* Par()==2 12 parameter && regions by float *
93//* Par()==3 12 parameter && regions by Name *
94//* Par()==4 12 parameter && regions by Name (for USRBIN only) *
95//***************************************************************************
96//
97// USRBIN
98//
99 if(strncmp(GetName(), "USRBIN", 6) == 0){
100 if (Par() == 0) {
101 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
102 What(1), What(2), GetLun(), What(4), What(5), What(6));
103 } else if (Par() == 1) {
104 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
105 What(1), What(2), GetLun(), What(4), What(5), What(6));
106 fprintf(fgFile, "USRBIN %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
107 What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
108 } else if (Par() == 2) {
109 if(What(1) == 2.0 || What(1) == 12){
110 fprintf(fgFile, "USRBIN %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
111 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
112 Float_t(GetRegionByName(GetRegName(2))), Float_t(GetRegionByName(GetRegName(3))));
113 fprintf(fgFile, "USRBIN %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
114 Float_t(GetRegionByName(GetRegName(1))), Float_t(GetRegionByName(GetRegName(2))),
115 Float_t(GetRegionByName(GetRegName(3))), 1., 1., 1., cont_line);
116 } else {
117 printf("Check consistency of SetUserScoring values \n");
118 }
119 }
120 }
121
122//
123// USRBDX
124//
125 if(strncmp(GetName(), "USRBDX", 6) == 0){
126 if (Par() == 2) {
127 fprintf(fgFile, "USRBDX %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
128 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
129 Float_t(GetRegionByName(GetRegName(2))), What(6));
130 } else if (Par() == 3) {
131 fprintf(fgFile, "USRBDX %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
132 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))),
133 Float_t(GetRegionByName(GetRegName(2))), What(6));
134 fprintf(fgFile, "USRBDX %10.1f%10.4g%10.1f%10.1f%10.1f%10.1f %s\n",
135 What(7), What(8), What(9), What(10), What(11), What(12), cont_line);
136 }
137 }
138
139//
140// USTRACK
141//
142 if(strncmp(GetName(), "USRTRACK", 6) == 0){
143 fprintf(fgFile, "USRTRACK %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
144 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))), What(4), What(5));
145 fprintf(fgFile, "USRTRACK %10.1f%10.4g %s\n",
146 What(7), What(8), cont_line);
147 }
148
149//
150// USRCOLL
151//
152 if(strncmp(GetName(), "USRCOLL", 6) == 0){
153 fprintf(fgFile, "USRCOLL %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",
154 What(1), What(2), GetLun(), Float_t(GetRegionByName(GetRegName(1))), What(4), What(5));
155 fprintf(fgFile, "USRCOLL %10.1f%10.4g %s\n",
156 What(7), What(8), cont_line);
157 }
158}
159
160
161Int_t TFlukaScoringOption::GetRegionByName(const char* detname)
162{
163// Get number of region for a given detector name
164 TGeoVolume* vol = dynamic_cast<TGeoVolume*>((gGeoManager->GetListOfVolumes())->FindObject(detname));
165 Int_t ireg = (vol)? vol->GetNumber() : -999;
166 return ireg;
167}