// Author: Ingo Froehlich
// Written: 14/02/2007
// Modified: 

#ifndef _PPROJECTOR_H_
#define _PPROJECTOR_H_

#include "PBulkInterface.h"
#include "PBatch.h"
#include "TH2.h"
#include "TH3.h"

#define PROJECTOR_MAX_BATCH 100
#include "TNtuple.h"

#define PROJECTOR_MAX_BRANCHES 50
#define PROJECTOR_MAX_STACK   100


class PProjector: public PBulkInterface {

 private:

    PBatch *batch[PROJECTOR_MAX_BATCH];
    TH3    *hist3[PROJECTOR_MAX_BATCH];
    TH2    *hist2[PROJECTOR_MAX_BATCH];
    TH1    *hist1[PROJECTOR_MAX_BATCH];
// PDensityMatrix *matrix[PROJECTOR_MAX_BATCH];
    Int_t   fFillFlag[PROJECTOR_MAX_BATCH];
    int     batch_pos, force_weight;

    int pid_param, link_param,batch_particle_param, batch_value_param,
	stream_default_pos_param, stream_max_pos_param;

    int key, key_x, key_y, key_z;
    Double_t *x, *y, *z, *w;

    Double_t *proj_nr;

    FILE *current_ascii_file;

    //for NTuple part:
    TNtuple *fp_out[PROJECTOR_MAX_BATCH], *fp_in[PROJECTOR_MAX_BATCH];
    Int_t   key_list_out[PROJECTOR_MAX_BATCH][PROJECTOR_MAX_BRANCHES];
    Int_t   key_pos_out[PROJECTOR_MAX_BATCH];
    Int_t   key_list_in[PROJECTOR_MAX_BATCH][PROJECTOR_MAX_BRANCHES];
    Int_t   key_pos_in[PROJECTOR_MAX_BATCH];
    Float_t values[PROJECTOR_MAX_BRANCHES];
    Float_t values_in[PROJECTOR_MAX_BATCH][PROJECTOR_MAX_BRANCHES];
    Int_t   num_events_in[PROJECTOR_MAX_BATCH];
    Int_t   num_events_in_c[PROJECTOR_MAX_BATCH];

    //for embedding particles
    Int_t stackpointer;
    PParticle stack[PROJECTOR_MAX_STACK];
    Int_t  SetParticles(PParticle ** mstack, int *decay_done, 
			int * num, int stacksize, Int_t first_time);  //set the particles from the stream

 protected:
    
    
 public:
    
    PProjector();
    ~PProjector();


    Bool_t Modify(PParticle **stack, int *decay_done, int *num, int stacksize);  //bulk interface
    
    Bool_t AddCommand(const char *command); //adds a command line to batch
    Bool_t Do(const char *command) {return AddCommand(command);};
    Bool_t AddHistogram(TH3 *histo, const char *command = "", 
			Int_t fillflag = 1); //Add a command and a histogram as a tool object
    Bool_t AddHistogram(TH2 * histo, const char *command = "", 
			Int_t fillflag = 1); //Add a command and a histogram as a tool object
    Bool_t AddHistogram(TH1 *histo, const char *command = "", 
			Int_t fillflag = 1); //Add a command and a histogram as a tool object
    //fillflag=0: do not fill
    //        =1: fill with weight
    //        =2: fill without weight

    Bool_t AddTGraph  (TGraph   *graph,   const char *command);
    Bool_t AddTGraph2D(TGraph2D *graph2d, const char *command);

    Bool_t AddInputTNtuple(TNtuple *n, const char *command = "");
    Bool_t Input(TNtuple *n) {
	return AddInputTNtuple(n);
    };
    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 CloseFile(void) {
	if (!current_ascii_file) return kFALSE;
	current_ascii_file = NULL;
	return kTRUE;
    };
    Bool_t IsFileOpen(void) {
	if (!current_ascii_file) return kFALSE;
	return kTRUE;
    }

    void Print(const Option_t *delme=NULL) const ;

    ClassDef(PProjector, 0) // Project particle array to histograms
};
#endif 

















 PProjector.h:1
 PProjector.h:2
 PProjector.h:3
 PProjector.h:4
 PProjector.h:5
 PProjector.h:6
 PProjector.h:7
 PProjector.h:8
 PProjector.h:9
 PProjector.h:10
 PProjector.h:11
 PProjector.h:12
 PProjector.h:13
 PProjector.h:14
 PProjector.h:15
 PProjector.h:16
 PProjector.h:17
 PProjector.h:18
 PProjector.h:19
 PProjector.h:20
 PProjector.h:21
 PProjector.h:22
 PProjector.h:23
 PProjector.h:24
 PProjector.h:25
 PProjector.h:26
 PProjector.h:27
 PProjector.h:28
 PProjector.h:29
 PProjector.h:30
 PProjector.h:31
 PProjector.h:32
 PProjector.h:33
 PProjector.h:34
 PProjector.h:35
 PProjector.h:36
 PProjector.h:37
 PProjector.h:38
 PProjector.h:39
 PProjector.h:40
 PProjector.h:41
 PProjector.h:42
 PProjector.h:43
 PProjector.h:44
 PProjector.h:45
 PProjector.h:46
 PProjector.h:47
 PProjector.h:48
 PProjector.h:49
 PProjector.h:50
 PProjector.h:51
 PProjector.h:52
 PProjector.h:53
 PProjector.h:54
 PProjector.h:55
 PProjector.h:56
 PProjector.h:57
 PProjector.h:58
 PProjector.h:59
 PProjector.h:60
 PProjector.h:61
 PProjector.h:62
 PProjector.h:63
 PProjector.h:64
 PProjector.h:65
 PProjector.h:66
 PProjector.h:67
 PProjector.h:68
 PProjector.h:69
 PProjector.h:70
 PProjector.h:71
 PProjector.h:72
 PProjector.h:73
 PProjector.h:74
 PProjector.h:75
 PProjector.h:76
 PProjector.h:77
 PProjector.h:78
 PProjector.h:79
 PProjector.h:80
 PProjector.h:81
 PProjector.h:82
 PProjector.h:83
 PProjector.h:84
 PProjector.h:85
 PProjector.h:86
 PProjector.h:87
 PProjector.h:88
 PProjector.h:89
 PProjector.h:90
 PProjector.h:91
 PProjector.h:92
 PProjector.h:93
 PProjector.h:94
 PProjector.h:95
 PProjector.h:96
 PProjector.h:97
 PProjector.h:98
 PProjector.h:99
 PProjector.h:100
 PProjector.h:101
 PProjector.h:102
 PProjector.h:103
 PProjector.h:104
 PProjector.h:105
 PProjector.h:106
 PProjector.h:107
 PProjector.h:108
 PProjector.h:109
 PProjector.h:110
 PProjector.h:111
 PProjector.h:112
 PProjector.h:113
 PProjector.h:114
 PProjector.h:115
 PProjector.h:116
 PProjector.h:117
 PProjector.h:118
 PProjector.h:119
 PProjector.h:120
 PProjector.h:121
 PProjector.h:122
 PProjector.h:123
 PProjector.h:124
 PProjector.h:125