31 #include <arpa/inet.h>
38 #define EXPECTED_NB_SIM_FRAGMENTS 18
39 #define NB_FEM_FRAGMENTS 72
40 #define MAX_FEM_DATA_BUFFER 2097152
50 std::cout <<
"Create SIM Reader" << std::endl;
62 Info(
"HarpoSimReader",
"Use default simulation for ionisation");
66 Info(
"HarpoSimReader",
"fIontype = %d", fIonType);
87 fMaxEvents = LONG_MAX;
113 Info(
"HarpoSimReader",
"Use default simulation for ionisation");
142 if ( FileName != (TString *) NULL )
173 if(
gHarpoDebug>0) Info(
"SetRootFile",
"%s",name->Data());
176 fNewFile =
new TFile(name->Data(),
"RECREATE",
"HARPO SIM Events");
200 if(!isDone)
return isDone;
212 else if (trdr == 1) {
220 std::cout <<
"UNKNOWN XDCC" << std::endl;
234 else if (trdr == 1) {
243 std::cout <<
"UNKNOWN YDCC" << std::endl;
251 Info(
"NextEvent",
"Ntracks = %d",nTracks);
252 Int_t pm[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
253 for(Int_t tr = 0; tr<nTracks; tr++){
257 x[0] = track->
GetX0();
258 x[1] = track->
GetY0();
259 x[2] = track->
GetZ0();
261 p[0] = track->
GetPx();
262 p[1] = track->
GetPy();
263 p[2] = track->
GetPz();
265 if(
gHarpoDebug>1) Info(
"NextEvent",
"%g %g %g %g %g %g",x[0],x[1],x[2],p[0],p[1],p[2]);
267 Double_t xup[3] = {150,150,300};
268 Double_t xdown[3] = {-150,-150,0};
270 Bool_t scint[6] = {1,1,1,1,1,1};
272 for(Int_t j = 0; j<3; j++){
273 for(Int_t i = 0; i<3; i++){
275 Double_t xtmp = x[i] + p[i]*(xup[j] + 50 - x[j])/p[j];
276 if(
gHarpoDebug>1) Info(
"NextEvent",
" %d %d %g",i,j,xtmp);
277 scint[2*j] = scint[2*j] && (xtmp<xup[i] && xtmp>xdown[i]);
278 xtmp = x[i] + p[i]*(xdown[j] - 50 - x[j])/p[j];
280 scint[2*j+1] = scint[2*j+1] && (xtmp<xup[i] && xtmp>xdown[i]);
288 pm[0] = pm[0] || scint[3];
289 pm[1] = pm[1] || scint[3];
290 pm[2] = pm[2] || scint[4];
291 pm[3] = pm[3] || scint[4];
292 pm[4] = pm[4] || scint[5];
293 pm[5] = pm[5] || scint[5];
294 pm[6] = pm[6] || scint[1];
295 pm[7] = pm[7] || scint[1];
296 pm[8] = pm[8] || scint[2];
297 pm[9] = pm[9] || scint[2];
298 pm[10] = pm[10] || scint[0];
299 pm[11] = pm[11] || scint[0];
305 for(Int_t i = 0; i<12; i++){
307 Int_t charge = 800*pm[i];
309 if(charge < 50)
continue;
361 if(
gHarpoDebug>1) Info(
"GenerateEventBasic",
"%d MC tracks generated",nTr);
362 for(Int_t iTr = 0; iTr<nTr; iTr++){
365 Info(
"GenerateEvent",
"fIonType %d",
fIonType);
380 Float_t xg = 0, yg = 0, zg = 0, tg = 0, pgx = 0, pgy = 0, pgz = 0, eg = 0, polax = 0, polay = 0, polaz = 0;
383 str->getline(line,256);
384 if(strstr(line,
"NEW EVENT") != NULL){
385 sscanf(line,
" NEW EVENT %f %f %f %f %f %f %f %f %f %f %f", &xg, &yg, &zg, &tg, &pgx, &pgy, &pgz, &eg, &polax, &polay, &polaz);
386 if(
gHarpoDebug>1) Info(
"GenerateEventFromText:",
"%s",line);
392 if(!str->good())
return false;
395 Info(
"GenerateEventFromText",
"ADDING PHOTON TRACK (%g %g %g %g) Pola (%g %g %g)",pgx,pgy,pgz,eg,polax,polay,polaz);
470 else if (trdr == 1) {
487 TString inputFile =
"testrun.dat";
490 Info(
"Init",
"Use default simulation file %s",inputFile.Data());
493 Info(
"Init",
"Reading ionisation points from %s",inputFile.Data());
494 fStr.open(inputFile.Data(), std::ifstream::in);
496 Warning(
"Init",
"Could not read file %s",inputFile.Data());
509 if(
gHarpoDebug>0) Info(
"Loop",
"maxevents = %li",maxevents);
525 for(Int_t i = 0; i<maxevents; i++){
546 return Loop(maxevents);
HarpoSimReadout * fHarpoReadout
Int_t ProcessTrack(TpcSimIonisationTrack *tr)
HarpoDccMap * GetDccMapX()
Bool_t GenerateEvent(HarpoSimEvent *simEvent)
HarpoDetHeader * fRunHeader[gkNDetectors]
A virtual class store event data for un detector.
TString * GetOutFile()
Get Output root file name.
void SetPolaz(Double_t value)
HarpoSimChamber * fHarpoChamber
void SetDriftChamber(TpcSimDriftChamber *readout)
Bool_t GenerateEventBasic(HarpoSimEvent *simEvent)
void SetTriggerType(Int_t val)
void SetReadout(HarpoSimReadout *readout)
void SetMCEvent(TpcSimMCEvent *event)
void SetPolay(Double_t value)
HarpoDetHeader * GetDetHeader()
A class which read HARPO sim file from one SIM and creant Sim Events and Sim Headers for SIM Events o...
HarpoSimEvent * GetEvent()
TpcSimEventGenerator * fEventGenerator
A class store HARPO row DCC event data and header. End provide access metods to the row data...
A class store HARPO row FEMINOS event data and header. End provide access metods to the row data...
HarpoSimAnalyse * fSimAnalyse
unpacked dcc data The class contains the data map for DCC or Feminos The data is stored as a 2D TMatr...
TpcSimIonisationTrack * GenerateTrack(TpcSimMCTrack *tr)
Int_t AddIonisationTrack(Int_t iTr, TpcSimIonisationTrack *tr)
A virtual base class for all HARPO detectors readers.
UInt_t _Charge
1 bit(40) - TDC Ramp
Long_t Loop()
Read errors.
Data from Keller temperuture and pressure sensors.
HarpoSimElectronics * fDigi
virtual ~HarpoSimReader()
TpcSimMCTrack * GetTrack(Int_t i)
A virtual class which define intrafece between HARPO Reader and Event Analysis code.
void SetE(Double_t value)
Bool_t GenerateEventFromText(HarpoSimEvent *simEvent, std::ifstream *str)
Bool_t Init()
Init method : Open in/out files and check run header signature.
Long64_t GetDetRdrType(HarpoDetType nDet)
Return type of reader impementation for given Harpo Detector.
void SetPolax(Double_t value)
void SetAnalyseFunction(HarpoSimAnalyse *func)
void SetSimFile(TString *name)
TpcSimMCEvent * GetMCEvent()
void SetElectronics(HarpoSimElectronics *digi)
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
A class store HARPO raw PMM2 event buffer and header. End provide access metods to the row data...
A one channel mesurements for Pmm2v2 card The class is represent one channel data of Pmm2v2 card for ...
void AddMes(Pmm2Mes &m)
Ruturn pointer to decoded data vector.
TpcSimIonisationChamber * fIonisationChamber
HarpoDccMap * GetDccMapY()
TpcSimIonisationTrack * GenerateTrackFromText(std::ifstream *str)
void AddTrack(TpcSimMCTrack *tr)
const ULong_t gkNDetectors
void SetHeader(UShort_t *data)
TpcSimDriftChamber * fDriftChamber
void SetRootFile(TString *name)
A class which keeps track of the entire configuration of the analysis.
TpcSimMCEvent * GenerateEvent(Int_t seed=0)
A class store HARPO EVENT : header and row data. Its provide also the methods for access to this data...
UInt_t _ChannelNum
Event can access to class varibales.
HarpoPedestal * GetPedestals(UInt_t ndet)