1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.19.1 2008/09/19 preghenella
19 Decode method updated:
20 it reads the CDH from the rawReader and sends it to the decoder;
21 LoadRawDataBuffers modified:
22 it corrects tof hit infos per ddlBC and deltaBC offsets
23 (in case of the static member fgApplyBCCorrections
24 has been setted to kTRUE);
25 Added static member fgApplyBCCorrections (kTRUE by default)
26 and the related static method ApplyBCCorrections;
28 Revision 1.19 2007/05/18 13:07:53 decaro
29 Error messages stored in the global raw-reader error log (Cvetan, Chiara)
31 Revision 1.18 2007/05/08 11:53:29 arcelli
32 Improved class flexibility for further use (R.Preghenella)
34 Revision 1.17 2007/05/03 08:53:50 decaro
35 Coding convention: RS3 violation -> suppression
37 Revision 1.16 2007/05/03 08:22:22 decaro
38 Coding convention: RN17 violation -> suppression
40 Revision 1.15 2007/04/30 15:22:06 arcelli
41 Change TOF digit Time, Tot etc to int type
43 Revision 1.14 2007/04/27 11:11:53 arcelli
44 updates for the new decoder
46 Revision 1.13 2007/03/16 11:46:35 decaro
47 Coding convention: RN17 rule violation -> suppression
49 Revision 1.12 2007/02/22 09:43:45 decaro
50 Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
52 Revision 1.11 2007/02/20 15:57:00 decaro
53 Raw data update: to read the TOF raw data defined in UNPACKED mode
55 Revision 1.10 2006/12/15 14:01:38 cvetan
58 Revision 1.9 2006/10/13 11:22:27 arcelli
59 remove warnings due to uninitialized AliTOFtdcDigit data members
61 Revision 1.8 2006/08/22 13:30:17 arcelli
62 removal of effective c++ warnings (C.Zampolli)
64 Revision 1.7 2006/08/10 14:46:54 decaro
65 TOF raw data format: updated version
67 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
68 Update TOF raw data format
69 according to the final version
70 (see the ALICE internal note in preparation
71 'ALICE TOF raw data format')
72 Added the methods for the correspoonding numbering
73 between the equipment IDs and the volume IDs:
78 Revision 0.02 2005/07/28 A. De Caro:
79 Update format TOF raw data
81 Correction of few wrong corrispondences
82 between 'software' and 'hardware' numberings
84 Revision 0.01 2005/07/22 A. De Caro
85 Implement methods Next()
93 ////////////////////////////////////////////////////////////////////////
95 // This class provides access to TOF raw data in DDL files. //
97 // It loops over all TOF raw data given by the AliRawReader. //
99 ////////////////////////////////////////////////////////////////////////
102 #include "Riostream.h"
104 #include "TClonesArray.h"
108 #include "AliRawReader.h"
110 #include "AliTOFGeometry.h"
111 #include "AliTOFrawData.h"
112 #include "AliTOFRawMap.h"
113 #include "AliTOFRawStream.h"
114 //#include "AliTOFCableLengthMap.h"
116 #include "AliTOFHitData.h"
118 #include "AliRawEventHeaderBase.h"
119 #include "AliRawDataHeader.h"
121 ClassImp(AliTOFRawStream)
123 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
145 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
146 //_____________________________________________________________________________
147 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
148 fRawReader(rawReader),
149 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
150 fDecoder(new AliTOFDecoder()),
175 fInsideTRMchain0(kFALSE),
176 fInsideTRMchain1(kFALSE),
178 //fPackedDataBuffer(),
179 fLocalEventCounterDRM(-1),
180 fLocalEventCounterLTM(-1),
181 //fLocalEventCounterTRM(),
182 //fLocalEventCounterChain(),
184 //fCableLengthMap(new AliTOFCableLengthMap()),
188 // create an object to read TOF raw digits
191 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
193 ResetPackedDataBuffer(i);
196 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
197 fTOFrawData->SetOwner();
200 fRawReader->Select("TOF");
202 for (Int_t jj=0;jj<13;jj++) {
203 fLocalEventCounterTRM[jj] = -1;
204 for (Int_t ii=0;ii<2;ii++) {
205 fLocalEventCounterChain[jj][ii] = -1;
206 fChainBunchID[jj][ii] = -1;
210 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
214 //_____________________________________________________________________________
215 AliTOFRawStream::AliTOFRawStream():
217 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
218 fDecoder(new AliTOFDecoder()),
243 fInsideTRMchain0(kFALSE),
244 fInsideTRMchain1(kFALSE),
246 //fPackedDataBuffer(),
247 fLocalEventCounterDRM(-1),
248 fLocalEventCounterLTM(-1),
249 //fLocalEventCounterTRM(),
250 //fLocalEventCounterChain(),
252 //fCableLengthMap(new AliTOFCableLengthMap()),
258 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
260 ResetPackedDataBuffer(i);
263 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
264 fTOFrawData->SetOwner();
266 for (Int_t j=0;j<13;j++){
267 fLocalEventCounterTRM[j] = -1;
268 for (Int_t k=0;k<2;k++){
269 fLocalEventCounterChain[j][k] = -1;
270 fChainBunchID[j][k] = -1;
276 //_____________________________________________________________________________
277 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
279 fRawReader(stream.fRawReader),
280 fTOFrawData(stream.fTOFrawData),
281 fDecoder(new AliTOFDecoder()),
284 fTRMchain(stream.fTRMchain),
286 fTDCchannel(stream.fTDCchannel),
289 fLeadingEdge(stream.fLeadingEdge),
290 fTrailingEdge(stream.fTrailingEdge),
291 fErrorFlag(stream.fErrorFlag),
292 fSector(stream.fSector),
293 fPlate(stream.fPlate),
294 fStrip(stream.fStrip),
297 fPackedDigits(stream.fPackedDigits),
298 fWordType(stream.fWordType),
299 fSlotID(stream.fSlotID),
301 fPSbit(stream.fPSbit),
302 fTDCerrorFlag(stream.fTDCerrorFlag),
303 fInsideDRM(stream.fInsideDRM),
304 fInsideTRM(stream.fInsideTRM),
305 fInsideLTM(stream.fInsideLTM),
306 fInsideTRMchain0(stream.fInsideTRMchain0),
307 fInsideTRMchain1(stream.fInsideTRMchain1),
309 //fPackedDataBuffer(),
310 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
311 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
312 //fLocalEventCounterTRM(),
313 //fLocalEventCounterChain(),
315 //fCableLengthMap(stream.fCableLengthMap),
316 fEventID(stream.fEventID)
322 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
323 fDataBuffer[i] = stream.fDataBuffer[i];
324 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
327 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
329 for (Int_t j=0;j<13;j++){
330 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
331 for (Int_t k=0;k<2;k++){
332 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
333 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
339 //_____________________________________________________________________________
340 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
343 // assignment operator
349 TObject::operator=(stream);
351 fRawReader = stream.fRawReader;
353 fTOFrawData = stream.fTOFrawData;
357 fTRMchain = stream.fTRMchain;
359 fTDCchannel = stream.fTDCchannel;
360 fTime = stream.fTime;
362 fLeadingEdge = stream.fLeadingEdge;
363 fTrailingEdge = stream.fTrailingEdge;
364 fErrorFlag = stream.fErrorFlag;
366 fSector = stream.fSector;
367 fPlate = stream.fPlate;
368 fStrip = stream.fStrip;
369 fPadX = stream.fPadX;
370 fPadZ = stream.fPadZ;
372 fPackedDigits = stream.fPackedDigits;
374 fWordType = stream.fWordType;
375 fSlotID = stream.fSlotID;
377 fPSbit = stream.fPSbit;
378 fTDCerrorFlag = stream.fTDCerrorFlag;
379 fInsideDRM = stream.fInsideDRM;
380 fInsideTRM = stream.fInsideTRM;
381 fInsideLTM = stream.fInsideLTM;
382 fInsideTRMchain0 = stream.fInsideTRMchain0;
383 fInsideTRMchain1 = stream.fInsideTRMchain1;
385 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
386 fDataBuffer[i] = stream.fDataBuffer[i];
387 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
390 fTOFrawData = stream.fTOFrawData;
392 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
393 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
394 for (Int_t j=0;j<13;j++){
395 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
396 for (Int_t k=0;k<2;k++){
397 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
398 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
402 //fCableLengthMap = stream.fCableLengthMap;
404 fEventID = stream.fEventID;
410 //_____________________________________________________________________________
411 AliTOFRawStream::~AliTOFRawStream()
419 fTOFrawData->Clear();
422 //delete fCableLengthMap;
427 //_____________________________________________________________________________
429 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
435 fTOFrawData->Clear();
437 TClonesArray &arrayTofRawData = *fTOFrawData;
441 // create raw data map
442 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
445 Int_t slot[4] = {-1, -1, -1, -1};
447 fLocalEventCounterDRM = -1;
448 fLocalEventCounterLTM = -1;
449 for (Int_t ii=0; ii<13; ii++)
450 fLocalEventCounterTRM[ii] = -1;
451 for (Int_t ii=0; ii<13; ii++)
452 for (Int_t jj=0; jj<2; jj++) {
453 fLocalEventCounterChain[ii][jj] = -1;
454 fChainBunchID[ii][jj] = -1;
458 fRawReader->Select("TOF", indexDDL, indexDDL);
460 Bool_t signal = kFALSE;
462 AliTOFrawData *rawDigit = NULL;
466 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
468 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
473 slot[3] = fTDCchannel;
475 if (rawMap->TestHit(slot) != kEmpty) {
477 rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
479 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
480 fLeadingEdge==-1 && fTrailingEdge!=-1) {
482 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
484 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
485 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
490 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
492 rawMap->SetHit(slot);
500 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
502 rawMap->SetHit(slot);
504 } // else if (rawMap->TestHit(slot) == kEmpty)
508 } // closed -> while (Next())
514 //_____________________________________________________________________________
515 Bool_t AliTOFRawStream::Next()
518 // Read next 32-bit word in TOF raw data files
519 // returns kFALSE if there is no word left
526 if (!fRawReader->ReadNextInt(data)) return kFALSE;
528 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
540 fDDL = fRawReader->GetDDLID();
542 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
544 switch (fWordType) { // switch word type
546 case GLOBAL_HEADER_TYPE: // global header
547 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
551 switch (fSlotID) { // switch global header slot ID
553 case DRM_ID_NUMBER: //DRM global header
554 if (fInsideDRM) { // unexpected DRM global headers -> exit
557 fInsideDRM = kTRUE; // DRM global header accepted
560 case LTM_ID_NUMBER: // LTM global header
561 if (fInsideLTM) { // unexpected LTM global headers -> exit
564 fInsideLTM = kTRUE; // LTM global header accepted
574 case 10: //TRM header
575 case 11: //TRM header
576 case 12: //TRM header
577 if (fInsideTRM) { // unexpected TRM global headers -> exit
580 fInsideTRM = kTRUE; // TRM global header accepted
581 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
584 default: // unexpected global header slot ID
587 } //end switch global header slot id
592 case GLOBAL_TRAILER_TYPE: // global trailer
593 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
595 switch (fSlotID) { // switch global trailer slot ID
597 case DRM_ID_NUMBER: // DRM global trailer
598 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
602 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
603 fLocalEventCounterDRM = GetField(data,dummy,4);
604 fInsideDRM = kFALSE; // DRM global trailer accepted
607 fInsideTRMchain0 = kFALSE;
608 fInsideTRMchain1 = kFALSE;
628 case LTM_ID_NUMBER: // LTM global trailer
629 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
633 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
634 fLocalEventCounterLTM = GetField(data,dummy,16);
635 fInsideLTM = kFALSE; // LTM global trailer accepted
637 case 15: //TRM global trailer
638 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
642 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
643 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
644 fInsideTRM = kFALSE; // TRM global trailer accepted
646 default: // unexpected global trailer slot ID
648 } //end switch global trailer slot id
654 case ERROR_TYPE: // TDC error
655 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
656 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
660 case FILLER_TYPE: // filler
664 default: // other word types
666 if (fInsideTRM) { // inside TRM
668 switch (fWordType) { // switch word type inside TRM
669 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
670 if (fInsideTRMchain0) { // unexpected TRM chain0 header
673 fInsideTRMchain0 = kTRUE;
676 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
677 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
679 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
680 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
684 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
685 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
686 fInsideTRMchain0 = kFALSE;
689 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
690 if (fInsideTRMchain1) { // unexpected TRM chain1 header
693 fInsideTRMchain1 = kTRUE;
696 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
697 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
699 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
700 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
704 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
705 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
706 fInsideTRMchain1 = kFALSE;
709 } // end switch word type inside TRM
711 } // end if (fInsideTRM)
715 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
716 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
717 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
718 ){ // inside TRM chains
720 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
721 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
722 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
723 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
732 switch (fPSbit) { // switch fPSbit bits inside TRM chains
734 case 0: // packing ok, digit time and TOT
735 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
736 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
738 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
740 if (fgApplyBCCorrections) {
741 AliDebug(2,"Apply nominal DDL BC time-shift correction");
742 AliDebug(2,"Apply deltaBC time-shift correction");
743 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
745 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
747 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
751 case 1: // leading edge digit, long digit time, no TOT
754 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
756 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
758 if (fgApplyBCCorrections) {
759 AliDebug(2,"Apply nominal DDL BC time-shift correction");
760 AliDebug(2,"Apply deltaBC time-shift correction");
761 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
763 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
765 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
769 case 2: // trailing edge digit, long digit time, no TOT
772 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
774 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
776 if (fgApplyBCCorrections) {
777 AliDebug(2,"Apply nominal DDL BC time-shift correction");
778 AliDebug(2,"Apply deltaBC time-shift correction");
779 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
781 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
783 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
787 case 3: // TOT overflow
788 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
789 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
791 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
793 if (fgApplyBCCorrections) {
794 AliDebug(2,"Apply nominal DDL BC time-shift correction");
795 AliDebug(2,"Apply deltaBC time-shift correction");
796 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
798 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
800 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
804 } // end switch PS bits inside TRM chains
806 } // end if is inside TRM chains
808 } // end switch on fWordType
814 //_____________________________________________________________________________
816 void AliTOFRawStream::SetSector()
819 // Evaluate the TOF sector number -> [ 0;17]
820 // corresponding to the TOF equipment IDs:
823 // fTRMchain -> [ 0; 1]
825 // fTDCchannel -> [ 0; 7]
830 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
835 //_____________________________________________________________________________
838 void AliTOFRawStream::SetPlate()
841 // Evaluate the TOF plate number ->[ 0; 4]
842 // corresponding to the TOF equipment IDs:
845 // fTRMchain -> [ 0; 1]
847 // fTDCchannel -> [ 0; 7]
851 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
853 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
858 //_____________________________________________________________________________
860 void AliTOFRawStream::SetStrip()
863 // Evaluate the TOF strip number per module -> [ 0; 14/18]
864 // corresponding to the TOF equipment IDs:
867 // fTRMchain -> [ 0; 1]
869 // fTDCchannel -> [ 0; 7]
874 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
875 || fSector==-1 || fPlate==-1))
876 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
881 //_____________________________________________________________________________
883 void AliTOFRawStream::SetPadZ()
886 // Evaluate the TOF padRow number per strip -> [ 0; 1]
887 // corresponding to the TOF equipment IDs:
890 // fTRMchain -> [ 0; 1]
892 // fTDCchannel -> [ 0; 7]
897 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
898 || fSector==-1 || fPlate==-1 || fStrip==-1))
900 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
901 if (iPadAlongTheStrip!=-1)
902 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
905 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
906 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
911 //_____________________________________________________________________________
913 void AliTOFRawStream::SetPadX()
916 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
917 // corresponding to the TOF equipment IDs:
920 // fTRMchain -> [ 0; 1]
922 // fTDCchannel -> [ 0; 7]
927 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
928 || fSector==-1 || fPlate==-1 || fStrip==-1))
930 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
931 if (iPadAlongTheStrip!=-1)
932 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
935 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
936 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
942 //----------------------------------------------------------------------------
943 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
949 return ((word & fieldMask) >> fieldPosition);
952 //----------------------------------------------------------------------------
953 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
956 // Returns the TOF plate number [0;4]
957 // corresponding to the TOF equipment ID numbers:
958 // iDDL -> DDL number per sector [0;3]
959 // nTRM -> TRM number [3;12]
960 // nTDC -> TDC number [0;14]
967 if (nTRM>=4 && nTRM<7) {
969 } else if (nTRM==7) {
970 if (nTDC<12) iPlate = 0;
972 } else if (nTRM>=8 && nTRM<11) {
974 } else if (nTRM==11) {
975 if (nTDC<9) iPlate = 1;
977 }else if (nTRM==12) {
981 } else if (iDDL==1) {
984 if (nTDC<3) iPlate = 0;
985 } else if (nTRM>=4 && nTRM<7) {
987 } else if (nTRM==7) {
988 if (nTDC<6) iPlate = 1;
990 } else if (nTRM>=8 && nTRM<11) {
992 } else if (nTRM==11) {
993 if (nTDC<9) iPlate = 2;
995 } else if (nTRM==12) {
999 } else if (iDDL==2) {
1001 if (nTRM>=4 && nTRM<7) {
1003 } else if (nTRM==7) {
1004 if (nTDC<12) iPlate = 4;
1006 } else if (nTRM>=8 && nTRM<11) {
1008 } else if (nTRM==11) {
1009 if (nTDC<9) iPlate = 3;
1011 }else if (nTRM==12) {
1015 } else if (iDDL==3) {
1018 if (nTDC<3) iPlate = 4;
1019 } else if (nTRM>=4 && nTRM<7) {
1021 } else if (nTRM==7) {
1022 if (nTDC<6) iPlate = 3;
1024 } else if (nTRM>=8 && nTRM<11) {
1026 } else if (nTRM==11) {
1027 if (nTDC<9) iPlate = 2;
1029 } else if (nTRM==12) {
1039 //----------------------------------------------------------------------------
1040 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1043 // Returns the TOF strip number per module:
1044 // [0;14], in the central plates,
1045 // [0;18], in the intermediate and external plates
1046 // corresponding to the TOF equipment ID numbers:
1047 // iDDL -> DDL number per sector [0;3]
1048 // nTRM -> TRM number [3;12]
1049 // nTDC -> TDC number [0;14]
1056 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1057 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1058 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1059 else if (nTRM== 7) {
1060 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1061 else iStrip = (Int_t)(nTDC/3.) - 4;
1063 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1064 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1065 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1066 else if (nTRM==11) {
1067 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1068 else iStrip = (Int_t)(nTDC/3.) - 3;
1070 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1072 } else if (iDDL==1) {
1074 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1075 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1076 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1077 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1078 else if (nTRM== 7) {
1079 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1080 else iStrip = 20 - (Int_t)(nTDC/3.);
1082 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1083 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1084 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1085 else if (nTRM==11) {
1086 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1087 else iStrip = 21 - (Int_t)(nTDC/3.);
1089 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1091 } else if (iDDL==2) {
1093 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1094 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1095 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1096 else if (nTRM== 7) {
1097 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1098 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1100 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1101 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1102 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1103 else if (nTRM==11) {
1104 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1105 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1107 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1109 } else if (iDDL==3) {
1111 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1112 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1113 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1114 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1115 else if (nTRM== 7) {
1116 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1117 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1119 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1120 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1121 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1122 else if (nTRM==11) {
1123 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1124 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1126 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1134 //----------------------------------------------------------------------------
1135 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1139 // Returns the TOF pad number per strip [0;95]
1140 // corresponding to the TOF equipment ID numbers:
1141 // iDDL -> DDL number per sector [0;3]
1142 // iChain -> TRM chain number [0;1]
1143 // nTDC -> TDC number [0;14]
1144 // iCH -> TDC channel number [0;7]
1147 Int_t iPadAlongTheStrip = -1;
1150 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1151 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1152 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1155 Int_t iTDClocal = -1;
1156 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1157 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1158 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1159 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1161 Int_t iCHlocal = iCH;
1162 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1164 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1166 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1167 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1168 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
1169 //AliWarning("Problems with the padX number!");
1171 return iPadAlongTheStrip;
1175 //----------------------------------------------------------------------------
1176 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1180 // Returns the TOF padX number [0;47]
1181 // corresponding to the TOF equipment ID numbers:
1182 // iDDL -> DDL number per sector [0;3]
1183 // iChain -> TRM chain number [0;1]
1184 // nTDC -> TDC number [0;14]
1185 // iCH -> TDC channel number [0;7]
1188 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1189 (Float_t(AliTOFGeometry::NpadZ())));
1195 //----------------------------------------------------------------------------
1196 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1200 // Returns the TOF padZ number [0;1]
1201 // corresponding to the TOF equipment ID numbers:
1202 // iDDL -> DDL number per sector [0;3]
1203 // iChain -> TRM chain number [0;1]
1204 // nTDC -> TDC number [0;14]
1205 // iCH -> TDC channel number [0;7]
1208 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1214 //----------------------------------------------------------------------------
1215 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1218 // Returns the sector number [0;17]
1219 // corresponing to the assigned DRM/DDL number [0;71]
1222 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1227 //----------------------------------------------------------------------------
1228 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1231 // Return the DRM/DDL number per sector [0;3]
1232 // corresponing to the assigned DRM/DDL number [0;71]
1235 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1241 //----------------------------------------------------------------------------
1242 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1244 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1246 //----------------------------------------------------------------------------
1247 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1248 Int_t nTDC, Int_t iCH,
1253 // nDDL (variable in [0;71]) -> number of the DDL file
1254 // nTRM (variable in [3;12]) -> number of the TRM slot
1255 // iChain (variable in [0; 1]) -> number of the TRM chain
1256 // nTDC (variable in [0;14]) -> number of the TDC
1257 // iCH (variable in [0; 7]) -> number of the TDC channel
1260 // sector number, i.e. volume[0] (variable in [0,17])
1261 // plate number, i.e. volume[1] (variable in [0, 5])
1262 // strip number, i.e. volume[2] (variable in [0,14/18])
1263 // padX number, i.e. volume[3] (variable in [0,47])
1264 // padZ number, i.e. volume[4] (variable in [0, 1])
1267 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1269 Int_t iSector = GetSectorNumber(nDDL);
1271 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1274 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1275 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number!/n");
1278 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1281 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1282 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number!\n");
1285 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1286 if (iPadAlongTheStrip==-1) {
1288 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1289 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip!\n");
1292 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1293 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1295 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1296 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1298 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1299 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1301 volume[0] = iSector;
1308 //-----------------------------------------------------------------------------
1309 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1311 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1314 //check and fix valid DDL range
1317 fRawReader->AddMinorErrorLog(kDDLMinError);
1318 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1322 fRawReader->AddMinorErrorLog(kDDLMaxError);
1323 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1326 //select required DDLs
1327 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1330 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1332 return(Decode(verbose));
1334 //-----------------------------------------------------------------------------
1335 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1337 // New decoder method
1340 Int_t currentEquipment;
1342 const AliRawDataHeader *currentCDH;
1345 UChar_t *data = 0x0;
1347 //loop and read DDL headers
1348 while(fRawReader->ReadHeader()){
1350 //memory leak prevention (actually data should be always 0x0 here)
1354 //get equipment infos
1355 currentEquipment = fRawReader->GetEquipmentId();
1356 currentDDL = fRawReader->GetDDLID();
1357 currentCDH = fRawReader->GetDataHeader();
1358 const Int_t kDataSize = fRawReader->GetDataSize();
1359 const Int_t kDataWords = kDataSize / 4;
1360 data = new UChar_t[kDataSize];
1363 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1366 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1368 //read equipment payload
1369 if (!fRawReader->ReadNext(data, kDataSize))
1371 fRawReader->AddMajorErrorLog(kDDLdataReading);
1373 AliWarning("Error while reading DDL data. Go to next equipment");
1380 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1383 //set up the decoder
1384 fDecoder->SetVerbose(verbose);
1385 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1386 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1389 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1390 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1391 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1399 fRawReader->Reset();
1402 AliInfo("All done");
1407 //---------------------------------------------------------------------------
1409 AliTOFRawStream::ResetBuffers()
1412 // To reset the buffers
1415 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1416 ResetDataBuffer(iDDL);
1417 ResetPackedDataBuffer(iDDL);
1421 //---------------------------------------------------------------------------
1423 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1426 // To load the buffers
1429 fTOFrawData->Clear();
1433 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1435 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1436 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1437 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1442 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1444 AliTOFHitData *hitData; //hit data pointer
1447 AliInfo("Filling TClonesArray ...");
1450 if (fgApplyBCCorrections) {
1451 AliInfo("Apply nominal DDL BC time-shift correction");
1452 AliInfo("Apply deltaBC time-shift correction");
1455 //loop over DDL packed hits
1456 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1457 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1458 Int_t hitACQ = hitData->GetACQ();
1459 Int_t hitPS = hitData->GetPS();
1460 Int_t hitSlotID = hitData->GetSlotID();
1461 Int_t hitChain = hitData->GetChain();
1462 Int_t hitTDC = hitData->GetTDC();
1463 Int_t hitChan = hitData->GetChan();
1464 Int_t hitTimeBin = hitData->GetTimeBin();
1465 Int_t hitTOTBin = hitData->GetTOTBin();
1467 if (fgApplyBCCorrections) {
1468 /* DDL BC shift time correction */
1469 hitTimeBin += fgkddlBCshift[indexDDL];
1470 /* deltaBC shift time correction */
1471 hitTimeBin += hitData->GetDeltaBunchID();
1474 Int_t hitLeading = hitData->GetTimeBin();
1475 Int_t hitTrailing = -1;
1476 Int_t hitError = -1;
1478 TClonesArray &arrayTofRawData = *fTOFrawData;
1479 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1486 AliInfo("Resetting buffers ...");
1488 fDataBuffer[indexDDL].Reset();
1489 fPackedDataBuffer[indexDDL].Reset();
1497 //---------------------------------------------------------------------------
1498 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1502 // nSector number -vol[0]- (variable in [0,17])
1503 // nPlate number -vol[1]- (variable in [0, 5])
1504 // nStrip number -vol[2]- (variable in [0,14/18])
1505 // nPadZ number -vol[3]- (variable in [0, 1])
1506 // nPadX number -vol[4]- (variable in [0,47])
1508 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1509 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1510 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1511 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1512 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1515 eqId[0] = Geant2DDL(vol);
1516 eqId[1] = Geant2TRM(vol);
1517 eqId[2] = Geant2TDC(vol);
1518 eqId[3] = Geant2Chain(vol);
1519 eqId[4] = Geant2Channel(vol);
1523 //---------------------------------------------------------------------------
1524 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1528 // nSector number -vol[0]- (variable in [0,17])
1529 // nPlate number -vol[1]- (variable in [0, 5])
1530 // nStrip number -vol[2]- (variable in [0,14/18])
1531 // nPadZ number -vol[3]- (variable in [0, 1])
1532 // nPadX number -vol[4]- (variable in [0,47])
1534 // nDDL (variable in [0;71]) -> number of the DDL
1540 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1541 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1544 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1545 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1548 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1549 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1552 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1553 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1554 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1555 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1556 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1557 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1561 Int_t nSector = vol[0];
1562 Int_t nPlate = vol[1];
1563 Int_t nStrip = vol[2];
1564 Int_t nPadX = vol[4];
1566 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1568 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1570 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1572 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1575 return 4*nSector+iDDL;
1579 //---------------------------------------------------------------------------
1580 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1584 // nSector number -vol[0]- (variable in [0,17])
1585 // nPlate number -vol[1]- (variable in [0, 5])
1586 // nStrip number -vol[2]- (variable in [0,14/18])
1587 // nPadZ number -vol[3]- (variable in [0, 1])
1588 // nPadX number -vol[4]- (variable in [0,47])
1590 // nTRM (variable in [3;12]) -> number of the TRM slot
1595 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1596 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1599 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1600 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1603 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1604 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1607 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1608 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1611 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1612 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1616 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1618 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1622 Int_t nPlate = vol[1];
1623 Int_t nStrip = vol[2];
1625 Int_t iDDL = Geant2DDL(vol)%4;
1632 if (nStrip<= 4) nTRM = 4;
1633 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1634 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1635 else if (nStrip>14) nTRM = 7;
1637 else if (nPlate==1) {
1638 if (nStrip== 0) nTRM = 7;
1639 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1640 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1641 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1642 else if (nStrip>15) nTRM = 11;
1644 else if (nPlate==2) {
1645 if (nStrip<= 1) nTRM = 11;
1646 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1653 if (nStrip== 0) nTRM = 3;
1654 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1655 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1656 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1657 else if (nStrip>15) nTRM = 7;
1659 else if (nPlate==1) {
1660 if (nStrip<=1) nTRM = 7;
1661 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1662 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1663 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1664 else if (nStrip>16) nTRM = 11;
1666 else if (nPlate==2) {
1667 if (nStrip<= 2) nTRM = 11;
1668 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1675 if (nStrip>=14) nTRM = 4;
1676 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1677 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1678 else if (nStrip< 4) nTRM = 7;
1680 else if (nPlate==3) {
1681 if (nStrip==18) nTRM = 7;
1682 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1683 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1684 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1685 else if (nStrip< 3) nTRM = 11;
1687 else if (nPlate==2) {
1688 if (nStrip>=13) nTRM = 11;
1689 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1696 if (nStrip==18) nTRM = 3;
1697 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1698 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1699 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1700 else if (nStrip< 3) nTRM = 7;
1702 else if (nPlate==3) {
1703 if (nStrip>=17) nTRM = 7;
1704 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1705 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1706 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1707 else if (nStrip< 2) nTRM = 11;
1709 else if (nPlate==2) {
1710 if (nStrip>=12) nTRM = 11;
1711 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1722 //---------------------------------------------------------------------------
1723 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1727 // nSector number -vol[0]- (variable in [0,17])
1728 // nPlate number -vol[1]- (variable in [0, 5])
1729 // nStrip number -vol[2]- (variable in [0,14/18])
1730 // nPadZ number -vol[3]- (variable in [0, 1])
1731 // nPadX number -vol[4]- (variable in [0,47])
1733 // nTDC (variable in [0;14]) -> number of the TDC
1738 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1739 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1742 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1743 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1746 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1747 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1750 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1751 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1752 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1753 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1754 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1755 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1759 Int_t nPlate = vol[1];
1760 Int_t nStrip = vol[2];
1761 Int_t iPadX = vol[4];
1763 Int_t iDDL = Geant2DDL(vol)%4;
1770 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1771 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1772 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1773 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1775 else if (nPlate==1) {
1776 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1777 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1778 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1779 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1780 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1782 else if (nPlate==2) {
1783 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1784 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1791 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1792 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1793 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1794 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1795 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1797 else if (nPlate==1) {
1798 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1799 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1800 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1801 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1802 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1804 else if (nPlate==2) {
1805 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1806 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1813 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1814 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1815 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1816 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1818 else if (nPlate==3) {
1819 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1820 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1821 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1822 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1823 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1825 else if (nPlate==2) {
1826 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1827 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1834 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1835 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1836 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1837 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1838 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1840 else if (nPlate==3) {
1841 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1842 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1843 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1844 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1845 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1847 else if (nPlate==2) {
1848 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1849 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1860 //---------------------------------------------------------------------------
1861 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1865 // nSector number -vol[0]- (variable in [0,17])
1866 // nPlate number -vol[1]- (variable in [0, 5])
1867 // nStrip number -vol[2]- (variable in [0,14/18])
1868 // nPadZ number -vol[3]- (variable in [0, 1])
1869 // nPadX number -vol[4]- variable in [0,47])
1871 // nChain (variable in [0; 1]) -> number of the TRM chain
1876 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1877 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1880 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1881 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1884 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1885 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1888 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1889 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1890 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1891 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1892 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1893 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1897 Int_t iPadX = vol[4];
1899 if (iPadX<12 || iPadX>=36) nChain = 0;
1906 //---------------------------------------------------------------------------
1907 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1911 // nSector number -vol[0]- (variable in [0,17])
1912 // nPlate number -vol[1]- (variable in [0, 5])
1913 // nStrip number -vol[2]- (variable in [0,14/18])
1914 // nPadZ number -vol[3]- (variable in [0, 1])
1915 // nPadX number -vol[4]- (variable in [0,47])
1917 // nChannel (variable in [0; 7]) -> number of the TDC channel
1920 Int_t nChannel = -1;
1922 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1923 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1926 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1927 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1930 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1931 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1934 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1935 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1936 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1937 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1938 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1939 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1943 Int_t iPadZ = vol[3];
1944 Int_t iPadX = vol[4];
1946 Int_t iDDL = Geant2DDL(vol)%4;
1951 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1954 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1957 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1960 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;