Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:58

0001 /*
0002  * SegmentationTest.cpp
0003  *
0004  *  Created on: Aug 28, 2013
0005  *      Author: Christian Grefe, CERN
0006  */
0007 
0008 #include "DD4hep/Detector.h"
0009 #include "DDSegmentation/BitField64.h"
0010 
0011 #include "DDSegmentation/SegmentationFactory.h"
0012 #include "DDSegmentation/SegmentationParameter.h"
0013 
0014 #include <set>
0015 
0016 using namespace std;
0017 using namespace dd4hep;
0018 using namespace detail;
0019 using namespace DDSegmentation;
0020 
0021 int main(int, char**) {
0022 
0023     SegmentationFactory* f = SegmentationFactory::instance();
0024 
0025     cout << "Registered Segmentations:" << std::endl;
0026     vector<string> segmentations = f->registeredSegmentations();
0027     vector<string>::const_iterator it;
0028     for (it = segmentations.begin(); it != segmentations.end(); ++it) {
0029         string typeName = *it;
0030         DDSegmentation::Segmentation* s = f->create(typeName);
0031         cout << "\t" << typeName << ", " << s->type() << endl;
0032         Parameters parameters = s->parameters();
0033         Parameters::iterator it2;
0034         for (it2 = parameters.begin(); it2 != parameters.end(); ++it2) {
0035             Parameter p = *it2;
0036             cout << "\t\t" << p->name() << " = " << p->value() << endl;
0037         }
0038         delete s;
0039     }
0040 
0041     DDSegmentation::Segmentation* s = f->create("CartesianGridXY", "system:8,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16");
0042     BitField64 d = s->decoder();
0043     d["system"] = 1;
0044     d["barrel"] = 0;
0045     d["module"] = 5;
0046     d["layer"] = 12;
0047     d["x"] = 10;
0048     d["y"] = -30;
0049     cout << "Neighbours of " << d.valueString() << ": "<< endl;
0050     CellID id = d.getValue();
0051     set<CellID> neighbours;
0052     s->neighbours(id, neighbours);
0053     set<CellID>::iterator itNeighbour;
0054     for (itNeighbour = neighbours.begin(); itNeighbour != neighbours.end(); ++itNeighbour) {
0055         d.setValue(*itNeighbour);
0056         cout << "\t" << d.valueString() << std::endl;
0057     }
0058     delete s;
0059     return 0;
0060 }