Pluto v6.3.0
Loading...
Searching...
No Matches
PDecayManager.h
Go to the documentation of this file.
1// PDecayManager Class Header
2//
3// Author: Volker Hejny
4// Written: 27.08.99
5// Revised: 21.06.00 MK
6// Revised: 21.03.05 R. Holzmann
7//
8// This header file contains
9// template class PNextList
10// template class PStack
11// class PReactionList
12// class PDecayManager
13//
14// While all these classes are global, the first three originally
15// planned as to be private to PDecayChannel. Due to some (maybe
16// trivial) problems with nested classes using rootcint, they were
17// put in a global scope.
18// --------------------------------------------------------------------------
19
20#ifndef _PDECAYLIST_H_
21#define _PDECAYLIST_H_
22
23#include "TObject.h"
24class TTree;
25class TClonesArray;
26class PReaction;
27class PChannel;
28class PParticle;
29class TPythia6;
30class PDecayChannel;
31
33#include "PReaction.h"
34#include "PBulkInterface.h"
35#include "PProjector.h"
36
37// the following templates and the class PReactionList are
38// private members of PDecayManager, but I due to problems using
39// ClassImp() and ClassDef() with nested classes, they are
40// not derived from TObject. The members are all public for better
41// use inside PDecayManager.
42
43// template PNextList:
44// implements a linked list of pointers(!) to object T. A delete does
45// not imply a delete of the object T itself. If this is wanted -> use
46// member function Delete().
47template<class T>
48class PNextList {
49 public:
50 T *Curr; // Pointer to object T
51 PNextList *Next; // Pointer to next list node
52
53 PNextList() : Curr(NULL), Next(NULL) {};
54 PNextList(T *t) : Curr(t), Next(NULL) {};
55 ~PNextList() { if (Next) delete Next; };
56
57 void Add(T *t) {
58 if (!Curr)
59 Curr = t; // if node still empty
60 else if (!Next)
61 Next = new PNextList<T>(t); // if node has no successor
62 else
63 Next->Add(t);
64 }
65
66 void Delete() { // delete all T objects
67 delete Curr;
68 if (Next)
69 Next->Delete();
70 }
71};
72// end of template PNextList
73
74// template PStack:
75// implements a last-in-first-out standard stack via a single linked
76// list. Additionally the number of objects is counted.
77template<class T>
78class PStack {
79 public:
80 PNextList<T> *top; // Pointer to top node
81 Int_t Count;
82
83 PStack() : top(NULL), Count(0) {};
84 ~PStack() { delete top; }; // delete the nodes, not
85 // the object itself
86 void Push(T* t) {
87 PNextList<T> *temp = new PNextList<T>(t); // new node with object T
88 temp->Next = top; // position before top node
89 top = temp; // make new node the top node
90 Count++;
91 }
92
93 T *Pop() {
94 if (!top) return NULL;
95 T *t = top->Curr; // this object is to be returned
96 PNextList<T> *t2 = top; // store top to delete
97 top = top->Next;
98 t2->Next = NULL; // unlink
99 delete t2;
100 Count--;
101 return t;
102 }
103
104 // Clone doubles the whole stack. Either an empty stack is
105 // used (giving UseThis as an argument) or a new stack is
106 // produced.
107 PStack<T> *Clone(PStack<T> *UseThis = NULL) {
108 PStack<T> *t1;
109 if (UseThis)
110 t1 = UseThis;
111 else
112 t1 = new PStack();
113 if (!top)
114 return t1; // return an empty stack
115 t1->Push(top->Curr); // push top node object
116 PNextList<T> *t2 = top;
117 while (t2->Next) { // add all node in t2 to t1
118 t2 = t2->Next;
119 t1->top->Add(t2->Curr);
120 }
121 t1->Count = Count; // synchronize Count
122 return t1;
123 }
124};
125// end of template PStack
126
127// class PReactionList:
128// implements two connected stacks of PChannel to organize the
129// already processed decay channels and the work to do.
130// The variable ReactionWeight contains the overall weight of
131// this specific channel.
133 public:
137 Int_t ID;
138 static Int_t maxID;
139
143 ReactionWeight = 1.;
144 ID = ++maxID;
145 };
146
148 delete Finished;
149 delete ToDo;
150 }
151
153 PReactionList *newRL = new PReactionList;
154 Finished->Clone(newRL->Finished);
155 ToDo->Clone(newRL->ToDo);
157 return newRL;
158 }
159};
160// end of class PReactionList
161
162// class PDecayManager:
163// PDecayManager manages the decay modes of all available particles
164// in Pluto and builds all possible decay chains from one starting
165// particle.
166// The list of decay modes is empty by default. The user has to take
167// care about the filling of these list.
168
169class PDecayManager : public TObject {
170
171 private:
172
173 Int_t verbose; // verbose flag (0/1)
174 Double_t CurrentWeight; // weight of currently active reaction
175 Int_t CurrentReactionNumber; // serial number of currently active reaction
176
177 PNextList<PParticle> *UsedParticles; // collection of used particles to delete them later on
178 PNextList<PParticle*> *UsedParticleArrays; // same for particle arrays
179 PNextList<PChannel> *UsedChannels; // same for used channels
180
181 PNextList<PReactionList> *ReactionList; // collection of all possible decay branches
182 PNextList<PReactionList> *CurrentReactionListPointer; // pointer to the currently active decay branch
183 PChannel **ListForReaction; // used for PReaction
184 PReaction *CurrentReaction; // pointer to currently used PReaction
185 Int_t NumberOfReactions; // nb of reactions in ReactionList
186
187 Int_t decaychannel_param; // param for all known particle decay modes
188 Bool_t fHGeant; // set if PLUTO runs in HGeant
189 void* userSelection; // selection function
190 Int_t nTrigCond; // trigger multiplicity
191
192 Bool_t fWriteIndex; // write parent indices out, if set
193
194 TPythia6 *fPythia; // pointer to Pythia object
195
196
197 // ContructPChannel is used internally to construct a new PChannel from
198 // parent particle *p and the decay channel *c1 and store it in the
199 // ToDo stack of PReactionList *RL.
200 // If CopyFlag is set, the particle *p is copied before using. This
201 // is necessary for the top channel.
202 void ConstructPChannel(PParticle *p, PDecayChannel *c1,
203 PReactionList *RL, Int_t CopyFlag=0);
204
205 // utility function for PrintReactionList
206 void PrintReactionListEntry(PReactionList*, ostream &os) const;
207 void PrintChain(PParticle *p, PChannel **l, Int_t c, ostream &os) const;
208
209 // wrapper for PList.getName() to avoid error for composed
210 // particles
211 using TObject::GetName;
212 const char *GetName(Int_t id) const;
213 Int_t maxFileSize;
214 Float_t tauMax;
215
217
218 int fileoutput_pos;
220
221
222 int bulkdecay_pos, pro_bulkdecay_pos;
223
225 PBulkInterface *pro_bulk[MAX_BULKDECAY];
226 PProjector *current_projector;
227
228
229
230 public:
231
234
235 void SetVerbose(Int_t v = 1); // set verbose on/off
236
237 // add/assign/get a specific decay channel to one particle either by
238 // particle id, by an instance of PParticle or just by name
239 void AddChannel(Int_t id, PDecayChannel *n);
241 void AddChannel(const char *p, PDecayChannel *n);
242 PDecayChannel *GetChannel(Int_t id) const;
245
246 // set the default decay channel for this particle (according to PDG)
247 void SetDefault(Int_t id, Int_t recursive=0);
248 void SetDefault(PParticle *p, Int_t recursive=0);
249 void SetDefault(const char *p, Int_t recursive=0);
250
251 // clear the channel
252 void Clear(Int_t id);
254 void MyClear(char *);
255
256 void Clear(const Option_t *delme=NULL) {
257 if (delme) MyClear((char*) delme);
258 };
259
260
261
262 // by specifying one start particle InitReaction does look for all
263 // possible decay chains and lists them in ReactionList. The initial
264 // decay channel can be given either by a special decay channel or,
265 // if it is a standard particle, the standard decay channel can be used.
266 void InitReaction(PParticle *start, PDecayChannel *c1 = NULL);
267
268 // GetNextReaction calls the constructor of PReaction for the next
269 // reaction in ReactionList. The given parameters are forwarded
270 // to the constructor. If wf is set, the weight stored in the reaction
271 // list is transfered to the initial particle; each reaction is simulated
272 // with the same nb. of events, product particles have a proper weight set.
273 // The second form is obsolete (and implies wf=0)
274 PReaction *GetNextReaction(int wf, const char *name, int f0=0, int f1=0,
275 int f2=0, int f3=0, TTree *tt=NULL);
276 PReaction *GetNextReaction(const char *name, int f0=0, int f1=0, int f2=0,
277 int f3=0, TTree *tt=NULL);
278
279 // loop does a loop over all possible reaction channels and write
280 // the output in a file name.root. The arguments are the same as
281 // in GetNextReaction.
282 Int_t Loop(int num, int wf, const char* name, int f0=0,
283 int f1=0, int f2=0, int f3=0, int rf=0);
284 Int_t loop(int num, int wf, const char* name, int f0=0,
285 int f1=0, int f2=0, int f3=0, int rf=0) {
286 return Loop(num, wf, name, f0, f1, f2, f3, rf);
287 }
288
289 // GetCurrentWeight provides the weight factor of the actual
290 // reaction
292
293 // prints out the decay channel list
294 void Print(const Option_t *delme=NULL) const {
295 if (delme && strlen(delme)) {
296 MyPrint((char*) delme);
297 }
298 else MyPrint();
299 };
300
301 void MyPrint() const;
302
303 // print out information for one specific particle
304 void Print(Int_t id) const;
305 void Print(PParticle *p) const;
306 void MyPrint(char *name) const;
307
308 void SetHGeant(Int_t fH) {
309 fHGeant = fH;
310 }
311 void SetUserSelection(void *f) {
312 userSelection = f;
313 }
314 void SetUserSelection(Int_t (*f)(PParticle*)) {
315 userSelection = (void*)f;
316 }
317 void SetTrigCond(Int_t n) {
318 nTrigCond = n;
319 }
320
321 // visualize the decay chains
322 void PrintReactionList() const;
323
324 void SetPythia(TPythia6 *p) {
325 fPythia = p;
326 }
327 void SetMaxFileSize(Int_t bytes) {
328 maxFileSize = bytes;
329 }
330 void SetDecayAll(Float_t tau=1.) {
331 tauMax = tau;
332 }
333
335 pdist->Disable("helicity_angles");
336 }
340
341 void SetWriteIndex(Bool_t flag) {
342 fWriteIndex = flag;
343 }
344
346 if (fileoutput_pos == MAX_FILEOUTPUT ) {
347 Warning("AddFileOutput", "MAX_FILEOUTPUT reached");
348 return kFALSE;
349 }
350 files[fileoutput_pos++] = file;
351 return kTRUE;
352 }
353
354 //These interfaces are analogue to PReaction:
355 Bool_t AddBulk(PBulkInterface *mybulk);
356 Bool_t AddPrologueBulk(PBulkInterface *mybulk); //Bulk IO before any decay
357
358 Bool_t Do(const char *command) {
359 return GetCurrentProjector()->AddCommand(command);
360 }
361 Bool_t Do(TH1F *f, char *command) {
362 return GetCurrentProjector()->AddHistogram(f, command);
363 }
364 Bool_t Do(TH2F *f, char *command) {
365 return GetCurrentProjector()->AddHistogram(f, command);
366 }
367 Bool_t Output(TNtuple *f, char *command = (char *)"") {
368 return GetCurrentProjector()->AddOutputTNtuple(f, command);
369 }
370 Bool_t Input(TNtuple *f) {
372 }
374 if (!bulkdecay_pos) {
375 current_projector = new PProjector();
376 AddBulk(current_projector);
377 } else {
378 if (strcmp("PProjector", bulk[bulkdecay_pos-1]->GetName()) == 0) {
379 current_projector = (PProjector *) bulk[bulkdecay_pos-1];
380 } else {
381 current_projector = new PProjector();
382 AddBulk(current_projector);
383 }
384 }
385 return current_projector;
386 }
387
388 ClassDef(PDecayManager,0)//Pluto Decay Manager Class
389
390}; // end of class PDecayManager
391
392#endif // _PDECAYLIST_H_
393
394
395
396
397
398
399
400
401
Float_t T
Definition NiNi_2AGeV.C:7
#define MAX_BULKDECAY
Definition PChannel.h:23
PDistributionManager * makeDistributionManager()
#define MAX_FILEOUTPUT
Definition PReaction.h:23
TFile * f2
PFermiMomentumGA * f1
TFile * f
Definition analyze_g12C.C:8
void MyPrint(char *name) const
void SetDefault(Int_t id, Int_t recursive=0)
void Print(PParticle *p) const
void MyPrint() const
void SetMaxFileSize(Int_t bytes)
Bool_t Do(TH1F *f, char *command)
void MyClear(char *)
void SetVerbose(Int_t v=1)
void SetUserSelection(Int_t(*f)(PParticle *))
PProjector * GetCurrentProjector(void)
void SetHGeant(Int_t fH)
void Print(const Option_t *delme=NULL) const
void SetUserSelection(void *f)
PDecayChannel * GetChannel(PParticle *p) const
Bool_t AddFileOutput(PFileOutput *file)
PReaction * GetNextReaction(int wf, const char *name, int f0=0, int f1=0, int f2=0, int f3=0, TTree *tt=NULL)
void SetDecayAll(Float_t tau=1.)
Bool_t Output(TNtuple *f, char *command=(char *)"")
void InitReaction(PParticle *start, PDecayChannel *c1=NULL)
void AddChannel(PParticle *p, PDecayChannel *n)
void SetWriteIndex(Bool_t flag)
void AddChannel(Int_t id, PDecayChannel *n)
PReaction * GetNextReaction(const char *name, int f0=0, int f1=0, int f2=0, int f3=0, TTree *tt=NULL)
void Clear(Int_t id)
void SetDefault(const char *p, Int_t recursive=0)
void Clear(const Option_t *delme=NULL)
void Print(Int_t id) const
PDecayChannel * GetChannel(Int_t id) const
Int_t loop(int num, int wf, const char *name, int f0=0, int f1=0, int f2=0, int f3=0, int rf=0)
Bool_t Do(const char *command)
Bool_t AddBulk(PBulkInterface *mybulk)
Bool_t AddPrologueBulk(PBulkInterface *mybulk)
void DisableHelicityAngle(void)
Bool_t Do(TH2F *f, char *command)
void SetPythia(TPythia6 *p)
void Clear(PParticle *p)
PDecayChannel * GetChannel(char *n) const
PDistributionManager * GetDistributionManager(void)
void PrintReactionList() const
Bool_t Input(TNtuple *f)
void SetTrigCond(Int_t n)
void AddChannel(const char *p, PDecayChannel *n)
Int_t Loop(int num, int wf, const char *name, int f0=0, int f1=0, int f2=0, int f3=0, int rf=0)
void SetDefault(PParticle *p, Int_t recursive=0)
Double_t GetCurrentWeight()
void Add(T *t)
void Delete()
PNextList * Next
PNextList(T *t)
Bool_t AddOutputTNtuple(TNtuple *n, 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)
Double_t ReactionWeight
PStack< PChannel > * ToDo
PStack< PChannel > * Finished
static Int_t maxID
PReactionList * Clone()
void Push(T *t)
PNextList< T > * top
T * Pop()
Int_t Count
PStack< T > * Clone(PStack< T > *UseThis=NULL)
PChannel * c[]
PParticle * p
Definition dp_mult.C:24
Int_t n
Definition etap+omeg.C:21
PCommandList * l