Pluto v6.3.0
Loading...
Searching...
No Matches
PReaction.h
Go to the documentation of this file.
1// Author: M.A. Kagarlis
2// Written: 03.02.99
3// Revised: 21.04.05 R.H.
4// PReaction Class Header
5
6#ifndef _PREACTION_H_
7#define _PREACTION_H_
8
9#include "TClonesArray.h"
10#include "TTree.h"
11#include "TFile.h"
12#include "TMethodCall.h"
13#include "PChannel.h"
14// #include "G__ci.h"
15
17#include "PStdData.h"
18#include "PFileOutput.h"
19#include "PBulkInterface.h"
20#include "PProjector.h"
21#include "PPlutoBulkDecay.h"
22
23#define MAX_FILEOUTPUT 5
24
25
26#define MIN_PARTICLE_STACKSIZE 500
27#define INC_PARTICLE_STACKSIZE 100
28#define MAX_PARTICLE_STACKSIZE 10000
29#define MAX_REACTION_FILTERS 100
30
31
32class TPythia6;
33class PFilter;
34
36
37class PReaction : public TObject {
38
39 friend class PDecayManager;
40 public:
41
43
44 PReaction(const char *filename);
45
46 PReaction(PChannel **, const char *, int n=2, int f0=1, int f1=0, int f2=0, int f3=0, TTree *ttree=NULL);
47
48 PReaction(PChannel **, int n=2, unsigned int ff=0, TTree *ttree=NULL, const char *filename=NULL);
49
50 PReaction(Double_t momentum, const char *beam, const char *target, const char *reaction, const char *file_name=NULL,
51 Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL);
52 // build reaction from a descriptor string
53 PReaction(const char *command, const char *beam, const char *target,
54 const char *reaction, const char *file_name=NULL,
55 Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL);
56 // build reaction from a descriptor string but uses energy parser
57 PReaction(PParticle *, const char *reaction, const char *file_name=NULL,
58 Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL);
59 // build reaction from a descriptor string but uses a seed particle
60
61 void AddReaction(const char *reaction);
62 //add a reaction to the list
63
65 // Reaction destructor
66
68
69 int loop(int i=-1, int wf=0, int verbose=1) {
70 //kept for backward compatibility
71 return Loop(i, wf, verbose);
72 };
73
74 int Loop(int i=-1, int wf=0, int verbose=1);
75 // number of events to simulate
76
77 int GetNumAll() { return ndpar; }
78 // returns number of all the particles in the reaction
79
80 int *GetCIndex() {
81 return cindex.GetArray(); }
82 // returns product channel index
83
84 void VertexYes() {
85 // turn on vertex calculation after initialization
86 if (IsExtTree()) return;
87 getVERTEX = 1;
88 ropt = ropt | ff2;
89 }
90
91 void VertexNo() {
92 // turn off vertex calculation after initialization
93 if (IsExtTree()) return;
94 getVERTEX = 0;
95 ropt=~((~ropt)|ff2);
96 }
97
98
99 void allParticles() {
100 // put all particles on root file after initialization
101 if (IsExtTree()) return;
102 allPARTICLES = 1;
103 ropt = ropt | ff0;
104 }
105
107 // put tracked particles on root file file after initialization
108 if (IsExtTree()) return;
109 allPARTICLES = 0;
110 ropt=~((~ropt)|ff0);
111 }
112
113 void asciiYes() {
114 // enable ascii output for GEANT after initialization
115 if (IsExtTree()) return;
116 asciiOUTPUT = 1;
117 ropt = ropt | ff3;
118 SetName(filename);
119 }
120
121 void asciiNo() {
122 // disable ascii output for GEANT after initialization
123 if (IsExtTree()) return;
124 asciiOUTPUT = 0;
125 ropt=~((~ropt)|ff3);
126 SetName(filename);
127 }
128
129 void SetName(const char *);
130 // sets up output file names
131
132 PParticle **GetProducts() { return particle_stack; }
133 // returns product pointer
134
135 void SetFilter(int ch_id, PFilter *filter);
136 // This function is invoked by the Filter class. It directs loop to
137 // impose a filter at address (*filter) following the decay represented
138 // by the reaction Channel number ch_id. See also PFilter.
139
140 PFilter **GetFilter() { return NULL; }
141 // returns pointer to array of existing filters
142
143 void Print(const Option_t *delme=NULL) const;
144 void PrintReport() const; //Print a final report after sampling
145
146 void Close();
147 // close root output file
148
149 void SetHGeant(int flag) {HGeant = (flag!=0);} // set to 1, if PLUTO is run
150 // from the HGeant prompt
151 void setHGeant(int flag) {SetHGeant(flag);}; //backward comp.
152
153 void SetUserSelection(Int_t (*f)(PParticle*)) { // compiled user selection
154 SetUserSelection((void*)f);
155 }
156 void SetUserSelection(void *f); // interpreted user selection
157
158 void SetUserAnalysis(Int_t (*f)(PParticle**,Int_t)) { // compiled analysis
159 SetUserAnalysis((void*)f);
160 }
161 void SetUserAnalysis(void *f); // interpreted user analysis
162
163 void SetTrigCond(Int_t n) {nTrigCond = n;} // set trigger level
164
165 void setDecayAll(Float_t tau=1.) {
166 Warning ("setDecayAll", "This method is depreciated: use SetDecayAll()");
167 SetDecayAll(tau);
168 }
169
170 void SetDecayAll(Float_t tau=1.) {
171 // decay all particles with
172 // lifetime < tau (in ns)
173 // choose either Pluto or Pythia, depending on availability
174
175 //if (allPARTICLES && (asciiOUTPUT||HGeant) ) {
176 // Warning ("setDecayAll",
177 // "\nOptions decayALL & allPARTICLES & (asciiOUTPUT||HGeant) incompatible!\n\n");
178 // return;
179 //}
180
181 //Wrapper to the new scheme
182 tauMax = tau; // go to sec
183
184
185#ifdef USE_PYTHIA6
186
187 PPythiaBulkDecay *pl = new PPythiaBulkDecay();
188 pl->SetPythia(fPythia);
189 pl->SetTauMax(tauMax);
190 AddBulk(pl);
191
192#else
193
195 pl->SetRecursiveMode(1);
196 pl->SetTauMax(tauMax);
197 AddBulk(pl);
198
199#endif
200
201 }
202
203
204 void SetPythia(TPythia6 *p) {fPythia=p;} // set pointer to Pythia
205
206 void SetMaxFileSize(Int_t bytes) {nMaxBytes = bytes;} // set max file size
207
208#if 0
209 Int_t testPointer(void *p2f) { // determine type of pointer-to-function
210 // (see CINT reference manual for details)
211 if (p2f == NULL) return -1;
212 Int_t ret = G__isinterpretedp2f(p2f);
213 char *fname;
214 fname = G__p2f2funcname(p2f);
215 printf("Pointer to function %s is of type %d\n",fname,ret);
216 return ret;
217 }
218#endif
219
220 void SetWriteIndex(Bool_t flag) {
221 if (flag == kTRUE) writeINDEX = 1;
222 else writeINDEX = 0;
223 }
224
225 void DisableWeightReset() {weight_reset=0;};
226
227 Int_t GetReactionId() { return reactionId; }
228
232
234 if (fileoutput_pos == MAX_FILEOUTPUT ) {
235 Warning("AddFileOutput", "MAX_FILEOUTPUT reached");
236 return kFALSE;
237 }
238 files[fileoutput_pos++] = file;
239 return kTRUE;
240 }
241
242 Bool_t AddBulk(PBulkInterface *mybulk);
243 Bool_t AddPrologueBulk(PBulkInterface *mybulk); //Bulk IO before any decay
244
245 Bool_t Do(const char *command) {
246 return GetCurrentProjector()->AddCommand(command);
247 }
248 Bool_t Do(TH1 *f, const char *command, Int_t flag=1) {
249 return GetCurrentProjector()->AddHistogram(f,command,flag);
250 }
251 Bool_t Do(TH2 *f, const char *command, Int_t flag=1) {
252 return GetCurrentProjector()->AddHistogram(f,command,flag);
253 }
254 Bool_t Do(TH3 *f, const char *command, Int_t flag=1) {
255 return GetCurrentProjector()->AddHistogram(f,command,flag);
256 }
257 Bool_t Output(TNtuple *f, const char *command = (char *)"") {
258 return GetCurrentProjector()->AddOutputTNtuple(f,command);
259 }
260 Bool_t Input(TNtuple *f) {
262 }
263 Bool_t Output(const char *f, const char *command="") {
264 return GetCurrentProjector()->AddOutputASCII(f,command);
265 }
266 Bool_t Input(const char *f, const char *command="") {
267 return GetCurrentProjector()->AddInputASCII(f, command);
268 }
269 Bool_t CloseFile(void) {
270 return GetCurrentProjector()->CloseFile();
271 }
272
274 if (!bulkdecay_pos) {
275 current_projector = new PProjector();
276 AddBulk(current_projector);
277 } else {
278 if ((strcmp("PProjector", bulk[bulkdecay_pos-1]->GetName()) == 0)) {
279 if ((bulk[bulkdecay_pos-1]->GetPriority() > FILTER_PRIORITY) ||
280 ((PProjector *)bulk[bulkdecay_pos-1])->IsFileOpen()) {
281 current_projector = (PProjector *)bulk[bulkdecay_pos-1];
282 } else {
283 current_projector = new PProjector();
284 AddBulk(current_projector);
285 }
286 } else {
287 current_projector = new PProjector();
288 AddBulk(current_projector);
289 }
290/* if ((strcmp("PProjector",bulk[bulkdecay_pos-1] -> GetName())==0) */
291/* && (bulk[bulkdecay_pos-1] -> GetPriority() > FILTER_PRIORITY)) { */
292/* current_projector = (PProjector *)bulk[bulkdecay_pos-1]; */
293/* } else { */
294
295/* current_projector = new PProjector(); */
296/* AddBulk(current_projector); */
297/* } */
298 }
299 return current_projector;
300 }
301
302 void Preheating(Int_t num) {pre_heating=num;}; //Perform num dummy decays
303
304 void IsInline(void) {
305 //pure inline PReaction, e.g. FAIRROOT
306 is_inline = 1;
307 }
308
309 private:
310
311 Int_t reactionId; // reaction identifier
312 Int_t (*userSelection)(PParticle*);
313 Int_t (*userAnalysis)(PParticle**,Int_t);
314
315 Int_t num_filters;
316 Int_t filter_keys[MAX_REACTION_FILTERS], filter_counter[MAX_REACTION_FILTERS];
317 Double_t *filter_values[MAX_REACTION_FILTERS];
318
319 int nchan, ntpar, ndpar, nclones, loop_count, reset_count, status;
320 // number of reaction channels (channels),
321 // number of non-decayed (tracked) particles,
322 // number of decay products,
323 // number of filters
324 // number of times loop function invoked
325 // number of reset calls
326 // error status
327 static int activeCnt; // number of clones for root branches,
328
329 TArrayI cindex, dindex, ftrack;
330 // channel index of the decay products,
331 // indices of parents to channels after the 1st
332 // flag indicating whether particle is tracked (1) or not (0)
333
334 unsigned int ropt, allPARTICLES, asciiOUTPUT, writeINDEX,
335 resetCHANNELS, getVERTEX, extTREE, HGeant, decayALL, inactivate_decayed_particles;
336 static const unsigned int ff0, ff1, ff2, ff3, ff4;
337 // option flags (see constructor)
338
339 Float_t tauMax; // max lifetime for decay (see decayALL option)
340
341 PChannel **channel;
342 // address of array of pointers to reaction channels
343
344 TString filename, file1, file2, original_filename,reaction_string;
345 // output file name, filename.evt for (GEANT), filename.root (ROOT)
346 void ConvertFilename(void);
347
348 TTree *tree;
349 // address of the event tree
350
351 PParticle **particle_stack;
352 // Particle stack for the event loop
353 int decay_done[MAX_PARTICLE_STACKSIZE];
354 int stacksize;
355
356 PParticle **particle;
357 //particles from the PChannel list
358
359 static TClonesArray *evt[MAX_NUM_BRANCHES+1];
360 // particle clone
361
362 TFile *rootfile;
363 // the root output file
364
365 int size_branches;
366 int key_branches[MAX_NUM_BRANCHES];
367 int doonce;
368
369 int fileoutput_pos;
371 int bulkdecay_pos, pro_bulkdecay_pos;
372
374 PBulkInterface *pro_bulk[MAX_BULKDECAY];
375 PProjector *current_projector;
376
377
378 Int_t nTrigCond;
379
380 TPythia6 *fPythia;
381
382 void SetReactionId(void);
383 // calculate reaction id from list of products of 1st channel
384
385 void SetUp(PChannel **);
386 // get the channels and particles, identify the physics, set up the defaults.
387
388 Bool_t parse_script(const char *e, const char *beam, const char *target, const char *reaction, const char *file_name=NULL,
389 Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL);
390
391 void InitLoop();
392 // resets the dynamical objects of the reaction and opens files
393
394 Int_t IsExtTree() { return extTREE; }
395 // check whether tree is external
396
397 Int_t ParseChannel(PParticle *parent, const char *channel,
398 TList &plutoList, Int_t &numChannels);
399 // parse string describing reaction
400 PParticle *MakeParticle(char * name);
401
402 Int_t nMaxBytes;
403
404 static FILE *asciif;
405 static Int_t globalEventCounter;
406
407 Int_t weight_reset;
408 Int_t is_inline;
409
410 // beam axis skewing and smearing
411 /* Double_t thetaBeam, phiBeam, sigmaBeam; */
412 /* Double_t beam_energy,beam_momentum; //for consecutive reactions */
413 const char *r_beam, *r_target;
414
415 //From batch system
416 Double_t *vertex_x, *vertex_y, *vertex_z;
417 Double_t *event_impact_param , *event_plane;
418 Double_t *weight_version;
419
420 // ascii file
421
422 static void passEvent(float, float, float, int, int*, int*, int*, int*,
423 float*, float*, float*, float*,
424 float*, float*, float*, float*) {;}
425 // dummy HGeant interface. Comment to make HGeant routine visible!
426
427
428 Int_t pre_heating;
429 PReaction *sub_reaction;
430
431 ClassDef(PReaction, 0) //Pluto Reaction Class
432
433};
434
435#endif // _PREACTION_H_
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
#define FILTER_PRIORITY
#define MAX_BULKDECAY
Definition PChannel.h:23
#define MAX_NUM_BRANCHES
Definition PDefines.h:19
PDistributionManager * makeDistributionManager()
#define MAX_FILEOUTPUT
Definition PReaction.h:23
Int_t select(PParticle *)
#define MAX_PARTICLE_STACKSIZE
Definition PReaction.h:28
#define MAX_REACTION_FILTERS
Definition PReaction.h:29
TFile * f2
PFermiMomentumGA * f1
TFile * f
Definition analyze_g12C.C:8
TClonesArray * evt
PPlutoBulkDecay * pl
Definition bulk_decay.C:6
Bool_t CloseFile(void)
Definition PProjector.h:94
Bool_t AddInputASCII(const char *filename, const char *command="")
Bool_t AddOutputTNtuple(TNtuple *n, const char *command="")
Bool_t AddOutputASCII(const char *filename, const char *command="")
Bool_t AddCommand(const char *command)
Bool_t AddInputTNtuple(TNtuple *n, const char *command="")
Bool_t AddHistogram(TH3 *histo, const char *command="", Int_t fillflag=1)
void trackedParticles()
Definition PReaction.h:106
PReaction(const char *filename)
void DisableWeightReset()
Definition PReaction.h:225
void asciiNo()
Definition PReaction.h:121
void InitChannels()
int loop(int i=-1, int wf=0, int verbose=1)
Definition PReaction.h:69
PDistributionManager * GetDistributionManager(void)
Definition PReaction.h:229
void IsInline(void)
Definition PReaction.h:304
void PrintReport() const
void SetTrigCond(Int_t n)
Definition PReaction.h:163
void SetUserAnalysis(Int_t(*f)(PParticle **, Int_t))
Definition PReaction.h:158
Int_t GetReactionId()
Definition PReaction.h:227
Bool_t Do(TH1 *f, const char *command, Int_t flag=1)
Definition PReaction.h:248
void SetUserSelection(Int_t(*f)(PParticle *))
Definition PReaction.h:153
Bool_t Input(TNtuple *f)
Definition PReaction.h:260
Bool_t AddFileOutput(PFileOutput *file)
Definition PReaction.h:233
void SetUserSelection(void *f)
void VertexYes()
Definition PReaction.h:84
PReaction(const char *command, const char *beam, const char *target, const char *reaction, const char *file_name=NULL, Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL)
void setHGeant(int flag)
Definition PReaction.h:151
Bool_t Output(const char *f, const char *command="")
Definition PReaction.h:263
Bool_t AddPrologueBulk(PBulkInterface *mybulk)
friend class PDecayManager
Definition PReaction.h:39
int * GetCIndex()
Definition PReaction.h:80
PReaction(PChannel **, int n=2, unsigned int ff=0, TTree *ttree=NULL, const char *filename=NULL)
Bool_t Input(const char *f, const char *command="")
Definition PReaction.h:266
Bool_t Output(TNtuple *f, const char *command=(char *)"")
Definition PReaction.h:257
void AddReaction(const char *reaction)
void SetUserAnalysis(void *f)
void VertexNo()
Definition PReaction.h:91
Bool_t Do(TH2 *f, const char *command, Int_t flag=1)
Definition PReaction.h:251
void SetWriteIndex(Bool_t flag)
Definition PReaction.h:220
int GetNumAll()
Definition PReaction.h:77
void asciiYes()
Definition PReaction.h:113
void SetPythia(TPythia6 *p)
Definition PReaction.h:204
void SetHGeant(int flag)
Definition PReaction.h:149
int Loop(int i=-1, int wf=0, int verbose=1)
void SetName(const char *)
PProjector * GetCurrentProjector(void)
Definition PReaction.h:273
void Close()
void SetDecayAll(Float_t tau=1.)
Definition PReaction.h:170
Bool_t Do(const char *command)
Definition PReaction.h:245
Bool_t AddBulk(PBulkInterface *mybulk)
PParticle ** GetProducts()
Definition PReaction.h:132
void SetFilter(int ch_id, PFilter *filter)
void Preheating(Int_t num)
Definition PReaction.h:302
PFilter ** GetFilter()
Definition PReaction.h:140
void SetMaxFileSize(Int_t bytes)
Definition PReaction.h:206
PReaction(PChannel **, const char *, int n=2, int f0=1, int f1=0, int f2=0, int f3=0, TTree *ttree=NULL)
PReaction(PParticle *, const char *reaction, const char *file_name=NULL, Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL)
void allParticles()
Definition PReaction.h:99
void setDecayAll(Float_t tau=1.)
Definition PReaction.h:165
PReaction(Double_t momentum, const char *beam, const char *target, const char *reaction, const char *file_name=NULL, Int_t f0=1, Int_t f1=0, Int_t f2=0, Int_t f3=0, TTree *ttree=NULL)
Bool_t CloseFile(void)
Definition PReaction.h:269
Bool_t Do(TH3 *f, const char *command, Int_t flag=1)
Definition PReaction.h:254
void Print(const Option_t *delme=NULL) const
PParticle * p
Definition dp_mult.C:24
TString filename("eta_dalitz_a")
Int_t n
Definition etap+omeg.C:21
PParticle * target
Definition fermi_dd.C:9
PParticle * beam