Belle II Software development
CDCWireConstraints Class Reference
Inheritance diagram for CDCWireConstraints:
Constraints

Public Member Functions

def __init__ (self, filename='cdc-wire-constraints.txt', layers=None, layer_rigid=True, layer_radius=None, cdc_radius=False, hemisphere=None)
 
def configure_collector (self, collector)
 
def get_label (self, layer, wire, parameter)
 
def generate (self)
 

Public Attributes

 layers
 List of layers for whose wires to generate the constraints.
 
 layer_rigid
 6 x 56 (6/layer) constraints.
 
 layer_radius
 2 x 56 constraints: Sum(dr)=0 for all wires in each layer at each end-plate -> layer radius kept same by this constraint (1 per layer)
 
 cdc_radius
 2 Constraints: Sum(dr)=0 for all wires in CDC at each end-plate -> "average CDC radius" kept same by this constraint (1 per CDC)
 
 hemisphere
 list of layer subject to hemisphere constraints
 

Static Public Attributes

list wires_in_layer
 CDC layer/wire configuration.
 

Detailed Description

Various constraints for CDC wires (w.r.t. layers)

Definition at line 384 of file constraints.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  filename = 'cdc-wire-constraints.txt',
  layers = None,
  layer_rigid = True,
  layer_radius = None,
  cdc_radius = False,
  hemisphere = None 
)
Initialize constraint

Parameters
----------
filename : str
  Can override the default file name
layers : list (int)
  List of layer numbers for which to generate the constraints (default is 0..55)
layer_rigid : bool
  6 constraints - fix sum of shifts of wire ends in x/y/rotation at fwd/bwd end-plate
layer_radius : list(int)
  2 constraints to fix average change of layer radius (wires in layer moving away from origin) for all layers in list
cdc_radius : bool
  1 constraint - fix average change in CDC radius from all wires
hemisphere : list(int)
  Modifies rigid and layer_radius (layer_radius constraint is added if not present for selected layer(s))
  constraint by splitting the constraints for a given list of layers to L/R up/down half of CDC

Reimplemented from Constraints.

Definition at line 401 of file constraints.py.

408 hemisphere=None):
409 """Initialize constraint
410
411 Parameters
412 ----------
413 filename : str
414 Can override the default file name
415 layers : list (int)
416 List of layer numbers for which to generate the constraints (default is 0..55)
417 layer_rigid : bool
418 6 constraints - fix sum of shifts of wire ends in x/y/rotation at fwd/bwd end-plate
419 layer_radius : list(int)
420 2 constraints to fix average change of layer radius (wires in layer moving away from origin) for all layers in list
421 cdc_radius : bool
422 1 constraint - fix average change in CDC radius from all wires
423 hemisphere : list(int)
424 Modifies rigid and layer_radius (layer_radius constraint is added if not present for selected layer(s))
425 constraint by splitting the constraints for a given list of layers to L/R up/down half of CDC
426
427 """
428
429 super().__init__(filename)
430
431 if layers is None:
432 layers = list(range(0, 56))
433 self.layers = layers
434
438 self.layer_rigid = layer_rigid
439
441 if layer_radius is None:
442 layer_radius = []
443 self.layer_radius = layer_radius
444
446 self.cdc_radius = cdc_radius
447
448 if hemisphere is None:
449 hemisphere = []
450 self.hemisphere = hemisphere
451

Member Function Documentation

◆ configure_collector()

def configure_collector (   self,
  collector 
)
Enables wire-by-wire derivatives in collector

Reimplemented from Constraints.

Definition at line 452 of file constraints.py.

452 def configure_collector(self, collector):
453 """Enables wire-by-wire derivatives in collector
454 """
455 basf2.B2WARNING("Adding CDC wire constraints -> enabling wire-by-wire alignment derivatives")
456 collector.param('enableWireByWireAlignment', True)
457

◆ generate()

def generate (   self)
Generate constraints 

Reimplemented from Constraints.

Definition at line 466 of file constraints.py.

