#ifndef ALDIGICODE_HH #define ALDIGICODE_HH 1 // class to contain the list of counters that define a piece of // RunII Silicon down to a side of a wafer: // barrel, layer, wedge, halfladder, wafer, side // L00 0-1 0 0-11 0-2 0-1 0-1 // SVX 0-2 1-5 0-11 0-1 0-1 0-1 // ISL 6C 1 6 0-27 0-1 0-2 0-1 // ISL 6B,F 0,2 6 0-23 0-1 0-2 0-1 // ISL 7B,F 0,2 7 0-35 0-1 0-2 0-1 // barrels are represented by the first avail. layer i.e. SVX B0 has b=0,l=1 // // User specifies whether this represents a halfladder or a wafer etc. // this is referred to as the "resolution" // User specifies whether it is part of a collection that includes // or does not include major parts of the detector such as the ISL // this is referred to as the "coverage" or UsedDetectors // // The information identifying this device is available three ways // 1) as a "code", which is a SiDigiCode added to the // wafer if necessary: AlDigiCode= SiDigiCode+(wafer<<14) // use the "code" accessors to handle this interface // 2) as an index, indicating the position in a list // of all the devices that you specified (always reproducable) // compact, from 0 to the number of devices // 3) as barrel/layer etc. use the named accessors for this interface // // The class may be zeroed to the first component: AlDigiCode a=0; // it may be incremented: AlDigiCode a++ // it converts to an integer (the index (2nd) representation) // via operator int(): array[AlDigiCode] // // It can be << in the form: "0 0 0 0 0 0" // It can be be converted to two other formats returned in strings // // Typical use: // AlDigiCode ad; // ad.SetResolution(AlDigiCode::LADDER); // ad will represent a ladder // ad.setUsedDetectors(AlDigiCode::SVX); // only use the SVX, ignore ISL, L00 // for(ad=0; ad!=al.getNtotal(); ad++) { // std::cout << ad << std::endl; // std::cout << ad.getTitle() << std::endl; // myarray[ad]=something; // convert to int // int code = ad.getCode(); // return the SiDigiCode + wafer<<14 // ad.getBarrel(); // what barrel is it on? // } // // Ray Culbertson, FNAL // 10/7/00 - original // #include #include #include using namespace std; class AlDigiCode { public: AlDigiCode(); // create it and prepare to iterateover some subset of detector pieces AlDigiCode(int resol, int cover); // ceate it and point it to a piece // created this way, it doesn't know what it is pointing to // until setResolution is called AlDigiCode(int bar, int lay, int wed, int hlad, int waf, int sid); ~AlDigiCode(); // fills a string: "0 0 0 0 0 0" // reflecting b/l/ w/h/w/s char* getName(char* title); // fills a string: 3703301 which breaks down: b/l/w/h/w/s= 3/7/03/3/0/1 char* getCompactName(char* title); // returns a string like: "bar: 0 lay: 0 wed: 00 hld: 0 waf: 0 sid: 0" char* getTitle(char* title); // write it out to a stream like: "0 0 0 0 0 0" // reflecting b/l/ w/h/w/s friend ostream& operator << (std::ostream& os, AlDigiCode& rhs); friend istream& operator >> (std::istream& is, AlDigiCode& rhs); // return the individual pointers for the piece represented by this int getBarrel(); int getWedge(); int getLayer(); int getHalfLadder(); int getWafer(); int getSide(); int getNtotal(); // the number of devices you requested via resol and cover // return the code as a sparse pseudo-SiDigiCode integer int getCode(); //return the code as a compact index in a set of requested detector pieces int getIndex(); // set the parameters void setBarrel(int bar); void setLayer(int lay); void setWedge(int wed); void setHalfLadder(int hlad); void setWafer(int waf); void setSide(int sid); void setPar(int bar, int lay, int wed=0, int hlad=0, int waf=0, int sid=0); //set the code to a given integer - data is checked if it is valid void setCode(int code); //set the position as a index void setIndex(int index); // convert to int (the compact index) naturally // note: you can't construct it from an index though // because it is an unknown state without resol and cover set operator int(); const AlDigiCode& operator ++(); const AlDigiCode operator ++(int); const AlDigiCode& operator --(); const AlDigiCode operator --(int); AlDigiCode& operator = (const int rhs); bool operator < (AlDigiCode& rhs); bool operator > (AlDigiCode& rhs); bool operator <= (AlDigiCode& rhs); bool operator >= (AlDigiCode& rhs); bool operator == (AlDigiCode& rhs); bool operator != (AlDigiCode& rhs); // change the resolution and coverage at any time void setResolution(int resol); // resolution flags to use as arguments to the above static const int FRAME,BARREL,LADDER,HALFLADDER,WAFER,SIDE; // change the coverage on the fly void setUsedDetectors(int cover); // coverage flags, can be ORed: setUsedDetectors( SVX0 || SVX1 ) static const int SVX0, SVX1, SVX2, L00_0, L00_1, ISL_6B, ISL_6C, ISL_6F, ISL_7B, ISL_7F, SVX, L00, SVX_L00, CENTRAL, ISL, ALL; private: // resol is what kind of device (the resolution of the iterations) int _resol; // cover is the coverage or which detectors are included int _cover; int _nTotal; // this is the data indicating the detector that this represents bool _validIndex; // do not update index representation until needed int _index; // representation as index in a set void restoreIndex(); bool _validCode; // do not update code representation until needed int _code; // representation in pseudo-digicode void restoreCode(); int _barrel,_layer,_wedge,_halfladder,_wafer,_side; void checkValid(); // are the settings valid? used to check input // not useful for user, internal state is always valid void count(); // find nTotal void init(); // load arrays while avoiding initialization // set all to zero, result of error void clear() {_barrel=0; _layer=0; _wedge=0; _halfladder=0; _wafer=0; _side=0; _index=0; _code=0; _validCode=false; _validIndex=true;}; // internally the whole set is broken down into 10 regular detectors: // 3 SVX barrels, 2 L00 barrels, 5 ISL barrels // sum of the number of pieces for each subdetector int _nPieces[10]; // numerology for each subdetector in the list of 10 int NLayers[10]; // 5 in SVX, 1 elsewhere int NWedges[10]; // 12, 24, 28 or 36 int NHalfLadders[10]; // 2 everywhere but L00, where it's 3 int NWafers[10]; // waf per half-ladd =2, except 3 in ISL }; //end AlDigiCode #endif