| 1 |
#ifndef PAMVMCDIGMGR_H |
| 2 |
#define PAMVMCDIGMGR_H |
| 3 |
#include <iostream> |
| 4 |
|
| 5 |
#include <TSystem.h> |
| 6 |
#include <TMap.h> |
| 7 |
#include <TObjString.h> |
| 8 |
#include "PamVMCDigitizer.h" |
| 9 |
#include "PamVMCTrkDig.h" |
| 10 |
#include "PamVMCDigRunHeader.h" |
| 11 |
#include "PamVMCDigRunTrailer.h" |
| 12 |
#include "PamVMCTofDig.h" |
| 13 |
#include "PamVMCAcDig.h" |
| 14 |
#include "PamVMCCaloDig.h" |
| 15 |
#include "PamVMCS4Dig.h" |
| 16 |
#include "PamVMCNDDig.h" |
| 17 |
|
| 18 |
class PamVMCDigMgr: public TObject { |
| 19 |
|
| 20 |
private: |
| 21 |
|
| 22 |
static PamVMCDigMgr * fdig; |
| 23 |
TMap fdigmap; |
| 24 |
|
| 25 |
/* This method calls only from manager. It is owner of all |
| 26 |
digitizer objects */ |
| 27 |
void SetDIG(const char *name, PamVMCDigitizer *detDIG){ |
| 28 |
fdigmap.Add(new TObjString(name),detDIG); |
| 29 |
fdigmap.Print(); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
protected: |
| 34 |
PamVMCDigMgr(){ |
| 35 |
//detectors should be ordered.. First calibrations |
| 36 |
SetDIG("Tof", new PamVMCTofDig()); |
| 37 |
SetDIG("AC", new PamVMCAcDig()); |
| 38 |
SetDIG("CAST",new PamVMCCaloDig()); |
| 39 |
SetDIG("TSPA", new PamVMCTrkDig()); |
| 40 |
SetDIG("S4",new PamVMCS4Dig()); |
| 41 |
SetDIG("NDTI",new PamVMCNDDig()); |
| 42 |
SetDIG("RunHeader", new PamVMCDigRunHeader()); |
| 43 |
SetDIG("RunTrailer", new PamVMCDigRunTrailer()); |
| 44 |
} |
| 45 |
|
| 46 |
public: |
| 47 |
|
| 48 |
~PamVMCDigMgr(){ fdigmap.DeleteAll(); } |
| 49 |
|
| 50 |
static PamVMCDigMgr * Instance(); |
| 51 |
|
| 52 |
PamVMCDigitizer * GetDIG(const char *name){ |
| 53 |
return (PamVMCDigitizer*)fdigmap(name); |
| 54 |
} |
| 55 |
|
| 56 |
/* All digitizers load calibrations and calibrate */ |
| 57 |
void LoadCalib(){ |
| 58 |
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
| 59 |
TObject *o; while( o=(TObject *) n->Next()) { |
| 60 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->LoadCalib(); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/* This calls digitization for all detector */ |
| 65 |
void Digitize(Int_t EventNo, Int_t PrimaryPDG){ |
| 66 |
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
| 67 |
TObject *o; while( o=(TObject *) n->Next()) { |
| 68 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->Digitize(); |
| 69 |
} |
| 70 |
|
| 71 |
TObject* ob1 = fdigmap.FindObject("Tof"); |
| 72 |
if(ob1) ((PamVMCTofDig*)((TPair*)ob1)->Value())->DigitizeTOF(EventNo, PrimaryPDG); |
| 73 |
|
| 74 |
TObject* ob2 = fdigmap.FindObject("AC"); |
| 75 |
if(ob2) ((PamVMCAcDig*)((TPair*)ob2)->Value())->DigitizeAC(EventNo); |
| 76 |
|
| 77 |
/* +++From this moment all detctors a filled their buffers an we will form packet+++ */ |
| 78 |
|
| 79 |
TObject* b1 = fdigmap.FindObject("Tof"); |
| 80 |
if(b1) ((PamVMCTofDig*)((TPair*)b1)->Value())->WriteToBuff(); |
| 81 |
|
| 82 |
cout<<"TOF Written.."<<endl; |
| 83 |
|
| 84 |
TObject* b2 = fdigmap.FindObject("AC"); |
| 85 |
if(b2) ((PamVMCAcDig*)((TPair*)b2)->Value())->WriteToBuff(); |
| 86 |
|
| 87 |
cout<<"AC Written.."<<endl; |
| 88 |
|
| 89 |
TObject* b3 = fdigmap.FindObject("CAST"); |
| 90 |
if(b3) ((PamVMCCaloDig*)((TPair*)b3)->Value())->WriteToBuff(); |
| 91 |
|
| 92 |
cout<<"CALO Written.."<<endl; |
| 93 |
|
| 94 |
TObject* b4 = fdigmap.FindObject("TSPA"); |
| 95 |
if(b4) ((PamVMCTrkDig*)((TPair*)b4)->Value())->WriteToBuff(); |
| 96 |
|
| 97 |
cout<<"TRK Written.."<<endl; |
| 98 |
|
| 99 |
TObject* b5 = fdigmap.FindObject("S4"); |
| 100 |
if(b5) ((PamVMCS4Dig*)((TPair*)b5)->Value())->WriteToBuff(); |
| 101 |
|
| 102 |
cout<<"S4 Written.."<<endl; |
| 103 |
|
| 104 |
TObject* b6 = fdigmap.FindObject("NDTI"); |
| 105 |
if(b6) ((PamVMCNDDig*)((TPair*)b6)->Value())->WriteToBuff(); |
| 106 |
|
| 107 |
cout<<"ND Written.."<<endl; |
| 108 |
|
| 109 |
} |
| 110 |
|
| 111 |
/* This written for RunTrailer. It should put his data |
| 112 |
to raw-file only once, when run is over */ |
| 113 |
void FinishRun(){ |
| 114 |
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
| 115 |
TObject *o; while( o=(TObject *) n->Next()) { |
| 116 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->FinishRun(); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
virtual void Print(const Option_t* = "") const { fdigmap.Print(); } |
| 121 |
|
| 122 |
void PrintCollections(){ |
| 123 |
TMapIter *n= (TMapIter *)fdigmap.MakeIterator(); |
| 124 |
TObject *o; while( o=(TObject *) n->Next()) { |
| 125 |
((PamVMCDigitizer *)fdigmap.GetValue(o))->PrintCollections(); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
}; |
| 130 |
|
| 131 |
#endif |