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"
105 #include "TStopwatch.h"
109 #include "AliRawReader.h"
111 #include "AliTOFGeometry.h"
112 #include "AliTOFrawData.h"
113 #include "AliTOFRawMap.h"
114 #include "AliTOFRawStream.h"
115 #include "AliTOFdigit.h"
116 #include "AliTOFSDigit.h"
117 //#include "AliTOFCableLengthMap.h"
119 #include "AliTOFHitData.h"
121 #include "AliRawEventHeaderBase.h"
122 #include "AliRawDataHeader.h"
124 ClassImp(AliTOFRawStream)
126 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
148 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
149 //_____________________________________________________________________________
150 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
151 fRawReader(rawReader),
152 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
153 fDecoder(new AliTOFDecoder()),
178 fInsideTRMchain0(kFALSE),
179 fInsideTRMchain1(kFALSE),
181 //fPackedDataBuffer(),
182 fLocalEventCounterDRM(-1),
183 fLocalEventCounterLTM(-1),
184 //fLocalEventCounterTRM(),
185 //fLocalEventCounterChain(),
187 //fCableLengthMap(new AliTOFCableLengthMap()),
189 fNewDecoderVersion(0)
192 // create an object to read TOF raw digits
195 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
197 ResetPackedDataBuffer(i);
200 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
201 fTOFrawData->SetOwner();
204 fRawReader->Select("TOF");
206 for (Int_t jj=0;jj<13;jj++) {
207 fLocalEventCounterTRM[jj] = -1;
208 for (Int_t ii=0;ii<2;ii++) {
209 fLocalEventCounterChain[jj][ii] = -1;
210 fChainBunchID[jj][ii] = -1;
214 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
218 //_____________________________________________________________________________
219 AliTOFRawStream::AliTOFRawStream():
221 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
222 fDecoder(new AliTOFDecoder()),
247 fInsideTRMchain0(kFALSE),
248 fInsideTRMchain1(kFALSE),
250 //fPackedDataBuffer(),
251 fLocalEventCounterDRM(-1),
252 fLocalEventCounterLTM(-1),
253 //fLocalEventCounterTRM(),
254 //fLocalEventCounterChain(),
256 //fCableLengthMap(new AliTOFCableLengthMap()),
258 fNewDecoderVersion(0)
263 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
265 ResetPackedDataBuffer(i);
268 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
269 fTOFrawData->SetOwner();
271 for (Int_t j=0;j<13;j++){
272 fLocalEventCounterTRM[j] = -1;
273 for (Int_t k=0;k<2;k++){
274 fLocalEventCounterChain[j][k] = -1;
275 fChainBunchID[j][k] = -1;
281 //_____________________________________________________________________________
282 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
284 fRawReader(stream.fRawReader),
285 fTOFrawData(stream.fTOFrawData),
286 fDecoder(new AliTOFDecoder()),
289 fTRMchain(stream.fTRMchain),
291 fTDCchannel(stream.fTDCchannel),
294 fLeadingEdge(stream.fLeadingEdge),
295 fTrailingEdge(stream.fTrailingEdge),
296 fErrorFlag(stream.fErrorFlag),
297 fSector(stream.fSector),
298 fPlate(stream.fPlate),
299 fStrip(stream.fStrip),
302 fPackedDigits(stream.fPackedDigits),
303 fWordType(stream.fWordType),
304 fSlotID(stream.fSlotID),
306 fPSbit(stream.fPSbit),
307 fTDCerrorFlag(stream.fTDCerrorFlag),
308 fInsideDRM(stream.fInsideDRM),
309 fInsideTRM(stream.fInsideTRM),
310 fInsideLTM(stream.fInsideLTM),
311 fInsideTRMchain0(stream.fInsideTRMchain0),
312 fInsideTRMchain1(stream.fInsideTRMchain1),
314 //fPackedDataBuffer(),
315 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
316 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
317 //fLocalEventCounterTRM(),
318 //fLocalEventCounterChain(),
320 //fCableLengthMap(stream.fCableLengthMap),
321 fEventID(stream.fEventID),
322 fNewDecoderVersion(stream.fNewDecoderVersion)
328 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
329 fDataBuffer[i] = stream.fDataBuffer[i];
330 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
333 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
335 for (Int_t j=0;j<13;j++){
336 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
337 for (Int_t k=0;k<2;k++){
338 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
339 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
345 //_____________________________________________________________________________
346 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
349 // assignment operator
355 TObject::operator=(stream);
357 fRawReader = stream.fRawReader;
359 fTOFrawData = stream.fTOFrawData;
363 fTRMchain = stream.fTRMchain;
365 fTDCchannel = stream.fTDCchannel;
366 fTime = stream.fTime;
368 fLeadingEdge = stream.fLeadingEdge;
369 fTrailingEdge = stream.fTrailingEdge;
370 fErrorFlag = stream.fErrorFlag;
372 fSector = stream.fSector;
373 fPlate = stream.fPlate;
374 fStrip = stream.fStrip;
375 fPadX = stream.fPadX;
376 fPadZ = stream.fPadZ;
378 fPackedDigits = stream.fPackedDigits;
380 fWordType = stream.fWordType;
381 fSlotID = stream.fSlotID;
383 fPSbit = stream.fPSbit;
384 fTDCerrorFlag = stream.fTDCerrorFlag;
385 fInsideDRM = stream.fInsideDRM;
386 fInsideTRM = stream.fInsideTRM;
387 fInsideLTM = stream.fInsideLTM;
388 fInsideTRMchain0 = stream.fInsideTRMchain0;
389 fInsideTRMchain1 = stream.fInsideTRMchain1;
391 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
392 fDataBuffer[i] = stream.fDataBuffer[i];
393 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
396 fTOFrawData = stream.fTOFrawData;
398 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
399 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
400 for (Int_t j=0;j<13;j++){
401 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
402 for (Int_t k=0;k<2;k++){
403 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
404 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
408 //fCableLengthMap = stream.fCableLengthMap;
410 fEventID = stream.fEventID;
411 fNewDecoderVersion = stream.fNewDecoderVersion;
417 //_____________________________________________________________________________
418 AliTOFRawStream::~AliTOFRawStream()
426 fTOFrawData->Clear();
429 //delete fCableLengthMap;
434 //_____________________________________________________________________________
436 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
442 fTOFrawData->Clear();
444 TClonesArray &arrayTofRawData = *fTOFrawData;
448 // create raw data map
449 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
452 Int_t slot[4] = {-1, -1, -1, -1};
454 fLocalEventCounterDRM = -1;
455 fLocalEventCounterLTM = -1;
456 for (Int_t ii=0; ii<13; ii++)
457 fLocalEventCounterTRM[ii] = -1;
458 for (Int_t ii=0; ii<13; ii++)
459 for (Int_t jj=0; jj<2; jj++) {
460 fLocalEventCounterChain[ii][jj] = -1;
461 fChainBunchID[ii][jj] = -1;
465 fRawReader->Select("TOF", indexDDL, indexDDL);
467 Bool_t signal = kFALSE;
469 AliTOFrawData *rawDigit = NULL;
473 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
475 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
480 slot[3] = fTDCchannel;
482 if (rawMap->TestHit(slot) != kEmpty) {
484 rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
486 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
487 fLeadingEdge==-1 && fTrailingEdge!=-1) {
489 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
491 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
492 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
497 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
499 rawMap->SetHit(slot);
507 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
509 rawMap->SetHit(slot);
511 } // else if (rawMap->TestHit(slot) == kEmpty)
515 } // closed -> while (Next())
521 //_____________________________________________________________________________
522 Bool_t AliTOFRawStream::Next()
525 // Read next 32-bit word in TOF raw data files
526 // returns kFALSE if there is no word left
533 if (!fRawReader->ReadNextInt(data)) return kFALSE;
535 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
547 fDDL = fRawReader->GetDDLID();
549 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
551 switch (fWordType) { // switch word type
553 case GLOBAL_HEADER_TYPE: // global header
554 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
558 switch (fSlotID) { // switch global header slot ID
560 case DRM_ID_NUMBER: //DRM global header
561 if (fInsideDRM) { // unexpected DRM global headers -> exit
564 fInsideDRM = kTRUE; // DRM global header accepted
567 case LTM_ID_NUMBER: // LTM global header
568 if (fInsideLTM) { // unexpected LTM global headers -> exit
571 fInsideLTM = kTRUE; // LTM global header accepted
581 case 10: //TRM header
582 case 11: //TRM header
583 case 12: //TRM header
584 if (fInsideTRM) { // unexpected TRM global headers -> exit
587 fInsideTRM = kTRUE; // TRM global header accepted
588 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
591 default: // unexpected global header slot ID
594 } //end switch global header slot id
599 case GLOBAL_TRAILER_TYPE: // global trailer
600 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
602 switch (fSlotID) { // switch global trailer slot ID
604 case DRM_ID_NUMBER: // DRM global trailer
605 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
609 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
610 fLocalEventCounterDRM = GetField(data,dummy,4);
611 fInsideDRM = kFALSE; // DRM global trailer accepted
614 fInsideTRMchain0 = kFALSE;
615 fInsideTRMchain1 = kFALSE;
635 case LTM_ID_NUMBER: // LTM global trailer
636 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
640 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
641 fLocalEventCounterLTM = GetField(data,dummy,16);
642 fInsideLTM = kFALSE; // LTM global trailer accepted
644 case 15: //TRM global trailer
645 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
649 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
650 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
651 fInsideTRM = kFALSE; // TRM global trailer accepted
653 default: // unexpected global trailer slot ID
655 } //end switch global trailer slot id
661 case ERROR_TYPE: // TDC error
662 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
663 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
667 case FILLER_TYPE: // filler
671 default: // other word types
673 if (fInsideTRM) { // inside TRM
675 switch (fWordType) { // switch word type inside TRM
676 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
677 if (fInsideTRMchain0) { // unexpected TRM chain0 header
680 fInsideTRMchain0 = kTRUE;
683 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
684 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
686 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
687 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
691 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
692 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
693 fInsideTRMchain0 = kFALSE;
696 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
697 if (fInsideTRMchain1) { // unexpected TRM chain1 header
700 fInsideTRMchain1 = kTRUE;
703 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
704 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
706 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
707 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
711 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
712 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
713 fInsideTRMchain1 = kFALSE;
716 } // end switch word type inside TRM
718 } // end if (fInsideTRM)
722 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
723 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
724 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
725 ){ // inside TRM chains
727 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
728 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
729 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
730 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
739 switch (fPSbit) { // switch fPSbit bits inside TRM chains
741 case 0: // packing ok, digit time and TOT
742 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
743 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
745 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
747 if (fgApplyBCCorrections) {
748 AliDebug(2,"Apply nominal DDL BC time-shift correction");
749 AliDebug(2,"Apply deltaBC time-shift correction");
750 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
752 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
754 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
758 case 1: // leading edge digit, long digit time, no TOT
761 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
763 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
765 if (fgApplyBCCorrections) {
766 AliDebug(2,"Apply nominal DDL BC time-shift correction");
767 AliDebug(2,"Apply deltaBC time-shift correction");
768 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
770 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
772 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
776 case 2: // trailing edge digit, long digit time, no TOT
779 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
781 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
783 if (fgApplyBCCorrections) {
784 AliDebug(2,"Apply nominal DDL BC time-shift correction");
785 AliDebug(2,"Apply deltaBC time-shift correction");
786 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
788 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
790 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
794 case 3: // TOT overflow
795 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
796 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
798 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
800 if (fgApplyBCCorrections) {
801 AliDebug(2,"Apply nominal DDL BC time-shift correction");
802 AliDebug(2,"Apply deltaBC time-shift correction");
803 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
805 (Int_t)(fgkddlBCshift[fDDL]*25./AliTOFGeometry::TdcBinWidth()*1.E+03)
807 (Int_t)((fChainBunchID[fTRM][fTRMchain]-fEventID)*25./AliTOFGeometry::TdcBinWidth()*1.E+03);
811 } // end switch PS bits inside TRM chains
813 } // end if is inside TRM chains
815 } // end switch on fWordType
821 //_____________________________________________________________________________
823 void AliTOFRawStream::SetSector()
826 // Evaluate the TOF sector number -> [ 0;17]
827 // corresponding to the TOF equipment IDs:
830 // fTRMchain -> [ 0; 1]
832 // fTDCchannel -> [ 0; 7]
837 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
842 //_____________________________________________________________________________
845 void AliTOFRawStream::SetPlate()
848 // Evaluate the TOF plate number ->[ 0; 4]
849 // corresponding to the TOF equipment IDs:
852 // fTRMchain -> [ 0; 1]
854 // fTDCchannel -> [ 0; 7]
858 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
860 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
865 //_____________________________________________________________________________
867 void AliTOFRawStream::SetStrip()
870 // Evaluate the TOF strip number per module -> [ 0; 14/18]
871 // corresponding to the TOF equipment IDs:
874 // fTRMchain -> [ 0; 1]
876 // fTDCchannel -> [ 0; 7]
881 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
882 || fSector==-1 || fPlate==-1))
883 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
888 //_____________________________________________________________________________
890 void AliTOFRawStream::SetPadZ()
893 // Evaluate the TOF padRow number per strip -> [ 0; 1]
894 // corresponding to the TOF equipment IDs:
897 // fTRMchain -> [ 0; 1]
899 // fTDCchannel -> [ 0; 7]
904 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
905 || fSector==-1 || fPlate==-1 || fStrip==-1))
907 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
908 if (iPadAlongTheStrip!=-1)
909 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
912 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
913 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
918 //_____________________________________________________________________________
920 void AliTOFRawStream::SetPadX()
923 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
924 // corresponding to the TOF equipment IDs:
927 // fTRMchain -> [ 0; 1]
929 // fTDCchannel -> [ 0; 7]
934 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
935 || fSector==-1 || fPlate==-1 || fStrip==-1))
937 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
938 if (iPadAlongTheStrip!=-1)
939 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
942 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
943 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
949 //----------------------------------------------------------------------------
950 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
956 return ((word & fieldMask) >> fieldPosition);
959 //----------------------------------------------------------------------------
960 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
963 // Returns the TOF plate number [0;4]
964 // corresponding to the TOF equipment ID numbers:
965 // iDDL -> DDL number per sector [0;3]
966 // nTRM -> TRM number [3;12]
967 // nTDC -> TDC number [0;14]
974 if (nTRM>=4 && nTRM<7) {
976 } else if (nTRM==7) {
977 if (nTDC<12) iPlate = 0;
979 } else if (nTRM>=8 && nTRM<11) {
981 } else if (nTRM==11) {
982 if (nTDC<9) iPlate = 1;
984 }else if (nTRM==12) {
988 } else if (iDDL==1) {
991 if (nTDC<3) iPlate = 0;
992 } else if (nTRM>=4 && nTRM<7) {
994 } else if (nTRM==7) {
995 if (nTDC<6) iPlate = 1;
997 } else if (nTRM>=8 && nTRM<11) {
999 } else if (nTRM==11) {
1000 if (nTDC<9) iPlate = 2;
1002 } else if (nTRM==12) {
1006 } else if (iDDL==2) {
1008 if (nTRM>=4 && nTRM<7) {
1010 } else if (nTRM==7) {
1011 if (nTDC<12) iPlate = 4;
1013 } else if (nTRM>=8 && nTRM<11) {
1015 } else if (nTRM==11) {
1016 if (nTDC<9) iPlate = 3;
1018 }else if (nTRM==12) {
1022 } else if (iDDL==3) {
1025 if (nTDC<3) iPlate = 4;
1026 } else if (nTRM>=4 && nTRM<7) {
1028 } else if (nTRM==7) {
1029 if (nTDC<6) iPlate = 3;
1031 } else if (nTRM>=8 && nTRM<11) {
1033 } else if (nTRM==11) {
1034 if (nTDC<9) iPlate = 2;
1036 } else if (nTRM==12) {
1046 //----------------------------------------------------------------------------
1047 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1050 // Returns the TOF strip number per module:
1051 // [0;14], in the central plates,
1052 // [0;18], in the intermediate and external plates
1053 // corresponding to the TOF equipment ID numbers:
1054 // iDDL -> DDL number per sector [0;3]
1055 // nTRM -> TRM number [3;12]
1056 // nTDC -> TDC number [0;14]
1063 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1064 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1065 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1066 else if (nTRM== 7) {
1067 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1068 else iStrip = (Int_t)(nTDC/3.) - 4;
1070 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1071 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1072 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1073 else if (nTRM==11) {
1074 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1075 else iStrip = (Int_t)(nTDC/3.) - 3;
1077 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1079 } else if (iDDL==1) {
1081 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1082 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1083 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1084 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1085 else if (nTRM== 7) {
1086 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1087 else iStrip = 20 - (Int_t)(nTDC/3.);
1089 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1090 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1091 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1092 else if (nTRM==11) {
1093 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1094 else iStrip = 21 - (Int_t)(nTDC/3.);
1096 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1098 } else if (iDDL==2) {
1100 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1101 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1102 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1103 else if (nTRM== 7) {
1104 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1105 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1107 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1108 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1109 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1110 else if (nTRM==11) {
1111 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1112 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1114 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1116 } else if (iDDL==3) {
1118 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1119 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1120 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1121 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1122 else if (nTRM== 7) {
1123 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1124 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1126 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1127 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1128 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1129 else if (nTRM==11) {
1130 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1131 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1133 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1141 //----------------------------------------------------------------------------
1142 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1146 // Returns the TOF pad number per strip [0;95]
1147 // corresponding to the TOF equipment ID numbers:
1148 // iDDL -> DDL number per sector [0;3]
1149 // iChain -> TRM chain number [0;1]
1150 // nTDC -> TDC number [0;14]
1151 // iCH -> TDC channel number [0;7]
1154 Int_t iPadAlongTheStrip = -1;
1157 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1158 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1159 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1162 Int_t iTDClocal = -1;
1163 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1164 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1165 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1166 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1168 Int_t iCHlocal = iCH;
1169 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1171 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1173 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1174 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1175 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
1176 //AliWarning("Problems with the padX number!");
1178 return iPadAlongTheStrip;
1182 //----------------------------------------------------------------------------
1183 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1187 // Returns the TOF padX number [0;47]
1188 // corresponding to the TOF equipment ID numbers:
1189 // iDDL -> DDL number per sector [0;3]
1190 // iChain -> TRM chain number [0;1]
1191 // nTDC -> TDC number [0;14]
1192 // iCH -> TDC channel number [0;7]
1195 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1196 (Float_t(AliTOFGeometry::NpadZ())));
1202 //----------------------------------------------------------------------------
1203 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1207 // Returns the TOF padZ number [0;1]
1208 // corresponding to the TOF equipment ID numbers:
1209 // iDDL -> DDL number per sector [0;3]
1210 // iChain -> TRM chain number [0;1]
1211 // nTDC -> TDC number [0;14]
1212 // iCH -> TDC channel number [0;7]
1215 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1221 //----------------------------------------------------------------------------
1222 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1225 // Returns the sector number [0;17]
1226 // corresponing to the assigned DRM/DDL number [0;71]
1229 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1234 //----------------------------------------------------------------------------
1235 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1238 // Return the DRM/DDL number per sector [0;3]
1239 // corresponing to the assigned DRM/DDL number [0;71]
1242 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1248 //----------------------------------------------------------------------------
1249 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1251 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1253 //----------------------------------------------------------------------------
1254 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1255 Int_t nTDC, Int_t iCH,
1260 // nDDL (variable in [0;71]) -> number of the DDL file
1261 // nTRM (variable in [3;12]) -> number of the TRM slot
1262 // iChain (variable in [0; 1]) -> number of the TRM chain
1263 // nTDC (variable in [0;14]) -> number of the TDC
1264 // iCH (variable in [0; 7]) -> number of the TDC channel
1267 // sector number, i.e. volume[0] (variable in [0,17])
1268 // plate number, i.e. volume[1] (variable in [0, 5])
1269 // strip number, i.e. volume[2] (variable in [0,14/18])
1270 // padX number, i.e. volume[3] (variable in [0,47])
1271 // padZ number, i.e. volume[4] (variable in [0, 1])
1274 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1276 Int_t iSector = GetSectorNumber(nDDL);
1278 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1281 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1282 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number!\n");
1285 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1288 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1289 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number!\n");
1292 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1293 if (iPadAlongTheStrip==-1) {
1295 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1296 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip!\n");
1299 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1300 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1302 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1303 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1305 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1306 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1308 volume[0] = iSector;
1315 //-----------------------------------------------------------------------------
1316 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1318 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1321 //check and fix valid DDL range
1324 fRawReader->AddMinorErrorLog(kDDLMinError);
1325 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1329 fRawReader->AddMinorErrorLog(kDDLMaxError);
1330 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1333 //select required DDLs
1334 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1337 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1339 return(Decode(verbose));
1341 //-----------------------------------------------------------------------------
1342 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1344 // New decoder method
1347 Int_t currentEquipment;
1349 const AliRawDataHeader *currentCDH;
1352 UChar_t *data = 0x0;
1354 //loop and read DDL headers
1355 while(fRawReader->ReadHeader()){
1357 //memory leak prevention (actually data should be always 0x0 here)
1361 //get equipment infos
1362 currentEquipment = fRawReader->GetEquipmentId();
1363 currentDDL = fRawReader->GetDDLID();
1364 currentCDH = fRawReader->GetDataHeader();
1365 const Int_t kDataSize = fRawReader->GetDataSize();
1366 const Int_t kDataWords = kDataSize / 4;
1367 data = new UChar_t[kDataSize];
1370 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1373 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1375 //read equipment payload
1376 if (!fRawReader->ReadNext(data, kDataSize))
1378 fRawReader->AddMajorErrorLog(kDDLdataReading);
1380 AliWarning("Error while reading DDL data. Go to next equipment");
1387 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1390 //set up the decoder
1391 fDecoder->SetVerbose(verbose);
1392 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1393 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1396 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1397 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1398 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1406 fRawReader->Reset();
1409 AliInfo("All done");
1414 //---------------------------------------------------------------------------
1416 AliTOFRawStream::ResetBuffers()
1419 // To reset the buffers
1422 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1423 ResetDataBuffer(iDDL);
1424 ResetPackedDataBuffer(iDDL);
1428 //---------------------------------------------------------------------------
1430 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1433 // To load the buffers
1436 fTOFrawData->Clear();
1440 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1442 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1443 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1444 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1449 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1451 AliTOFHitData *hitData; //hit data pointer
1454 AliInfo("Filling TClonesArray ...");
1457 if (fgApplyBCCorrections) {
1458 AliInfo("Apply nominal DDL BC time-shift correction");
1459 AliInfo("Apply deltaBC time-shift correction");
1462 //loop over DDL packed hits
1463 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1464 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1465 Int_t hitACQ = hitData->GetACQ();
1466 Int_t hitPS = hitData->GetPS();
1467 Int_t hitSlotID = hitData->GetSlotID();
1468 Int_t hitChain = hitData->GetChain();
1469 Int_t hitTDC = hitData->GetTDC();
1470 Int_t hitChan = hitData->GetChan();
1471 Int_t hitTimeBin = hitData->GetTimeBin();
1472 Int_t hitTOTBin = hitData->GetTOTBin();
1474 if (fgApplyBCCorrections) {
1475 /* DDL BC shift time correction */
1476 hitTimeBin += fgkddlBCshift[indexDDL];
1477 /* deltaBC shift time correction */
1478 hitTimeBin += hitData->GetDeltaBunchID();
1481 Int_t hitLeading = hitData->GetTimeBin();
1482 Int_t hitTrailing = -1;
1483 Int_t hitError = -1;
1485 TClonesArray &arrayTofRawData = *fTOFrawData;
1486 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1493 AliInfo("Resetting buffers ...");
1495 fDataBuffer[indexDDL].Reset();
1496 fPackedDataBuffer[indexDDL].Reset();
1504 //---------------------------------------------------------------------------
1505 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1509 // nSector number -vol[0]- (variable in [0,17])
1510 // nPlate number -vol[1]- (variable in [0, 5])
1511 // nStrip number -vol[2]- (variable in [0,14/18])
1512 // nPadZ number -vol[3]- (variable in [0, 1])
1513 // nPadX number -vol[4]- (variable in [0,47])
1515 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1516 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1517 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1518 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1519 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1522 eqId[0] = Geant2DDL(vol);
1523 eqId[1] = Geant2TRM(vol);
1524 eqId[2] = Geant2TDC(vol);
1525 eqId[3] = Geant2Chain(vol);
1526 eqId[4] = Geant2Channel(vol);
1530 //---------------------------------------------------------------------------
1531 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1535 // nSector number -vol[0]- (variable in [0,17])
1536 // nPlate number -vol[1]- (variable in [0, 5])
1537 // nStrip number -vol[2]- (variable in [0,14/18])
1538 // nPadZ number -vol[3]- (variable in [0, 1])
1539 // nPadX number -vol[4]- (variable in [0,47])
1541 // nDDL (variable in [0;71]) -> number of the DDL
1547 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1548 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1551 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1552 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1555 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1556 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1559 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1560 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1561 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1562 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1563 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1564 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1568 Int_t nSector = vol[0];
1569 Int_t nPlate = vol[1];
1570 Int_t nStrip = vol[2];
1571 Int_t nPadX = vol[4];
1573 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1575 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1577 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1579 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1582 return 4*nSector+iDDL;
1586 //---------------------------------------------------------------------------
1587 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1591 // nSector number -vol[0]- (variable in [0,17])
1592 // nPlate number -vol[1]- (variable in [0, 5])
1593 // nStrip number -vol[2]- (variable in [0,14/18])
1594 // nPadZ number -vol[3]- (variable in [0, 1])
1595 // nPadX number -vol[4]- (variable in [0,47])
1597 // nTRM (variable in [3;12]) -> number of the TRM slot
1602 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1603 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1606 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1607 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1610 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1611 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1614 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1615 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1618 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1619 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1623 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1625 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1629 Int_t nPlate = vol[1];
1630 Int_t nStrip = vol[2];
1632 Int_t iDDL = Geant2DDL(vol)%4;
1639 if (nStrip<= 4) nTRM = 4;
1640 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1641 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1642 else if (nStrip>14) nTRM = 7;
1644 else if (nPlate==1) {
1645 if (nStrip== 0) nTRM = 7;
1646 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1647 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1648 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1649 else if (nStrip>15) nTRM = 11;
1651 else if (nPlate==2) {
1652 if (nStrip<= 1) nTRM = 11;
1653 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1660 if (nStrip== 0) nTRM = 3;
1661 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1662 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1663 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1664 else if (nStrip>15) nTRM = 7;
1666 else if (nPlate==1) {
1667 if (nStrip<=1) nTRM = 7;
1668 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1669 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1670 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1671 else if (nStrip>16) nTRM = 11;
1673 else if (nPlate==2) {
1674 if (nStrip<= 2) nTRM = 11;
1675 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1682 if (nStrip>=14) nTRM = 4;
1683 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1684 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1685 else if (nStrip< 4) nTRM = 7;
1687 else if (nPlate==3) {
1688 if (nStrip==18) nTRM = 7;
1689 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1690 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1691 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1692 else if (nStrip< 3) nTRM = 11;
1694 else if (nPlate==2) {
1695 if (nStrip>=13) nTRM = 11;
1696 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1703 if (nStrip==18) nTRM = 3;
1704 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1705 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1706 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1707 else if (nStrip< 3) nTRM = 7;
1709 else if (nPlate==3) {
1710 if (nStrip>=17) nTRM = 7;
1711 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1712 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1713 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1714 else if (nStrip< 2) nTRM = 11;
1716 else if (nPlate==2) {
1717 if (nStrip>=12) nTRM = 11;
1718 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1729 //---------------------------------------------------------------------------
1730 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1734 // nSector number -vol[0]- (variable in [0,17])
1735 // nPlate number -vol[1]- (variable in [0, 5])
1736 // nStrip number -vol[2]- (variable in [0,14/18])
1737 // nPadZ number -vol[3]- (variable in [0, 1])
1738 // nPadX number -vol[4]- (variable in [0,47])
1740 // nTDC (variable in [0;14]) -> number of the TDC
1745 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1746 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1749 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1750 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1753 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1754 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1757 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1758 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1759 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1760 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1761 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1762 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1766 Int_t nPlate = vol[1];
1767 Int_t nStrip = vol[2];
1768 Int_t iPadX = vol[4];
1770 Int_t iDDL = Geant2DDL(vol)%4;
1777 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1778 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1779 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1780 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1782 else if (nPlate==1) {
1783 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1784 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1785 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1786 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1787 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1789 else if (nPlate==2) {
1790 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1791 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1798 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1799 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1800 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1801 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1802 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1804 else if (nPlate==1) {
1805 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1806 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1807 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1808 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1809 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1811 else if (nPlate==2) {
1812 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1813 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1820 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1821 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1822 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1823 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1825 else if (nPlate==3) {
1826 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1827 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1828 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1829 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1830 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1832 else if (nPlate==2) {
1833 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1834 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1841 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1842 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1843 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1844 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1845 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1847 else if (nPlate==3) {
1848 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1849 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1850 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1851 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1852 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1854 else if (nPlate==2) {
1855 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1856 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1867 //---------------------------------------------------------------------------
1868 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1872 // nSector number -vol[0]- (variable in [0,17])
1873 // nPlate number -vol[1]- (variable in [0, 5])
1874 // nStrip number -vol[2]- (variable in [0,14/18])
1875 // nPadZ number -vol[3]- (variable in [0, 1])
1876 // nPadX number -vol[4]- variable in [0,47])
1878 // nChain (variable in [0; 1]) -> number of the TRM chain
1883 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1884 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1887 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1888 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1891 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1892 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1895 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1896 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1897 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1898 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1899 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1900 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1904 Int_t iPadX = vol[4];
1906 if (iPadX<12 || iPadX>=36) nChain = 0;
1913 //---------------------------------------------------------------------------
1914 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1918 // nSector number -vol[0]- (variable in [0,17])
1919 // nPlate number -vol[1]- (variable in [0, 5])
1920 // nStrip number -vol[2]- (variable in [0,14/18])
1921 // nPadZ number -vol[3]- (variable in [0, 1])
1922 // nPadX number -vol[4]- (variable in [0,47])
1924 // nChannel (variable in [0; 7]) -> number of the TDC channel
1927 Int_t nChannel = -1;
1929 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1930 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1933 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1934 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1937 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1938 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1941 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1942 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1943 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1944 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1945 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1946 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1950 Int_t iPadZ = vol[3];
1951 Int_t iPadX = vol[4];
1953 Int_t iDDL = Geant2DDL(vol)%4;
1958 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1961 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1964 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1967 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1975 //____________________________________________________________________________
1976 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
1979 // Converts raw data to digits for TOF
1982 TStopwatch stopwatch;
1985 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
1986 //digitsTree->Branch("TOF", &fDigits);
1987 TClonesArray &aDigits = *digitsArray;
1992 SetRawReader(rawReader);
1995 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
1997 TClonesArray staticRawData("AliTOFrawData",10000);
1998 staticRawData.Clear();
1999 TClonesArray * clonesRawData = &staticRawData;
2002 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2005 const Int_t kMaxNumberOfTracksPerDigit = 3;
2006 Int_t tracks[kMaxNumberOfTracksPerDigit];
2007 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2013 AliTOFrawData *tofRawDatum = 0;
2014 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2017 if (fNewDecoderVersion) {
2018 AliInfo("Using New Decoder \n");
2019 LoadRawDataBuffers(indexDDL, 0);
2022 LoadRawData(indexDDL);
2024 clonesRawData = GetRawData();
2025 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2026 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2028 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2030 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2031 if (tofRawDatum->GetTOF()==-1) continue;
2033 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2034 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2036 dummy = detectorIndex[3];
2037 detectorIndex[3] = detectorIndex[4];//padz
2038 detectorIndex[4] = dummy;//padx
2040 digit[0] = tofRawDatum->GetTOF();
2041 digit[1] = tofRawDatum->GetTOT();
2042 digit[2] = tofRawDatum->GetTOT();
2043 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2045 dummy = detectorIndex[3];
2046 detectorIndex[3] = detectorIndex[4];//padx
2047 detectorIndex[4] = dummy;//padz
2049 // Do not reconstruct anything in the holes
2050 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2051 if (detectorIndex[1]==2) { // plate with holes
2057 last = digitsArray->GetEntriesFast();
2058 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2061 if (indexDDL<10) ftxt << " " << indexDDL;
2062 else ftxt << " " << indexDDL;
2063 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2064 else ftxt << " " << tofRawDatum->GetTRM();
2065 ftxt << " " << tofRawDatum->GetTRMchain();
2066 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2067 else ftxt << " " << tofRawDatum->GetTDC();
2068 ftxt << " " << tofRawDatum->GetTDCchannel();
2070 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2071 else ftxt << " -> " << detectorIndex[0];
2072 ftxt << " " << detectorIndex[1];
2073 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2074 else ftxt << " " << detectorIndex[2];
2075 ftxt << " " << detectorIndex[4];
2076 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2077 else ftxt << " " << detectorIndex[3];
2079 if (digit[1]<10)ftxt << " " << digit[1];
2080 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2081 else ftxt << " " << digit[1];
2082 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2083 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2084 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2085 else ftxt << " " << digit[3] << endl;
2088 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2090 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2091 digit[0], digit[1], digit[3]));
2094 } // loop on tofRawData array
2096 clonesRawData->Clear();
2100 //if (fVerbose==2) ftxt.close();
2103 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2105 Int_t nDigits = digitsArray->GetEntries();
2106 AliDebug(1, Form("Got %d TOF digits", nDigits));
2107 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2108 stopwatch.RealTime(),stopwatch.CpuTime()));
2112 //____________________________________________________________________________
2113 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
2116 // Converts raw data to sdigits for TOF
2119 TStopwatch stopwatch;
2124 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2125 TClonesArray &aSDigits = *sdigitsArray;
2128 SetRawReader(rawReader);
2131 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2133 TClonesArray staticRawData("AliTOFrawData",10000);
2134 staticRawData.Clear();
2135 TClonesArray * clonesRawData = &staticRawData;
2138 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2145 AliTOFrawData *tofRawDatum = 0;
2146 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2149 if (fNewDecoderVersion) {
2150 AliInfo("Using New Decoder \n");
2151 LoadRawDataBuffers(indexDDL, 0);
2154 LoadRawData(indexDDL);
2156 clonesRawData = GetRawData();
2157 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2158 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2160 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2162 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2163 if (tofRawDatum->GetTOF()==-1) continue;
2165 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2166 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2168 dummy = detectorIndex[3];
2169 detectorIndex[3] = detectorIndex[4];//padz
2170 detectorIndex[4] = dummy;//padx
2172 digit[0] = tofRawDatum->GetTOF();
2173 digit[1] = tofRawDatum->GetTOT();
2175 dummy = detectorIndex[3];
2176 detectorIndex[3] = detectorIndex[4];//padx
2177 detectorIndex[4] = dummy;//padz
2179 // Do not reconstruct anything in the holes
2180 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2181 if (detectorIndex[1]==2) { // plate with holes
2187 last = sdigitsArray->GetEntriesFast();
2188 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2191 if (indexDDL<10) ftxt << " " << indexDDL;
2192 else ftxt << " " << indexDDL;
2193 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2194 else ftxt << " " << tofRawDatum->GetTRM();
2195 ftxt << " " << tofRawDatum->GetTRMchain();
2196 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2197 else ftxt << " " << tofRawDatum->GetTDC();
2198 ftxt << " " << tofRawDatum->GetTDCchannel();
2200 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2201 else ftxt << " -> " << detectorIndex[0];
2202 ftxt << " " << detectorIndex[1];
2203 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2204 else ftxt << " " << detectorIndex[2];
2205 ftxt << " " << detectorIndex[4];
2206 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2207 else ftxt << " " << detectorIndex[3];
2209 if (digit[1]<10)ftxt << " " << digit[1];
2210 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2211 else ftxt << " " << digit[1];
2212 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2213 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2214 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2215 else ftxt << " " << digit[3] << endl;
2218 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2220 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2221 digit[0], digit[1], digit[3]));
2226 clonesRawData->Clear();
2230 //if (fVerbose==2) ftxt.close();
2232 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2234 Int_t nSDigits = sdigitsArray->GetEntries();
2235 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2236 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2237 stopwatch.RealTime(),stopwatch.CpuTime()));