]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testManuListSt345.C
Corrected the list of bus patches with reverted manus
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testManuListSt345.C
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 //
19 // Macro to generate manu list per buspatch for station 3, 4 and 5
20 // Christian Finck, Subatech
21 //
22
23 #if !defined(__CINT__) || defined(__MAKECINT__)
24
25 #include "AliMpSegmentation.h"
26 #include "AliMpVSegmentation.h"
27 #include "AliMpDEManager.h"
28 #include "AliMpBusPatch.h"
29 #include "AliMpIntPair.h"
30
31 #include <TArrayI.h>
32 #include <TList.h>
33
34 #endif
35
36 void testManuListSt345(Char_t* fileNamePre = "BusPatchToManu")
37 {
38    
39   Int_t planeOffset = 1024;
40   Int_t nBusPatch = 0;
41   Int_t nManu = 0;
42
43   Char_t fileName[255];
44   AliMpBusPatch* busPatchManager = new AliMpBusPatch();
45   busPatchManager->ReadBusPatchFile();
46
47   // loop over DDL station 345
48   for (Int_t iDDL = 8; iDDL < 20; ++iDDL) {
49
50     sprintf(fileName,"%s%d%s", fileNamePre, iDDL, ".dat");
51  
52     FILE* fp = fopen(fileName,"w");
53     printf("DDL # %d\n", iDDL);
54     fprintf(fp, "DDL # %d\n", iDDL);
55     TArrayI deArray = busPatchManager->GetDeInDDL(iDDL);
56
57     // list of DE in the given DDL
58     for (Int_t detElemId = 0; detElemId < deArray.GetSize(); ++detElemId) {
59
60       // list of bus patch for a given DE
61       TArrayI* busArray = busPatchManager->GetBusfromDE(deArray[detElemId]);
62
63       // list of manu per DE
64       TList manuList;
65       for ( Int_t cath = 0; cath <=1 ; ++cath ) {
66         const AliMpVSegmentation* seg 
67           = AliMpSegmentation::Instance()->GetMpSegmentation(deArray[detElemId],cath);
68         
69         TArrayI manus;
70
71         seg->GetAllElectronicCardIDs(manus);
72           
73         // filling class
74         for ( Int_t im = 0; im < manus.GetSize(); ++im ) {
75
76           AliMpIntPair* manu = new AliMpIntPair((manus[im] & 0x3FF), cath, kTRUE);// remove the offfset
77           manuList.Add(manu);
78         }        
79       }
80       manuList.Sort();
81       //      printf("Number of manu %d\n", manuList.GetEntries());
82
83       // writing into files/stdout
84       Int_t posPrev = -1;
85       Int_t manuIdPrev = 0;
86       for (Int_t iEntry = 0; iEntry < manuList.GetEntries(); iEntry++) {
87
88         AliMpIntPair* manuPtr = (AliMpIntPair*)manuList.At(iEntry);
89         Int_t pos = manuPtr->GetFirst()/100;
90         Int_t manuId;
91         nManu++;
92
93         if (manuPtr->GetSecond())
94           manuId = manuPtr->GetFirst() + planeOffset;
95         else
96           manuId = manuPtr->GetFirst();
97
98         if (pos != posPrev) {
99           if (posPrev != -1) {
100             printf("%d;\n", manuIdPrev);
101             fprintf(fp,"%d;\n", manuIdPrev);
102
103           }
104           printf("%d %d %d-", deArray[detElemId], 
105                  AliMpBusPatch::GetLocalBusID(busArray->At(pos),iDDL), manuId);
106           fprintf(fp,"%d %d-", AliMpBusPatch::GetLocalBusID(busArray->At(pos),iDDL), manuId);
107           nBusPatch++;
108
109         } else if ( manuId != manuIdPrev+1) {
110           printf("%d; ", manuIdPrev);
111           printf("%d-", manuId);
112           fprintf(fp,"%d; ", manuIdPrev);
113           fprintf(fp,"%d-", manuId);
114
115         }
116      
117         posPrev = pos;
118         manuIdPrev = manuId;
119         if (iEntry ==  manuList.GetEntries()-1) {
120           printf("%d;\n", manuId);
121           fprintf(fp,"%d;\n", manuId);
122         }
123       }
124     }
125     fclose(fp);
126   }
127   fflush(stdout);
128   printf("Number of buspatches %d and manus %d\n", nBusPatch, nManu);
129
130   delete busPatchManager;
131 }
132