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(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);
507 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
511 } // else if (rawMap.TestHit(slot) == kEmpty)
515 } // closed -> while (Next())
519 //_____________________________________________________________________________
520 Bool_t AliTOFRawStream::Next()
523 // Read next 32-bit word in TOF raw data files
524 // returns kFALSE if there is no word left
531 if (!fRawReader->ReadNextInt(data)) return kFALSE;
533 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
545 fDDL = fRawReader->GetDDLID();
547 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
549 switch (fWordType) { // switch word type
551 case GLOBAL_HEADER_TYPE: // global header
552 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
556 switch (fSlotID) { // switch global header slot ID
558 case DRM_ID_NUMBER: //DRM global header
559 if (fInsideDRM) { // unexpected DRM global headers -> exit
562 fInsideDRM = kTRUE; // DRM global header accepted
565 case LTM_ID_NUMBER: // LTM global header
566 if (fInsideLTM) { // unexpected LTM global headers -> exit
569 fInsideLTM = kTRUE; // LTM global header accepted
579 case 10: //TRM header
580 case 11: //TRM header
581 case 12: //TRM header
582 if (fInsideTRM) { // unexpected TRM global headers -> exit
585 fInsideTRM = kTRUE; // TRM global header accepted
586 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
589 default: // unexpected global header slot ID
592 } //end switch global header slot id
597 case GLOBAL_TRAILER_TYPE: // global trailer
598 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
600 switch (fSlotID) { // switch global trailer slot ID
602 case DRM_ID_NUMBER: // DRM global trailer
603 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
607 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
608 fLocalEventCounterDRM = GetField(data,dummy,4);
609 fInsideDRM = kFALSE; // DRM global trailer accepted
612 fInsideTRMchain0 = kFALSE;
613 fInsideTRMchain1 = kFALSE;
633 case LTM_ID_NUMBER: // LTM global trailer
634 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
638 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
639 fLocalEventCounterLTM = GetField(data,dummy,16);
640 fInsideLTM = kFALSE; // LTM global trailer accepted
642 case 15: //TRM global trailer
643 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
647 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
648 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
649 fInsideTRM = kFALSE; // TRM global trailer accepted
651 default: // unexpected global trailer slot ID
653 } //end switch global trailer slot id
659 case ERROR_TYPE: // TDC error
660 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
661 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
665 case FILLER_TYPE: // filler
669 default: // other word types
671 if (fInsideTRM) { // inside TRM
673 switch (fWordType) { // switch word type inside TRM
674 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
675 if (fInsideTRMchain0) { // unexpected TRM chain0 header
678 fInsideTRMchain0 = kTRUE;
681 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
682 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
684 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
685 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
689 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
690 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
691 fInsideTRMchain0 = kFALSE;
694 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
695 if (fInsideTRMchain1) { // unexpected TRM chain1 header
698 fInsideTRMchain1 = kTRUE;
701 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
702 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
704 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
705 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
709 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
710 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
711 fInsideTRMchain1 = kFALSE;
714 } // end switch word type inside TRM
716 } // end if (fInsideTRM)
720 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
721 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
722 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
723 ){ // inside TRM chains
725 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
726 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
727 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
728 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
737 switch (fPSbit) { // switch fPSbit bits inside TRM chains
739 case 0: // packing ok, digit time and TOT
740 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
741 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
743 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
745 if (fgApplyBCCorrections) {
746 AliDebug(2,"Apply nominal DDL BC time-shift correction");
747 AliDebug(2,"Apply deltaBC time-shift correction");
748 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
749 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
753 case 1: // leading edge digit, long digit time, no TOT
756 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
758 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
760 if (fgApplyBCCorrections) {
761 AliDebug(2,"Apply nominal DDL BC time-shift correction");
762 AliDebug(2,"Apply deltaBC time-shift correction");
763 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
764 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
768 case 2: // trailing edge digit, long digit time, no TOT
771 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
773 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
775 if (fgApplyBCCorrections) {
776 AliDebug(2,"Apply nominal DDL BC time-shift correction");
777 AliDebug(2,"Apply deltaBC time-shift correction");
778 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
779 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
783 case 3: // TOT overflow
784 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
785 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
787 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
789 if (fgApplyBCCorrections) {
790 AliDebug(2,"Apply nominal DDL BC time-shift correction");
791 AliDebug(2,"Apply deltaBC time-shift correction");
792 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
793 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
797 } // end switch PS bits inside TRM chains
799 } // end if is inside TRM chains
801 } // end switch on fWordType
807 //_____________________________________________________________________________
809 void AliTOFRawStream::SetSector()
812 // Evaluate the TOF sector number -> [ 0;17]
813 // corresponding to the TOF equipment IDs:
816 // fTRMchain -> [ 0; 1]
818 // fTDCchannel -> [ 0; 7]
823 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
828 //_____________________________________________________________________________
831 void AliTOFRawStream::SetPlate()
834 // Evaluate the TOF plate number ->[ 0; 4]
835 // corresponding to the TOF equipment IDs:
838 // fTRMchain -> [ 0; 1]
840 // fTDCchannel -> [ 0; 7]
844 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
846 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
851 //_____________________________________________________________________________
853 void AliTOFRawStream::SetStrip()
856 // Evaluate the TOF strip number per module -> [ 0; 14/18]
857 // corresponding to the TOF equipment IDs:
860 // fTRMchain -> [ 0; 1]
862 // fTDCchannel -> [ 0; 7]
867 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
868 || fSector==-1 || fPlate==-1))
869 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
874 //_____________________________________________________________________________
876 void AliTOFRawStream::SetPadZ()
879 // Evaluate the TOF padRow number per strip -> [ 0; 1]
880 // corresponding to the TOF equipment IDs:
883 // fTRMchain -> [ 0; 1]
885 // fTDCchannel -> [ 0; 7]
890 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
891 || fSector==-1 || fPlate==-1 || fStrip==-1))
893 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
894 if (iPadAlongTheStrip!=-1)
895 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
898 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
899 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
904 //_____________________________________________________________________________
906 void AliTOFRawStream::SetPadX()
909 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
910 // corresponding to the TOF equipment IDs:
913 // fTRMchain -> [ 0; 1]
915 // fTDCchannel -> [ 0; 7]
920 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
921 || fSector==-1 || fPlate==-1 || fStrip==-1))
923 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
924 if (iPadAlongTheStrip!=-1)
925 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
928 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
929 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
935 //----------------------------------------------------------------------------
936 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
942 return ((word & fieldMask) >> fieldPosition);
945 //----------------------------------------------------------------------------
946 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
949 // Returns the TOF plate number [0;4]
950 // corresponding to the TOF equipment ID numbers:
951 // iDDL -> DDL number per sector [0;3]
952 // nTRM -> TRM number [3;12]
953 // nTDC -> TDC number [0;14]
960 if (nTRM>=4 && nTRM<7) {
962 } else if (nTRM==7) {
963 if (nTDC<12) iPlate = 0;
965 } else if (nTRM>=8 && nTRM<11) {
967 } else if (nTRM==11) {
968 if (nTDC<9) iPlate = 1;
970 }else if (nTRM==12) {
974 } else if (iDDL==1) {
977 if (nTDC<3) iPlate = 0;
978 } else if (nTRM>=4 && nTRM<7) {
980 } else if (nTRM==7) {
981 if (nTDC<6) iPlate = 1;
983 } else if (nTRM>=8 && nTRM<11) {
985 } else if (nTRM==11) {
986 if (nTDC<9) iPlate = 2;
988 } else if (nTRM==12) {
992 } else if (iDDL==2) {
994 if (nTRM>=4 && nTRM<7) {
996 } else if (nTRM==7) {
997 if (nTDC<12) iPlate = 4;
999 } else if (nTRM>=8 && nTRM<11) {
1001 } else if (nTRM==11) {
1002 if (nTDC<9) iPlate = 3;
1004 }else if (nTRM==12) {
1008 } else if (iDDL==3) {
1011 if (nTDC<3) iPlate = 4;
1012 } else if (nTRM>=4 && nTRM<7) {
1014 } else if (nTRM==7) {
1015 if (nTDC<6) iPlate = 3;
1017 } else if (nTRM>=8 && nTRM<11) {
1019 } else if (nTRM==11) {
1020 if (nTDC<9) iPlate = 2;
1022 } else if (nTRM==12) {
1032 //----------------------------------------------------------------------------
1033 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1036 // Returns the TOF strip number per module:
1037 // [0;14], in the central plates,
1038 // [0;18], in the intermediate and external plates
1039 // corresponding to the TOF equipment ID numbers:
1040 // iDDL -> DDL number per sector [0;3]
1041 // nTRM -> TRM number [3;12]
1042 // nTDC -> TDC number [0;14]
1049 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1050 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1051 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1052 else if (nTRM== 7) {
1053 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1054 else iStrip = (Int_t)(nTDC/3.) - 4;
1056 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1057 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1058 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1059 else if (nTRM==11) {
1060 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1061 else iStrip = (Int_t)(nTDC/3.) - 3;
1063 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1065 } else if (iDDL==1) {
1067 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1068 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1069 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1070 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1071 else if (nTRM== 7) {
1072 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1073 else iStrip = 20 - (Int_t)(nTDC/3.);
1075 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1076 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1077 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1078 else if (nTRM==11) {
1079 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1080 else iStrip = 21 - (Int_t)(nTDC/3.);
1082 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1084 } else if (iDDL==2) {
1086 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1087 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1088 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1089 else if (nTRM== 7) {
1090 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1091 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1093 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1094 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1095 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1096 else if (nTRM==11) {
1097 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1098 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1100 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1102 } else if (iDDL==3) {
1104 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1105 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1106 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1107 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1108 else if (nTRM== 7) {
1109 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1110 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1112 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1113 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1114 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1115 else if (nTRM==11) {
1116 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1117 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1119 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1127 //----------------------------------------------------------------------------
1128 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1132 // Returns the TOF pad number per strip [0;95]
1133 // corresponding to the TOF equipment ID numbers:
1134 // iDDL -> DDL number per sector [0;3]
1135 // iChain -> TRM chain number [0;1]
1136 // nTDC -> TDC number [0;14]
1137 // iCH -> TDC channel number [0;7]
1140 Int_t iPadAlongTheStrip = -1;
1143 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1144 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1145 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1148 Int_t iTDClocal = -1;
1149 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1150 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1151 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1152 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1154 Int_t iCHlocal = iCH;
1155 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1157 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1159 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1160 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1161 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
1162 //AliWarning("Problems with the padX number!");
1164 return iPadAlongTheStrip;
1168 //----------------------------------------------------------------------------
1169 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1173 // Returns the TOF padX number [0;47]
1174 // corresponding to the TOF equipment ID numbers:
1175 // iDDL -> DDL number per sector [0;3]
1176 // iChain -> TRM chain number [0;1]
1177 // nTDC -> TDC number [0;14]
1178 // iCH -> TDC channel number [0;7]
1181 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1182 (Float_t(AliTOFGeometry::NpadZ())));
1188 //----------------------------------------------------------------------------
1189 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1193 // Returns the TOF padZ number [0;1]
1194 // corresponding to the TOF equipment ID numbers:
1195 // iDDL -> DDL number per sector [0;3]
1196 // iChain -> TRM chain number [0;1]
1197 // nTDC -> TDC number [0;14]
1198 // iCH -> TDC channel number [0;7]
1201 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1207 //----------------------------------------------------------------------------
1208 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1211 // Returns the sector number [0;17]
1212 // corresponing to the assigned DRM/DDL number [0;71]
1215 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1220 //----------------------------------------------------------------------------
1221 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1224 // Return the DRM/DDL number per sector [0;3]
1225 // corresponing to the assigned DRM/DDL number [0;71]
1228 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1234 //----------------------------------------------------------------------------
1235 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1237 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1239 //----------------------------------------------------------------------------
1240 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1241 Int_t nTDC, Int_t iCH,
1246 // nDDL (variable in [0;71]) -> number of the DDL file
1247 // nTRM (variable in [3;12]) -> number of the TRM slot
1248 // iChain (variable in [0; 1]) -> number of the TRM chain
1249 // nTDC (variable in [0;14]) -> number of the TDC
1250 // iCH (variable in [0; 7]) -> number of the TDC channel
1253 // sector number, i.e. volume[0] (variable in [0,17])
1254 // plate number, i.e. volume[1] (variable in [0, 5])
1255 // strip number, i.e. volume[2] (variable in [0,14/18])
1256 // padX number, i.e. volume[3] (variable in [0,47])
1257 // padZ number, i.e. volume[4] (variable in [0, 1])
1260 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1262 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1264 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1265 //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);
1269 Int_t iSector = GetSectorNumber(nDDL);
1271 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1274 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1275 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1279 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1282 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1283 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1287 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1288 if (iPadAlongTheStrip==-1) {
1290 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1291 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1292 nDDL, iChain, nTDC, iCH);
1295 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1296 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1298 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1299 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1301 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1302 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1304 volume[0] = iSector;
1311 //-----------------------------------------------------------------------------
1312 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1314 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1317 //check and fix valid DDL range
1320 fRawReader->AddMinorErrorLog(kDDLMinError);
1321 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1325 fRawReader->AddMinorErrorLog(kDDLMaxError);
1326 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1329 //select required DDLs
1330 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1333 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1335 return(Decode(verbose));
1337 //-----------------------------------------------------------------------------
1338 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1340 // New decoder method
1343 Int_t currentEquipment;
1345 const AliRawDataHeader *currentCDH;
1348 UChar_t *data = 0x0;
1350 //loop and read DDL headers
1351 while(fRawReader->ReadHeader()){
1353 //memory leak prevention (actually data should be always 0x0 here)
1357 //get equipment infos
1358 currentEquipment = fRawReader->GetEquipmentId();
1359 currentDDL = fRawReader->GetDDLID();
1360 currentCDH = fRawReader->GetDataHeader();
1361 const Int_t kDataSize = fRawReader->GetDataSize();
1362 const Int_t kDataWords = kDataSize / 4;
1363 data = new UChar_t[kDataSize];
1366 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1369 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1371 //read equipment payload
1372 if (!fRawReader->ReadNext(data, kDataSize))
1374 fRawReader->AddMajorErrorLog(kDDLdataReading);
1376 AliWarning("Error while reading DDL data. Go to next equipment");
1383 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1386 //set up the decoder
1387 fDecoder->SetVerbose(verbose);
1388 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1389 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1392 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1393 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1394 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1395 ResetDataBuffer(currentDDL);
1396 ResetPackedDataBuffer(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() - 37);
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()));