GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PrismaWatchers.C
Go to the documentation of this file.
1 
2 
3 #include "PrismaWatchers.h"
4 #include "MetaWatchers.h"
6 
7 #include "TMath.h"
8 
9 #include <iomanip>
10 
11 //includes for libPrisma.so or any other library needed
12 #include "RandomGenerator.hh"
13 
14 namespace {
15  const int pM = 0; //monitor
16  const int pA = 2; //MCP:x,y
17  const int pR = 6; //MWPPC:tof,xleft,xright,xcathode,y
18  const int pI = 4; //4 IC sections:A,B,C,D
19  const int pS = 4; //4 Side sections:A,B,C,D
20 }
21 
23 
24 BasePrismaWatcher::BasePrismaWatcher(const char *name, const char *title):
25  RancLegnaroWatcher(name,title),
26  fPM(0x0),
27  fCurrentSize(0),
28  fDetData()
29 {
30 }
31 
33 {
34  if ( fPM )
35  delete fPM;
36 
37  for (size_t i = 0; i < fDetData.size(); i++) {
38  if ( fDetData [i] ) {
39  delete fDetData[i]; fDetData[i] = 0x0;
40  }
41  }
42 }
43 
44 void BasePrismaWatcher::Configure(const char *pmanager, const char *plut)
45 {
46  if ( fPM )
47  { delete fPM; fPM = 0x0; }
48 
49  if ( InitLUT(plut) ) {
50  fPM = new prismaManager(pmanager); Random::randomize();
51  }
52 }
53 
54 Bool_t BasePrismaWatcher::InitLUT(const char *filename)
55 {
56  FILE * conf_file;
57  if( (conf_file = fopen(filename,"r")) == 0x0) {
58  std::cout << " Error, cannot open " << filename << std::endl; return false;
59  }
60 
61  for (Int_t ii = 0; ii< gMaxSlotsForPrisma*gMaxChannels; ii++) {
62  Int_t Conv, Ch, Cont;
63  if(fscanf(conf_file,"%d %d %d",&Conv,&Ch,&Cont) != 3) {
64  cout << "Error reading line " << ii << " of " << filename << endl;
65  fclose(conf_file);
66 
67  return false;
68  }
69  LUT[Conv][Ch]= Cont;
70  std::cout << "LUT[ " << Conv << " ][ " << std::setw(2) << Ch << " ] = " << std::setw(3) << LUT[Conv][Ch] << std::endl;
71  }
72 
73  std::cout << "Prisma LUT " << filename << " is correctl initialised " << std::endl; return true;
74 }
75 
76 detData *BasePrismaWatcher::GetNextDetData(Int_t ndet, Int_t npar)
77 {
78  detData *data;
79 
80  // stack not large enough, so add one element
81  if ( fCurrentSize == fDetData.size() ) {
82  data = new detData (ndet,npar);
83  fDetData.push_back( data );
84  }
85  else { data = fDetData[fCurrentSize++]; data->reset_detData(ndet,npar); }
86 
87  return data;
88 }
89 
90 void BasePrismaWatcher::Exec(Option_t * option)
91 {
92  // cannot extract data, manager is not set properly
93  if ( fPM == 0x0 )
94  return;
95 
96  // event
97  Int_t numDet[gmaxTypes]; detData* aData;
98 
99  // to load data fron ancillary frame to rawBuf
101  RancLegnaroWatcher::Exec(option);
102  if ( GetLastExecStatus() != 0 )
103  return;
104 
105  // fill the map with the current data obtained using the LUT and rawBuf
106  ::memset(theMap, 0, sizeof(theMap));
107 
108  for (int ii= 0; ii < gMaxSlotsForPrisma; ii++) {
109  for (int jj=0; jj < gMaxChannels; jj++) {
110  //std::cout << " LUT[" << ii << "]["<< jj<<"]= " << LUT[ii][jj] << std::endl;
111  if ( LUT[ii][jj] < 0)
112  continue;
113  theMap[ LUT[ii][jj] ] = rawBuf[ii*gMaxChannels+jj]; // Converter[ii].GetValue(jj);
114  }
115  }
116 
117  // count the number of data (parameter) in the event for each type of detector
118  int nParam[gmaxTypes][gMaxSections]; ::memset(nParam,0,sizeof(int)*gmaxTypes*gMaxSections);
119 
120  for (int zz=0; zz<gmaxTypes; zz++) {
121  numDet[zz]=0;
122  for (int jj=0; jj<gMaxSections; jj++){
123  for (int ii=0; ii<6; ii++) {
124  if ( theMap[60*zz+6*jj+ii] > 250.f ){
125  nParam[zz][jj]++;
126  }
127  }
128  }
129  }
130 
131  for (int zz=0; zz<gmaxTypes; zz++){
132  for (int jj=0; jj<gMaxSections; jj++){
133  if( nParam[zz][jj] > 0 )
134  numDet[zz]++;
135  }
136  }
137 
138  // Reset stack of data
140 
141 
142  theMcpData.clear();
143 
144  for (int jj=0; jj<gMaxSections; jj++ ) {
145  if( nParam[0][jj] < 1 )
146  continue;
147  aData = GetNextDetData(jj,pA); theMcpData.push_back( aData );
148  for(int ii=0; ii<pA; ii++ )
149  if (theMap[6*jj+ii] > 0)
150  aData->set( ii, theMap[6*jj+ii] + Random::uniform() - 0.5 );
151  else
152  aData->set( ii, 0 );
153  }
154 
155 
156  thePpacData.clear();
157 
158  // for(int jj=0; jj<numDet[1]; jj++ ) {
159  for(int jj=0; jj<gMaxSections; jj++ ) {
160  if( nParam[1][jj] < 1 )
161  continue;
162  aData = GetNextDetData(jj,pR); thePpacData.push_back( aData );
163  for(int ii=0; ii<pR; ii++ )
164  if ( theMap[60 + 6*jj+ii] > 0 )
165  aData->set( ii, theMap[60 + 6*jj+ii] + Random::uniform() - 0.5 );
166  else
167  aData->set( ii, 0 );
168  }
169 
170  /* for(int jj=0; jj<numDet[1]; jj++ ) {
171  aData = thePpacData[jj];
172  std::cout << "numm = " << numDet[1] << " " << nParam[1][aData->num_det()] << std::endl;
173  for(int ii=0; ii<pR; ii++ )
174  std::cout << "numDet= " <<aData->num_det() << " det_data= "<<aData->get(ii) << std::endl;
175  } */
176 
177 
178  theIcData.clear();
179 
180  // for(int jj=0; jj<numDet[2]; jj++ ) {
181  for(int jj=0; jj<gMaxSections; jj++ ) {
182  if( nParam[2][jj] < 1 )
183  continue;
184  aData = GetNextDetData(jj,pI); theIcData.push_back( aData );
185  for(int ii=0; ii<pI; ii++ )
186  if (theMap[120 + 6*jj+ii]>0)
187  aData->set( ii, theMap[120 + 6*jj+ii] + Random::uniform() - 0.5 );
188  else
189  aData->set( ii, 0 );
190  }
191 
192 
193  theSideData.clear();
194 
195  // for( int jj=0; jj<numDet[3]; jj++ ) {
196  for(int jj=0; jj<gMaxSections; jj++ ) {
197  if( nParam[3][jj] < 1 )
198  continue;
199  aData = GetNextDetData(jj,pS); theSideData.push_back( aData );
200  for(int ii=0; ii<pS; ii++ )
201  if (theMap[180 + 6*jj+ii]>0)
202  aData->set( ii, theMap[180 + 6*jj+ii] + Random::uniform() - 0.5 );
203  else
204  aData->set( ii, 0 );
205  }
206 
207 #if 0
208 
209  cout << " Testing new event " << endl;
210  for(int ii=0; ii<(int)theMcpData.size(); ii++ ) {
211  aData = theMcpData[ii];
212  cout << endl << "New MCP " << (*aData) << endl;
213  }
214  for(int ii=0; ii<(int)thePpacData.size(); ii++ ) {
215  aData = thePpacData[ii];
216  cout << endl << "New PPAC " << (*aData) << endl;
217  }
218 
219  for(int ii=0; ii<(int)theIcData.size(); ii++ ) {
220  aData = theIcData[ii];
221  cout << endl << "New IC " << (*aData) << endl;
222  }
223 
224  for(int ii=0; ii<(int)theSideData.size(); ii++ ) {
225  aData = theSideData[ii];
226  cout << endl << "New Side " << (*aData) << endl;
227  }
228 
229 #endif
230 
232 }
233 
234 
236 
237 RawPrisma::RawPrisma(const char *name, const char *title) : BasePrismaWatcher(name, title),
238  fFP( new TObjArray(gMaxSections) ),
239  fLR( new TObjArray(gMaxSections) )
240 {
241  // histograms belongs to the pool
242  fFP->SetOwner(false);
243  fLR->SetOwner(false);
244 
245  TH2F *h;
246  for (Int_t i = 0; i < gMaxSections; i++) {
247  h = new TH2F(Form("TOF_Xfp%d",i),Form("TOF_Xfp%d",i), 512, 0, 4096, 512, 0, 4096);
248  fFP->AddAt(h,i);
249  AddToPool(h);
250  h = new TH2F(Form("fLR%d",i),Form("fLR%d",i), 512, 0, 4096, 512, 0, 4096);
251  fLR->AddAt(h,i);
252  AddToPool(h);
253  }
254 }
255 
257 {
258 }
259 
260 void RawPrisma::Exec(Option_t * option)
261 {
262  // No need to pass events to prismaManager, only the raw content is needed
264  RancLegnaroWatcher::Exec(option);
265  if ( GetLastExecStatus() != 0 )
266  return;
267 
268  if ( lenrawBuf == 0 )
269  return;
270 
271  // fLR->At(0] ->Fill( Converter[2].GetValue( 3), Converter[2].GetValue( 0) + Converter[2].GetValue( 1));
272  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+3], rawBuf[2*gMaxChannels+0] + rawBuf[2*gMaxChannels+1] );
273  // fLR->At(1] ->Fill( Converter[2].GetValue(23), Converter[2].GetValue( 2) + Converter[2].GetValue(22));
274  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+23], rawBuf[2*gMaxChannels+2] + rawBuf[2*gMaxChannels+22] );
275  // fLR->At(2] ->Fill( Converter[2].GetValue(24), Converter[2].GetValue( 4) + Converter[2].GetValue( 5));
276  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+24], rawBuf[2*gMaxChannels+4] + rawBuf[2*gMaxChannels+5] );
277  // fLR->At(3] ->Fill( Converter[2].GetValue(25), Converter[2].GetValue( 6) + Converter[2].GetValue( 7));
278  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+25], rawBuf[2*gMaxChannels+6] + rawBuf[2*gMaxChannels+7] );
279  // fLR->At(4] ->Fill( Converter[2].GetValue(26), Converter[2].GetValue( 8) + Converter[2].GetValue( 9));
280  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+26], rawBuf[2*gMaxChannels+8] + rawBuf[2*gMaxChannels+9] );
281  // fLR->At(5] ->Fill( Converter[2].GetValue(27), Converter[2].GetValue(10) + Converter[2].GetValue(11));
282  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+27], rawBuf[2*gMaxChannels+10] + rawBuf[2*gMaxChannels+11] );
283  // fLR->At(6] ->Fill( Converter[2].GetValue(28), Converter[2].GetValue(12) + Converter[2].GetValue(13));
284  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+28], rawBuf[2*gMaxChannels+12] + rawBuf[2*gMaxChannels+13] );
285  // fLR->At(7] ->Fill( Converter[2].GetValue(29), Converter[2].GetValue(14) + Converter[2].GetValue(15));
286  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+29], rawBuf[2*gMaxChannels+14] + rawBuf[2*gMaxChannels+15] );
287  // fLR->At(8] ->Fill( Converter[2].GetValue(30), Converter[2].GetValue(16) + Converter[2].GetValue(17));
288  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+30], rawBuf[2*gMaxChannels+16] + rawBuf[2*gMaxChannels+17] );
289  // fLR->At(9] ->Fill( Converter[2].GetValue(31), Converter[2].GetValue(18) + Converter[2].GetValue(19));
290  ((TH2F *)fLR->At(0)) ->Fill( rawBuf[2*gMaxChannels+31], rawBuf[2*gMaxChannels+18] + rawBuf[2*gMaxChannels+18] );
291 
292  ((TH2F *)fFP->At(0)) ->Fill( rawBuf[2*gMaxChannels+0] - rawBuf[2*gMaxChannels+1], rawBuf[22+0] );
293  ((TH2F *)fFP->At(1)) ->Fill( rawBuf[2*gMaxChannels+2] - rawBuf[2*gMaxChannels+22], rawBuf[22+1] );
294  ((TH2F *)fFP->At(2)) ->Fill( rawBuf[2*gMaxChannels+4] - rawBuf[2*gMaxChannels+5], rawBuf[22+2] );
295  ((TH2F *)fFP->At(3)) ->Fill( rawBuf[2*gMaxChannels+6] - rawBuf[2*gMaxChannels+7], rawBuf[22+3] );
296  ((TH2F *)fFP->At(4)) ->Fill( rawBuf[2*gMaxChannels+8] - rawBuf[2*gMaxChannels+9], rawBuf[22+4] );
297  ((TH2F *)fFP->At(5)) ->Fill( rawBuf[2*gMaxChannels+10] - rawBuf[2*gMaxChannels+11], rawBuf[22+5] );
298  ((TH2F *)fFP->At(6)) ->Fill( rawBuf[2*gMaxChannels+12] - rawBuf[2*gMaxChannels+13], rawBuf[22+6] );
299  ((TH2F *)fFP->At(7)) ->Fill( rawBuf[2*gMaxChannels+14] - rawBuf[2*gMaxChannels+15], rawBuf[22+7] );
300  ((TH2F *)fFP->At(8)) ->Fill( rawBuf[2*gMaxChannels+16] - rawBuf[2*gMaxChannels+17], rawBuf[22+8] );
301  ((TH2F *)fFP->At(9)) ->Fill( rawBuf[2*gMaxChannels+18] - rawBuf[2*gMaxChannels+18], rawBuf[22+9] );
302 }
303 
305 
306 DisplayPrisma::DisplayPrisma(const char *name, const char *title): BasePrismaWatcher(name, title)
307 {
308  /* Ic_Range = new TH2F("Ic_Range", "Ic_Range", 1024,0,2000,1024,0,2000);
309  AddToPool(Ic_Range); */
310  IcABvsABCD = new TH2F("Ic_ABvsABCD", "E_DeltaE_AB", 1024,0,12000,2048,0,8000);
311  AddToPool(IcABvsABCD);
312  IcAvsABCD = new TH2F("Ic_AvsABCD", "E_DeltaE_A", 1024,0,12000,2048,0,8000);
313  AddToPool(IcAvsABCD);
314  TOF_D = new TH2F("ToF(ns)vsX_FP(mm)", "ToFvsx_FP", 1024,0,1024,4096,0,4096);
315  AddToPool(TOF_D);
316  PRISMA_MCPcal = new TH2F("MCPcal", "MCP calibrated", 1024,-50,50, 1024,-50,50);
317  AddToPool(PRISMA_MCPcal);
318  PRISMA_X_FP = new TH1I("PRISMA_Xfc","X focal plane in PRISMA",4096,0,4096);
319  AddToPool(PRISMA_X_FP);
320  PRISMA_Vel = new TH1I("PRISMA_Vel","Velocity in PRISMA",8000,0,0.25);
321  AddToPool(PRISMA_Vel);
322  Range_Energy = new TH2F("Range_Energy", "Range_Energy", 1024,0,4096, 1024,0,20000);
323  AddToPool(Range_Energy);
324  Vel_Theta = new TH2F("Vel_Theta", "Vel_Theta", 1023,1,1024, 1024,0,0.2);
325  AddToPool(Vel_Theta);
326  a_over_q = new TH2F("a_over_q", "a_over_q", 1024,0,1200, 4096,0,450);
327  AddToPool(a_over_q);
328  Energy_RBeta = new TH2F("Energy_RBeta", "Energy_RBeta", 1024,0,4096, 1024,0,20000);
329  AddToPool(Energy_RBeta);
330  PRISMA_Mass = new TH1F("PRISMA_Mas", "PRISMA_Mas", 4096,0,4096);
331  AddToPool(PRISMA_Mass);
332 }
333 
334 void DisplayPrisma::DoCanvas(TCanvas *c, Option_t * /*o*/)
335 {
336  // TString opt = o;
337 
338  c->Divide(5,2,0.0001,0.0001);
339  c->cd(1);
340  IcABvsABCD->Draw("col");
341  c->cd(2);
342  IcAvsABCD->Draw("col");
343  c->cd(3);
344  TOF_D->Draw("col");
345  c->cd(4);
346  PRISMA_MCPcal->Draw("col");
347  c->cd(5);
348  PRISMA_X_FP->Draw();
349  c->cd(6);
350  Range_Energy->Draw("col");
351  c->cd(7);
352  PRISMA_Vel->Draw("");
353  c->cd(8);
354  a_over_q->Draw("col");
355  c->cd(9);
356  Energy_RBeta->Draw("col");
357  c->cd(10);
358  PRISMA_Mass->Draw();
359  /*
360  if ( opt.Contains("cor") ) {
361  cas = 1;
362  }
363  switch( cas ) {
364  case 1:
365  c->Divide(2,5,0.0001,0.0001);
366  for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
367  c->cd(i+1);
368  fCor->At(i)->Draw();
369  }
370  break;
371  default:
372  // show segments
373  c->Divide(6,6,0.0001,0.0001);
374  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
375  c->cd(i+1);
376  fSeg->At(i)->Draw();
377  }
378  }
379  */
380 
381 }
382 
383 
384 void DisplayPrisma::Exec(Option_t *option)
385 {
386  const double c_light = 29.97295 * cm/ns;
387 
388  // fill the array of floats and compute the PRISMA physics
389  SetLastExecStatus(0u);
390  BasePrismaWatcher::Exec(option);
391  if ( GetLastExecStatus() != 0 )
392  return;
393 
394  if ( fPM->length() > 0. ) {
395 
396  Vector3D Vel = fPM->velocity()/c_light;
397 
398  // Ic_Range -> Fill(fPM->range()/mm,fPM->ic_energy());
399  IcABvsABCD -> Fill(fPM->ic_energy(),fPM->ic_energy_AB_DE());
400  //IcAvsABCD -> Fill(fPM->ic_energy(),fPM->ic_energy_A_DE());
401  TOF_D -> Fill(fPM->x_fp() /mm, 10*fPM->tof()/ns);
402  PRISMA_MCPcal -> Fill(fPM->mcp_x()/mm , fPM->mcp_y()/mm) ;
403  PRISMA_X_FP -> Fill( fPM->x_fp() /mm) ;
404  PRISMA_Vel -> Fill( Vel.rho() ) ;
405  Range_Energy->Fill(fPM->range(), fPM->ic_energy()) ;
406  Vel_Theta->Fill(10.*fPM->theta_c()/degree, Vel.rho() );
407  a_over_q->Fill(fPM->x_fp()/mm, fPM->a_over_q_uncal());
408  Energy_RBeta->Fill(fPM->r_beta(),fPM->ic_energy());
409  PRISMA_Mass->Fill(fPM->Mass());
410  }
411 
412 }
413 
415 EvePrisma::EvePrisma(const char *name, const char *title)
416  : BasePrismaWatcher(name, title),
417  fMaxCycle(100),
418  fConfFileName(Gw::AgataEventDisplay::GetDefaultPrismaConf()),
419  fPathFile(Gw::AgataEventDisplay::GetDefaultAgataPath())
420 {
421  fTypeName = AgataEventDisplay::Instance()->RegisterBranch("Prisma");
422  AgataEventDisplay::Instance()->SetTrackStyle("Rectangle", fTypeName);
423 }
424 
425 void EvePrisma::SetActive(Bool_t active)
426 {
427  TTask::SetActive(active);
428  AgataEventDisplay::Instance()->Reset();
429 }
430 
431 void EvePrisma::ShowEve(const Char_t* prismaConfFile, const Char_t* agataPathFile)
432 {
437 }
438 
439 void EvePrisma::Exec(Option_t *option)
440 {
441  const double c_light = 29.97295 * cm/ns;
442  //static Int_t count = 0;
443 
444  // fill the array of floats and compute the PRISMA physics
446  BasePrismaWatcher::Exec(option);
447  if ( GetLastExecStatus() != 0 )
448  return;
449 
450  Vector3D Vel = fPM->velocity()/c_light;
451  Vector3D posQpoleIn = fPM->getPosQuadrupoleIn();
452  Vector3D posQpoleOut = fPM->getPosQuadrupoleOut();
453  Vector3D posDipIn = fPM->getPosDipoleIn();
454  Vector3D posDipOut = fPM->getPosDipoleOut();
455  Vector3D posFP = fPM->getPosFocalPlane();
456  Vector3D center = fPM->getCenter();
457  Float_t radius = fPM->radius();
458 
459  if ( fPM->length() > 0. ) {
460 
462  TrackHit* hit = agataContainer->NewTrackHit(fTypeName);
463  StdHit* thit = 0x0;
464 
465  // MCP
466  thit = hit->NewHit();
467  thit->SetX(-fPM->mcp_x()/cm);
468  thit->SetY( fPM->mcp_y()/cm);
469  thit->SetZ(25);
470  thit->SetE(fPM->energy_over_beta()+100);
471 
472  // QPole
473  thit = hit->NewHit();
474  thit->SetX(-posQpoleIn.X()/cm);
475  thit->SetY( posQpoleIn.Z()/cm);
476  thit->SetZ( posQpoleIn.Y()/cm);
477  thit->SetE(fPM->energy_over_beta()+100);
478 
479  thit = hit->NewHit();
480  thit->SetX(-posQpoleOut.X()/cm);
481  thit->SetY( posQpoleOut.Z()/cm);
482  thit->SetZ( posQpoleOut.Y()/cm);
483  thit->SetE(fPM->energy_over_beta()+100);
484 
485  // Dipole in
486  thit = hit->NewHit();
487  thit->SetX(-posDipIn.X()/cm);
488  thit->SetY( posDipIn.Z()/cm);
489  thit->SetZ( posDipIn.Y()/cm);
490  thit->SetE(fPM->energy_over_beta()+100);
491 
492  // In Dipole
493  Float_t phi1 = TMath::Abs(TMath::ATan((posDipIn.X()-center.X())/(posDipIn.Y()-center.Y())));
494  Float_t phi2 = TMath::Abs(TMath::ATan((posDipOut.X()-center.X())/(posDipOut.Y()-center.Y())));
495  Float_t dphi = TMath::Abs(phi2-phi1)/10.;
496 
497  for (Int_t i = 1; i < 10; ++i) {
498  thit = hit->NewHit();
499  thit->SetX(-(center.X()/cm - radius*TMath::Sin(phi1 - float(i)*dphi)/cm));
500  thit->SetY( posDipIn.Z()/cm);
501  thit->SetZ( center.Y()/cm + radius*TMath::Cos(phi1 - float(i)*dphi)/cm);
502  thit->SetE(fPM->energy_over_beta()+100);
503  }
504 
505  // Dipole Out
506  thit = hit->NewHit();
507  thit->SetX(-posDipOut.X()/cm);
508  thit->SetY( posDipIn.Z()/cm);
509  thit->SetZ( posDipOut.Y()/cm);
510  thit->SetE(fPM->energy_over_beta()+100);
511 
512  // Focal Plane
513  thit = hit->NewHit();
514  thit->SetX(-posFP.X()/cm);
515  thit->SetY( posFP.Z()/cm);
516  thit->SetZ( posFP.Y()/cm);
517  thit->SetE(fPM->energy_over_beta()+100);
518 
519  // Ionization Chamber
520  if (fPM->path() > 0) {
521  Float_t phi = TMath::ATan(-(posFP.X()-posDipOut.X())/(posFP.Y()-posDipOut.Y()));
522  Float_t x = -posFP.X()/cm + fPM->path()*TMath::Sin(phi)/10; // path in mm !
523  Float_t z = posFP.Y()/cm + fPM->path()*TMath::Cos(phi)/10;
524  thit = hit->NewHit();
525  thit->SetX(x);
526  thit->SetY(0.);
527  thit->SetZ(z);
528  thit->SetE(fPM->energy_over_beta()+100);
529  }
530  // printf("%f %f %f %f\n", phi1*TMath::RadToDeg(), phi2*TMath::RadToDeg(), posDipOut.X()/cm, center.X()/cm - radius*TMath::Sin(phi2)/cm);
531  // printf("%f %f %f %f\n\n", phi1*TMath::RadToDeg(), phi2*TMath::RadToDeg(), posDipOut.Y()/cm, center.Y()/cm + radius*TMath::Cos(phi2)/cm);
532 
533  agataContainer->FillTracks(fTypeName);
534 
535  if (agataContainer->GetNofEvents() > fMaxCycle) {
536  TTask::SetActive(false);
537  }
538  }
539 
540 }
541 
543 
544 DoPrismaDoppler::DoPrismaDoppler(const char *name, const char *title): BasePrismaWatcher(name, title), VertexBuilder()
545 {
546  fVertexFrame = MainFrameFactory::theMainFactory().
547  NewSharedFrame( FactoryItem("Agata","meta:vertex",Version(0,0)), FactoryItem("Agata","meta:vertex",Version(1,1)) );
548 
549  fIsToBeDeleted = true;
550 }
551 
552 void DoPrismaDoppler::Exec(Option_t *option)
553 {
554  const double c_light = 29.97295 * cm/ns;
555 
556  // fill the array of floats and compute the PRISMA physics
558  BasePrismaWatcher::Exec(option);
559  if ( GetLastExecStatus() != 0 )
560  return;
561 
562  // now get Velocity vector from prismaManager and pass it to VertexWatcher
563  Vector3D Vel; VertexInterface *gdata = GetVertex();
564 
565  if ( fPM->length() > 0. && fPM->tof()/ns > 100 && fPM->tof()/ns < 300 )
566  // if ( fPM->length() > 0. )
567  Vel = fPM->velocity()/c_light;
568  else
569  Vel = Vector3D(0,0,0);
570 
571  gdata->SetPosition(0,0,0);
572  gdata->SetDirection(Vel.X(),Vel.Y(),Vel.Z());
573  gdata->SetBeta(Vel.rho());
574 }
575 
577 
578 MyPrismaTree::MyPrismaTree(const char *name, const char *title, TTree *tree) :
579 BasePrismaWatcher(name,title), TTreeBuilder(name,title,tree)
580 {
581  if ( GetTree() ) { // just add the branch for that watcher
582  SetBranches();
583  }
584 }
585 
587 {
588  GetTree()->Branch("AoverQ", &fAoverQ, "AoverQ/F");
589  GetTree()->Branch("Radius", &fRadius, "Radius/F");
590  GetTree()->Branch("Ic_AB_DE", &fIc_AB_DE, "AoverQ/F");
591  GetTree()->Branch("Ic", &fIc, "Ic/F");
592  GetTree()->Branch("x_fp", &fx_fp, "x_fp/F");
593  GetTree()->Branch("TOF", &fTOF, "TOF/F");
594  GetTree()->Branch("Range", &fRange, "Range/F");
595  GetTree()->Branch("Ic_A_DE",&fIc_A_DE,"Ic_A_DE");
596 }
597 
599 {
600 }
601 
602 void MyPrismaTree::Exec(Option_t *option)
603 {
604  if ( gDebug > 3 )
605  printf("MyPrismaTree::Exec is called \n");
606 
607  // fill the array of floats and compute the PRISMA physics
609  BasePrismaWatcher::Exec(option);
610  if ( GetLastExecStatus() != 0 )
611  return;
612 
613  fAoverQ = fPM->a_over_q_uncal();
614  fRadius = fPM->path();
615  fIc_AB_DE = fPM->ic_energy_AB_DE();
616  fIc = fPM->ic_energy();
617  fx_fp = fPM->x_fp() /mm;
618  fTOF = fPM->tof()/ns;
619  fRange = fPM->range();
620  fIc_A_DE = fPM->ic_energy_A_DE();
621 
622  // fill the tree only if this is the owner of the tree ... otherwise by TreeMaster
623  FillTree();
624 }
625 
626 
AgataEventContainer class that contains agata event to be displayed.
virtual VertexInterface * GetVertex()
Get the vertex data interface.
std::vector< detData * > theSideData
printf("******************************************************************** \n")
DisplayPrisma(const char *name, const char *title)
virtual void Exec(Option_t *option="")
watch the current frame
Interface for any watcher that is a VertexBuilder.
StdHit * NewHit()
Add a new hit to the track (filling mode). The Stack is emptied by calling Reset. ...
DoPrismaDoppler(const char *name, const char *title)
AgataEventDisplay a class to work on a specific event display.
virtual void ShowEve(const Char_t *prismaConfFile, const Char_t *agataPathFile)
show eve event display
virtual void SetActive(Bool_t active=true)
Toggle active task.
prismaManager * fPM
virtual void SetZ(Float_t z)
Bool_t InitLUT(const char *)
to init the LUT from a file
BasePrismaWatcher(const char *name, const char *title)
detData * GetNextDetData(Int_t, Int_t)
Next detData in the pool.
virtual void SetPosition(Double_t, Double_t, Double_t, Double_t=0.0)=0
Set the position of the source (last argument is used in case the position depends on time) ...
ClassImp(BasePrismaWatcher)
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
Apply the doppler correction.
TObject * AddToPool(TObject *ob)
facility for other watchers: keep a list of all histograms (objects) for global operations ...
Definition: Watchers.cpp:446
void FillTracks(Option_t *type="Agata")
static const Int_t gmaxTypes
Base for a watcher on an ancillary (raw) frame.
virtual ~BasePrismaWatcher()
Bool_t fIsToBeDeleted
True if the vertex frame is to be deleted by this. Otherwise it is extracted from a trigger i...
AgataEventContainer * GetEventContainer() const
virtual void SetY(Float_t y)
Base for a watcher on Prisma (raw) frame.
void BuildDefaultGeometry(Bool_t danteGeo=true, Bool_t prismaGeo=true, Bool_t agataGeo=true, Bool_t passiveGeo=true)
void ResetDetDataStack()
Reset stack.
virtual void SetE(Float_t e)
void SetLastExecStatus(Short_t s=0)
reset last status. 0 means no error, 0 < means error, > 0 means ok with conditions ...
Definition: Watchers.h:294
Base class for a Watcher that fill a TTree or some branches of a TTree.
Definition: TTreeWatchers.h:51
virtual void Exec(Option_t *option="")
watch the current frame
Base class for version numbers.
Definition: Version.h:38
static const UShort_t gMaxChannels
virtual void SetX(Float_t x)
Setter position & energy.
static const Int_t gMaxSections
TrackHit * NewTrackHit(Option_t *type="Agata")
add current track hit (added to current track hit list)
virtual void Exec(Option_t *option="")
watch the current frame
EvePrisma(const char *name, const char *title)
virtual void FillTree()
Fill the tree if it is the owner of the tree.
Float_t rawBuf[gMaxSlots *gMaxChannels+gExtraSize]
static const UShort_t gMaxSlotsForPrisma
virtual void Exec(Option_t *option="")
watch the current frame
ADF::LogMessage & endl(ADF::LogMessage &log)
static void SetDefaultAgataPath(const Char_t *name)
virtual void SetDirection(Double_t, Double_t, Double_t, Double_t=0.0)=0
set the direction of the source (last argument is used in case the position depends on time) ...
std::vector< detData * > thePpacData
Short_t GetLastExecStatus() const
to get the last status
Definition: Watchers.h:300
SharedFP * fVertexFrame
Pointer to a Vertex Frame. Has to do SharedFP since can be in the data flow.
virtual void Exec(Option_t *option="")
watch the current frame
RawPrisma(const char *name, const char *title)
virtual void SetBeta(Double_t, Double_t=0.0)=0
set recoil velocity
virtual void SetBranches()
virtual void Exec(Option_t *option="")
watch the current frame
void Configure(const char *pmanager="Conf/", const char *plut="Conf/")
std::vector< detData * > theIcData
std::vector< detData * > theMcpData
MyPrismaTree(const char *name, const char *title, TTree *tree=0x0)
virtual void Exec(Option_t *option="")
watch the current frame
Int_t GetNofEvents() const
get Number of events
Base class that described an item in a Factory.
Definition: FactoryItem.h:52
static AgataEventDisplay * Instance()
static void SetDefaultPrismaConf(const Char_t *name)
TTree * GetTree()
to get the current Tree