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 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1276 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1278 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1279 //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);
1283 Int_t iSector = GetSectorNumber(nDDL);
1285 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1288 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1289 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1293 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1296 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1297 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1301 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1302 if (iPadAlongTheStrip==-1) {
1304 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1305 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1306 nDDL, iChain, nTDC, iCH);
1309 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1310 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1312 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1313 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1315 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1316 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1318 volume[0] = iSector;
1325 //-----------------------------------------------------------------------------
1326 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1328 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1331 //check and fix valid DDL range
1334 fRawReader->AddMinorErrorLog(kDDLMinError);
1335 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1339 fRawReader->AddMinorErrorLog(kDDLMaxError);
1340 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1343 //select required DDLs
1344 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1347 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1349 return(Decode(verbose));
1351 //-----------------------------------------------------------------------------
1352 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1354 // New decoder method
1357 Int_t currentEquipment;
1359 const AliRawDataHeader *currentCDH;
1362 UChar_t *data = 0x0;
1364 //loop and read DDL headers
1365 while(fRawReader->ReadHeader()){
1367 //memory leak prevention (actually data should be always 0x0 here)
1371 //get equipment infos
1372 currentEquipment = fRawReader->GetEquipmentId();
1373 currentDDL = fRawReader->GetDDLID();
1374 currentCDH = fRawReader->GetDataHeader();
1375 const Int_t kDataSize = fRawReader->GetDataSize();
1376 const Int_t kDataWords = kDataSize / 4;
1377 data = new UChar_t[kDataSize];
1380 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1383 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1385 //read equipment payload
1386 if (!fRawReader->ReadNext(data, kDataSize))
1388 fRawReader->AddMajorErrorLog(kDDLdataReading);
1390 AliWarning("Error while reading DDL data. Go to next equipment");
1397 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1400 //set up the decoder
1401 fDecoder->SetVerbose(verbose);
1402 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1403 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1406 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1407 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1408 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1416 fRawReader->Reset();
1419 AliInfo("All done");
1424 //---------------------------------------------------------------------------
1426 AliTOFRawStream::ResetBuffers()
1429 // To reset the buffers
1432 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1433 ResetDataBuffer(iDDL);
1434 ResetPackedDataBuffer(iDDL);
1438 //---------------------------------------------------------------------------
1440 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1443 // To load the buffers
1446 fTOFrawData->Clear();
1450 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1452 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1453 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1454 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1459 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1461 AliTOFHitData *hitData; //hit data pointer
1464 AliInfo("Filling TClonesArray ...");
1467 if (fgApplyBCCorrections) {
1468 AliInfo("Apply nominal DDL BC time-shift correction");
1469 AliInfo("Apply deltaBC time-shift correction");
1472 //loop over DDL packed hits
1473 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1474 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1475 Int_t hitACQ = hitData->GetACQ();
1476 Int_t hitPS = hitData->GetPS();
1477 Int_t hitSlotID = hitData->GetSlotID();
1478 Int_t hitChain = hitData->GetChain();
1479 Int_t hitTDC = hitData->GetTDC();
1480 Int_t hitChan = hitData->GetChan();
1481 Int_t hitTimeBin = hitData->GetTimeBin();
1482 Int_t hitTOTBin = hitData->GetTOTBin();
1484 if (fgApplyBCCorrections) {
1485 /* DDL BC shift time correction */
1486 hitTimeBin += fgkddlBCshift[indexDDL];
1487 /* deltaBC shift time correction */
1488 hitTimeBin += hitData->GetDeltaBunchID();
1491 Int_t hitLeading = hitData->GetTimeBin();
1492 Int_t hitTrailing = -1;
1493 Int_t hitError = -1;
1495 TClonesArray &arrayTofRawData = *fTOFrawData;
1496 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1503 AliInfo("Resetting buffers ...");
1505 fDataBuffer[indexDDL].Reset();
1506 fPackedDataBuffer[indexDDL].Reset();
1514 //---------------------------------------------------------------------------
1515 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1519 // nSector number -vol[0]- (variable in [0,17])
1520 // nPlate number -vol[1]- (variable in [0, 5])
1521 // nStrip number -vol[2]- (variable in [0,14/18])
1522 // nPadZ number -vol[3]- (variable in [0, 1])
1523 // nPadX number -vol[4]- (variable in [0,47])
1525 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1526 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1527 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1528 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1529 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1532 eqId[0] = Geant2DDL(vol);
1533 eqId[1] = Geant2TRM(vol);
1534 eqId[2] = Geant2TDC(vol);
1535 eqId[3] = Geant2Chain(vol);
1536 eqId[4] = Geant2Channel(vol);
1540 //---------------------------------------------------------------------------
1541 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1545 // nSector number -vol[0]- (variable in [0,17])
1546 // nPlate number -vol[1]- (variable in [0, 5])
1547 // nStrip number -vol[2]- (variable in [0,14/18])
1548 // nPadZ number -vol[3]- (variable in [0, 1])
1549 // nPadX number -vol[4]- (variable in [0,47])
1551 // nDDL (variable in [0;71]) -> number of the DDL
1557 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1558 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1561 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1562 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1565 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1566 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1569 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1570 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1571 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1572 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1573 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1574 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1578 Int_t nSector = vol[0];
1579 Int_t nPlate = vol[1];
1580 Int_t nStrip = vol[2];
1581 Int_t nPadX = vol[4];
1583 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1585 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1587 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1589 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1592 return 4*nSector+iDDL;
1596 //---------------------------------------------------------------------------
1597 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1601 // nSector number -vol[0]- (variable in [0,17])
1602 // nPlate number -vol[1]- (variable in [0, 5])
1603 // nStrip number -vol[2]- (variable in [0,14/18])
1604 // nPadZ number -vol[3]- (variable in [0, 1])
1605 // nPadX number -vol[4]- (variable in [0,47])
1607 // nTRM (variable in [3;12]) -> number of the TRM slot
1612 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1613 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1616 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1617 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1620 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1621 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1624 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1625 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1628 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1629 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1633 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1635 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1639 Int_t nPlate = vol[1];
1640 Int_t nStrip = vol[2];
1642 Int_t iDDL = Geant2DDL(vol)%4;
1649 if (nStrip<= 4) nTRM = 4;
1650 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1651 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1652 else if (nStrip>14) nTRM = 7;
1654 else if (nPlate==1) {
1655 if (nStrip== 0) nTRM = 7;
1656 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1657 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1658 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1659 else if (nStrip>15) nTRM = 11;
1661 else if (nPlate==2) {
1662 if (nStrip<= 1) nTRM = 11;
1663 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1670 if (nStrip== 0) nTRM = 3;
1671 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1672 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1673 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1674 else if (nStrip>15) nTRM = 7;
1676 else if (nPlate==1) {
1677 if (nStrip<=1) nTRM = 7;
1678 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1679 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1680 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1681 else if (nStrip>16) nTRM = 11;
1683 else if (nPlate==2) {
1684 if (nStrip<= 2) nTRM = 11;
1685 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1692 if (nStrip>=14) nTRM = 4;
1693 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1694 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1695 else if (nStrip< 4) nTRM = 7;
1697 else if (nPlate==3) {
1698 if (nStrip==18) nTRM = 7;
1699 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1700 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1701 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1702 else if (nStrip< 3) nTRM = 11;
1704 else if (nPlate==2) {
1705 if (nStrip>=13) nTRM = 11;
1706 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1713 if (nStrip==18) nTRM = 3;
1714 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1715 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1716 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1717 else if (nStrip< 3) nTRM = 7;
1719 else if (nPlate==3) {
1720 if (nStrip>=17) nTRM = 7;
1721 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1722 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1723 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1724 else if (nStrip< 2) nTRM = 11;
1726 else if (nPlate==2) {
1727 if (nStrip>=12) nTRM = 11;
1728 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1739 //---------------------------------------------------------------------------
1740 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1744 // nSector number -vol[0]- (variable in [0,17])
1745 // nPlate number -vol[1]- (variable in [0, 5])
1746 // nStrip number -vol[2]- (variable in [0,14/18])
1747 // nPadZ number -vol[3]- (variable in [0, 1])
1748 // nPadX number -vol[4]- (variable in [0,47])
1750 // nTDC (variable in [0;14]) -> number of the TDC
1755 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1756 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1759 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1760 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1763 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1764 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1767 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1768 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1769 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1770 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1771 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1772 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1776 Int_t nPlate = vol[1];
1777 Int_t nStrip = vol[2];
1778 Int_t iPadX = vol[4];
1780 Int_t iDDL = Geant2DDL(vol)%4;
1787 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1788 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1789 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1790 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1792 else if (nPlate==1) {
1793 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1794 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1795 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1796 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1797 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1799 else if (nPlate==2) {
1800 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1801 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1808 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1809 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1810 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1811 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1812 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1814 else if (nPlate==1) {
1815 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1816 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1817 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1818 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1819 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1821 else if (nPlate==2) {
1822 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1823 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1830 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1831 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1832 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1833 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1835 else if (nPlate==3) {
1836 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1837 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1838 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1839 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1840 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1842 else if (nPlate==2) {
1843 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1844 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1851 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1852 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1853 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1854 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1855 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1857 else if (nPlate==3) {
1858 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1859 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1860 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1861 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1862 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1864 else if (nPlate==2) {
1865 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1866 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1877 //---------------------------------------------------------------------------
1878 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1882 // nSector number -vol[0]- (variable in [0,17])
1883 // nPlate number -vol[1]- (variable in [0, 5])
1884 // nStrip number -vol[2]- (variable in [0,14/18])
1885 // nPadZ number -vol[3]- (variable in [0, 1])
1886 // nPadX number -vol[4]- variable in [0,47])
1888 // nChain (variable in [0; 1]) -> number of the TRM chain
1893 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1894 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1897 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1898 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1901 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1902 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1905 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1906 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1907 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1908 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1909 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1910 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1914 Int_t iPadX = vol[4];
1916 if (iPadX<12 || iPadX>=36) nChain = 0;
1923 //---------------------------------------------------------------------------
1924 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1928 // nSector number -vol[0]- (variable in [0,17])
1929 // nPlate number -vol[1]- (variable in [0, 5])
1930 // nStrip number -vol[2]- (variable in [0,14/18])
1931 // nPadZ number -vol[3]- (variable in [0, 1])
1932 // nPadX number -vol[4]- (variable in [0,47])
1934 // nChannel (variable in [0; 7]) -> number of the TDC channel
1937 Int_t nChannel = -1;
1939 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1940 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1943 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1944 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1947 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1948 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1951 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1952 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1953 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1954 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1955 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1956 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1960 Int_t iPadZ = vol[3];
1961 Int_t iPadX = vol[4];
1963 Int_t iDDL = Geant2DDL(vol)%4;
1968 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1971 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1974 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
1977 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
1985 //____________________________________________________________________________
1986 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
1989 // Converts raw data to digits for TOF
1992 TStopwatch stopwatch;
1995 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
1996 //digitsTree->Branch("TOF", &fDigits);
1997 TClonesArray &aDigits = *digitsArray;
2002 SetRawReader(rawReader);
2005 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2007 TClonesArray staticRawData("AliTOFrawData",10000);
2008 staticRawData.Clear();
2009 TClonesArray * clonesRawData = &staticRawData;
2012 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2015 const Int_t kMaxNumberOfTracksPerDigit = 3;
2016 Int_t tracks[kMaxNumberOfTracksPerDigit];
2017 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2023 AliTOFrawData *tofRawDatum = 0;
2024 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2027 if (fNewDecoderVersion) {
2028 AliInfo("Using New Decoder \n");
2029 LoadRawDataBuffers(indexDDL, 0);
2032 LoadRawData(indexDDL);
2034 clonesRawData = GetRawData();
2035 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2036 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2038 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2040 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2041 if (tofRawDatum->GetTOF()==-1) continue;
2043 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2044 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2046 dummy = detectorIndex[3];
2047 detectorIndex[3] = detectorIndex[4];//padz
2048 detectorIndex[4] = dummy;//padx
2050 digit[0] = tofRawDatum->GetTOF();
2051 digit[1] = tofRawDatum->GetTOT();
2052 digit[2] = tofRawDatum->GetTOT();
2053 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2055 dummy = detectorIndex[3];
2056 detectorIndex[3] = detectorIndex[4];//padx
2057 detectorIndex[4] = dummy;//padz
2059 // Do not reconstruct anything in the holes
2060 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2061 if (detectorIndex[1]==2) { // plate with holes
2067 last = digitsArray->GetEntriesFast();
2068 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2071 if (indexDDL<10) ftxt << " " << indexDDL;
2072 else ftxt << " " << indexDDL;
2073 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2074 else ftxt << " " << tofRawDatum->GetTRM();
2075 ftxt << " " << tofRawDatum->GetTRMchain();
2076 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2077 else ftxt << " " << tofRawDatum->GetTDC();
2078 ftxt << " " << tofRawDatum->GetTDCchannel();
2080 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2081 else ftxt << " -> " << detectorIndex[0];
2082 ftxt << " " << detectorIndex[1];
2083 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2084 else ftxt << " " << detectorIndex[2];
2085 ftxt << " " << detectorIndex[4];
2086 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2087 else ftxt << " " << detectorIndex[3];
2089 if (digit[1]<10)ftxt << " " << digit[1];
2090 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2091 else ftxt << " " << digit[1];
2092 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2093 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2094 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2095 else ftxt << " " << digit[3] << endl;
2098 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2100 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2101 digit[0], digit[1], digit[3]));
2104 } // loop on tofRawData array
2106 clonesRawData->Clear();
2110 //if (fVerbose==2) ftxt.close();
2113 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2115 Int_t nDigits = digitsArray->GetEntries();
2116 AliDebug(1, Form("Got %d TOF digits", nDigits));
2117 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2118 stopwatch.RealTime(),stopwatch.CpuTime()));
2122 //____________________________________________________________________________
2123 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
2126 // Converts raw data to sdigits for TOF
2129 TStopwatch stopwatch;
2134 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2135 TClonesArray &aSDigits = *sdigitsArray;
2138 SetRawReader(rawReader);
2141 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2143 TClonesArray staticRawData("AliTOFrawData",10000);
2144 staticRawData.Clear();
2145 TClonesArray * clonesRawData = &staticRawData;
2148 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2155 AliTOFrawData *tofRawDatum = 0;
2156 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2159 if (fNewDecoderVersion) {
2160 AliInfo("Using New Decoder \n");
2161 LoadRawDataBuffers(indexDDL, 0);
2164 LoadRawData(indexDDL);
2166 clonesRawData = GetRawData();
2167 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2168 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2170 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2172 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2173 if (tofRawDatum->GetTOF()==-1) continue;
2175 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2176 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2178 dummy = detectorIndex[3];
2179 detectorIndex[3] = detectorIndex[4];//padz
2180 detectorIndex[4] = dummy;//padx
2182 digit[0] = tofRawDatum->GetTOF();
2183 digit[1] = tofRawDatum->GetTOT();
2185 dummy = detectorIndex[3];
2186 detectorIndex[3] = detectorIndex[4];//padx
2187 detectorIndex[4] = dummy;//padz
2189 // Do not reconstruct anything in the holes
2190 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2191 if (detectorIndex[1]==2) { // plate with holes
2197 last = sdigitsArray->GetEntriesFast();
2198 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2201 if (indexDDL<10) ftxt << " " << indexDDL;
2202 else ftxt << " " << indexDDL;
2203 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2204 else ftxt << " " << tofRawDatum->GetTRM();
2205 ftxt << " " << tofRawDatum->GetTRMchain();
2206 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2207 else ftxt << " " << tofRawDatum->GetTDC();
2208 ftxt << " " << tofRawDatum->GetTDCchannel();
2210 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2211 else ftxt << " -> " << detectorIndex[0];
2212 ftxt << " " << detectorIndex[1];
2213 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2214 else ftxt << " " << detectorIndex[2];
2215 ftxt << " " << detectorIndex[4];
2216 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2217 else ftxt << " " << detectorIndex[3];
2219 if (digit[1]<10)ftxt << " " << digit[1];
2220 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2221 else ftxt << " " << digit[1];
2222 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2223 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2224 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2225 else ftxt << " " << digit[3] << endl;
2228 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2230 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2231 digit[0], digit[1], digit[3]));
2236 clonesRawData->Clear();
2240 //if (fVerbose==2) ftxt.close();
2242 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2244 Int_t nSDigits = sdigitsArray->GetEntries();
2245 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2246 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2247 stopwatch.RealTime(),stopwatch.CpuTime()));