GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ADTree.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 #include "ADTree.h"
22 #include "TSystem.h"
23 #include "TH1.h"
24 
25 #include "MetaWatchers.h"
27 
28 //--------------------------------------------------------------------------/
29 //ClassImp(ADKeyTree);
30 
31 ADKeyTree::ADKeyTree(const char *name, const char *title, TTree *tree) :
32  Watcher(name,title),
33  TTreeBuilder(name,title,tree)
34 {
35  if ( GetTree() ) { // just add the branch for that watcher
36  SetBranches();
37  }
38 }
39 
41 {
42  // Action once a the Frame is passed to this
43  fFrame = trigger->GetInputSharedFP();
44 
45  // unset the frame to be treated
46  if ( fFrame == 0x0 )
47  return false;
48 
49  // trigger and Frame set,
50  fKey = dynamic_cast<const AgataKey *>(fFrame->GetFrame()->GetKey());
51  if ( fKey == 0x0 ) {
52  return false;
53  }
54  else{
55  return true;
56  }
57 }
58 
60 {
61  GetTree()->Branch("EventNumber", &fEventNumber, "evnumber/i");
62  GetTree()->Branch("TimeStamp", &fTimestamp, "timestamp/l");
63 }
64 
65 void ADKeyTree::Exec(Option_t * /*option*/)
66 {
67  // for debugging purpose
68  if ( gDebug > 3 )
69  printf("ADKeyTree::Exec is called \n");
70 
71  // be sure the frame has been set properly
72  if ( fFrame == 0x0 || !fFrame->IsValid() )
73  { SetLastExecStatus(1); return; }
74 
75  // get event # and timestamp from the key and fill the tree
76  fEventNumber = fKey->GetEventNumber();
77  fTimestamp = fKey->GetTimeStamp();
78 
79  // fill the tree only if this is the owner of the tree ... otherwise by TreeMaster
80  FillTree();
81 }
82 
83 //--------------------------------------------------------------------------/
84 //ClassImp(ADTrackTree);
85 
86 ADTrackTree::ADTrackTree(const char *name, const char *title, TTree *tree) :
87  TrackedWatcher(name,title),
88  TTreeBuilder(name,title,tree),
89  fVertexBuilder(0x0)
90 {
91  // Vertex used for doppler correction, last registered
92  fVertexBuilder = VertexBuilder::theCurrentVertexBuilder();
93 
94  if ( GetTree() ) { // just add the branch for that watcher
95  SetBranches();
96  }
97 }
98 
100 {
101  GetTree()->Branch("nbTrack",&nbTrack,"nbTrack/I");
102  GetTree()->Branch("trackE", trackE, "trackE[nbTrack]/F");
103  GetTree()->Branch("trackEDC", trackEDC, "trackEDC[nbTrack]/F");
104  GetTree()->Branch("trackX1",trackX1,"trackX1[nbTrack]/F");
105  GetTree()->Branch("trackY1",trackY1,"trackY1[nbTrack]/F");
106  GetTree()->Branch("trackZ1",trackZ1,"trackZ1[nbTrack]/F");
107  GetTree()->Branch("trackX2",trackX2,"trackX2[nbTrack]/F");
108  GetTree()->Branch("trackY2",trackY2,"trackY2[nbTrack]/F");
109  GetTree()->Branch("trackZ2",trackZ2,"trackZ2[nbTrack]/F");
110  GetTree()->Branch("trackXS",trackXS,"trackXS[nbTrack]/F");
111  GetTree()->Branch("trackYS",trackYS,"trackYS[nbTrack]/F");
112  GetTree()->Branch("trackZS",trackZS,"trackZS[nbTrack]/F");
113  GetTree()->Branch("cosTheta",cosTheta,"cosTheta[nbTrack]/F");
114  GetTree()->Branch("trackT", trackT, "trackT[nbTrack]/F");
115  GetTree()->Branch("trackCrystalID",trackCrystalID,"trackCrystalID[nbTrack]/I");
116 
117  GetTree()->Branch("TStrack", &fTimestamp, "TStrack/l");
118 
119 #ifdef CHECK_COMMISSIONING_GANIL
120  GetTree()->Branch("Eg",Eg,"Eg[45]/F");
121  GetTree()->Branch("Eg1",Eg1,"Eg1[45]/F");
122  GetTree()->Branch("EgA",EgA,"EgA[45]/F");
123 #endif
124 }
125 
127 {
128 }
129 
130 #include "TVector3.h"
131 
132 void ADTrackTree::Exec(Option_t * /*option*/)
133 {
134  // be sure the frame has been set properly
135  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
137  return;
138  }
139 
141  fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
142 
143  // to get the data part of the frame
144  const GammaTrackedInterface *data = GetCstDataPointer<GammaTrackedInterface>(fFrame);
145  VertexInterface *vertex = fVertexBuilder->GetVertex();
146 
147  // Check Costheta
148  Double_t px, py, pz, dx, dy, dz;
149  vertex->GetPosition (px, py, pz); vertex->GetDirection(dx, dy, dz);
150 
151 #ifdef CHECK_COMMISSIONING_GANIL
152  for (UShort_t i = 0u; i < MaxG; i++)
153  Eg[i] = Eg1[i] = EgA[i] = 0.;
154 #endif
155 
156  // now fill the tree
157  nbTrack = data->GetNbGamma();
158  for (UShort_t i = 0u; i < nbTrack; i++) {
159 
160  const TrackedHit *gamma1 = data->GetGamma(i);
161  const Hit *hit1 = gamma1->GetHit();
162 
163  Double_t x = gamma1->GetX() - px;
164  Double_t y = gamma1->GetY() - py;
165  Double_t z = gamma1->GetZ() + fZOffset - pz;
166 
167  // cout << gamma1->GetID() << " " << gamma1->GetT() << " " << gamma1->GetE()<< " " << << endl;
168  // cout << gamma1->GetE() << " " << hit1->GetT() << " " << hit1->GetID(1) << " " << endl;
169 
170  Double_t dd = x*x + y*y + z*z;
171  if( !(dd == 0.0) ) {
172  cosTheta[i] = (x*dx + y*dy + z*dz)/::sqrt(dd);
173  }
174  else
175  {
176  cosTheta[i] = 0.;
177  }
178 
179  trackE[i] = gamma1->GetE();
180  trackCrystalID[i] = gamma1->GetID();
181  trackEDC[i] = DoDopplerCorrection(gamma1, vertex);
182 
183  // cout << " IN TrackTree " << i << " " << trackE[i] << " " << trackEDC[i] << endl;
184 
185  trackXS[i] = x;
186  trackYS[i] = y;
187  trackZS[i] = z;
188  trackT[i] = hit1->GetT();
189  trackCrystalID[i] = hit1->GetID(1);
190 
191 #ifdef CHECK_COMMISSIONING_GANIL
192  TVector3 Vecg;
193  if(i<MaxG)
194  {
195  Eg1[i] = trackE[i];
196  //New Formula Zgoubi coordinates considered
197 
198  Double_t Beta = vertex->GetBeta();
199  Double_t Gamma = vertex->GetGamma();
200  Double_t XV = dy;
201  Double_t YV = -1.*dx;
202  Double_t ZV = dz;
203  Vecg.SetXYZ(trackYS[i],-1.*trackXS[i],trackZS[i]);
204 
205  Double_t Theta = Vecg.Theta();
206  Double_t Phi = Vecg.Phi();
207 
208  Float_t CosAlpha =
209  sin(Theta)*
210  cos(Phi)*
211  XV +
212  YV*
213  sin(Theta) *
214  sin(Phi) +
215  ZV*cos(Theta);
216 
217  Eg[i] = Eg1[i] * (Gamma)*(1.0 - (Beta)*CosAlpha);
218  EgA[i] = acos(CosAlpha) * TMath::RadToDeg();
219  }
220 #endif
221  trackX1[i] = gamma1->GetX();
222  trackY1[i] = gamma1->GetY();
223  trackZ1[i] = gamma1->GetZ();
224 
225 
226  if ( gamma1->GetHit(1) ) {
227  trackX2[i] = gamma1->GetHit(1)->GetX();
228  trackY2[i] = gamma1->GetHit(1)->GetY();
229  trackZ2[i] = gamma1->GetHit(1)->GetZ();
230  }
231  else {
232  trackX2[i] = gamma1->GetX();
233  trackY2[i] = gamma1->GetY();
234  trackZ2[i] = gamma1->GetZ();
235  }
236  }
237 
238 
239  /*
240 
241  // now fill the tree
242  nbTrack = data->GetNbGamma();
243  for (UShort_t i = 0u; i < nbTrack; i++) {
244 
245  const TrackedHit *gamma1 = data->GetGamma(i);
246 
247  trackE[i] = gamma1->GetE();
248  trackEDC[i] = DoDopplerCorrection(gamma1, vertex);
249 
250  trackX1[i] = gamma1->GetX();
251  trackY1[i] = gamma1->GetY();
252  trackZ1[i] = gamma1->GetZ();
253 
254  if ( gamma1->GetHit(1) ) {
255  trackX2[i] = gamma1->GetHit(1)->GetX();
256  trackY2[i] = gamma1->GetHit(1)->GetY();
257  trackZ2[i] = gamma1->GetHit(1)->GetZ();
258  }
259  else {
260  trackX2[i] = gamma1->GetX();
261  trackY2[i] = gamma1->GetY();
262  trackZ2[i] = gamma1->GetZ();
263  }
264  }
265  */
266  FillTree();
267 }
268 
269 //--------------------------------------------------------------------------/
270 //ClassImp(ADHitTree);
271 
272 ADHitTree::ADHitTree(const char *name, const char *title, TTree *tree) :
273  EventPSAWatcher(name,title),
274  TTreeBuilder(name,title,tree),
275  fVertexBuilder(0x0),
276  fTrans(0x0)
277 {
278  fVertexBuilder = VertexBuilder::theCurrentVertexBuilder();
279  if ( fVertexBuilder == 0x0 )
280  std::cout << "Should not be NULL " << std::endl;
281 
283  if ( gSystem->AccessPathName("CrystalPositionLookUpTable") ) { // does not exist
284  if ( gSystem->AccessPathName("CrystalPositionLookUpTable.dat") ) {
285  fLog << error << " CrystalPositionLookUpTable required " << nline;
286  }
287  else {
288  fLog << info << " Ge positions extracted from CrystalPositionLookUpTable.dat " << nline;
289  fTrans->ReadTransformations("CrystalPositionLookUpTable.dat");
290  }
291  }
292  else {
293  fLog << info << " Ge positions extracted from CrystalPositionLookUpTable.dat " << nline;
294  fTrans->ReadTransformations("CrystalPositionLookUpTable");
295  }
296 
297  if ( GetTree() ) { // just add the branch for that watcher
298  SetBranches();
299  }
300 
301  // create spetra
302  fIdSpectra = MakeTH1<TH1F>("hit_ID_spectra","Spectra of the ID ",100,0,100);
303  fSumSpectra = MakeTH1<TH1F>("SumSpectra","Sum of all core energy ",4096,0,4096);
304  fhitAgata = MakeTH3<TH3F>("hitDW","Tracking from TaDSSD to WallD ;x;y;z",100,-200.,200.,100,-200.,200.,200,-4000.,4000.);
305 
306 
307 }
308 
310 {
311 }
312 
314 {
315  GetTree()->Branch("nbHits",&nbHits,"nbHits/I");
316  GetTree()->Branch("ESum",&ESum,"ESum/F");
317  GetTree()->Branch("hitE",hitE,"hitE[nbHits]/F");
318  GetTree()->Branch("hitX",hitX,"hitX[nbHits]/F");
319  GetTree()->Branch("hitY",hitY,"hitY[nbHits]/F");
320  GetTree()->Branch("hitZ",hitZ,"hitZ[nbHits]/F");
321  GetTree()->Branch("hitGX",hitGX,"hitGX[nbHits]/F");
322  GetTree()->Branch("hitGY",hitGY,"hitGY[nbHits]/F");
323  GetTree()->Branch("hitGZ",hitGZ,"hitGZ[nbHits]/F");
324  GetTree()->Branch("hitId",hitId,"hitId[nbHits]/I");
325  GetTree()->Branch("hitSg",hitSg,"hitSg[nbHits]/I");
326 
327  GetTree()->Branch("nbCores",&nbCores,"nbCores/I");
328  GetTree()->Branch("coreId",coreId,"coreId[nbCores]/I");
329  GetTree()->Branch("coreE0",coreE0,"coreE0[nbCores]/F");
330  GetTree()->Branch("coreE1",coreE1,"coreE1[nbCores]/F");
331  GetTree()->Branch("coreT0",coreT0,"coreT0[nbCores]/F");
332  GetTree()->Branch("coreT1",coreT1,"coreT1[nbCores]/F");
333  GetTree()->Branch("coreDE0",coreDE0,"coreDE0[nbCores]/F");
334  GetTree()->Branch("coreDE1",coreDE1,"coreDE1[nbCores]/F");
335  GetTree()->Branch("velDop",velDop,"velDop[nbCores]/F");
336  GetTree()->Branch("hit_per_cryst",hit_per_cryst,"hit_per_cryst[nbCores]/I");
337 
338  GetTree()->Branch("TSHit", &fTimestamp, "TSHit/l");
339 }
340 
341 void ADHitTree::Exec(Option_t * /*option*/)
342 {
343  // cout << "Exec MyhitTree " << endl;
344  // be sure the frame has been set properly
345  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
346  SetLastExecStatus(1u);
347  return;
348  }
349  if ( !fFrame->IsValid() ){ //For empty event:data:psa purpose
350  nbHits =0;
351  nbCores =0;
352  for(int i=0; i<MaxCore ; i++) {//empty array coreE0 coreE1
353  coreE0[i]=-1;
354  coreE1[i]=-1;
355  coreT0[i]=-1;
356  coreT1[i]=-1;
357  velDop[i]=-1;
358  coreDE0[i]=-1;
359  coreDE1[i]=-1;
360  }
361  return;
362  }
363 
364  fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
365 
366  Double_t max_e0 = 0.0; Double_t xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal, xt,yt,zt; TrackedHitImp<EHit,EHit> gamma; Int_t nb_hits = 0;
367 
368  // the vertex used for doppler correction
369  VertexInterface *vertex = fVertexBuilder->GetVertex();
370 
371  // Get beta0 for doppler correction
372  Float_t beta0 =-1;
373  // Nb_of hits per crystals
374 
375  if ( vertex ) {
376  beta0=vertex->GetBeta();
377  }
378 
379  //Initialisation:
380  //--Init total number of hit per event
381  nbHits = nbCores = 0;
382 
383  for(UInt_t i = 0u; i < GetNbFramePSA(); ++i)
384  {
385  //
386  PSAInterface *data = GetDataPSA(i);
387 
388  //Fill spectra
389  fIdSpectra->Fill(data->GetUID());
390  fSumSpectra->Fill(data->GetE());
391 
392  nb_hits = data->GetNbHits();
393  // Core like branches
394  coreId[nbCores] = data->GetUID();
395  coreE0[nbCores] = data->GetE();
396  coreE1[nbCores] = data->GetE(1u);
397  coreT0[nbCores] = data->GetT();
398  coreT1[nbCores] = data->GetT(1u);
399  hit_per_cryst[nbCores] = nb_hits;
400  velDop[nbCores] = beta0;
401 
402  // Loop on the hit to get over the hits with the max of the energy
403  max_e0 = 0.0;
404  for (Int_t j = 0; j < nb_hits; ++j) {
405 
406  const PSAHit* pHit = (PSAHit*)data->GetHit(j);
407 
408  hitE[nbHits] = pHit->GetE();
409  ESum += hitE[nbHits];
410  hitX[nbHits] = pHit->GetX();
411  hitY[nbHits] = pHit->GetY();
412  hitZ[nbHits] = pHit->GetZ();
413  hitId[nbHits] = data->GetUID() ;
414  hitSg[nbHits] = pHit->GetID();
415 
416  //Get hit position
417  pHit->GetXYZ(xLocal, yLocal, zLocal);
418  //To the AGATA global ref
419  fTrans->Local2Global(data->GetUID(), xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal);
420 
421  // Set the Position of the hit in global ref of PRESPEC
422  hitGX[nbHits]= xGlobal; // inversion X-Y and opposite direction
423  hitGY[nbHits]= yGlobal; // inversion Y-X and opposite direction
424  hitGZ[nbHits]= zGlobal; // z
425  fhitAgata->Fill(xGlobal,yGlobal, zGlobal);
426 
427  // Now look for the hit with the highest energy, taken for Doppler correction
428  // Kind of tracking in crystal
429  //
430  //Get hit position
431  pHit->GetXYZ(xLocal, yLocal, zLocal);
432  //To the AGATA global ref
433  fTrans->Local2Global(data->GetUID(), xLocal, yLocal, zLocal, xGlobal, yGlobal, zGlobal);
434 
435  if ( vertex &&beta0>0 && beta0<1) { // Get the position of the source
436  vertex->GetPosition(xt,yt,zt);
437  fhitAgata->Fill(xt,yt,zt);
438  }
439 
440  if ( pHit->GetE() > max_e0 ) { // gamma contains the position of the interaction with the highest energy in 3D
441  // Situation @ GSI
442  // gamma.SetXYZ(-yGlobal, -xGlobal, zGlobal); //x,y,z->-y,-x,-z
443  // Situation @ GANIL ... TO BE Checked
444  gamma.SetXYZ(xGlobal, yGlobal, zGlobal);
445  max_e0 = pHit->GetE();
446  }
447 
448  nbHits++;
449  }
450 
451  Double_t edc0 = -1, edc1 = -1;
452  if ( vertex ) {
453  gamma.SetE(coreE0[nbCores]);
454  edc0 = DoDopplerCorrection(&gamma,vertex);
455  gamma.SetE(coreE1[nbCores]);
456  edc1 = DoDopplerCorrection(&gamma,vertex);
457  }
458  coreDE0[nbCores] = edc0; //if there is no vertex, no energy
459  coreDE1[nbCores] = edc1; //if there is no vertex, no energy
460 
461  if ( nbHits == 500 ) {
462  SetLastExecStatus(1u);
463  fLog << error << " Number of Hits to hit in ! " << nbHits << nline;
464  nbHits = nbCores = 0;
465  break;
466  }
467  nbCores++;
468 
469  } // end loop over PSA frame
470 
471  FillTree();
472 }
473 
475 {
476  Double_t e = hit->GetE(), beta = vertex->GetBeta(), gamma = vertex->GetGamma();
477 
478  Double_t px, py, pz, dx, dy, dz;
479  vertex->GetPosition (px, py, pz);
480  vertex->GetDirection(dx, dy, dz);
481 
482  // std::cout << " " << px << " " << py << " " << pz <<std::endl;
483  // std::cout << " " << dx << " " << dy << " " << dz <<std::endl;
484 
485  Double_t x = hit->GetX() - px;
486  Double_t y = hit->GetY() - py;
487  Double_t z = hit->GetZ() - pz;
488 
489  Double_t dd = x*x + y*y + z*z;
490  if( !(dd == 0.0) ) {
491  Double_t cosTheta = (x*dx + y*dy + z*dz)/::sqrt(dd);
492  e = VertexInterface::DopplerCorrection(e,beta,gamma,cosTheta);
493  }
494  else e = -1.0;
495 
496  return e;
497 }
498 
500 {
501  //Nothing yet.
502 }
503 
504 //ClassImp(ADCoincTree);
505 
506 ADCoincTree::ADCoincTree(const char *name, const char *title, TTree *tree)
507 : EventWatcher(name,title), TTreeBuilder(name,title,tree)
508 {
509  if ( GetTree() ) { // just add the branch for that watcher
510  SetBranches();
511  }
512 }
513 
515 {
516 }
517 
519 {
520  // cout << " SetBranches\t"<< fTSCoinc << endl;
521  GetTree()->Branch("TSDiff", &fTSCoinc, "TSDiff/F");
522 }
523 
524 void ADCoincTree::Exec(Option_t * /*option*/)
525 {
526  // to get the main key
527  AgataKey * mainkey = dynamic_cast<AgataKey *> (GetTrigger()->GetInputFrame(0u)->GetKey()), *subkey = 0x0;
528 
529  fTSCoinc = 0;
530 
531  // loop on subframes and compute the timestamp differences
532  for(UInt_t which = 1u; which < GetTrigger()->GetNbInputFrame(); which++){
533 
534  SharedFP *fp = GetTrigger()->GetInputSharedFP(which);
535  if ( fp == 0x0 || !fp->IsValid() )
536  continue;
537 
538  // the subkey
539  subkey = dynamic_cast<AgataKey *> (GetTrigger()->GetInputFrame(which)->GetKey());
540  break;
541  }
542  if ( subkey ) {
543  fTSCoinc = subkey->GetTimeStamp() - mainkey->GetTimeStamp();
544  }
545 
546  // fill the tree only if this is the owner of the tree ... otherwise by TreeMaster
547  FillTree();
548 }
549 
550 
551 //--------------------------------------------------------------------------/
552 //ClassImp(ADPSAHitTree);
553 
554 ADPSAHitTree::ADPSAHitTree(const char *name, const char *title, TTree *tree) :
555  PSAWatcher(name,title),
556  TTreeBuilder(name,title,tree)
557 {
558  if ( GetTree() ) { // just add the branch for that watcher
559  SetBranches();
560  }
561 }
562 
564 {
565 }
566 
568 {
569  GetTree()->Branch("number_of_hits",&number_of_hits,"number_of_hits/I");
570  GetTree()->Branch("hitE",hitE,"hitE[number_of_hits]/F");
571  GetTree()->Branch("hitX",hitX,"hitX[number_of_hits]/F");
572  GetTree()->Branch("hitY",hitY,"hitY[number_of_hits]/F");
573  GetTree()->Branch("hitZ",hitZ,"hitZ[number_of_hits]/F");
574  GetTree()->Branch("hitSg",hitSg,"hitSg[number_of_hits]/I");
575  GetTree()->Branch("coreE0",&coreE0,"coreE0/F");
576  GetTree()->Branch("coreE1",&coreE1,"coreE1/F");
577  GetTree()->Branch("coreT0",&coreT0,"coreT0/F");
578  GetTree()->Branch("coreT1",&coreT1,"coreT1/F");
579  GetTree()->Branch("EvtNbr", &fEfvtNbr, "EvtNbr/I");
580  GetTree()->Branch("TSHit", &fTimestamp, "TSHit/l");
581 }
582 
583 void ADPSAHitTree::Exec(Option_t * /*option*/)
584 {
585  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
586  SetLastExecStatus(1u);
587  return;
588  }
589 
590  fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
591  fEfvtNbr = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetEventNumber();
592 
593  const PSAInterface *data = GetCstDataPointer<PSAInterface>(fFrame);
594 
595  number_of_hits = data->GetNbHits();
596  coreE0 = data->GetE(0u);
597  coreE1 = data->GetE(1u);
598  coreT0 = data->GetT(0u);
599  coreT1 = data->GetT(1u);
600 
601  for( UShort_t i=0u; i < number_of_hits; i++ )
602  {
603  hitSg[i] = data->GetHit(i)->GetID(0);
604  hitE[i] = data->GetHit(i)->GetE();
605  hitX[i] = data->GetHit(i)->GetX();
606  hitY[i] = data->GetHit(i)->GetY();
607  hitZ[i] = data->GetHit(i)->GetZ();
608  }
609  FillTree();
610 }
611 
613 {
614  //Nothing yet.
615 }
616 
617 void ADPSAHitTree::Print(Option_t * /*option*/ ) const
618 {
619 // std::cout<<std::endl;
620 // int size = 3 + 3 + ((TString)GetName()).Length() + 5 + ((TString)GetTitle()).Length() + 3 + 3;
621 // for(int i=0; i<size ; i++) std::cout<<"*";
622 // std::cout<<std::endl;
623 // std::cout<<"*** "<<GetName()<<" --- "<<GetTitle()<<" ***"<<std::endl;
624 // for(int i=0; i<size ; i++) std::cout<<"*";
625 // std::cout<<std::endl;
626 }
627 
628 
629 //--------------------------------------------------------------------------/
630 //ClassImp(ADCrystalTree);
631 
632 ADCrystalTree::ADCrystalTree(const char *name, const char *title, TTree *tree) :
633  ShowSignals(name,title),
634  TTreeBuilder(name,title,tree)
635 {
636  memset(SegmentTraces, 0, kNSG*sizeof(Float_t)*kNSamples);
637  memset(CoreTraces, 0, kNCC*sizeof(Float_t)*kNSamples);
638 
639  for(int atseg = 0; atseg < kNSG; atseg++) {
640  SegE[atseg] = 0;
641  SegBaselines[atseg] = 0;
642  }
643  for(int atcore = 0; atcore < kNCC; atcore++) {
644  CoreE[atcore] = 0;
645  CoreBaselines[atcore] = 0;
646  }
647 
648  if ( GetTree() ) { // just add the branch for that watcher
649  SetBranches();
650  }
651 }
652 
654 {
655 }
656 
658 {
659  GetTree()->Branch("SegmentTraces", SegmentTraces, Form("SegmentTraces[%d]/F",kNSG*kNSamples));
660  GetTree()->Branch("CoreTraces", CoreTraces, Form("CoreTraces[%d]/F",kNCC*kNSamples));
661 
662  GetTree()->Branch("SegBaselines", SegBaselines, Form("SegBaselines[%d]/D",kNSG));
663  GetTree()->Branch("SegE", SegE, Form("SegE[%d]/D",kNSG));
664 
665  GetTree()->Branch("CoreBaselines", CoreBaselines, Form("CoreBaselines[%d]/D",kNCC));
666  GetTree()->Branch("CoreE", CoreE, Form("CoreE[%d]/D",kNCC));
667 
668  GetTree()->Branch("EvtNbr_crystal", &fEfvtNbr, "EvtNbr/I");
669  GetTree()->Branch("TSHit_crystal", &fTimestamp, "TSHit/l");
670 }
671 
672 void ADCrystalTree::Exec(Option_t * /*option*/)
673 {
674  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
675  SetLastExecStatus(1u);
676  return;
677  }
678 
680 
681  fTimestamp = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetTimeStamp();
682  fEfvtNbr = ((AgataKey *)fFrame->GetFrame()->GetKey())->GetEventNumber();
683 
684  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
685  Float_t val = 0;
686 
687  for (Int_t i = 0; i < kNCC; i++ )
688  {
689  for(UInt_t j=0 ; j<kNSamples ; j++)
690  CoreTraces[i*kNSamples+j] = data->GetCore(i)->GetSignal()->Get(val,j);
691 
692  CoreBaselines[i] = fFromSignal[0];
693  CoreE[i] = data->GetCore(i)->GetE();
694  }
695 
696  for (Int_t i = 0; i < kNSG; i++ )
697  {
698  for(UInt_t j=0 ; j<kNSamples ; j++)
699  {
700  SegmentTraces[i*kNSamples+j] = data->GetSegment(i)->GetSignal()->Get(val,j);
701 // std::cout<<SegmentTraces[i][j]<<std::endl;
702  }
703 
704  SegBaselines[i] = fFromSignal[0];
705  SegE[i] = data->GetSegment(i)->GetE();
706  }
707 
708 
709 // for (Int_t i = 0; i < kNSG; i++ )
710 // {
711 // for(uint j=0 ; j<ADF::CrystalInterface::kDefaultLength ; j++)
712 // {
713 // std::cout<<SegmentTraces[i][j]<<std::endl;
714 // }
715 // }
716 
717 // std::cin.get();
718 
719  FillTree();
720 }
721 
722 void ADCrystalTree::ConvertInGraph(TH1 *h, TGraph *g)
723 {
724  for(int i=0 ; i<h->GetNbinsX() ; i++)
725  {
726  g->SetPoint(i,h->GetBinLowEdge(i+1),h->GetBinCenter(i+1));
727  }
728 }
729 
731 {
732  //Nothing yet.
733 }
734 
735 void ADCrystalTree::Print(Option_t * /*option*/ ) const
736 {
737  std::cout<<std::endl;
738  int size = 3 + 3 + ((TString)GetName()).Length() + 5 + ((TString)GetTitle()).Length() + 3 + 3;
739  for(int i=0; i<size ; i++) std::cout<<"*";
740  std::cout<<std::endl;
741  std::cout<<"*** "<<GetName()<<" --- "<<GetTitle()<<" ***"<<std::endl;
742  for(int i=0; i<size ; i++) std::cout<<"*";
743  std::cout<<std::endl;
744 }
virtual Double_t GetE() const
Definition: CrystalFrame.h:64
Float_t fTSCoinc
Definition: ADTree.h:201
virtual Bool_t IsValid() const
true if it is a valid pointer
Definition: Frame.h:616
virtual void GetDirection(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the direction of the source (last argument is used in case the position depends on time) ...
virtual VertexInterface * GetVertex()
Get the vertex data interface.
virtual UShort_t GetNbHits() const =0
To know the number of Hits currently on the stack.
virtual Key * GetKey()=0
To get the Key associated to this frame.
virtual Double_t DoDopplerCorrection(const TrackedHit *hit, VertexInterface *vertex)
Do Doppler taking into account additionnal offset of the agat position (see SetAgataOffset) ...
printf("******************************************************************** \n")
virtual Frame * GetFrame() const
Definition: Frame.h:625
ADCrystalTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:632
UInt_t GetNbFramePSA()
number of PSA Frames extracted from the current event
virtual Double_t GetY() const
Definition: Hits.h:57
virtual ~ADPSAHitTree()
Definition: ADTree.C:563
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:65
virtual void SetBranches()
Definition: ADTree.C:518
virtual GeCore * GetCore(UShort_t)=0
to get each core
virtual void SetBranches()
Definition: ADTree.C:657
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:524
LogMessage & error(LogMessage &)
ULong64_t fTimestamp
Current timestamp.
Definition: ADTree.h:137
virtual void GetPosition(Double_t &, Double_t &, Double_t &, Double_t=0.0) const =0
get the position of the source (last argument is used in case the position depends on time) ...
virtual UShort_t Get(UShort_t, UInt_t) const =0
Method to get the value for a particular bin of the signal.
ULong64_t fTimestamp
Definition: ADTree.h:84
std::vector< Double_t > fFromSignal
Some characteritics extracted from the signal.
Int_t fEfvtNbr
Definition: ADTree.h:268
ADCoincTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:506
virtual Double_t GetE(UInt_t=0u) const =0
to get the energy associated to the core
virtual GeSegment * GetSegment(UShort_t)=0
to get individual segment
virtual Signal * GetSignal()
Definition: CrystalFrame.h:56
virtual Double_t GetE() const
Definition: Hits.h:67
virtual Int_t GetUID() const =0
to get the crystal ID
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:341
Interface to AgataKey.
virtual SharedFP * GetInputSharedFP(UInt_t which=0u)=0
to get back the Shared pointer that define this trigger
The tracking algorithm produces a stack of TrackedHits.
Definition: TrackedFrame.h:41
virtual TrackedHit * GetGamma(UShort_t) const =0
To get the current number of gammas in the stack.
virtual void Print(Option_t *option="") const
Definition: ADTree.C:617
void FillSpectraByUser()
Filling the spectra.
Definition: ADTree.C:499
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:583
SharedFP * fFrame
virtual Double_t GetT(UInt_t=0u) const =0
to get the time associated to the core
LogMessage & nline(LogMessage &)
virtual void SetBranches()
Definition: ADTree.C:99
virtual Double_t GetX() const
Definition: Hits.h:146
Int_t fEfvtNbr
Definition: ADTree.h:223
Data produced fro a Crystal.
Definition: CrystalFrame.h:106
AgataGeometryTransformer class that manage geometry transformations.
virtual Double_t GetE() const
Definition: Hits.h:158
void FillSpectraByUser()
Filling the spectra.
Definition: ADTree.C:612
AgataGeometryTransformer * fTrans
used to transform local to global [since otherwise done in tracking]
Definition: ADTree.h:139
virtual ULong64_t GetTimeStamp() const =0
To set the timestamp.
virtual Double_t GetBeta(Double_t=0.0) const =0
get recoil velocity
Base class for a Watcher.
Definition: Watchers.h:60
ADHitTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:272
ULong64_t fTimestamp
Current timestamp.
Definition: ADTree.h:267
virtual Int_t GetID(Int_t=0) const
Definition: Hits.h:111
virtual UInt_t GetNbInputFrame() const =0
number of input frames that define this trigger
ULong64_t fTimestamp
Current timestamp.
Definition: ADTree.h:222
virtual void Exec(Option_t *option="")
change for that signal baseline, threshold and overshoot
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
virtual Double_t GetT() const
Definition: Hits.h:72
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
Base class for a Watcher that fill a TTree or some branches of a TTree.
Definition: TTreeWatchers.h:51
Base class for a Hit.
Definition: Hits.h:35
LogMessage fLog
Definition: Watchers.h:86
virtual UInt_t GetEventNumber() const =0
To get the event number encoded.
virtual void SetBranches()
Definition: ADTree.C:313
virtual void SetBranches()
add branches to the ttree.
Definition: ADTree.C:59
virtual Frame * GetInputFrame(UInt_t which=0u)=0
to get back the frames that define this trigger
virtual Double_t GetZ() const
Definition: Hits.h:150
Base Watcher working for any event:data.
virtual ~ADHitTree()
Definition: ADTree.C:309
ADPSAHitTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:554
To work on Signals.
virtual Double_t DoDopplerCorrection(const TrackedHit *hit, VertexInterface *vertex)
Do Doppler taking into account additionnal offset of the agata position (see SetAgataOffset) ...
Definition: ADTree.C:474
virtual void SetXYZ(Double_t x, Double_t y, Double_t z)
Definition: Hits.h:314
virtual void SetE(Double_t e)
Definition: Hits.h:321
It is a hit associated to a list of Hits.
Definition: Hits.h:256
virtual Double_t GetX() const
Definition: Hits.h:55
PSAInterface * GetDataPSA(UInt_t which)
To get one by one the PSA Frames in one event (It fills fFramePSA). Read has beed called ! ...
A Shared Frame Pointer.
Definition: Frame.h:597
virtual Double_t GetGamma(Double_t=0.0) const
Definition: MetaFrame.h:77
void ConvertInGraph(TH1 *h, TGraph *g)
Definition: ADTree.C:722
virtual Int_t GetID(Int_t which_id=0) const
get crystal/segment id. if which_id > 0, get crystal ID.
Definition: PSAFrame.h:96
virtual void FillTree()
Fill the tree if it is the owner of the tree.
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:132
Base class for a trigger on a data flow.
Definition: Trigger.h:155
Bool_t ReadTransformations(const TString fileName)
read transformations file
ADF::LogMessage & endl(ADF::LogMessage &log)
ADKeyTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:31
ADTrackTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ADTree.C:86
static const int kNSamples
Definition: ADTree.h:263
virtual Double_t GetZ() const
Definition: Hits.h:59
virtual UShort_t GetNbGamma() const =0
To get the current number of gammas in the stack.
static const int kNCC
Definition: ADTree.h:261
void FillSpectraByUser()
Filling the spectra.
Definition: ADTree.C:730
virtual void Print(Option_t *option="") const
Definition: ADTree.C:735
SharedFP * fFrame
main frame i.e. event:data:psa
Concrete implementation of a tracked Hit.
Definition: Hits.h:279
static const int kNSG
Definition: ADTree.h:262
virtual ADF::DFTrigger * GetTrigger() const
To know the trigger in which the frame to be watched is embedded.
Definition: Watchers.h:360
*********************************** EventPSAWatcher Class **************************************/// ...
const Int_t size
Definition: BenchIO.C:24
virtual Double_t GetY() const
Definition: Hits.h:148
virtual ~ADCoincTree()
Definition: ADTree.C:514
virtual Hit * GetHit(UShort_t)=0
To get back a particular Hit (already on the stack !)
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
set the trigger on the main Frame whatever it is
Definition: ADTree.C:40
Base Watcher working for any kind of Frame (Frame interface)
void Local2Global(Int_t detID, Double_t xl, Double_t yl, Double_t zl, Double_t &xg, Double_t &yg, Double_t &zg) const
Transform point from the local reference frame of the detection id to the global reference frame...
virtual Hit * GetHit(UInt_t i=0) const =0
Get Hit number i of the track (already added with NewHit !!)
Base Watcher working for any kind of Trackek Frame (Frame interface) and.
virtual void GetXYZ(Double_t &x, Double_t &y, Double_t &z) const
Definition: Hits.h:155
virtual void SetBranches()
Definition: ADTree.C:567
virtual ~ADTrackTree()
Definition: ADTree.C:126
virtual void Exec(Option_t *option="")
watch the current frame
Definition: ADTree.C:672
TTree * GetTree()
to get the current Tree
static VertexBuilder * theCurrentVertexBuilder()
to get the current VertexWatcher (for other watchers) i.e. the last one registered.
virtual ~ADCrystalTree()
Definition: ADTree.C:653