Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaVDC.cxx
Go to the documentation of this file.
1
2// //
3// THaVDC //
4// //
5// High precision wire chamber class. //
6// //
7// Units used: //
8// For X, Y, and Z coordinates of track - meters //
9// For Theta and Phi angles of track - tan(angle) //
10// //
12
13#include "THaVDC.h"
14#include "THaEvData.h"
15#include "THaTrack.h"
16#include "THaVDCChamber.h"
17#include "THaVDCPoint.h"
18#include "THaVDCCluster.h"
19#include "THaVDCTrackID.h"
20#include "THaVDCPointPair.h"
21#include "THaScintillator.h"
22#include "THaSpectrometer.h"
23#include "TMath.h"
24#include "TClonesArray.h"
25#include "TList.h"
26#include "VarDef.h"
27#include "TROOT.h"
28#include "THaString.h"
30#include <map>
31#include <cstdio>
32#include <cstdlib>
33#include <cassert>
34#include <cctype>
35#include <sstream>
36#include <iostream>
37#include <iomanip>
38
39using namespace std;
40using namespace VDC;
41
42// Helper structure for parsing tensor data
43typedef vector<THaVDC::THaMatrixElement> MEvec_t;
44class MEdef_t {
45public:
46 MEdef_t() : elems(nullptr), npow(0), fpidx(0), isfp(false) {}
47 MEdef_t( Int_t npw, MEvec_t* elemp, Bool_t is_fp = false, Int_t fp_idx = 0 )
48 : elems(elemp), npow(npw), fpidx(fp_idx), isfp(is_fp) {}
49 MEvec_t* elems; // Pointer to member variable holding data
50 Int_t npow; // Number of exponents for this element type
51 Int_t fpidx; // Index into fFPMatrixElems
52 Bool_t isfp; // This defines a focal plane matrix element
53};
54
55//_____________________________________________________________________________
56THaVDC::THaVDC( const char* name, const char* description,
57 THaApparatus* apparatus ) :
58 THaTrackingDetector(name,description,apparatus),
59 // Create objects for the upper and lower chamber
60 fLower{new THaVDCChamber("uv1", "Lower VDC chamber", this)},
61 fUpper{new THaVDCChamber("uv2", "Upper VDC chamber", this)},
62 fLUpairs{new TClonesArray("THaVDCPointPair", 20)},
63 fNtracks(0), fEvNum(0),
64 // Default geometry parameters. Exact values are read in ReadDatabase.
65 fVDCAngle(-TMath::PiOver4()), fSin_vdc(-0.5*TMath::Sqrt2()),
66 fCos_vdc(0.5*TMath::Sqrt2()), fTan_vdc(-1.0),
67 fSpacing(0.33), fCentralDist(0.),
68 fNumIter(1), fErrorCutoff(1e9), fCoordType(kRotatingTransport),
69 fTimeCorrectionModule(nullptr)
70{
71 // Constructor
72 if( fLower->IsZombie() || fUpper->IsZombie() ) {
73 Error( Here("THaVDC()"), "Failed to create subdetectors." );
74 MakeZombie();
75 }
76
77 // Default behavior for now
79}
80
81//_____________________________________________________________________________
83{
84 // Destructor. Delete subdetectors.
85
87 delete fLower;
88 delete fUpper;
89 delete fLUpairs;
90}
91
92//_____________________________________________________________________________
94{
95 // Initialize VDC. Calls standard Init(), then initializes subdetectors.
96
97 if( IsZombie() || !fUpper || !fLower )
98 return fStatus = kInitError;
99
100 if( (fStatus = THaTrackingDetector::Init( date )) ||
101 (fStatus = fLower->Init( date )) ||
102 (fStatus = fUpper->Init( date )) )
103 return fStatus;
104
105 // Get the spacing between the VDC chambers
107
108 return fStatus = kOK;
109}
110
111//_____________________________________________________________________________
112static Int_t ParseMatrixElements( const string& MEstring,
113 map<string,MEdef_t>& matrix_map,
114 const char* prefix )
115{
116 // Parse the contents of MEstring (from the database) into the local
117 // member variables holding the matrix elements
118
119 //FIXME: move to HRS
120
121 const char* const here = "THaVDC::ParseMatrixElements";
122
123 istringstream ist(MEstring);
124 string word, w;
125 bool findnext = true, findpowers = true;
126 Int_t powers_left = 0;
127 auto cur = matrix_map.end();
129 while( ist >> word ) {
130 if( !findnext ) {
131 assert( cur != matrix_map.end() );
132 bool havenext = isalpha(word[0]);
133 if( findpowers ) {
134 assert( powers_left > 0 );
135 if( havenext || word.find_first_not_of("0123456789") != string::npos ||
136 atoi(word.c_str()) > 9 ) {
137 Error( Here(here,prefix), "Bad exponent = %s for matrix element \"%s\". "
138 "Must be integer between 0 and 9. Fix database.",
139 word.c_str(), w.c_str() );
141 }
142 ME.pw.push_back( atoi(word.c_str()) );
143 if( --powers_left == 0 ) {
144 // Read all exponents
145 if( cur->second.isfp ) {
146 // Currently only the "000" focal plane matrix elements are supported
147 if( ME.pw[0] != 0 || ME.pw[1] != 0 || ME.pw[2] != 0 ) {
148 Error( Here(here,prefix), "Bad coefficients of focal plane matrix "
149 "element %s = %d %d %d. Fix database.",
150 w.c_str(), ME.pw[0], ME.pw[1], ME.pw[2] );
152 } else {
153 findpowers = false;
154 }
155 }
156 else {
157 // Check if this element already exists, if so, skip
158 MEvec_t* mat = cur->second.elems;
159 assert(mat);
160 bool match = false;
161 for( auto it = mat->begin();
162 it != mat->end() && !(match = it->match(ME)); ++it ) {}
163 if( match ) {
164 Warning( Here(here,prefix), "Duplicate definition of matrix element %s. "
165 "Using first definition.", cur->first.c_str() );
166 findnext = true;
167 } else {
168 findpowers = false;
169 }
170 }
171 }
172 } else {
173 if( !havenext ) {
174 if( ME.poly.size() >= THaVDC::kPORDER )
175 havenext = true;
176 else {
177 ME.poly.push_back( atof(word.c_str()) );
178 if( ME.poly.back() != 0.0 ) {
179 ME.iszero = false;
180 ME.order = static_cast<int>(ME.poly.size());
181 }
182 }
183 }
184 if( havenext || ist.eof() ) {
185 if( ME.poly.empty() ) {
186 // No data read at all?
187 Error( Here(here,prefix), "Could not read in Matrix Element %s%d%d%d!",
188 w.c_str(), ME.pw[0], ME.pw[1], ME.pw[2]);
190 }
191 if( !ME.iszero ) {
192 MEvec_t* mat = cur->second.elems;
193 assert(mat);
194 // The focal plane matrix elements are stored in a single vector
195 if( cur->second.isfp ) {
196 THaVDC::THaMatrixElement& m = (*mat)[cur->second.fpidx];
197 if( m.order > 0 ) {
198 Warning( Here(here,prefix), "Duplicate definition of focal plane "
199 "matrix element %s. Using first definition.",
200 w.c_str() );
201 } else
202 m = ME;
203 } else
204 mat->push_back(ME);
205 }
206 findnext = true;
207 if( !havenext )
208 continue;
209 } // if (havenext)
210 } // if (findpowers) else
211 } // if (!findnext)
212 if( findnext ) {
213 cur = matrix_map.find(word);
214 if( cur == matrix_map.end() ) {
215 // Error( Here(here,prefix), "Unknown matrix element type %s. Fix database.",
216 // word.c_str() );
217 // return THaAnalysisObject::kInitError;
218 continue;
219 }
220 ME.clear();
221 findnext = false; findpowers = true;
222 powers_left = cur->second.npow;
223 w = word;
224 }
225 } // while(word)
226
228}
229
230//_____________________________________________________________________________
232{
233 // Read VDC database
234
235 const char* const here = "ReadDatabase";
236
237 FILE* file = OpenFile( date );
238 if( !file ) return kFileError;
239
240 // Read fOrigin and fSize (currently unused)
241 Int_t err = ReadGeometry( file, date );
242 if( err ) {
243 fclose(file);
244 return err;
245 }
246
247 // Read TRANSPORT matrices
248 //FIXME: move to HRS
249 fTMatrixElems.clear();
250 fDMatrixElems.clear();
251 fPMatrixElems.clear();
252 fPTAMatrixElems.clear();
253 fYMatrixElems.clear();
254 fYTAMatrixElems.clear();
255 fLMatrixElems.clear();
256
257 fFPMatrixElems.clear();
258 fFPMatrixElems.resize(3);
259
260 map<string,MEdef_t> matrix_map;
261
262 // TRANSPORT to focal-plane tensors
263 matrix_map["t"] = MEdef_t( 3, &fFPMatrixElems, true, 0 );
264 matrix_map["y"] = MEdef_t( 3, &fFPMatrixElems, true, 1 );
265 matrix_map["p"] = MEdef_t( 3, &fFPMatrixElems, true, 2 );
266 // Standard focal-plane to target matrix elements (D=delta, T=theta, Y=y, P=phi)
267 matrix_map["D"] = MEdef_t( 3, &fDMatrixElems );
268 matrix_map["T"] = MEdef_t( 3, &fTMatrixElems );
269 matrix_map["Y"] = MEdef_t( 3, &fYMatrixElems );
270 matrix_map["P"] = MEdef_t( 3, &fPMatrixElems );
271 // Additional matrix elements describing the dependence of y-target and
272 // phi-target on the /absolute value/ of theta, found necessary in optimizing
273 // the septum magnet optics (R. Feuerbach, March 1, 2005)
274 matrix_map["YTA"] = MEdef_t( 4, &fYTAMatrixElems );
275 matrix_map["PTA"] = MEdef_t( 4, &fPTAMatrixElems );
276 // Matrix for calculating pathlength from z=0 (target) to focal plane (meters)
277 // (R. Feuerbach, October 16, 2003)
278 matrix_map["L"] = MEdef_t( 4, &fLMatrixElems );
279
280 string MEstring, TCmodule;
281 DBRequest request1[] = {
282 { "matrixelem", &MEstring, kString },
283 { "time_cor", &TCmodule, kString, 0, true },
284 { nullptr }
285 };
286 err = LoadDB( file, date, request1, fPrefix );
287 if( err ) {
288 fclose(file);
289 return err;
290 }
291 if( MEstring.empty() ) {
292 Error( Here(here), "No matrix elements defined. Set \"maxtrixelem\" in database." );
293 fclose(file);
294 return kInitError;
295 }
296 // Parse the matrix elements
297 err = ParseMatrixElements( MEstring, matrix_map, fPrefix );
298 if( err ) {
299 fclose(file);
300 return err;
301 }
302 MEstring.clear();
303
304 // Ensure that we have all three focal plane matrix elements, else we cannot
305 // do anything sensible with the tracks
306 if( fFPMatrixElems[T000].order == 0 ) {
307 Error( Here(here), "Missing FP matrix element t000. Fix database." );
308 err = kInitError;
309 }
310 if( fFPMatrixElems[Y000].order == 0 ) {
311 Error( Here(here), "Missing FP matrix element y000. Fix database." );
312 err = kInitError;
313 }
314 if( fFPMatrixElems[P000].order == 0 ) {
315 Error( Here(here), "Missing FP matrix element p000. Fix database." );
316 err = kInitError;
317 }
318 if( err ) {
319 fclose(file);
320 return err;
321 }
322
323 // If given, find the module for calculating an event-by-event
324 // time offset correction
325 if( !TCmodule.empty() ) {
327 (FindModule(TCmodule.c_str(), "Podd::TimeCorrectionModule", false));
328 if( !fTimeCorrectionModule ) {
329 Warning( Here(here), "Time correction module \"%s\" not found. "
330 "Event-by-event time offsets will NOT be used!\nCheck \"time_cor\" database key",
331 TCmodule.c_str() );
332 }
333 }
334
335 // Compute derived geometry quantities
336 fTan_vdc = fFPMatrixElems[T000].poly[0];
340
341 // Define the VDC coordinate axes in the "TRANSPORT system" (z along particle
342 // direction at central momentum)
344
345 // Read configuration parameters
346 fErrorCutoff = 1e9;
347 fNumIter = 1;
349 Int_t disable_tracking = 0, disable_finetrack = 0, only_fastest_hit = 1;
350 Int_t do_tdc_hardcut = 1, do_tdc_softcut = 0, ignore_negdrift = 0;
351#ifdef MCDATA
352 Int_t mc_data = 0;
353#endif
354 string coord_type;
355
356 DBRequest request[] = {
357 { "max_matcherr", &fErrorCutoff, kDouble, 0, true },
358 { "num_iter", &fNumIter, kInt, 0, true },
359 { "coord_type", &coord_type, kString, 0, true },
360 { "disable_tracking", &disable_tracking, kInt, 0, true },
361 { "disable_finetrack", &disable_finetrack, kInt, 0, true },
362 { "only_fastest_hit", &only_fastest_hit, kInt, 0, true },
363 { "do_tdc_hardcut", &do_tdc_hardcut, kInt, 0, true },
364 { "do_tdc_softcut", &do_tdc_softcut, kInt, 0, true },
365 { "ignore_negdrift", &ignore_negdrift, kInt, 0, true },
366#ifdef MCDATA
367 { "MCdata", &mc_data, kInt, 0, true },
368#endif
369 { nullptr }
370 };
371
372 err = LoadDB( file, date, request, fPrefix );
373 fclose(file);
374 if( err )
375 return err;
376
377 // Analysis control flags
378 SetBit( kOnlyFastest, only_fastest_hit );
379 SetBit( kHardTDCcut, do_tdc_hardcut );
380 SetBit( kSoftTDCcut, do_tdc_softcut );
381 SetBit( kIgnoreNegDrift, ignore_negdrift );
382#ifdef MCDATA
383 SetBit( kMCdata, mc_data );
384#endif
385 SetBit( kDecodeOnly, disable_tracking );
386 SetBit( kCoarseOnly, !disable_tracking && disable_finetrack );
387
388 if( !coord_type.empty() ) {
389 if( THaString::CmpNoCase(coord_type, "Transport") == 0 )
391 else if( THaString::CmpNoCase(coord_type, "RotatingTransport") == 0 )
393 else {
394 Error( Here(here), "Invalid coordinate type coord_type = %s. "
395 "Must be \"Transport\" or \"RotatingTransport\". Fix database.",
396 coord_type.c_str() );
397 return kInitError;
398 }
399 }
400
401 // Sanity checks of parameters
402 if( fErrorCutoff < 0.0 ) {
403 Warning( Here(here), "Negative max_matcherr = %6.2lf makes no sense, "
404 "taking absolute.", fErrorCutoff );
406 } else if( fErrorCutoff == 0.0 ) {
407 Error( Here(here), "Illegal parameter max_matcherr = 0.0. Must be > 0. "
408 "Fix database." );
409 return kInitError;
410 }
411 if( fNumIter < 0) {
412 Warning( Here(here), "Negative num_iter = %d makes no sense, "
413 "taking absolute.", fNumIter );
415 } else if( fNumIter > 10 ) {
416 Error( Here(here), "Illegal parameter num_iter = %d. Must be <= 10. "
417 "Fix database.", fNumIter );
418 return kInitError;
419 }
420
421 if( fDebug > 0 ) {
422#ifdef MCDATA
423 Info( Here(here), "VDC flags fastest/hardcut/softcut/noneg/mcdata/"
424 "decode/coarse = %d/%d/%d/%d/%d/%d/%d", TestBit(kOnlyFastest),
427#else
428 Info( Here(here), "VDC flags fastest/hardcut/softcut/noneg/"
429 "decode/coarse = %d/%d/%d/%d/%d/%d", TestBit(kOnlyFastest),
432#endif
433 }
434
435 // figure out the track length from the origin to the s1 plane
436 // since we take the VDC to be the origin of the coordinate
437 // space, this is actually pretty simple
438 const THaDetector* s1 = nullptr;
439 if( GetApparatus() )
440 // TODO: need? if so, change to HRS reference detector
441 s1 = GetApparatus()->GetDetector("s1");
442 if(s1 == nullptr)
443 fCentralDist = 0;
444 else
445 fCentralDist = s1->GetOrigin().Z();
446
447 CalcMatrix(1.,fLMatrixElems); // tensor without explicit polynomial in x_fp
448
449 fIsInit = true;
450 return kOK;
451}
452
453//_____________________________________________________________________________
455{
456 // Initialize global variables and lookup table for decoder
457
459 if( ret )
460 return ret;
461
462 // Register variables in global list
463
464 RVarDef vars[] = {
465 { "time_cor", "Trigger time offset (s)", "GetTimeCorrectionUnchecked()" },
466 { nullptr }
467 };
468 return DefineVarsFromList( vars, mode );
469}
470
471//_____________________________________________________________________________
473{
474 // Construct tracks from pairs of upper and lower points and add
475 // them to 'tracks'
476
477 // TODO:
478 // Only make combos whose projections are close
479 // do a real 3D fit, not just compute 3D chi2?
480
481#ifdef WITH_DEBUG
482 if( fDebug>1 ) {
483 cout << "-----------------------------------------------\n";
484 cout << "ConstructTracks: ";
485 if( mode == 0 )
486 cout << "iterating";
487 if( mode == 1 )
488 cout << "coarse tracking";
489 if( mode == 2 )
490 cout << "fine tracking";
491 cout << endl;
492 }
493#endif
494 UInt_t theStage = ( mode == 1 ) ? kCoarse : kFine;
495
496 fLUpairs->Clear();
497
498 Int_t nUpper = fUpper->GetNPoints();
499 Int_t nLower = fLower->GetNPoints();
500
501#ifdef WITH_DEBUG
502 if( fDebug>1 )
503 cout << "nUpper/nLower = " << nUpper << " " << nLower << endl;
504#endif
505
506 // One plane has no tracks, the other does
507 // -> maybe recoverable with loss of precision
508 // FIXME: Only do this if missing cluster recovery flag set
509 if( (nUpper == 0) xor (nLower == 0) ) {
510 //FIXME: Put missing cluster recovery code here
511 //For now, do nothing
512#ifdef WITH_DEBUG
513 if( fDebug>1 )
514 cout << "missing cluster " << nLower << " " << nUpper << endl;
515#endif
516 }
517
518 Int_t nPairs = 0; // Number of point pairs to consider
519
520 for( int i = 0; i < nLower; i++ ) {
521 THaVDCPoint* lowerPoint = fLower->GetPoint(i);
522 assert(lowerPoint);
523
524 for( int j = 0; j < nUpper; j++ ) {
525 THaVDCPoint* upperPoint = fUpper->GetPoint(j);
526 assert(upperPoint);
527
528 // Compute projection error of the selected pair of points
529 // i.e., how well the two points point at each other.
530 // Don't bother with pairs that are obviously mismatched
531 Double_t error =
532 THaVDCPointPair::CalcError( lowerPoint, upperPoint, fSpacing );
533
534 // Don't create pairs whose matching error is too big
535 if( error >= fErrorCutoff )
536 continue;
537
538 // Create new point pair
539 auto* thePair = new( (*fLUpairs)[nPairs++] )
540 THaVDCPointPair( lowerPoint, upperPoint, fSpacing );
541
542 // Explicitly mark these points as unpartnered
543 lowerPoint->SetPartner( nullptr );
544 upperPoint->SetPartner( nullptr );
545
546 // Further analyze this pair
547 //TODO: Several things come to mind, to be tested:
548 // - calculate global slope
549 // - recompute drift distances using global slope
550 // - refit cluster using new distances
551 // - calculate global chi2
552 // - sort pairs by this global chi2 later?
553 // - could do all of this before deciding to keep this pair
554 thePair->Analyze();
555 }
556 }
557
558 // Initialize counters
559 int n_exist = 0, n_mod = 0;
560#ifdef WITH_DEBUG
561 //int n_oops = 0;
562#endif
563 // How many tracks already exist in the global track array?
564 if( tracks )
565 n_exist = tracks->GetLast()+1;
566
567 // Sort pairs in order of ascending matching error
568 if( nPairs > 1 )
569 fLUpairs->Sort();
570
571#ifdef WITH_DEBUG
572 if( fDebug>1 ) {
573 cout << nPairs << " pairs.\n";
574 fLUpairs->Print();
575 }
576#endif
577
578 Int_t nTracks = 0; // Number of reconstructed tracks
579
580 // Mark pairs as partners, starting with the best matches,
581 // until all tracks are marked.
582 for( int i = 0; i < nPairs; i++ ) {
583 auto* thePair = static_cast<THaVDCPointPair*>( fLUpairs->At(i) );
584 assert( thePair );
585 assert( thePair->GetError() < fErrorCutoff );
586
587#ifdef WITH_DEBUG
588 if( fDebug>1 ) {
589 cout << "Pair " << i << ": ";
590 thePair->Print("NOHEAD");
591 }
592#endif
593
594 // Skip pairs where any of the points already has at least one used cluster
595 if( thePair->HasUsedCluster() ) {
596#ifdef WITH_DEBUG
597 if( fDebug>1 )
598 cout << " ... skipped (cluster already used)." << endl;
599#endif
600 continue;
601 }
602#ifdef WITH_DEBUG
603 if( fDebug>1 )
604 cout << " ... good." << endl;
605#endif
606
607 // Get the points of the pair
608 THaVDCPoint* lowerPoint = thePair->GetLower();
609 THaVDCPoint* upperPoint = thePair->GetUpper();
610 assert( lowerPoint && upperPoint );
611
612 // All partnered pairs must have a used cluster and hence never get here,
613 // else there is a bug in the underlying logic
614 assert( lowerPoint->GetPartner() == nullptr && upperPoint->GetPartner() == nullptr );
615
616 // Use the pair. This partners the points, marks its clusters as used
617 // and calculates global slopes
618 thePair->Use();
619 nTracks++;
620
621#ifdef WITH_DEBUG
622 if( fDebug>2 ) {
623 thePair->Print("TRACKP");
624 }
625#endif
626
627 // If the 'tracks' array was given, add THaTracks to it
628 // (or modify existing ones).
629 if (tracks) {
630
631 // Decide whether this is a new track or an old track
632 // that is being updated
633 auto* thisID = new THaVDCTrackID(lowerPoint,upperPoint);
634 THaTrack* theTrack = nullptr;
635 bool found = false;
636 int t = 0;
637 for( ; t < n_exist; t++ ) {
638 theTrack = static_cast<THaTrack*>( tracks->At(t) );
639 // This test is true if an existing track has exactly the same clusters
640 // as the current one (defined by lowerPoint/upperPoint)
641 if( theTrack && theTrack->GetCreator() == this &&
642 *thisID == *theTrack->GetID() ) {
643 found = true;
644 break;
645 }
646#ifdef WITH_DEBUG
647 // FIXME: for debugging
648 //n_oops++;
649#endif
650 }
651
652 UInt_t flag = theStage;
653 if( nPairs > 1 )
654 flag |= kMultiTrack;
655
656 if( found ) {
657#ifdef WITH_DEBUG
658 if( fDebug>1 )
659 cout << "Track " << t << " modified.\n";
660#endif
661 delete thisID;
662 ++n_mod;
663 } else {
664#ifdef WITH_DEBUG
665 if( fDebug>1 )
666 cout << "Track " << tracks->GetLast()+1 << " added.\n";
667#endif
668 theTrack = AddTrack(*tracks, 0.0, 0.0, 0.0, 0.0, thisID );
669 // theTrack->SetID( thisID );
670 // theTrack->SetCreator( this );
671 theTrack->AddCluster( lowerPoint );
672 theTrack->AddCluster( upperPoint );
673 assert( tracks->IndexOf(theTrack) >= 0 );
674 theTrack->SetTrkNum( tracks->IndexOf(theTrack)+1 );
675 thePair->Associate( theTrack );
676 if( theStage == kFine )
677 flag |= kReassigned;
678 }
679
680 theTrack->SetD(lowerPoint->GetX(), lowerPoint->GetY(),
681 lowerPoint->GetTheta(), lowerPoint->GetPhi());
682 theTrack->SetFlag( flag );
683
684 // Calculate the TRANSPORT coordinates
685 CalcFocalPlaneCoords(theTrack);
686
687 // Calculate the chi2 of the track from the distances to the wires
688 // in the associated clusters
689 chi2_t chi2 = thePair->CalcChi2();
690 theTrack->SetChi2( chi2.first, chi2.second - 4 );
691
692#ifdef WITH_DEBUG
693 if( fDebug>2 ) {
694 Double_t chisq = chi2.first;
695 Int_t nhits = chi2.second;
696 cout << " chi2/ndof = " << chisq << "/" << nhits-4;
697 if( nhits > 4 )
698 cout << " = " << chisq/(nhits-4);
699 cout << endl;
700 }
701#endif
702 }
703 }
704
705#ifdef WITH_DEBUG
706 if( fDebug>1 )
707 cout << nTracks << " good tracks.\n";
708#endif
709
710 // Delete tracks that were not updated
711 if( tracks && n_exist > n_mod ) {
712 // bool modified = false;
713 for( int i = 0; i < tracks->GetLast()+1; i++ ) {
714 auto* theTrack = static_cast<THaTrack*>( tracks->At(i) );
715 // Track created by this class and not updated?
716 if( (theTrack->GetCreator() == this) &&
717 ((theTrack->GetFlag() & kStageMask) != theStage ) ) {
718 // First, release clusters pointing to this track
719 for( int j = 0; j < nPairs; j++ ) {
720 auto* thePair = static_cast<THaVDCPointPair*>( fLUpairs->At(i) );
721 assert(thePair);
722 if( thePair->GetTrack() == theTrack ) {
723 thePair->Associate(nullptr);
724 break;
725 }
726 }
727 // Then, remove the track
728 tracks->RemoveAt(i);
729 // modified = true;
730#ifdef WITH_DEBUG
731 if( fDebug>1 )
732 cout << "Track " << i << " deleted.\n";
733#endif
734 }
735 }
736 // Get rid of empty slots - they may cause trouble in the Event class and
737 // with global variables.
738 // Note that the PIDinfo and vertices arrays are not reordered.
739 // Therefore, PID and vertex information must always be retrieved from the
740 // track objects, not from the PID and vertex TClonesArrays.
741 // FIXME: Is this really what we want?
742 // FIXME: invalidates some or all the track numbers in the clusters
743// if( modified )
744// tracks->Compress();
745 }
746
747 // Assign index to each track (0 = first/"best", 1 = second, etc.)
748 if( tracks ) {
749 for( int i = 0; i < tracks->GetLast()+1; i++ ) {
750 auto* theTrack = static_cast<THaTrack*>( tracks->At(i) );
751 assert( theTrack );
752 theTrack->SetIndex(i);
753 }
754 }
755
756 return nTracks;
757}
758
759//_____________________________________________________________________________
761{
762 // Clear event-by-event data
763
765 fLower->Clear(opt);
766 fUpper->Clear(opt);
767}
768
769//_____________________________________________________________________________
771{
772 // Decode data from VDC planes
773
774#ifdef WITH_DEBUG
775 // Save current event number for diagnostics
776 fEvNum = evdata.GetEvNum();
777 if( fDebug>1 ) {
778 cout << "=========================================\n";
779 cout << "Event: " << fEvNum << endl;
780 }
781#endif
782
783 fLower->Decode(evdata);
784 fUpper->Decode(evdata);
785
786 return 0;
787}
788
789//_____________________________________________________________________________
791{
792 // Coarse Tracking
793
794 if( TestBit(kDecodeOnly) )
795 return 0;
796
799
800 // Build tracks and mark them as level 1
802
803 return 0;
804}
805
806//_____________________________________________________________________________
808{
809 // Calculate exact track position and angle using drift time information.
810 // Assumes that CoarseTrack has been called (ie - clusters are matched)
811
813 return 0;
814
815 fLower->FineTrack();
816 fUpper->FineTrack();
817
818 //FindBadTracks(tracks);
819 //CorrectTimeOfFlight(tracks);
820
821// for (Int_t i = 0; i < fNumIter; i++) {
822// ConstructTracks();
823// fLower->FineTrack();
824// fUpper->FineTrack();
825// }
826
827// fNtracks = ConstructTracks( &tracks, 2 );
828
829 return 0;
830}
831
832//_____________________________________________________________________________
834{
835 // Calculate the target location and momentum at the target.
836 // Assumes that CoarseTrack() and FineTrack() have both been called.
837
838 Int_t n_exist = tracks.GetLast()+1;
839 for( Int_t t = 0; t < n_exist; t++ ) {
840 auto* theTrack = static_cast<THaTrack*>( tracks.At(t) );
841 CalcTargetCoords(theTrack);
842 }
843
844 return 0;
845}
846
847#if 0
848//_____________________________________________________________________________
849void THaVDC::DetToTrackTransportCoords( Double_t& x, Double_t& y,
850 Double_t& theta, Double_t& phi ) const
851{
852 // Convert given Transport coordinates from detector (VDC) frame to
853 // track (TRANSPORT) frame.
854
855 // This algorithm gives the exact same results as the explicit formulas
856 // in CalcFocalPlaneCoords if DetToTrackCoords is a simple rotation
857 // about y by fVDCAngle. Because the VDC frame is assumed to be the
858 // track reference frame, this is always true, so we don't need the full
859 // generality of the coordinate transformation, and the explicit formulas
860 // are more efficient.
861
862 // Define two points along the track in VDC coordinates
863 TVector3 x0( x, y, 0. );
864 TVector3 x1( x0 + TVector3(theta, phi, 1.) );
865 // Convert these two points to the TRANSPORT frame
866 x0 = DetToTrackCoord(x0);
867 x1 = DetToTrackCoord(x1);
868 // Calculate the new direction vector
869 TVector3 t = x1 - x0;
870 // Normalize it to z=1, and we have the projected TRANSPORT angles
871 Double_t invz = 1./t.Z();
872 theta = t.X()*invz;
873 phi = t.Y()*invz;
874 // Project one of the points back to z=0 along the direction vector
875 // to get the TRANSPORT positions
876 x = x0.X() - x0.Z()*theta;
877 y = x0.Y() - x0.Z()*phi;
878}
879#endif
880
881//_____________________________________________________________________________
883{
884 // calculates focal plane coordinates from detector coordinates
885
886 // first calculate the transport frame coordinates
887 // (see DetToTrackTransportCoords above for the general algorithm)
888 Double_t theta = (track->GetDTheta()+fTan_vdc) /
889 (1.0-track->GetDTheta()*fTan_vdc);
890 Double_t x = track->GetDX() * (fCos_vdc + theta * fSin_vdc);
891 Double_t phi = track->GetDPhi() / (fCos_vdc - track->GetDTheta() * fSin_vdc);
892 Double_t y = track->GetDY() + fSin_vdc*phi*track->GetDX();
893
894 // then calculate the rotating transport frame coordinates
895 Double_t r_x = x;
896
897 // calculate the focal-plane matrix elements
899
900 Double_t r_y = y - fFPMatrixElems[Y000].v; // Y000
901
902 // Calculate now the tan(rho) and cos(rho) of the local rotation angle.
903 Double_t tan_rho_loc = fFPMatrixElems[T000].v; // T000
904 Double_t cos_rho_loc = 1.0/sqrt(1.0+tan_rho_loc*tan_rho_loc);
905
906 Double_t r_phi = (track->GetDPhi() - fFPMatrixElems[P000].v /* P000 */ ) /
907 (1.0-track->GetDTheta()*tan_rho_loc) / cos_rho_loc;
908 Double_t r_theta = (track->GetDTheta()+tan_rho_loc) /
909 (1.0-track->GetDTheta()*tan_rho_loc);
910
911 // set the values we calculated
912 track->Set(x, y, theta, phi);
913 track->SetR(r_x, r_y, r_theta, r_phi);
914}
915
916//_____________________________________________________________________________
918{
919 // calculates target coordinates from focal plane coordinates
920
921 const Int_t kNUM_PRECOMP_POW = 10;
922
923 // first select the coords to use
924 Double_t x_fp, y_fp, th_fp, ph_fp;
925 if( fCoordType == kTransport ) {
926 x_fp = track->GetX();
927 y_fp = track->GetY();
928 th_fp = track->GetTheta();
929 ph_fp = track->GetPhi();
930 } else { // kRotatingTransport
931 x_fp = track->GetRX();
932 y_fp = track->GetRY();
933 th_fp = track->GetRTheta();
934 ph_fp = track->GetRPhi();
935 }
936
937 // calculate the powers we need
938 Double_t powers[kNUM_PRECOMP_POW][5]; // {(x), th, y, ph, abs(th) }
939 for(int i=0; i<kNUM_PRECOMP_POW; i++) {
940 powers[i][0] = pow(x_fp, i);
941 powers[i][1] = pow(th_fp, i);
942 powers[i][2] = pow(y_fp, i);
943 powers[i][3] = pow(ph_fp, i);
944 powers[i][4] = pow(TMath::Abs(th_fp),i);
945 }
946
947 // calculate the matrices we need
954
955 // calculate the coordinates at the target
956 Double_t theta = CalcTargetVar(fTMatrixElems, powers);
957 Double_t phi = CalcTargetVar(fPMatrixElems, powers) +
961
962 auto* app = static_cast<THaSpectrometer*>(GetApparatus());
963 // calculate momentum
965 Double_t p = app->GetPcentral() * (1.0+dp);
966
967 // pathlength matrix is for the Transport coord plane
968 Double_t pathl = CalcTarget2FPLen(fLMatrixElems, powers);
969
970 //FIXME: estimate x ??
971 Double_t x = 0.0;
972
973 // Save the target quantities with the tracks
974 track->SetTarget(x, y, theta, phi);
975 track->SetDp(dp);
976 track->SetMomentum(p);
977 track->SetPathLen(pathl);
978
979 app->TransportToLab( p, theta, phi, track->GetPvect() );
980}
981
982
983//_____________________________________________________________________________
984void THaVDC::CalcMatrix( const Double_t x, vector<THaMatrixElement>& matrix )
985{
986 // calculates the values of the matrix elements for a given location
987 // by evaluating a polynomial in x of order it->order with
988 // coefficients given by it->poly
989
990 for( auto& ME : matrix ) {
991 ME.v = 0.0;
992 if( ME.order > 0 ) {
993 for( int i = ME.order - 1; i >= 1; i-- )
994 ME.v = x * (ME.v + ME.poly[i]);
995 ME.v += ME.poly[0];
996 }
997 }
998}
999
1000//_____________________________________________________________________________
1001Double_t THaVDC::CalcTargetVar(const vector<THaMatrixElement>& matrix,
1002 const Double_t powers[][5])
1003{
1004 // calculates the value of a variable at the target
1005 // the x-dependence is already in the matrix, so only 1-3 (or np) used
1006 Double_t retval=0.0;
1007 for( const auto& ME : matrix )
1008 if( ME.v != 0.0 ) {
1009 Double_t v = ME.v;
1010 auto np = ME.pw.size(); // generalize for extra matrix elems.
1011 for( size_t i = 0; i < np; ++i )
1012 v *= powers[ME.pw[i]][i + 1];
1013 retval += v;
1014 // retval += it->v * powers[it->pw[0]][1]
1015 // * powers[it->pw[1]][2]
1016 // * powers[it->pw[2]][3];
1017 }
1018
1019 return retval;
1020}
1021
1022//_____________________________________________________________________________
1023Double_t THaVDC::CalcTarget2FPLen(const vector<THaMatrixElement>& matrix,
1024 const Double_t powers[][5])
1025{
1026 // calculates distance from the nominal target position (z=0)
1027 // to the transport plane
1028
1029 Double_t retval=0.0;
1030 for( const auto& ME : matrix )
1031 if( ME.v != 0.0 )
1032 retval += ME.v * powers[ME.pw[0]][0]
1033 * powers[ME.pw[1]][1]
1034 * powers[ME.pw[2]][2]
1035 * powers[ME.pw[3]][3];
1036
1037 return retval;
1038}
1039
1040//_____________________________________________________________________________
1042{
1043 const static Double_t v = 3.0e-8; // for now, assume that everything travels at c
1044
1045 // get scintillator planes
1046 auto* s1 = static_cast<THaScintillator*>( GetApparatus()->GetDetector("s1") );
1047 auto* s2 = static_cast<THaScintillator*>( GetApparatus()->GetDetector("s2") );
1048
1049 if( (s1 == nullptr) || (s2 == nullptr) )
1050 return;
1051
1052 // adjusts calculated times so that the time of flight to S1
1053 // is the same as a track going through the middle of the VDC
1054 // (i.e. x_det = 0) at a 45 deg angle (theta_t and phi_t = 0)
1055 // assumes that at least the coarse tracking has been performed
1056
1057 Int_t n_exist = tracks.GetLast()+1;
1058 //cerr<<"num tracks: "<<n_exist<<endl;
1059 for( Int_t t = 0; t < n_exist; t++ ) {
1060 auto* track = static_cast<THaTrack*>( tracks.At(t) );
1061
1062 // calculate the correction, since it's on a per track basis
1063 Double_t s1_dist = 0.0, vdc_dist = 0.0;
1064 s1->CalcPathLen(track, s1_dist);
1065 CalcPathLen(track, vdc_dist);
1066
1067 // since the z=0 of the transport coords is inclined with respect
1068 // to the VDC plane, the VDC correction depends on the location of
1069 // the track
1070 Double_t dist = (track->GetX() < 0) ? s1_dist + vdc_dist
1071 : s1_dist - vdc_dist;
1072
1073 Double_t tdelta = ( fCentralDist - dist) / v;
1074 //cout<<"time correction: "<<tdelta<<endl;
1075
1076 // apply the correction
1077 Int_t n_clust = track->GetNclusters();
1078 for( Int_t i = 0; i < n_clust; i++ ) {
1079 auto* the_point = static_cast<THaVDCPoint*>( track->GetCluster(i) );
1080 if( !the_point )
1081 continue;
1082
1083 the_point->GetUCluster()->SetTimeCorrection(tdelta);
1084 the_point->GetVCluster()->SetTimeCorrection(tdelta);
1085 }
1086 }
1087}
1088
1089//_____________________________________________________________________________
1091{
1092 // Flag tracks that don't intercept S2 scintillator as bad
1093
1094 auto* s2 = static_cast<THaScintillator*>( GetApparatus()->GetDetector("s2") );
1095
1096 if(s2 == nullptr) {
1097 //cerr<<"Could not find s2 plane!!"<<endl;
1098 return;
1099 }
1100
1101 Int_t n_exist = tracks.GetLast()+1;
1102 for( Int_t t = 0; t < n_exist; t++ ) {
1103 auto* track = static_cast<THaTrack*>( tracks.At(t) );
1104
1105 // project the current x and y positions into the s2 plane
1106 // if the tracks go out of the bounds of the s2 plane,
1107 // toss the track out
1108 Double_t x2, y2; // dummy variables
1109 if( !s2->CalcInterceptCoords(track, x2, y2) ||
1110 !s2->IsInActiveArea(x2, y2) ) {
1111
1112 // for now, we just flag the tracks as bad
1113 track->SetFlag( track->GetFlag() | kBadTrack );
1114
1115 //tracks.RemoveAt(t);
1116#ifdef WITH_DEBUG
1117 //cout << "Track " << t << " deleted.\n";
1118#endif
1119 }
1120 }
1121
1122 // get rid of the slots for the deleted tracks
1123 //tracks.Compress();
1124}
1125
1126//_____________________________________________________________________________
1127void THaVDC::PrintME( const string& header,
1128 const vector<THaMatrixElement>& matrix )
1129{
1130 // Print given matrix elements
1131
1132 cout << header << endl;
1133 for( const auto& ME : matrix ) {
1134 for(int pw : ME.pw) {
1135 cout << " " << setw(2) << pw;
1136 }
1137 for( int j = 0; j < ME.order; j++ ) {
1138 cout << " " << setprecision(4) << ME.poly[j];
1139 }
1140 cout << endl;
1141 }
1142}
1143
1144//_____________________________________________________________________________
1145void THaVDC::Print(const Option_t* opt) const
1146{
1148
1149 TString sopt(opt);
1150 sopt.ToUpper();
1151 if( sopt.Contains("ME") || sopt.Contains("MATRIX") ) {
1152 // Print out the optics matrices
1153 PrintME("Matrix FP (t000, y000, p000)", fFPMatrixElems);
1154 PrintME("Transport Matrix: D-terms", fDMatrixElems);
1155 PrintME("Transport Matrix: T-terms", fTMatrixElems);
1156 PrintME("Transport Matrix: Y-terms", fYMatrixElems);
1157 PrintME("Transport Matrix: YTA-terms (abs(theta))", fYTAMatrixElems);
1158 PrintME("Transport Matrix: P-terms", fPMatrixElems);
1159 PrintME("Transport Matrix: PTA-terms", fPTAMatrixElems);
1160 PrintME("Matrix L", fLMatrixElems);
1161 }
1162}
1163
1164//_____________________________________________________________________________
1166{
1167 // Special VDC geometry reader. Reads only the optional "size" parameters and
1168 // ignores "position" and "angle".
1169 // Since the VDC defines the origin of the TRANSPORT coordinate system, we
1170 // always have fOrigin = (0,0,0). The VDC angle is the T000 focal plane matrix
1171 // element and so should not be read separately here.
1172
1173 const char* const here = "ReadGeometry";
1174
1175 fOrigin.SetXYZ(0,0,0); // by definition
1176
1177 vector<double> size;
1178 DBRequest request[] = {
1179 { "size", &size, kDoubleV, 0, true,
1180 0, "\"size\" (detector size [m])" },
1181 { nullptr }
1182 };
1183 Int_t err = LoadDB( file, date, request );
1184 if( err )
1185 return kInitError;
1186
1187 if( !size.empty() ) {
1188 if( size.size() != 3 ) {
1189 Error( Here(here), "Incorrect number of values = %u for "
1190 "detector size. Must be exactly 3. Fix database.",
1191 static_cast<unsigned int>(size.size()) );
1192 return 2;
1193 }
1194 if( size[0] == 0 || size[1] == 0 || size[2] == 0 ) {
1195 Error( Here(here), "Illegal zero detector dimension. Fix database." );
1196 return 3;
1197 }
1198 if( size[0] < 0 || size[1] < 0 || size[2] < 0 ) {
1199 Warning( Here(here), "Illegal negative value for detector dimension. "
1200 "Taking absolute. Check database." );
1201 }
1202 fSize[0] = 0.5 * TMath::Abs(size[0]);
1203 fSize[1] = 0.5 * TMath::Abs(size[1]);
1204 fSize[2] = TMath::Abs(size[2]);
1205 }
1206 else
1207 fSize[0] = fSize[1] = fSize[2] = kBig;
1208
1209 return 0;
1210}
1211
1212//_____________________________________________________________________________
1214{
1215 // Set debug level of the VDC and the chamber/plane subdetectors
1216
1218 fLower->SetDebug(level);
1219 fUpper->SetDebug(level);
1220}
1221
1222//_____________________________________________________________________________
1223// TODO: Change return type to std::optional once we support C++17
1224std::pair<Double_t,bool> THaVDC::GetTimeCorrection() const
1225{
1226 // Return time correction for current event, if available.
1227 // If time corrections are not enabled or not available for the current
1228 // event, the bool in the returned pair is false.
1229
1231 return make_pair(fTimeCorrectionModule->TimeOffset(), true);
1232 return make_pair(0.0, false);
1233}
1234
1235//_____________________________________________________________________________
1237{
1238 // Version of GetTimeCorrection for global variables
1239
1240 auto r = GetTimeCorrection();
1241 return r.first;
1242}
1243
#define kOK
Definition BdataLoc.cxx:40
#define kInitError
Definition BdataLoc.cxx:41
int Int_t
unsigned int UInt_t
const Data_t kBig
Definition DataType.h:15
UInt_t fEvNum
Index of currently open file.
ROOT::R::TRInterface & r
#define s1(x)
size_t size(const MatrixT &matrix)
bool Bool_t
double Double_t
const char Option_t
winID w
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
char name[80]
vector< THaVDC::THaMatrixElement > MEvec_t
Definition THaVDC.cxx:43
static Int_t ParseMatrixElements(const string &MEstring, map< string, MEdef_t > &matrix_map, const char *prefix)
Definition THaVDC.cxx:112
static const char *const here
Definition THaVar.cxx:64
MEdef_t()
Definition THaVDC.cxx:46
Int_t npow
Definition THaVDC.cxx:50
Int_t fpidx
Definition THaVDC.cxx:51
Bool_t isfp
Definition THaVDC.cxx:52
MEvec_t * elems
Definition THaVDC.cxx:49
MEdef_t(Int_t npw, MEvec_t *elemp, Bool_t is_fp=false, Int_t fp_idx=0)
Definition THaVDC.cxx:47
void Clear(Option_t *option="") override
void Sort(Int_t upto=kMaxInt) override
virtual void Print(Option_t *option, const char *wildcard, Int_t recurse=1) const
virtual void SetDebug(Int_t level)
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual FILE * OpenFile(const TDatime &date)
virtual THaDetector * GetDetector(const char *name)
Double_t fSize[3]
virtual void DefineAxes(Double_t rotation_angle)
TVector3 DetToTrackCoord(const TVector3 &point) const
THaApparatus * GetApparatus() const
UInt_t GetEvNum() const
Definition THaEvData.h:56
Bool_t CalcPathLen(THaTrack *track, Double_t &t)
Double_t GetDPhi() const
Definition THaTrack.h:101
THaTrackingDetector * GetCreator() const
Definition THaTrack.h:77
void Set(Double_t x, Double_t y, Double_t theta, Double_t phi)
Definition THaTrack.h:143
Double_t GetDX() const
Definition THaTrack.h:98
Double_t GetDTheta() const
Definition THaTrack.h:100
Double_t GetX() const
Definition THaTrack.h:90
Double_t GetRTheta() const
Definition THaTrack.h:104
Double_t GetRY() const
Definition THaTrack.h:103
Double_t GetRX() const
Definition THaTrack.h:102
Double_t GetPhi() const
Definition THaTrack.h:87
Int_t AddCluster(THaCluster *c)
Definition THaTrack.cxx:55
Double_t GetTheta() const
Definition THaTrack.h:89
void SetR(Double_t x, Double_t y, Double_t theta, Double_t phi)
Definition THaTrack.h:271
TVector3 & GetPvect()
Definition THaTrack.h:119
void SetMomentum(Double_t p)
Definition THaTrack.h:170
THaTrackID * GetID() const
Definition THaTrack.h:83
Double_t GetY() const
Definition THaTrack.h:91
void SetDp(Double_t dp)
Definition THaTrack.h:171
void SetTrkNum(Int_t n)
Definition THaTrack.h:172
void SetFlag(UInt_t flag)
Definition THaTrack.h:168
void SetTarget(Double_t x, Double_t y, Double_t theta, Double_t phi)
Definition THaTrack.h:283
Double_t GetDY() const
Definition THaTrack.h:99
void SetD(Double_t x, Double_t y, Double_t theta, Double_t phi)
Definition THaTrack.h:259
void SetPathLen(Double_t pathl)
Definition THaTrack.h:152
void SetChi2(Double_t chi2, Int_t ndof)
Definition THaTrack.h:165
Double_t GetRPhi() const
Definition THaTrack.h:105
virtual THaTrack * AddTrack(TClonesArray &tracks, Double_t x, Double_t y, Double_t theta, Double_t phi, THaTrackID *ID=nullptr)
THaVDCPlane * GetUPlane() const
virtual void Clear(Option_t *opt="")
virtual Int_t CoarseTrack()
THaVDCPoint * GetPoint(Int_t i) const
virtual void SetDebug(Int_t level)
virtual Int_t FineTrack()
Int_t GetNPoints() const
virtual Int_t Decode(const THaEvData &evData)
virtual EStatus Init(const TDatime &date)
void SetTimeCorrection(Double_t dt)
Double_t GetZ() const
Definition THaVDCPlane.h:61
static Double_t CalcError(THaVDCPoint *lowerPoint, THaVDCPoint *upperPoint, Double_t spacing)
Double_t GetTheta() const
Definition THaVDCPoint.h:37
THaVDCCluster * GetUCluster() const
Definition THaVDCPoint.h:28
void SetPartner(THaVDCPoint *partner)
Definition THaVDCPoint.h:48
Double_t GetPhi() const
Definition THaVDCPoint.h:38
Double_t GetY() const
Definition THaVDCPoint.h:36
THaVDCPoint * GetPartner() const
Definition THaVDCPoint.h:31
Double_t GetX() const
Definition THaVDCPoint.h:35
std::vector< int > pw
Definition THaVDC.h:93
std::vector< double > poly
Definition THaVDC.h:97
Double_t fSpacing
Definition THaVDC.h:119
std::vector< THaMatrixElement > fTMatrixElems
Definition THaVDC.h:131
Double_t fErrorCutoff
Definition THaVDC.h:127
static Double_t CalcTarget2FPLen(const std::vector< THaMatrixElement > &matrix, const Double_t powers[][5])
Definition THaVDC.cxx:1023
std::vector< THaMatrixElement > fFPMatrixElems
Definition THaVDC.h:137
@ kPORDER
Definition THaVDC.h:80
UInt_t fEvNum
Definition THaVDC.h:112
virtual Int_t ConstructTracks(TClonesArray *tracks=nullptr, Int_t flag=0)
Definition THaVDC.cxx:472
virtual void SetDebug(Int_t level)
Definition THaVDC.cxx:1213
void CalcTargetCoords(THaTrack *the_track)
Definition THaVDC.cxx:917
@ kTransport
Definition THaVDC.h:102
@ kRotatingTransport
Definition THaVDC.h:102
virtual Int_t FineTrack(TClonesArray &tracks)
Definition THaVDC.cxx:807
std::vector< THaMatrixElement > fPTAMatrixElems
Definition THaVDC.h:134
Double_t GetTimeCorrectionUnchecked() const
Definition THaVDC.cxx:1236
virtual Int_t DefineVariables(EMode mode=kDefine)
Definition THaVDC.cxx:454
Double_t fVDCAngle
Definition THaVDC.h:115
std::vector< THaMatrixElement > fLMatrixElems
Definition THaVDC.h:141
virtual ~THaVDC()
Definition THaVDC.cxx:82
virtual Int_t ReadDatabase(const TDatime &date)
Definition THaVDC.cxx:231
std::vector< THaMatrixElement > fDMatrixElems
Definition THaVDC.h:132
virtual Int_t Decode(const THaEvData &)
Definition THaVDC.cxx:770
virtual Int_t ReadGeometry(FILE *file, const TDatime &date, Bool_t required=false)
Definition THaVDC.cxx:1165
void CorrectTimeOfFlight(TClonesArray &tracks)
Definition THaVDC.cxx:1041
std::pair< Double_t, bool > GetTimeCorrection() const
Definition THaVDC.cxx:1224
TClonesArray * fLUpairs
Definition THaVDC.h:110
std::vector< THaMatrixElement > fYMatrixElems
Definition THaVDC.h:135
static void CalcMatrix(double x, std::vector< THaMatrixElement > &matrix)
Definition THaVDC.cxx:984
ECoordType fCoordType
Definition THaVDC.h:128
THaVDCChamber * fLower
Definition THaVDC.h:106
Double_t fCentralDist
Definition THaVDC.h:121
std::vector< THaMatrixElement > fPMatrixElems
Definition THaVDC.h:133
static void PrintME(const std::string &header, const std::vector< THaMatrixElement > &matrix)
Definition THaVDC.cxx:1127
Double_t fTan_vdc
Definition THaVDC.h:118
static Double_t CalcTargetVar(const std::vector< THaMatrixElement > &matrix, const double powers[][5])
Definition THaVDC.cxx:1001
@ kOnlyFastest
Definition THaVDC.h:68
@ kDecodeOnly
Definition THaVDC.h:76
@ kSoftTDCcut
Definition THaVDC.h:71
@ kCoarseOnly
Definition THaVDC.h:77
@ kIgnoreNegDrift
Definition THaVDC.h:72
@ kHardTDCcut
Definition THaVDC.h:70
virtual void Clear(Option_t *opt="")
Definition THaVDC.cxx:760
Int_t fNumIter
Definition THaVDC.h:126
@ kFine
Definition THaVDC.h:60
@ kCoarse
Definition THaVDC.h:59
@ kMultiTrack
Definition THaVDC.h:62
@ kReassigned
Definition THaVDC.h:61
@ kBadTrack
Definition THaVDC.h:63
@ kStageMask
Definition THaVDC.h:57
std::vector< THaMatrixElement > fYTAMatrixElems
Definition THaVDC.h:136
void Print(const Option_t *opt="") const
Definition THaVDC.cxx:1145
THaVDCChamber * fUpper
Definition THaVDC.h:107
THaVDC(const char *name, const char *description="", THaApparatus *a=nullptr)
Definition THaVDC.cxx:56
Podd::TimeCorrectionModule * fTimeCorrectionModule
Definition THaVDC.h:143
void FindBadTracks(TClonesArray &tracks)
Definition THaVDC.cxx:1090
Double_t fSin_vdc
Definition THaVDC.h:116
Int_t fNtracks
Definition THaVDC.h:111
void CalcFocalPlaneCoords(THaTrack *track)
Definition THaVDC.cxx:882
@ P000
Definition THaVDC.h:103
@ T000
Definition THaVDC.h:103
@ Y000
Definition THaVDC.h:103
virtual Int_t CoarseTrack(TClonesArray &tracks)
Definition THaVDC.cxx:790
virtual Int_t FindVertices(TClonesArray &tracks)
Definition THaVDC.cxx:833
Double_t fCos_vdc
Definition THaVDC.h:117
void Print(Option_t *option="") const override
void Clear(Option_t *option="") override
TObject * At(Int_t idx) const override
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
void MakeZombie()
virtual void Info(const char *method, const char *msgfmt,...) const
void ToUpper()
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t Z() const
void SetXYZ(Double_t x, Double_t y, Double_t z)
Double_t Y() const
Double_t X() const
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v, const T1 &y)
Double_t y[n]
Double_t x[n]
double dist(AxisAngle const &r1, AxisAngle const &r2)
Expr< UnaryOp< Sqrt< T >, Expr< A, T, D, D2, R >, T >, T, D, D2, R > sqrt(const Expr< A, T, D, D2, R > &rhs)
void Error(const char *location, const char *fmt,...)
void Warning(const char *location, const char *fmt,...)
int CmpNoCase(const string &r, const string &s)
Definition THaString.cxx:19
Double_t ATan(Double_t)
constexpr Double_t Sqrt2()
constexpr Double_t PiOver4()
Double_t Cos(Double_t)
Double_t Abs(Double_t d)
Double_t Sin(Double_t)
std::pair< Double_t, Int_t > chi2_t
STL namespace.
v
TMarker m
ClassImp(TPyArg)
void tracks()