466 def generate(self):
467 """Generate constraints """
468 print("Generating constraints for CDC wires...")
469 consts = []
470
471 layers = self.layers
472
473 if self.layer_rigid:
474 for layer in layers:
475 const = Constraint()
476 # sum of wire X (BWD) in layer
477 for wire in range(0, self.wires_in_layer[layer]):
478 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), 1.)
479 consts.append(const)
480
481 for layer in layers:
482 const = Constraint()
483 # sum of wire Y (BWD) in layer
484 for wire in range(0, self.wires_in_layer[layer]):
485 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), 1.)
486 consts.append(const)
487
488 for layer in set(layers) - set(self.hemisphere):
489 const = Constraint()
490 # sum of wire rotations (BWD) in layer
491 for wire in range(0, self.wires_in_layer[layer]):
492
493 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
494
495 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), -math.sin(wirePhi))
496 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.cos(wirePhi))
497 consts.append(const)
498
499 for layer in layers:
500 const = Constraint()
501 # sum of wire X (FWD) in layer
502 for wire in range(0, self.wires_in_layer[layer]):
503 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), 1.)
504 consts.append(const)
505
506 for layer in layers:
507 const = Constraint()
508 # sum of wire Y (FWD) in layer
509 for wire in range(0, self.wires_in_layer[layer]):
510 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), 1.)
511 consts.append(const)
512
513 for layer in set(layers) - set(self.hemisphere):
514 const = Constraint()
515 # sum of wire rotations (FWD) in layer
516 for wire in range(0, self.wires_in_layer[layer]):
517
518 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
519
520 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), -math.sin(wirePhi))
521 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.cos(wirePhi))
522 consts.append(const)
523
524 for layer in self.hemisphere:
525 const = Constraint()
526 # sum of wire rotations (BWD) in layer ... RIGHT hemisphere
527 for wire in range(0, self.wires_in_layer[layer]):
528
529 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
530
531 if math.cos(wirePhi) <= 0.:
532 continue
533
534 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), -math.sin(wirePhi))
535 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.cos(wirePhi))
536 consts.append(const)
537
538 for layer in self.hemisphere:
539 const = Constraint()
540 # sum of wire rotations (BWD) in layer ... LEFT hemisphere
541 for wire in range(0, self.wires_in_layer[layer]):
542
543 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
544
545 if math.cos(wirePhi) > 0.:
546 continue
547
548 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), -math.sin(wirePhi))
549 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.cos(wirePhi))
550 consts.append(const)
551
552 for layer in self.hemisphere:
553 const = Constraint()
554 # sum of wire rotations (FWD) in layer ... RIGHT
555 for wire in range(0, self.wires_in_layer[layer]):
556
557 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
558
559 if math.cos(wirePhi) <= 0.:
560 continue
561
562 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), -math.sin(wirePhi))
563 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.cos(wirePhi))
564 consts.append(const)
565
566 for layer in self.hemisphere:
567 const = Constraint()
568 # sum of wire rotations (FWD) in layer ... LEFT
569 for wire in range(0, self.wires_in_layer[layer]):
570
571 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
572
573 if math.cos(wirePhi) > 0.:
574 continue
575
576 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), -math.sin(wirePhi))
577 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.cos(wirePhi))
578 consts.append(const)
579
580 # layer_radius:
581 for layer in [lyr for lyr in self.layer_radius if lyr not in self.hemisphere]:
582 const = Constraint()
583 # sum of wire rotations (BWD) in layer
584 for wire in range(0, self.wires_in_layer[layer]):
585
586 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
587
588 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), +math.cos(wirePhi))
589 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.sin(wirePhi))
590 const.add(self.get_label(layer, 0, 0), 0.)
591 consts.append(const)
592
593 for layer in [lyr for lyr in self.layer_radius if lyr not in self.hemisphere]:
594 const = Constraint()
595 # sum of wire rotations (FWD) in layer
596 for wire in range(0, self.wires_in_layer[layer]):
597
598 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
599
600 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), +math.cos(wirePhi))
601 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.sin(wirePhi))
602 const.add(self.get_label(layer, 0, 0), 0.)
603 consts.append(const)
604
605 # hemisphere:
606 for layer in self.hemisphere:
607 const = Constraint()
608 # sum of wire rotations (BWD) in layer
609 for wire in range(0, self.wires_in_layer[layer]):
610
611 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
612
613 if math.sin(wirePhi) >= 0:
614 continue
615
616 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), +math.cos(wirePhi))
617 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.sin(wirePhi))
618 const.add(self.get_label(layer, 0, 0), 0.)
619 consts.append(const)
620
621 for layer in self.hemisphere:
622 const = Constraint()
623 # sum of wire rotations (BWD) in layer
624 for wire in range(0, self.wires_in_layer[layer]):
625
626 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
627
628 if math.sin(wirePhi) < 0:
629 continue
630
631 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), +math.cos(wirePhi))
632 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.sin(wirePhi))
633 const.add(self.get_label(layer, 0, 0), 0.)
634 consts.append(const)
635
636 for layer in self.hemisphere:
637 const = Constraint()
638 # sum of wire rotations (FWD) in layer
639 for wire in range(0, self.wires_in_layer[layer]):
640
641 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
642
643 if math.sin(wirePhi) >= 0:
644 continue
645
646 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), +math.cos(wirePhi))
647 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.sin(wirePhi))
648 const.add(self.get_label(layer, 0, 0), 0.)
649 consts.append(const)
650
651 for layer in self.hemisphere:
652 const = Constraint()
653 # sum of wire rotations (FWD) in layer
654 for wire in range(0, self.wires_in_layer[layer]):
655
656 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
657
658 if math.sin(wirePhi) < 0:
659 continue
660
661 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), +math.cos(wirePhi))
662 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.sin(wirePhi))
663 const.add(self.get_label(layer, 0, 0), 0.)
664 consts.append(const)
665
666 if self.cdc_radius:
667 const = Constraint()
668 for layer in layers:
669 # sum of wire rotations (BWD) in layer
670 for wire in range(0, self.wires_in_layer[layer]):
671 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getBackwardPos3D().phi()
672 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdX), +math.cos(wirePhi))
673 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireBwdY), +math.sin(wirePhi))
674 consts.append(const)
675
676 const = Constraint()
677 for layer in layers:
678 # sum of wire rotations (FWD) in layer
679 for wire in range(0, self.wires_in_layer[layer]):
680 wirePhi = Belle2.TrackFindingCDC.CDCWire.getInstance(Belle2.WireID(layer, wire)).getForwardPos3D().phi()
681 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdX), +math.cos(wirePhi))
682 const.add(self.get_label(layer, wire, Belle2.CDCAlignment.wireFwdY), +math.sin(wirePhi))
683 consts.append(const)
684
685 return consts
686
687
688# ------------ Main: Generate some constraint files with default config (no time-dependence, default global tags) ------
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convenience object. Does not construct a new object.
Definition: CDCWire.cc:24
Class to identify a wire inside the CDC.
Definition: WireID.h:34

