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;
216 //_____________________________________________________________________________
217 AliTOFRawStream::AliTOFRawStream():
219 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
220 fDecoder(new AliTOFDecoder()),
245 fInsideTRMchain0(kFALSE),
246 fInsideTRMchain1(kFALSE),
248 //fPackedDataBuffer(),
249 fLocalEventCounterDRM(-1),
250 fLocalEventCounterLTM(-1),
251 //fLocalEventCounterTRM(),
252 //fLocalEventCounterChain(),
254 //fCableLengthMap(new AliTOFCableLengthMap()),
256 fNewDecoderVersion(0)
261 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
263 ResetPackedDataBuffer(i);
266 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
267 fTOFrawData->SetOwner();
269 for (Int_t j=0;j<13;j++){
270 fLocalEventCounterTRM[j] = -1;
271 for (Int_t k=0;k<2;k++){
272 fLocalEventCounterChain[j][k] = -1;
273 fChainBunchID[j][k] = -1;
279 //_____________________________________________________________________________
280 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
282 fRawReader(stream.fRawReader),
283 fTOFrawData(stream.fTOFrawData),
284 fDecoder(new AliTOFDecoder()),
287 fTRMchain(stream.fTRMchain),
289 fTDCchannel(stream.fTDCchannel),
292 fLeadingEdge(stream.fLeadingEdge),
293 fTrailingEdge(stream.fTrailingEdge),
294 fErrorFlag(stream.fErrorFlag),
295 fSector(stream.fSector),
296 fPlate(stream.fPlate),
297 fStrip(stream.fStrip),
300 fPackedDigits(stream.fPackedDigits),
301 fWordType(stream.fWordType),
302 fSlotID(stream.fSlotID),
304 fPSbit(stream.fPSbit),
305 fTDCerrorFlag(stream.fTDCerrorFlag),
306 fInsideDRM(stream.fInsideDRM),
307 fInsideTRM(stream.fInsideTRM),
308 fInsideLTM(stream.fInsideLTM),
309 fInsideTRMchain0(stream.fInsideTRMchain0),
310 fInsideTRMchain1(stream.fInsideTRMchain1),
312 //fPackedDataBuffer(),
313 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
314 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
315 //fLocalEventCounterTRM(),
316 //fLocalEventCounterChain(),
318 //fCableLengthMap(stream.fCableLengthMap),
319 fEventID(stream.fEventID),
320 fNewDecoderVersion(stream.fNewDecoderVersion)
326 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
327 fDataBuffer[i] = stream.fDataBuffer[i];
328 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
331 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
333 for (Int_t j=0;j<13;j++){
334 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
335 for (Int_t k=0;k<2;k++){
336 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
337 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
343 //_____________________________________________________________________________
344 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
347 // assignment operator
353 TObject::operator=(stream);
355 fRawReader = stream.fRawReader;
357 fTOFrawData = stream.fTOFrawData;
361 fTRMchain = stream.fTRMchain;
363 fTDCchannel = stream.fTDCchannel;
364 fTime = stream.fTime;
366 fLeadingEdge = stream.fLeadingEdge;
367 fTrailingEdge = stream.fTrailingEdge;
368 fErrorFlag = stream.fErrorFlag;
370 fSector = stream.fSector;
371 fPlate = stream.fPlate;
372 fStrip = stream.fStrip;
373 fPadX = stream.fPadX;
374 fPadZ = stream.fPadZ;
376 fPackedDigits = stream.fPackedDigits;
378 fWordType = stream.fWordType;
379 fSlotID = stream.fSlotID;
381 fPSbit = stream.fPSbit;
382 fTDCerrorFlag = stream.fTDCerrorFlag;
383 fInsideDRM = stream.fInsideDRM;
384 fInsideTRM = stream.fInsideTRM;
385 fInsideLTM = stream.fInsideLTM;
386 fInsideTRMchain0 = stream.fInsideTRMchain0;
387 fInsideTRMchain1 = stream.fInsideTRMchain1;
389 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
390 fDataBuffer[i] = stream.fDataBuffer[i];
391 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
394 fTOFrawData = stream.fTOFrawData;
396 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
397 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
398 for (Int_t j=0;j<13;j++){
399 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
400 for (Int_t k=0;k<2;k++){
401 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
402 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
406 //fCableLengthMap = stream.fCableLengthMap;
408 fEventID = stream.fEventID;
409 fNewDecoderVersion = stream.fNewDecoderVersion;
415 //_____________________________________________________________________________
416 AliTOFRawStream::~AliTOFRawStream()
424 fTOFrawData->Clear();
427 //delete fCableLengthMap;
432 //_____________________________________________________________________________
434 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
440 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
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));
751 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
755 case 1: // leading edge digit, long digit time, no TOT
758 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
760 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
762 if (fgApplyBCCorrections) {
763 AliDebug(2,"Apply nominal DDL BC time-shift correction");
764 AliDebug(2,"Apply deltaBC time-shift correction");
765 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
766 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
770 case 2: // trailing edge digit, long digit time, no TOT
773 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
775 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
777 if (fgApplyBCCorrections) {
778 AliDebug(2,"Apply nominal DDL BC time-shift correction");
779 AliDebug(2,"Apply deltaBC time-shift correction");
780 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
781 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
785 case 3: // TOT overflow
786 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
787 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
789 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
791 if (fgApplyBCCorrections) {
792 AliDebug(2,"Apply nominal DDL BC time-shift correction");
793 AliDebug(2,"Apply deltaBC time-shift correction");
794 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
795 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
799 } // end switch PS bits inside TRM chains
801 } // end if is inside TRM chains
803 } // end switch on fWordType
809 //_____________________________________________________________________________
811 void AliTOFRawStream::SetSector()
814 // Evaluate the TOF sector number -> [ 0;17]
815 // corresponding to the TOF equipment IDs:
818 // fTRMchain -> [ 0; 1]
820 // fTDCchannel -> [ 0; 7]
825 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
830 //_____________________________________________________________________________
833 void AliTOFRawStream::SetPlate()
836 // Evaluate the TOF plate number ->[ 0; 4]
837 // corresponding to the TOF equipment IDs:
840 // fTRMchain -> [ 0; 1]
842 // fTDCchannel -> [ 0; 7]
846 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
848 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
853 //_____________________________________________________________________________
855 void AliTOFRawStream::SetStrip()
858 // Evaluate the TOF strip number per module -> [ 0; 14/18]
859 // corresponding to the TOF equipment IDs:
862 // fTRMchain -> [ 0; 1]
864 // fTDCchannel -> [ 0; 7]
869 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
870 || fSector==-1 || fPlate==-1))
871 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
876 //_____________________________________________________________________________
878 void AliTOFRawStream::SetPadZ()
881 // Evaluate the TOF padRow number per strip -> [ 0; 1]
882 // corresponding to the TOF equipment IDs:
885 // fTRMchain -> [ 0; 1]
887 // fTDCchannel -> [ 0; 7]
892 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
893 || fSector==-1 || fPlate==-1 || fStrip==-1))
895 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
896 if (iPadAlongTheStrip!=-1)
897 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
900 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
901 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
906 //_____________________________________________________________________________
908 void AliTOFRawStream::SetPadX()
911 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
912 // corresponding to the TOF equipment IDs:
915 // fTRMchain -> [ 0; 1]
917 // fTDCchannel -> [ 0; 7]
922 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
923 || fSector==-1 || fPlate==-1 || fStrip==-1))
925 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
926 if (iPadAlongTheStrip!=-1)
927 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
930 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
931 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
937 //----------------------------------------------------------------------------
938 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
944 return ((word & fieldMask) >> fieldPosition);
947 //----------------------------------------------------------------------------
948 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
951 // Returns the TOF plate number [0;4]
952 // corresponding to the TOF equipment ID numbers:
953 // iDDL -> DDL number per sector [0;3]
954 // nTRM -> TRM number [3;12]
955 // nTDC -> TDC number [0;14]
962 if (nTRM>=4 && nTRM<7) {
964 } else if (nTRM==7) {
965 if (nTDC<12) iPlate = 0;
967 } else if (nTRM>=8 && nTRM<11) {
969 } else if (nTRM==11) {
970 if (nTDC<9) iPlate = 1;
972 }else if (nTRM==12) {
976 } else if (iDDL==1) {
979 if (nTDC<3) iPlate = 0;
980 } else if (nTRM>=4 && nTRM<7) {
982 } else if (nTRM==7) {
983 if (nTDC<6) iPlate = 1;
985 } else if (nTRM>=8 && nTRM<11) {
987 } else if (nTRM==11) {
988 if (nTDC<9) iPlate = 2;
990 } else if (nTRM==12) {
994 } else if (iDDL==2) {
996 if (nTRM>=4 && nTRM<7) {
998 } else if (nTRM==7) {
999 if (nTDC<12) iPlate = 4;
1001 } else if (nTRM>=8 && nTRM<11) {
1003 } else if (nTRM==11) {
1004 if (nTDC<9) iPlate = 3;
1006 }else if (nTRM==12) {
1010 } else if (iDDL==3) {
1013 if (nTDC<3) iPlate = 4;
1014 } else if (nTRM>=4 && nTRM<7) {
1016 } else if (nTRM==7) {
1017 if (nTDC<6) iPlate = 3;
1019 } else if (nTRM>=8 && nTRM<11) {
1021 } else if (nTRM==11) {
1022 if (nTDC<9) iPlate = 2;
1024 } else if (nTRM==12) {
1034 //----------------------------------------------------------------------------
1035 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1038 // Returns the TOF strip number per module:
1039 // [0;14], in the central plates,
1040 // [0;18], in the intermediate and external plates
1041 // corresponding to the TOF equipment ID numbers:
1042 // iDDL -> DDL number per sector [0;3]
1043 // nTRM -> TRM number [3;12]
1044 // nTDC -> TDC number [0;14]
1051 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1052 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1053 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1054 else if (nTRM== 7) {
1055 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1056 else iStrip = (Int_t)(nTDC/3.) - 4;
1058 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1059 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1060 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1061 else if (nTRM==11) {
1062 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1063 else iStrip = (Int_t)(nTDC/3.) - 3;
1065 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1067 } else if (iDDL==1) {
1069 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1070 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1071 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1072 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1073 else if (nTRM== 7) {
1074 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1075 else iStrip = 20 - (Int_t)(nTDC/3.);
1077 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1078 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1079 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1080 else if (nTRM==11) {
1081 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1082 else iStrip = 21 - (Int_t)(nTDC/3.);
1084 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1086 } else if (iDDL==2) {
1088 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1089 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1090 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1091 else if (nTRM== 7) {
1092 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1093 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1095 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1096 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1097 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1098 else if (nTRM==11) {
1099 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1100 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1102 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1104 } else if (iDDL==3) {
1106 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1107 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1108 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1109 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1110 else if (nTRM== 7) {
1111 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1112 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1114 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1115 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1116 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1117 else if (nTRM==11) {
1118 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1119 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1121 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1129 //----------------------------------------------------------------------------
1130 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1134 // Returns the TOF pad number per strip [0;95]
1135 // corresponding to the TOF equipment ID numbers:
1136 // iDDL -> DDL number per sector [0;3]
1137 // iChain -> TRM chain number [0;1]
1138 // nTDC -> TDC number [0;14]
1139 // iCH -> TDC channel number [0;7]
1142 Int_t iPadAlongTheStrip = -1;
1145 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1146 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1147 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1150 Int_t iTDClocal = -1;
1151 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1152 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1153 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1154 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1156 Int_t iCHlocal = iCH;
1157 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1159 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1161 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1162 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1163 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
1164 //AliWarning("Problems with the padX number!");
1166 return iPadAlongTheStrip;
1170 //----------------------------------------------------------------------------
1171 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1175 // Returns the TOF padX number [0;47]
1176 // corresponding to the TOF equipment ID numbers:
1177 // iDDL -> DDL number per sector [0;3]
1178 // iChain -> TRM chain number [0;1]
1179 // nTDC -> TDC number [0;14]
1180 // iCH -> TDC channel number [0;7]
1183 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1184 (Float_t(AliTOFGeometry::NpadZ())));
1190 //----------------------------------------------------------------------------
1191 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1195 // Returns the TOF padZ number [0;1]
1196 // corresponding to the TOF equipment ID numbers:
1197 // iDDL -> DDL number per sector [0;3]
1198 // iChain -> TRM chain number [0;1]
1199 // nTDC -> TDC number [0;14]
1200 // iCH -> TDC channel number [0;7]
1203 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1209 //----------------------------------------------------------------------------
1210 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1213 // Returns the sector number [0;17]
1214 // corresponing to the assigned DRM/DDL number [0;71]
1217 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1222 //----------------------------------------------------------------------------
1223 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1226 // Return the DRM/DDL number per sector [0;3]
1227 // corresponing to the assigned DRM/DDL number [0;71]
1230 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1236 //----------------------------------------------------------------------------
1237 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1239 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1241 //----------------------------------------------------------------------------
1242 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1243 Int_t nTDC, Int_t iCH,
1248 // nDDL (variable in [0;71]) -> number of the DDL file
1249 // nTRM (variable in [3;12]) -> number of the TRM slot
1250 // iChain (variable in [0; 1]) -> number of the TRM chain
1251 // nTDC (variable in [0;14]) -> number of the TDC
1252 // iCH (variable in [0; 7]) -> number of the TDC channel
1255 // sector number, i.e. volume[0] (variable in [0,17])
1256 // plate number, i.e. volume[1] (variable in [0, 5])
1257 // strip number, i.e. volume[2] (variable in [0,14/18])
1258 // padX number, i.e. volume[3] (variable in [0,47])
1259 // padZ number, i.e. volume[4] (variable in [0, 1])
1262 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1264 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1266 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1267 //printf("Info -> AliTOFRawStream::EquipmentId2VolumeId: Signal not coming from a TOF pad but -probably- from a TOF OR signal (%2d %2d %2d)\n", nDDL, nTRM, nTDC);
1271 Int_t iSector = GetSectorNumber(nDDL);
1273 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1276 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1277 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1281 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1284 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1285 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1289 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1290 if (iPadAlongTheStrip==-1) {
1292 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1293 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1294 nDDL, iChain, nTDC, iCH);
1297 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1298 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1300 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1301 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1303 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1304 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1306 volume[0] = iSector;
1313 //-----------------------------------------------------------------------------
1314 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1316 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1319 //check and fix valid DDL range
1322 fRawReader->AddMinorErrorLog(kDDLMinError);
1323 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1327 fRawReader->AddMinorErrorLog(kDDLMaxError);
1328 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1331 //select required DDLs
1332 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1335 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1337 return(Decode(verbose));
1339 //-----------------------------------------------------------------------------
1340 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1342 // New decoder method
1345 Int_t currentEquipment;
1347 const AliRawDataHeader *currentCDH;
1350 UChar_t *data = 0x0;
1352 //loop and read DDL headers
1353 while(fRawReader->ReadHeader()){
1355 //memory leak prevention (actually data should be always 0x0 here)
1359 //get equipment infos
1360 currentEquipment = fRawReader->GetEquipmentId();
1361 currentDDL = fRawReader->GetDDLID();
1362 currentCDH = fRawReader->GetDataHeader();
1363 const Int_t kDataSize = fRawReader->GetDataSize();
1364 const Int_t kDataWords = kDataSize / 4;
1365 data = new UChar_t[kDataSize];
1368 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1371 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1373 //read equipment payload
1374 if (!fRawReader->ReadNext(data, kDataSize))
1376 fRawReader->AddMajorErrorLog(kDDLdataReading);
1378 AliWarning("Error while reading DDL data. Go to next equipment");
1385 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1388 //set up the decoder
1389 fDecoder->SetVerbose(verbose);
1390 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1391 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1394 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1395 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1396 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1404 fRawReader->Reset();
1407 AliInfo("All done");
1412 //---------------------------------------------------------------------------
1414 AliTOFRawStream::ResetBuffers()
1417 // To reset the buffers
1420 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1421 ResetDataBuffer(iDDL);
1422 ResetPackedDataBuffer(iDDL);
1426 //---------------------------------------------------------------------------
1428 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1431 // To load the buffers
1434 fTOFrawData->Clear();
1438 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1440 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1441 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1442 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1447 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1449 AliTOFHitData *hitData; //hit data pointer
1452 AliInfo("Filling TClonesArray ...");
1455 if (fgApplyBCCorrections) {
1456 AliInfo("Apply nominal DDL BC time-shift correction");
1457 AliInfo("Apply deltaBC time-shift correction");
1460 //loop over DDL packed hits
1461 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1462 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1463 Int_t hitACQ = hitData->GetACQ();
1464 Int_t hitPS = hitData->GetPS();
1465 Int_t hitSlotID = hitData->GetSlotID();
1466 Int_t hitChain = hitData->GetChain();
1467 Int_t hitTDC = hitData->GetTDC();
1468 Int_t hitChan = hitData->GetChan();
1469 Int_t hitTimeBin = hitData->GetTimeBin();
1470 Int_t hitTOTBin = hitData->GetTOTBin();
1472 if (fgApplyBCCorrections) {
1473 /* DDL BC shift time correction */
1474 hitTimeBin += 1024 * fgkddlBCshift[indexDDL];
1475 /* deltaBC shift time correction */
1476 hitTimeBin += 1024 * hitData->GetDeltaBunchID();
1479 Int_t hitLeading = hitData->GetTimeBin();
1480 Int_t hitTrailing = -1;
1481 Int_t hitError = -1;
1483 TClonesArray &arrayTofRawData = *fTOFrawData;
1484 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1491 AliInfo("Resetting buffers ...");
1493 fDataBuffer[indexDDL].Reset();
1494 fPackedDataBuffer[indexDDL].Reset();
1502 //---------------------------------------------------------------------------
1503 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1507 // nSector number -vol[0]- (variable in [0,17])
1508 // nPlate number -vol[1]- (variable in [0, 5])
1509 // nStrip number -vol[2]- (variable in [0,14/18])
1510 // nPadZ number -vol[3]- (variable in [0, 1])
1511 // nPadX number -vol[4]- (variable in [0,47])
1513 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1514 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1515 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1516 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1517 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1520 eqId[0] = Geant2DDL(vol);
1521 eqId[1] = Geant2TRM(vol);
1522 eqId[2] = Geant2TDC(vol);
1523 eqId[3] = Geant2Chain(vol);
1524 eqId[4] = Geant2Channel(vol);
1528 //---------------------------------------------------------------------------
1529 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1533 // nSector number -vol[0]- (variable in [0,17])
1534 // nPlate number -vol[1]- (variable in [0, 5])
1535 // nStrip number -vol[2]- (variable in [0,14/18])
1536 // nPadZ number -vol[3]- (variable in [0, 1])
1537 // nPadX number -vol[4]- (variable in [0,47])
1539 // nDDL (variable in [0;71]) -> number of the DDL
1545 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1546 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1549 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1550 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1553 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1554 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1557 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1558 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1559 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1560 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1561 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1562 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1566 Int_t nSector = vol[0];
1567 Int_t nPlate = vol[1];
1568 Int_t nStrip = vol[2];
1569 Int_t nPadX = vol[4];
1571 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1573 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1575 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1577 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1580 return 4*nSector+iDDL;
1584 //---------------------------------------------------------------------------
1585 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1589 // nSector number -vol[0]- (variable in [0,17])
1590 // nPlate number -vol[1]- (variable in [0, 5])
1591 // nStrip number -vol[2]- (variable in [0,14/18])
1592 // nPadZ number -vol[3]- (variable in [0, 1])
1593 // nPadX number -vol[4]- (variable in [0,47])
1595 // nTRM (variable in [3;12]) -> number of the TRM slot
1600 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1601 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1604 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1605 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1608 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1609 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1612 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1613 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1616 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1617 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1621 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1623 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1627 Int_t nPlate = vol[1];
1628 Int_t nStrip = vol[2];
1630 Int_t iDDL = Geant2DDL(vol)%4;
1637 if (nStrip<= 4) nTRM = 4;
1638 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1639 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1640 else if (nStrip>14) nTRM = 7;
1642 else if (nPlate==1) {
1643 if (nStrip== 0) nTRM = 7;
1644 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1645 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1646 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1647 else if (nStrip>15) nTRM = 11;
1649 else if (nPlate==2) {
1650 if (nStrip<= 1) nTRM = 11;
1651 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1658 if (nStrip== 0) nTRM = 3;
1659 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1660 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1661 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1662 else if (nStrip>15) nTRM = 7;
1664 else if (nPlate==1) {
1665 if (nStrip<=1) nTRM = 7;
1666 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1667 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1668 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1669 else if (nStrip>16) nTRM = 11;
1671 else if (nPlate==2) {
1672 if (nStrip<= 2) nTRM = 11;
1673 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1680 if (nStrip>=14) nTRM = 4;
1681 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1682 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1683 else if (nStrip< 4) nTRM = 7;
1685 else if (nPlate==3) {
1686 if (nStrip==18) nTRM = 7;
1687 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1688 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1689 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1690 else if (nStrip< 3) nTRM = 11;
1692 else if (nPlate==2) {
1693 if (nStrip>=13) nTRM = 11;
1694 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1701 if (nStrip==18) nTRM = 3;
1702 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1703 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1704 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1705 else if (nStrip< 3) nTRM = 7;
1707 else if (nPlate==3) {
1708 if (nStrip>=17) nTRM = 7;
1709 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1710 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1711 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1712 else if (nStrip< 2) nTRM = 11;
1714 else if (nPlate==2) {
1715 if (nStrip>=12) nTRM = 11;
1716 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1727 //---------------------------------------------------------------------------
1728 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1732 // nSector number -vol[0]- (variable in [0,17])
1733 // nPlate number -vol[1]- (variable in [0, 5])
1734 // nStrip number -vol[2]- (variable in [0,14/18])
1735 // nPadZ number -vol[3]- (variable in [0, 1])
1736 // nPadX number -vol[4]- (variable in [0,47])
1738 // nTDC (variable in [0;14]) -> number of the TDC
1743 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1744 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1747 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1748 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1751 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1752 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1755 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1756 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1757 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1758 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1759 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1760 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1764 Int_t nPlate = vol[1];
1765 Int_t nStrip = vol[2];
1766 Int_t iPadX = vol[4];
1768 Int_t iDDL = Geant2DDL(vol)%4;
1775 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1776 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1777 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1778 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1780 else if (nPlate==1) {
1781 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1782 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1783 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1784 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1785 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1787 else if (nPlate==2) {
1788 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1789 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1796 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1797 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1798 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1799 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1800 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1802 else if (nPlate==1) {
1803 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1804 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1805 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1806 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1807 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1809 else if (nPlate==2) {
1810 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1811 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1818 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1819 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1820 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1821 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1823 else if (nPlate==3) {
1824 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1825 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1826 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1827 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1828 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1830 else if (nPlate==2) {
1831 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1832 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1839 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1840 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1841 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1842 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1843 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1845 else if (nPlate==3) {
1846 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1847 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1848 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1849 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1850 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1852 else if (nPlate==2) {
1853 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1854 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1865 //---------------------------------------------------------------------------
1866 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1870 // nSector number -vol[0]- (variable in [0,17])
1871 // nPlate number -vol[1]- (variable in [0, 5])
1872 // nStrip number -vol[2]- (variable in [0,14/18])
1873 // nPadZ number -vol[3]- (variable in [0, 1])
1874 // nPadX number -vol[4]- variable in [0,47])
1876 // nChain (variable in [0; 1]) -> number of the TRM chain
1881 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1882 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1885 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1886 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1889 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1890 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1893 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1894 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1895 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1896 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1897 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1898 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1902 Int_t iPadX = vol[4];
1904 if (iPadX<12 || iPadX>=36) nChain = 0;
1911 //---------------------------------------------------------------------------
1912 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1916 // nSector number -vol[0]- (variable in [0,17])
1917 // nPlate number -vol[1]- (variable in [0, 5])
1918 // nStrip number -vol[2]- (variable in [0,14/18])
1919 // nPadZ number -vol[3]- (variable in [0, 1])
1920 // nPadX number -vol[4]- (variable in [0,47])
1922 // nChannel (variable in [0; 7]) -> number of the TDC channel
1925 Int_t nChannel = -1;
1927 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1928 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1931 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1932 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1935 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1936 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1939 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1940 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1941 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1942 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1943 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1944 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1948 Int_t iPadZ = vol[3];
1949 Int_t iPadX = vol[4];
1951 Int_t iDDL = Geant2DDL(vol)%4;
1956 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1959 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1962 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1965 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1973 //____________________________________________________________________________
1974 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
1977 // Converts raw data to digits for TOF
1980 TStopwatch stopwatch;
1983 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
1984 //digitsTree->Branch("TOF", &fDigits);
1985 TClonesArray &aDigits = *digitsArray;
1990 SetRawReader(rawReader);
1993 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
1995 TClonesArray staticRawData("AliTOFrawData",10000);
1996 staticRawData.Clear();
1997 TClonesArray * clonesRawData = &staticRawData;
2000 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2003 const Int_t kMaxNumberOfTracksPerDigit = 3;
2004 Int_t tracks[kMaxNumberOfTracksPerDigit];
2005 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2011 AliTOFrawData *tofRawDatum = 0;
2012 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2015 if (fNewDecoderVersion) {
2016 AliInfo("Using New Decoder \n");
2017 LoadRawDataBuffers(indexDDL, 0);
2020 LoadRawData(indexDDL);
2022 clonesRawData = GetRawData();
2023 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2024 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2026 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2028 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2029 if (tofRawDatum->GetTOF()==-1) continue;
2031 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2032 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2034 dummy = detectorIndex[3];
2035 detectorIndex[3] = detectorIndex[4];//padz
2036 detectorIndex[4] = dummy;//padx
2038 digit[0] = tofRawDatum->GetTOF();
2039 digit[1] = tofRawDatum->GetTOT();
2040 digit[2] = tofRawDatum->GetTOT();
2041 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2043 dummy = detectorIndex[3];
2044 detectorIndex[3] = detectorIndex[4];//padx
2045 detectorIndex[4] = dummy;//padz
2047 // Do not reconstruct anything in the holes
2048 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2049 if (detectorIndex[1]==2) { // plate with holes
2055 last = digitsArray->GetEntriesFast();
2056 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2059 if (indexDDL<10) ftxt << " " << indexDDL;
2060 else ftxt << " " << indexDDL;
2061 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2062 else ftxt << " " << tofRawDatum->GetTRM();
2063 ftxt << " " << tofRawDatum->GetTRMchain();
2064 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2065 else ftxt << " " << tofRawDatum->GetTDC();
2066 ftxt << " " << tofRawDatum->GetTDCchannel();
2068 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2069 else ftxt << " -> " << detectorIndex[0];
2070 ftxt << " " << detectorIndex[1];
2071 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2072 else ftxt << " " << detectorIndex[2];
2073 ftxt << " " << detectorIndex[4];
2074 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2075 else ftxt << " " << detectorIndex[3];
2077 if (digit[1]<10)ftxt << " " << digit[1];
2078 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2079 else ftxt << " " << digit[1];
2080 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2081 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2082 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2083 else ftxt << " " << digit[3] << endl;
2086 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2088 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2089 digit[0], digit[1], digit[3]));
2092 } // loop on tofRawData array
2094 clonesRawData->Clear();
2098 //if (fVerbose==2) ftxt.close();
2101 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2103 Int_t nDigits = digitsArray->GetEntries();
2104 AliDebug(1, Form("Got %d TOF digits", nDigits));
2105 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2106 stopwatch.RealTime(),stopwatch.CpuTime()));
2110 //____________________________________________________________________________
2111 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
2114 // Converts raw data to sdigits for TOF
2117 TStopwatch stopwatch;
2122 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2123 TClonesArray &aSDigits = *sdigitsArray;
2126 SetRawReader(rawReader);
2129 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2131 TClonesArray staticRawData("AliTOFrawData",10000);
2132 staticRawData.Clear();
2133 TClonesArray * clonesRawData = &staticRawData;
2136 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2143 AliTOFrawData *tofRawDatum = 0;
2144 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2147 if (fNewDecoderVersion) {
2148 AliInfo("Using New Decoder \n");
2149 LoadRawDataBuffers(indexDDL, 0);
2152 LoadRawData(indexDDL);
2154 clonesRawData = GetRawData();
2155 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2156 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2158 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2160 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2161 if (tofRawDatum->GetTOF()==-1) continue;
2163 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2164 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2166 dummy = detectorIndex[3];
2167 detectorIndex[3] = detectorIndex[4];//padz
2168 detectorIndex[4] = dummy;//padx
2170 digit[0] = tofRawDatum->GetTOF();
2171 digit[1] = tofRawDatum->GetTOT();
2173 dummy = detectorIndex[3];
2174 detectorIndex[3] = detectorIndex[4];//padx
2175 detectorIndex[4] = dummy;//padz
2177 // Do not reconstruct anything in the holes
2178 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2179 if (detectorIndex[1]==2) { // plate with holes
2185 last = sdigitsArray->GetEntriesFast();
2186 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2189 if (indexDDL<10) ftxt << " " << indexDDL;
2190 else ftxt << " " << indexDDL;
2191 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2192 else ftxt << " " << tofRawDatum->GetTRM();
2193 ftxt << " " << tofRawDatum->GetTRMchain();
2194 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2195 else ftxt << " " << tofRawDatum->GetTDC();
2196 ftxt << " " << tofRawDatum->GetTDCchannel();
2198 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2199 else ftxt << " -> " << detectorIndex[0];
2200 ftxt << " " << detectorIndex[1];
2201 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2202 else ftxt << " " << detectorIndex[2];
2203 ftxt << " " << detectorIndex[4];
2204 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2205 else ftxt << " " << detectorIndex[3];
2207 if (digit[1]<10)ftxt << " " << digit[1];
2208 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2209 else ftxt << " " << digit[1];
2210 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2211 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2212 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2213 else ftxt << " " << digit[3] << endl;
2216 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2218 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2219 digit[0], digit[1], digit[3]));
2224 clonesRawData->Clear();
2228 //if (fVerbose==2) ftxt.close();
2230 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2232 Int_t nSDigits = sdigitsArray->GetEntries();
2233 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2234 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2235 stopwatch.RealTime(),stopwatch.CpuTime()));