#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
#include "AliFMDParameters.h"
#include "AliLog.h"
+#include "AliFMDDebug.h"
#include <iostream>
#include <iomanip>
return kTRUE;
}
-//____________________________________________________________________
-Bool_t
-AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t addr,
- UShort_t& det, Char_t& ring,
- UShort_t& sec, Short_t& str) const
-{
- // Translate a hardware address to detector coordinates.
- //
- // See also Hardware2Detector that accepts 4 inputs
- UInt_t board = (addr >> 7) & 0x1F;
- UInt_t altro = (addr >> 4) & 0x7;
- UInt_t chan = (addr & 0xf);
- return Hardware2Detector(ddl, board, altro, chan, det, ring, sec, str);
-}
//____________________________________________________________________
Bool_t
-AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t altro, UInt_t chan,
- UShort_t& det, Char_t& ring,
+AliFMDAltroMapping::Channel2StripBase(UShort_t board, UShort_t altro,
+ UShort_t chan, Char_t& ring,
UShort_t& sec, Short_t& str) const
{
// Translate a hardware address to detector coordinates.
// return the first strip, as seen by the ALTRO channel, in the
// given range.
//
- det = ddl + 1;
- ring = (board % 2) == 0 ? 'I' : 'O';
+ ring = Board2Ring(board);
switch (ring) {
case 'i':
case 'I':
break;
}
if (sec % 2) str += 127;
+ // AliFMDDebug(1, ("%02x/%x/%x Base strip = %d", board, altro, chan, str));
return kTRUE;
}
+//____________________________________________________________________
+void
+AliFMDAltroMapping::Timebin2Strip(UShort_t sec,
+ UShort_t timebin,
+ UShort_t preSamples,
+ UShort_t sampleRate,
+ Short_t& stripOff,
+ UShort_t& sample) const
+{
+ // Compute the strip off-set in the current channel from the sector
+ // and timebin. Also needed for this computation is the basic
+ // offset in timebins, as well as the sample rat.
+ UShort_t t = (timebin - preSamples);
+ sample = (t % sampleRate);
+ t -= sample;
+ stripOff = (sec % 2 ? -1 : 1) * t / sampleRate;
+}
+
+#if 0
//____________________________________________________________________
Bool_t
-AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t addr,
- UShort_t timebin, UShort_t preSamples,
- UShort_t sampleRate,
- UShort_t& det, Char_t& ring,
- UShort_t& sec, Short_t& str,
- UShort_t& sam) const
+AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t board,
+ UInt_t altro, UInt_t chan,
+ UShort_t& det, Char_t& ring,
+ UShort_t& sec, Short_t& str) const
+{
+ // See also Hardware2Detector that requires 3 inputs
+ det = DDL2Detector(ddl);
+ return Channel2StripBase(board, altro, chan, ring, sec, str);
+}
+
+
+//____________________________________________________________________
+Bool_t
+AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t addr,
+ UShort_t& det, Char_t& ring,
+ UShort_t& sec, Short_t& str) const
{
// Translate a hardware address to detector coordinates.
//
// See also Hardware2Detector that accepts 4 inputs
- UInt_t board = (addr >> 7) & 0x1F;
- UInt_t altro = (addr >> 4) & 0x7;
- UInt_t chan = (addr & 0xf);
- return Hardware2Detector(ddl, board, altro, chan,
- timebin, preSamples, sampleRate,
- det, ring, sec, str, sam);
+ UShort_t board, altro, chan;
+ ChannelAddress(addr, board, altro, chan);
+ return Hardware2Detector(ddl,board, altro, chan, det,ring, sec, str);
}
+#endif
//____________________________________________________________________
Bool_t
-AliFMDAltroMapping::Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t altro, UInt_t chan,
- UInt_t timebin, UInt_t preSamples,
- UInt_t sampleRate,
+AliFMDAltroMapping::Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t altro, UShort_t chan,
+ UShort_t timebin, UShort_t preSamples,
+ UShort_t sampleRate,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const
// to detector coordinates and sample number. Note, that this
// conversion depends on the oversampling rate and the number of
// pre-samples
- if (!Hardware2Detector(ddl, board, altro, chan, det, ring, sec, str))
+ Short_t baseStrip, stripOffset, tdet = DDL2Detector(ddl);
+ if (tdet < 0) return kFALSE;
+ det = tdet;
+ if (!Channel2StripBase(board, altro, chan, ring, sec, baseStrip))
return kFALSE;
- UShort_t t = (timebin - preSamples);
- sam = (t % sampleRate);
- t -= sam;
- str += (sec % 2 ? -1 : 1) * t / sampleRate;
- // if (sec % 2) sam = sampleRate - 1 - sam;
+ Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOffset, sam);
#if 0
- AliFMDDebug(3, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
- " (pre=%2d, rate=%d)",
- ddl, board, altro, chan, timebin,
- det, ring, sec, str, sam, preSamples, sampleRate));
+ AliFMDDebug(1, ("0x%x/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%2d,%3d]-%d "
+ "(pre=%d,rate=%d,base=%3d,off=%3d)",
+ ddl,
+ board,
+ altro,
+ chan,
+ timebin,
+ det,
+ ring,
+ sec,
+ str,
+ sam,
+ preSamples,
+ sampleRate,
+ baseStrip,
+ stripOffset));
#endif
+ str = baseStrip + stripOffset;
return kTRUE;
}
-
//____________________________________________________________________
Bool_t
-AliFMDAltroMapping::Detector2Hardware(UShort_t det, Char_t ring,
- UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& chan) const
+AliFMDAltroMapping::Hardware2Detector(UShort_t ddl, UShort_t addr,
+ UShort_t timebin, UShort_t preSamples,
+ UShort_t sampleRate,
+ UShort_t& det, Char_t& ring,
+ UShort_t& sec, Short_t& str,
+ UShort_t& sam) const
+{
+ // Translate a hardware address to detector coordinates.
+ //
+ // See also Hardware2Detector that accepts 4 inputs
+ UShort_t board, altro, chan;
+ ChannelAddress(addr, board, altro, chan);
+ return Hardware2Detector(ddl, board, altro, chan,
+ timebin, preSamples, sampleRate,
+ det, ring, sec, str, sam);
+}
+
+
+//____________________________________________________________________
+Short_t
+AliFMDAltroMapping::Sector2Board(Char_t ring, UShort_t sec) const
+{
+ switch (ring) {
+ case 'I':
+ case 'i':
+ return (sec / 10) * 16;
+ case 'O':
+ case 'o':
+ return (sec / 20) * 16 + 1;
+ }
+ return -1;
+}
+
+//_____________________________________________ _______________________
+Bool_t
+AliFMDAltroMapping::Strip2Channel(Char_t ring, UShort_t sec,
+ UShort_t str, UShort_t& board,
+ UShort_t& altro, UShort_t& chan) const
{
// Translate detector coordinates to a hardware address.
// The ddl is simply
// With this information, we can decode the detector coordinates to
// give us a unique hardware address
//
- ddl = (det - 1);
UInt_t tmp = 0;
switch (ring) {
case 'I':
return kTRUE;
}
+//_____________________________________________ _______________________
+UShort_t
+AliFMDAltroMapping::Strip2Timebin(UShort_t sec, UShort_t strip,
+ UShort_t sam, UShort_t preSamples,
+ UShort_t sampleRate) const
+{
+ UShort_t timebin = preSamples;
+ if (sec % 2) timebin += (127 - (strip % 128)) * sampleRate;
+ else timebin += (strip % 128) * sampleRate;
+ timebin += sam;
+ return timebin;
+}
+
+#if 0
+//_____________________________________________ _______________________
+Bool_t
+AliFMDAltroMapping::Detector2Hardware(UShort_t det, Char_t ring,
+ UShort_t sec, UShort_t str,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& chan) const
+{
+ ddl = Detector2DDL(det);
+ return Strip2Channel(ring, sec, str, board, altro, chan);
+}
+
+
//____________________________________________________________________
Bool_t
AliFMDAltroMapping::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& addr) const
+ UShort_t& ddl, UShort_t& addr) const
{
// Translate detector coordinates to a hardware address.
//
// See also Detector2Hardware that returns 4 parameters.
- UInt_t board = 0;
- UInt_t altro = 0;
- UInt_t chan = 0;
+ UShort_t board = 0;
+ UShort_t altro = 0;
+ UShort_t chan = 0;
if (!Detector2Hardware(det,ring,sec,str,ddl,board,altro,chan)) return kFALSE;
- addr = chan + (altro << 4) + (board << 7);
+ addr = ChannelAddress(board, altro, chan);
return kTRUE;
}
+#endif
//____________________________________________________________________
Bool_t
AliFMDAltroMapping::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UShort_t preSamples, UShort_t sampleRate,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& channel,
+ UShort_t preSamples,
+ UShort_t sampleRate,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& channel,
UShort_t& timebin) const
{
- if (!Detector2Hardware(det,ring,sec,str,ddl,board,altro,channel))
- return kFALSE;
- timebin = preSamples;
- if (sec % 2)
- timebin += (127 - (str % 128)) * sampleRate;
- else
- timebin += (str % 128) * sampleRate;
- timebin += sam;
+ ddl = Detector2DDL(det);
+ if (!Strip2Channel(ring,sec,str,board,altro,channel)) return kFALSE;
+ timebin = Strip2Timebin(sec, str, sam, preSamples, sampleRate);
return kTRUE;
}
UShort_t sec, UShort_t str,
UShort_t sam,
UShort_t preSamples, UShort_t sampleRate,
- UInt_t& ddl, UInt_t& hwaddr,
+ UShort_t& ddl, UShort_t& hwaddr,
UShort_t& timebin) const
{
- UInt_t board = 0;
- UInt_t altro = 0;
- UInt_t chan = 0;
+ UShort_t board = 0;
+ UShort_t altro = 0;
+ UShort_t chan = 0;
if (!Detector2Hardware(det, ring, sec, str, sam,
preSamples, sampleRate,
ddl, board, altro, chan, timebin)) return kFALSE;
- hwaddr = chan + (altro << 4) + (board << 7);
+ hwaddr = ChannelAddress(board, altro, chan);
return kTRUE;
}
+//____________________________________________________________________
+UInt_t
+AliFMDAltroMapping::ChannelAddress(UShort_t board, UShort_t altro,
+ UShort_t channel) const
+{
+ return (((board & 0x1F) << 7) | ((altro & 0x7) << 4) | (channel & 0xF));
+}
+
+//____________________________________________________________________
+void
+AliFMDAltroMapping::ChannelAddress(UShort_t hwaddr, UShort_t& board,
+ UShort_t& altro, UShort_t& channel) const
+{
+ board = ((hwaddr >> 7) & 0x1F);
+ altro = ((hwaddr >> 4) & 0x07);
+ channel = ((hwaddr >> 0) & 0x0F);
+}
//____________________________________________________________________
Int_t
// pad | strip
// sector | ring
//
- UInt_t ddl, hwaddr;
Char_t r = Char_t(ring);
- if (!Detector2Hardware(1, r, sec, str, ddl, hwaddr))
- return -1;
- return hwaddr;
+ UShort_t board, altro, channel;
+ Strip2Channel(r, sec, str, board, altro, channel);
+ return ChannelAddress(board, altro, channel);
}
//____________________________________________________________________
// pad | strip
// sector | ring
//
- UShort_t det;
Char_t ring;
- UShort_t sec;
- Short_t str;
- Int_t ddl = 0;
- if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
- return Int_t(sec);
+ UShort_t board, altro, channel, sector;
+ Short_t baseStrip;
+ ChannelAddress(hwaddr, board, altro, channel);
+ if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+ return -1;
+ return Int_t(sector);
}
//____________________________________________________________________
// pad | strip
// sector | ring
//
- UShort_t det;
Char_t ring;
- UShort_t sec;
- Short_t str;
- Int_t ddl = 0;
- if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
- return Int_t(str);
+ UShort_t board, altro, channel, sector;
+ Short_t baseStrip;
+ ChannelAddress(hwaddr, board, altro, channel);
+ if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+ return -1;
+ return Int_t(baseStrip);
}
//____________________________________________________________________
// pad | strip
// sector | ring
//
- UShort_t det;
Char_t ring;
- UShort_t sec;
- Short_t str;
- Int_t ddl = 0;
- if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
+ UShort_t board, altro, channel, sector;
+ Short_t baseStrip;
+ ChannelAddress(hwaddr, board, altro, channel);
+ if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+ return -1;
return Int_t(ring);
}
{
TString opt(option);
opt.ToLower();
- UInt_t ddl, board, chip, chan, addr;
+ UShort_t ddl, board, chip, chan, addr;
UShort_t det, sec;
- Short_t str;
+ Short_t strBase;
Char_t rng;
if (opt.Contains("hw") || opt.Contains("hardware")) {
for (ddl = 0; ddl <= 2; ddl++) {
Int_t boards[] = { 0, 16, (ddl == 0 ? 32 : 1), 17, 32};
Int_t* ptr = boards;
+ det = DDL2Detector(ddl);
while ((board = *(ptr++)) < 32) {
for (chip = 0; chip <= 2; chip++) {
- UInt_t nchan = (chip == 1 ? 8 : 16);
+ UShort_t nchan = (chip == 1 ? 8 : 16);
for (chan = 0; chan < nchan; chan++) {
- Hardware2Detector(ddl, board, chip, chan, det, rng, sec, str);
- addr = ((board & 0x1f) << 7) | ((chip & 0x7) << 4) | (chan & 0xf);
+ Channel2StripBase(board, chip, chan, rng, sec, strBase);
+ addr = ChannelAddress(board, chip, chan);
std::cout << " "
- << std::setw(3) << ddl << " | "
- << std::setfill('0') << std::hex << " 0x"
- << std::setw(2) << board << " | 0x"
- << std::setw(1) << chip << " | 0x"
- << std::setw(1) << chan << " | 0x"
- << std::setw(3) << addr << " | "
- << std::setfill(' ') << std::dec << " FMD"
- << std::setw(1) << det << rng << "["
- << std::setw(2) << sec << "," << std::setw(3) << str
- << "]" << std::endl;
+ << std::setw(3) << ddl << " | "
+ << std::setfill('0') << std::hex << " 0x"
+ << std::setw(2) << board << " | 0x"
+ << std::setw(1) << chip << " | 0x"
+ << std::setw(1) << chan << " | 0x"
+ << std::setw(3) << addr << " | "
+ << std::setfill(' ') << std::dec << " FMD"
+ << std::setw(1) << det << rng << "["
+ << std::setw(2) << sec << ","
+ << std::setw(3) << strBase << "]" << std::endl;
} // for chan ...
if (chip == 2 && *ptr >= 32) continue;
std::cout << " + + + + + "
for (det = 1; det <= 3; det++) {
Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'),'\0' };
Char_t* ptr = rings;
+ ddl = Detector2DDL(det);
while ((rng = *(ptr++)) != '\0') {
UShort_t nsec = (rng == 'I' ? 20 : 40);
UShort_t nstr = (rng == 'I' ? 512 : 256);
for (sec = 0; sec < nsec; sec++) {
- for (str = 0; str < nstr; str += 128) {
- ddl = board = chip = chan;
- Detector2Hardware(det,rng,sec,str,ddl,board,chip,chan);
- addr = ((board & 0x1f) << 7) | ((chip & 0x7) << 4) | (chan & 0xf);
- std::cout << std::setfill(' ') << std::dec << " FMD"
- << std::setw(1) << det << rng << "["
- << std::setw(2) << sec << ","
- << std::setw(3) << str << "] | "
- << std::setw(3) << ddl << " | 0x"
- << std::setfill('0') << std::hex
- << std::setw(2) << board << " | 0x"
- << std::setw(1) << chip << " | 0x"
- << std::setw(1) << chan << " | 0x"
- << std::setw(3) << addr << std::endl;
+ for (strBase = 0; strBase < nstr; strBase += 128) {
+ Strip2Channel(rng, sec, strBase, board, chip, chan);
+ addr = ChannelAddress(board, chip, chan);
+ std::cout << std::setfill(' ') << std::dec << " FMD"
+ << std::setw(1) << det << rng << "["
+ << std::setw(2) << sec << ","
+ << std::setw(3) << strBase << "] | "
+ << std::setw(3) << ddl << " | 0x"
+ << std::setfill('0') << std::hex
+ << std::setw(2) << board << " | 0x"
+ << std::setw(1) << chip << " | 0x"
+ << std::setw(1) << chan << " | 0x"
+ << std::setw(3) << addr << std::endl;
} // for str ...
} // for sec ...
if (*ptr == '\0') continue;
AliFMDAltroMapping();
/** Destructor */
virtual ~AliFMDAltroMapping() {}
+ /** Return detector number corresponding to given DDL number
+ @param ddl DDL number
+ @return Detector number */
+ Short_t DDL2Detector(UInt_t ddl) const { return (ddl<=2 ? ddl + 1 : -1); }
+ /** Return the ring identifier corresponding to a board number
+ @param board Board number
+ @return Ring identifier */
+ Char_t Board2Ring(UShort_t board) const { return (board%2)?'O':'I'; }
+
+ /** Return the strip base number corresponding to a channel address
+ @param board Board number
+ @param altro Altro number
+ @param channel Channel number
+ @param ring On return, the ring ID
+ @param sec On return, the sector number
+ @param strip On return, the strip base offset
+ @return @c true on success */
+ Bool_t Channel2StripBase(UShort_t board, UShort_t altro,
+ UShort_t chan, Char_t& ring,
+ UShort_t& sec, Short_t& str) const;
+ /** Return the strip, sample corresponding to a timebin
+ @param sec Sector
+ @param timebin Time bin
+ @param preSamples Number of pre-samples
+ @param sampleRate Oversampling rate
+ @param strip On return, the strip number in this channel
+ @param sam On return, the sample number */
+ void Timebin2Strip(UShort_t sec, UShort_t timebin,
+ UShort_t preSamples, UShort_t sampleRate,
+ Short_t& strip, UShort_t& sample) const;
+
+#if 0
+ /** Map a hardware address into a detector index.
+ @param hwaddr Hardware address.
+ @param ring On return, the ring ID
+ @param sec On return, the sector #
+ @param str On return, the base of strip #
+ @return @c true on success, false otherwise */
+ Bool_t Hardware2Detector(UInt_t hwaddr,
+ Char_t& ring, UShort_t& sec, Short_t& str) const;
/** Map a hardware address into a detector index.
@param ddl Hardware DDL number
@param hwaddr Hardware address.
Bool_t Hardware2Detector(UInt_t ddl, UInt_t hwaddr,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str) const;
+ /** Map a hardware address into a detector index.
+ @param ddl Hardware DDL number
+ @param board FEC number
+ @param altro ALTRO number
+ @param channel Channel number
+ @param det On return, the detector #
+ @param ring On return, the ring ID
+ @param sec On return, the sector #
+ @param str On return, the base of strip #
+ @return @c true on success, false otherwise */
+ Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
+ UInt_t altro, UInt_t channel,
+ UShort_t& det, Char_t& ring,
+ UShort_t& sec, Short_t& str) const;
+#endif
/** Map a hardware address into a detector index.
@param ddl Hardware DDL number
@param hwaddr Hardware address.
@param str On return, the base of strip #
@param sam On return, the sample number for this strip
@return @c true on success, false otherwise */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t hwaddr,
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
UShort_t timebin, UShort_t preSamples,
UShort_t sampleRate,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const;
- /** Map a hardware address into a detector index.
- @param ddl Hardware DDL number
- @param board FEC number
- @param altro ALTRO number
- @param channel Channel number
- @param det On return, the detector #
- @param ring On return, the ring ID
- @param sec On return, the sector #
- @param str On return, the base of strip #
- @return @c true on success, false otherwise */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t altro, UInt_t channel,
- UShort_t& det, Char_t& ring,
- UShort_t& sec, Short_t& str) const;
/** Map a hardware address into a detector index.
@param ddl Hardware DDL number
@param board FEC number
@param str On return, the base of strip #
@param sam On return, the sample number for this strip
@return @c true on success, false otherwise */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t altro, UInt_t chan,
- UInt_t timebin, UInt_t preSamples,
- UInt_t sampleRate,
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t altro, UShort_t chan,
+ UShort_t timebin, UShort_t preSamples,
+ UShort_t sampleRate,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const;
+
+
+
+ /** Return DDL number corresponding to given detector number
+ @param det Detector number
+ @return DDL number */
+ UShort_t Detector2DDL(UShort_t det) const { return det - 1; }
+ /** Return board address corresponding to a sector
+ @param ring Ring identifier
+ @param sec Sector number
+ @return The board number, or negative number in case of failure */
+ Short_t Sector2Board(Char_t ring, UShort_t sec) const;
+ /** Convert strip address to a channel address.
+ @param ring Ring identifier
+ @param sec Sector number
+ @param str Strip number
+ @param board On return, contains the board number
+ @param altro On return, contains the altro number
+ @param chan On return, contains the channel number
+ @return @c true on success. */
+ Bool_t Strip2Channel(Char_t ring, UShort_t sec,
+ UShort_t str, UShort_t& board,
+ UShort_t& altro, UShort_t& chan) const;
+ /** Get the timebin correspoding to a strip and sample
+ @param sec Sector number
+ @param str Strip number
+ @param sam Sample number
+ @param preSamples Number of pre-samples.
+ @param sampleRate The over-sampling rate
+ @return the timebin corresponding to the passed strip */
+ UShort_t Strip2Timebin(UShort_t sec, UShort_t strip,
+ UShort_t sam, UShort_t preSamples,
+ UShort_t sampleRate) const;
+
+#if 0
/** Map a detector index into a hardware address.
@param det The detector #
@param ring The ring ID
@return @c true on success, false otherwise */
Bool_t Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& channel) const;
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& channel) const;
+ /** Map a detector index into a hardware address.
+ @param det The detector #
+ @param ring The ring ID
+ @param sec The sector #
+ @param str The strip #
+ @param ddl On return, hardware DDL number
+ @param hwaddr On return, hardware address.
+ @return @c true on success, false otherwise */
+ Bool_t Detector2Hardware(UShort_t det, Char_t ring,
+ UShort_t sec, UShort_t str,
+ UShort_t& ddl, UShort_t& hwaddr) const;
+#endif
/** Map a detector index into a hardware address.
@param det The detector #
@param ring The ring ID
Bool_t Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UShort_t preSamples, UShort_t sampleRate,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& channel,
+ UShort_t preSamples, UShort_t sampleRate,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& channel,
UShort_t& timebin) const;
- /** Map a detector index into a hardware address.
- @param det The detector #
- @param ring The ring ID
- @param sec The sector #
- @param str The strip #
- @param ddl On return, hardware DDL number
- @param hwaddr On return, hardware address.
- @return @c true on success, false otherwise */
- Bool_t Detector2Hardware(UShort_t det, Char_t ring,
- UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& hwaddr) const;
/** Map a detector index into a hardware address.
@param det The detector #
@param ring The ring ID
Bool_t Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UShort_t preSamples, UShort_t sampleRate,
- UInt_t& ddl, UInt_t& hwaddr,
+ UShort_t preSamples, UShort_t sampleRate,
+ UShort_t& ddl, UShort_t& hwaddr,
UShort_t& timebin) const;
+ /** Convert board, chip, channel to a hardware address
+ @param board Board number
+ @param altro Altro number
+ @param channel Channel number
+ @return hardware address of a channel */
+ UInt_t ChannelAddress(UShort_t board, UShort_t altro, UShort_t channel) const;
+ /** Convert a channel address to board, altro, channel fields
+ @param hwaddr Channel address
+ @param board On return, the Board number
+ @param altro On return, the Altro number
+ @param channel On return, the Channel number */
+ void ChannelAddress(UShort_t hwaddr, UShort_t& board, UShort_t& altro,
+ UShort_t& channel) const;
/** convert a partial detector index into a hardware address
@param sector Sector number
@param str Strip number
#include "TMath.h"
#include "TGraphErrors.h"
#include "AliFMDParameters.h"
+#include "AliFMDAltroMapping.h"
//_____________________________________________________________________
ClassImp(AliFMDGainDA)
{
AliFMDParameters* pars = AliFMDParameters::Instance();
- UInt_t ddl, board,chip,ch;
- pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+ // UInt_t ddl, board,chip,ch;
+ UShort_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
+ // pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+ /// pars->GetAltroMap()->Strip2Channel(
Int_t halfring = GetHalfringIndex(det,ring,board/16);
if(GetCurrentEvent()> (fNumberOfStripsPerChip*fEventsPerChannel.At(halfring)))
return;
if(strip % fNumberOfStripsPerChip) return;
- if(((GetCurrentEvent()) % fPulseLength.At(halfring)) && GetCurrentEvent() > 0) return;
+ if(((GetCurrentEvent()) % fPulseLength.At(halfring))
+ && GetCurrentEvent() > 0) return;
Int_t vaChip = strip/fNumberOfStripsPerChip;
TH1S* hChannel = GetChannelHistogram(det,ring,sec,vaChip);
}
Double_t mean = hChannel->GetMean();
Double_t rms = hChannel->GetRMS();
- Double_t pulse = Double_t(fCurrentPulse.At(halfring)) * fPulseSize.At(halfring);
+ Double_t pulse = (Double_t(fCurrentPulse.At(halfring))
+ * fPulseSize.At(halfring));
Int_t firstBin = hChannel->GetXaxis()->GetFirst();
Int_t lastBin = hChannel->GetXaxis()->GetLast();
hChannel->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms);
hChannel->GetXaxis()->SetRange(firstBin,lastBin);
- Int_t channelNumber = strip + (GetCurrentEvent()-1)/((fPulseLength.At(halfring)*fHighPulse)/fPulseSize.At(halfring));
+ Int_t channelNumber = (strip +
+ (GetCurrentEvent()-1)
+ / ((fPulseLength.At(halfring)*fHighPulse)
+ / fPulseSize.At(halfring)));
TGraphErrors* channel = GetChannel(det,ring,sec,channelNumber);
for (UShort_t sec = 0; sec < nSector; sec++) {
for (UShort_t str = 0; str < nStrip; str++) {
Int_t idx = DET2IDX(det, ring, sec, str);
- UInt_t ddl, addr;
+ UShort_t ddl, addr, time, sam=0;
Double_t val = 0;
switch (what) {
case kLocalPulseGain: // Path to PulseGain calib object
case kLocalSampleRate: // Path to SampleRate calib object
val = GetSampleRate(det,ring,sec,str); break;
case kLocalAltroMap: // Path to AltroMap calib object
- Detector2Hardware(det,ring,sec,str, ddl, addr);
+ Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time);
val = addr; break;
case kLocalZeroSuppression: // Path to ZeroSuppression cal object
val = GetZeroSuppression(det,ring,sec,str); break;
std::cout << "dead" << std::endl;
continue;
}
- UInt_t ddl, addr;
- Detector2Hardware(det, ring, sec, str, ddl, addr);
+ UShort_t ddl, addr, time, sam=0;
+ Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
<< "+/-" << std::setw(7)
<< GetPedestalWidth(det, ring, sec, str)
//____________________________________________________________________
Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr,
+AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
UShort_t timebin,
- UShort_t& det, Char_t& ring,
+ UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const
{
// Translate a hardware address to detector coordinates.
//
// See also Hardware2Detector that accepts 4 inputs
- if (!Hardware2Detector(ddl, addr, det, ring, sec, str)) return kFALSE;
- UShort_t preSamples = GetPreSamples(det, ring, sec, str);
- UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
- if (!fAltroMap->Hardware2Detector(ddl, addr, timebin,
- preSamples, sampleRate,
- det, ring, sec, str, sam)) return kFALSE;
- AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
- " (pre=%2d, rate=%d)",
- ddl, ((addr >> 7) & 0x1F), ((addr >> 4) & 0x7), addr & 0xF,
- timebin, det, ring, sec, str, sam, preSamples, sampleRate));
- // str += GetMinStrip(det,ring,sec,str);
- return kTRUE;
-
+ if (!fAltroMap) return kFALSE;
+ UShort_t board, chip, chan;
+ fAltroMap->ChannelAddress(addr, board, chip, chan);
+ return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
}
//____________________________________________________________________
Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t chip, UInt_t chan,
+AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t chip, UShort_t chan,
UShort_t timebin,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
// Translate a hardware address to detector coordinates.
//
// See also Hardware2Detector that accepts 4 inputs
- if (!Hardware2Detector(ddl,board,chip,chan,det,ring,sec,str)) return kFALSE;
- UShort_t preSamples = GetPreSamples(det, ring, sec, str);
- UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
- if (!fAltroMap->Hardware2Detector(ddl, board, chip, chan, timebin,
- preSamples, sampleRate,
- det, ring, sec, str, sam)) return kFALSE;
- // str += GetMinStrip(det,ring,sec,str);
+ if (!fAltroMap) return kFALSE;
+ if (fAltroMap->DDL2Detector(ddl) < 0) return kFALSE;
+ Short_t stripBase = 0;
+ if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase))
+ return kFALSE;
+ UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
+ UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
+ Short_t stripOff = 0;
+ fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
+ str = stripBase + stripOff;
+ AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
+ " (pre=%2d, rate=%d)",
+ ddl, board, chip, chan, timebin,
+ det, ring, sec, str, sam, preSamples, sampleRate));
return kTRUE;
}
+#if 0
//__________________________________________________________________
Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t chip, UInt_t chan,
+AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t chip, UShort_t chan,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str) const
{
}
//__________________________________________________________________
Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t ddl, UInt_t addr,
+AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str) const
{
if (!fAltroMap) return kFALSE;
return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
}
+#endif
//____________________________________________________________________
Bool_t
AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& channel,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& channel,
UShort_t& timebin) const
{
if (!fAltroMap) return kFALSE;
-//__________________________________________________________________
-Bool_t
-AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
- UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& board,
- UInt_t& chip, UInt_t& chan) const
-{
- // Map detector index to hardware address
- if (!fAltroMap) return kFALSE;
- return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
-}
-
//____________________________________________________________________
Bool_t
AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UInt_t& ddl, UInt_t& addr,
+ UShort_t& ddl, UShort_t& addr,
UShort_t& timebin) const
{
if (!fAltroMap) return kFALSE;
ddl, addr, timebin);
}
+#if 0
+//__________________________________________________________________
+Bool_t
+AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
+ UShort_t sec, UShort_t str,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& chip, UShort_t& chan) const
+{
+ // Map detector index to hardware address
+ if (!fAltroMap) return kFALSE;
+ return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
+}
+
//__________________________________________________________________
Bool_t
AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& addr) const
+ UShort_t& ddl, UShort_t& addr) const
{
// Map detector index to hardware address
if (!fAltroMap) return kFALSE;
return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
}
-
+#endif
//__________________________________________________________________
Float_t
@param str On return, the base of strip #
@param sam On return, the sample number for this strip
@return @c true on success, false otherwise */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t altro, UInt_t chan,
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t altro, UShort_t chan,
UShort_t timebin,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const;
- /** Translate hardware address to detector coordinates
- @param ddl DDL number
- @param board Board address
- @param chip Chip #
- @param channel Channel #
- @param det On return, Detector # (1-3)
- @param ring On return, Ring ID ('I' or 'O')
- @param sec On return, Sector number (0-39)
- @param str On return, Strip number (0-511)
- @return @c true on success. */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t board,
- UInt_t chip, UInt_t channel,
- UShort_t& det, Char_t& ring,
- UShort_t& sec, Short_t& str) const;
/** Map a hardware address into a detector index.
@param ddl Hardware DDL number
@param hwaddr Hardware address.
@param str On return, the base of strip #
@param sam On return, the sample number for this strip
@return @c true on success, false otherwise */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t hwaddr,
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr,
UShort_t timebin,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const;
+#if 0
+ /** Translate hardware address to detector coordinates
+ @param ddl DDL number
+ @param board Board address
+ @param chip Chip #
+ @param channel Channel #
+ @param det On return, Detector # (1-3)
+ @param ring On return, Ring ID ('I' or 'O')
+ @param sec On return, Sector number (0-39)
+ @param str On return, Strip number (0-511)
+ @return @c true on success. */
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t board,
+ UShort_t chip, UShort_t channel,
+ UShort_t& det, Char_t& ring,
+ UShort_t& sec, Short_t& str) const;
/** Translate hardware address to detector coordinates
@param ddl DDL number
@param addr Hardware address
@param sec On return, Sector number (0-39)
@param str On return, Strip number (0-511)
@return @c true on success. */
- Bool_t Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
+ Bool_t Hardware2Detector(UShort_t ddl, UShort_t addr, UShort_t& det,
Char_t& ring, UShort_t& sec, Short_t& str) const;
+#endif
/** Map a detector index into a hardware address.
@param det The detector #
Bool_t Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UInt_t& ddl, UInt_t& board,
- UInt_t& altro, UInt_t& channel,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& altro, UShort_t& channel,
UShort_t& timebin) const;
- /** Translate detector coordinates to hardware address
- @param det Detector # (1-3)
- @param ring Ring ID ('I' or 'O')
- @param sec Sector number (0-39)
- @param str Strip number (0-511)
- @param ddl On return, DDL number
- @param board On return, Board address
- @param chip On return, Chip #
- @param channel On return, Channel #
- @return @c true on success. */
- Bool_t Detector2Hardware(UShort_t det, Char_t ring,
- UShort_t sec, UShort_t str,
- UInt_t& ddl, UInt_t& board,
- UInt_t& chip, UInt_t& channel) const;
/** Map a detector index into a hardware address.
@param det The detector #
@param ring The ring ID
Bool_t Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
- UInt_t& ddl, UInt_t& hwaddr,
+ UShort_t& ddl, UShort_t& hwaddr,
UShort_t& timebin) const;
+#if 0
+ /** Translate detector coordinates to hardware address
+ @param det Detector # (1-3)
+ @param ring Ring ID ('I' or 'O')
+ @param sec Sector number (0-39)
+ @param str Strip number (0-511)
+ @param ddl On return, DDL number
+ @param board On return, Board address
+ @param chip On return, Chip #
+ @param channel On return, Channel #
+ @return @c true on success. */
+ Bool_t Detector2Hardware(UShort_t det, Char_t ring,
+ UShort_t sec, UShort_t str,
+ UShort_t& ddl, UShort_t& board,
+ UShort_t& chip, UShort_t& channel) const;
/** Translate detector coordinates to hardware address
@param det Detector # (1-3)
@param ring Ring ID ('I' or 'O')
@param addr On return, Hardware address
@return @c true on success. */
Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec,
- UShort_t str, UInt_t& ddl, UInt_t& addr) const;
+ UShort_t str, UShort_t& ddl, UShort_t& addr) const;
+#endif
/** Get the map that translates hardware to detector coordinates
@return Get the map that translates hardware to detector
coordinates */
#include "AliFMDParameters.h"
#include "AliFMDRawReader.h"
#include "AliRawReader.h"
+#include "AliFMDAltroMapping.h"
//_____________________________________________________________________
// This is the class that collects the QA data for the FMD during
fmdReader.ReadAdcs(digitsAddress);
for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
//Raw ADC counts
- AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
- UShort_t det = digit->Detector();
- Char_t ring = digit->Ring();
- UShort_t sec = digit->Sector();
- UShort_t strip = digit->Strip();
- UInt_t ddl, board, chip, channel;
- AliFMDParameters* pars = AliFMDParameters::Instance();
- pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,channel);
+ AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
+ UShort_t det = digit->Detector();
+ Char_t ring = digit->Ring();
+ UShort_t sec = digit->Sector();
+ // UShort_t strip = digit->Strip();
+ AliFMDParameters* pars = AliFMDParameters::Instance();
+ Short_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
GetRawsData(index1)->Fill(digit->Counts());
#include "AliFMDDebug.h"
#include "AliFMDCalibSampleRate.h"
#include "AliFMDCalibStripRange.h"
+#include "AliFMDAltroMapping.h"
// #include "AliFMDAltroIO.h" // ALIFMDALTROIO_H
#include <TArrayS.h> // ROOT_TArrayS
#include <TTree.h> // ROOT_TTree
// return kFALSE;
// }
// Get sample rate
- AliFMDParameters* pars = AliFMDParameters::Instance();
- AliFMDRawStream input(fReader);
+ AliFMDParameters* pars = AliFMDParameters::Instance();
+ AliFMDAltroMapping* map = pars->GetAltroMap();
+ AliFMDRawStream input(fReader);
AliFMDDebug(5, ("Setting 7 word headers"));
input.SetShortDataHeader(!pars->HasCompleteHeader());
AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
- UShort_t det, sec, samp;
+ UShort_t det, sec, samp, board, chip, channel;
Short_t strbase;
Char_t ring;
- if (!pars->Hardware2Detector(ddl, hwaddr, det, ring, sec, strbase)) {
+
+ if (map->DDL2Detector(ddl) < 0) break;
+ det = map->DDL2Detector(ddl);
+ map->ChannelAddress(hwaddr, board, chip, channel);
+ if (!map->Channel2StripBase(board, chip, channel, ring, sec, strbase)) {
AliError(Form("Failed to get detector id from DDL %d, "
"hardware address 0x%03x", ddl, hwaddr));
continue;
for (size_t i = 0; i < last; i++) {
// if (i < preSamp) continue;
- Short_t str = strbase;
-
- UShort_t t = (i - preSamp);
- samp = (t % rate);
- t -= samp;
- str += (sec % 2 ? -1 : 1) * t / rate;
+ Short_t stroff = 0;
+ map->Timebin2Strip(sec, i, preSamp, rate, stroff, samp);
+ Short_t str = strbase + stroff;
AliFMDDebug(10, ("0x%04x/0x%03x/%04d maps to FMD%d%c[%2d,%3d]-%d",
ddl, hwaddr, i, det, ring, sec, str, samp));
UInt_t strip_high[18];
UInt_t pulse_size[18];
UInt_t pulse_length[18];
- AliFMDParameters* param = AliFMDParameters::Instance();
+ AliFMDParameters* param = AliFMDParameters::Instance();
+ AliFMDAltroMapping* map = param->GetAltroMap();
while(fReader->ReadNextData(fData)) {
if(ddl==0 && (i==1 || i==3)) continue;
UInt_t chip =0, channel=0;
- param->Hardware2Detector(ddl,boards[i],chip,channel,
- det,ring,sector,strip);
+ det = map->DDL2Detector(ddl);
+ map->Channel2StripBase(boards[i], chip, channel, ring, sector, strip);
UInt_t samplerate = 1;
if(sample_clk[boards[i]] == 0) {
Char_t ring = digit->Ring();
UShort_t sector = digit->Sector();
UShort_t strip = digit->Strip();
- UInt_t ddl;
- UInt_t addr;
- UShort_t time;
+ UShort_t ddl, addr, time;
AliFMDDebug(15, ("Processing digit # %5d FMD%d%c[%2d,%3d]",
i, det, ring, sector, strip));
# include <FMD/AliFMDAltroMapping.h>
// # include <FMD/AliFMDUShortMap.h>
// # include <FMD/AliFMDBoolMap.h>
+# include <AliLog.h>
# include <TError.h>
# include <iostream>
#endif
/** @ingroup ALTRO_test
*/
void
-TestAltroMapping(Int_t min=2, Int_t max=0)
+TestAltroMapping(Int_t min=1, Int_t max=3)
{
+ // AliLog::SetModuleDebugLevel("FMD", 1);
// if (min < 1 || min > 3) min = 1;
if (max < min) max = min;
// AliFMDParameters* param = AliFMDParameters::Instance();
AliFMDAltroMapping m;
- UShort_t presamp = 0;
+ UShort_t presamp = 19;
UShort_t oversamp = 4;
for (UShort_t det = min; det <= max; det++) {
for (UShort_t sec = 0; sec < nsec; sec++) {
for (Short_t str = 0; str < nstr; str ++ /*= 128*/) {
for(UShort_t sam = 0; sam < oversamp; sam++) {
- UInt_t ddl, hwaddr;
+ UShort_t ddl, hwaddr;
UShort_t timebin;
if (!m.Detector2Hardware(det, ring, sec, str, sam,
presamp, oversamp,