◆ get_label()

def get_label (   self,
  layer,
  wire,
  parameter 
)
Return GlobalLabel for wire parameter

Definition at line 458 of file constraints.py.

458 def get_label(self, layer, wire, parameter):
459 """Return GlobalLabel for wire parameter"""
460
461 wireid = Belle2.WireID(layer, wire).getEWire()
462 label = Belle2.GlobalLabel()
463 label.construct(Belle2.CDCAlignment.getGlobalUniqueID(), wireid, parameter)
464 return label.label()
465
static unsigned short getGlobalUniqueID()
Get global unique id.
Definition: CDCAlignment.h:109
Class to convert to/from global labels for Millepede II to/from detector & parameter identificators.
Definition: GlobalLabel.h:41

Member Data Documentation

◆ cdc_radius

cdc_radius

2 Constraints: Sum(dr)=0 for all wires in CDC at each end-plate -> "average CDC radius" kept same by this constraint (1 per CDC)

Definition at line 446 of file constraints.py.

◆ hemisphere

hemisphere

list of layer subject to hemisphere constraints

Definition at line 450 of file constraints.py.

◆ layer_radius

layer_radius

2 x 56 constraints: Sum(dr)=0 for all wires in each layer at each end-plate -> layer radius kept same by this constraint (1 per layer)

Definition at line 443 of file constraints.py.

◆ layer_rigid

layer_rigid

6 x 56 (6/layer) constraints.

Sum(dX_B/dY_B/drot_B/dX_FB/dY_FB/drot_FB)=0 for all wires in each layer -> removes the basic unconstrained DoF when aligning wires and layers simultaneously. Average shift and rotation of wires in layer (at each end-plate) = 0. -> coherent movements of wires absorbed in layer parameters

Definition at line 438 of file constraints.py.

◆ layers

layers

List of layers for whose wires to generate the constraints.

None = all layers

Definition at line 433 of file constraints.py.

◆ wires_in_layer

list wires_in_layer
static
Initial value:
= [
160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160,
192, 192, 192, 192, 192, 192,
224, 224, 224, 224, 224, 224,
256, 256, 256, 256, 256, 256,
288, 288, 288, 288, 288, 288,
320, 320, 320, 320, 320, 320,
352, 352, 352, 352, 352, 352,
384, 384, 384, 384, 384, 384]

CDC layer/wire configuration.

Definition at line 390 of file constraints.py.


The documentation for this class was generated from the following file: