]>
Commit | Line | Data |
---|---|---|
ea571096 | 1 | #include "AliMFTCluster.h" |
2 | #include "TFile.h" | |
3 | #include "AliMFTCluster.h" | |
4 | #include "TObjArray.h" | |
5 | #include "TClonesArray.h" | |
6 | #include "TTree.h" | |
7 | #include "AliMFTConstants.h" | |
8 | #include "TBranch.h" | |
9 | #include "TRandom.h" | |
10 | ||
11 | TFile *fileIn=0, *fileOut=0; | |
12 | ||
13 | const Int_t labelMCOffset = 1000000; | |
14 | Double_t misalignmentX[AliMFTConstants::fNMaxPlanes] = {0}; | |
15 | Double_t misalignmentY[AliMFTConstants::fNMaxPlanes] = {0}; | |
16 | ||
17 | //==================================================================================================================================================== | |
18 | ||
19 | void AddMisalignmentToClusters(Char_t *nameDir=".", | |
20 | Int_t seed = 12345, | |
8b0e6802 | 21 | Double_t misalignment = 0.0015) { |
ea571096 | 22 | |
23 | gRandom -> SetSeed(seed); | |
24 | ||
25 | TClonesArray *fRecPointsPerPlaneIn[AliMFTConstants::fNMaxPlanes] = {0}; | |
26 | TClonesArray *fRecPointsPerPlaneOut[AliMFTConstants::fNMaxPlanes] = {0}; | |
27 | ||
28 | fileIn = new TFile(Form("%s/MFT.RecPoints.root",nameDir)); | |
29 | fileOut = new TFile(Form("%s/MFT.RecPoints.Misaligned.root",nameDir), "recreate"); | |
30 | ||
31 | Int_t iEv=0; | |
32 | while (fileIn->cd(Form("Event%d",iEv))) { | |
33 | ||
34 | for (Int_t iPlane=0; iPlane<AliMFTConstants::fNMaxPlanes; iPlane++) { | |
35 | fRecPointsPerPlaneIn[iPlane] = new TClonesArray("AliMFTCluster"); | |
36 | fRecPointsPerPlaneOut[iPlane] = new TClonesArray("AliMFTCluster"); | |
37 | } | |
38 | ||
39 | printf("Event %d\n",iEv); | |
40 | TTree *treeIn = (TTree*) gDirectory->Get("TreeR"); | |
41 | treeIn -> SetName("TreeR_In"); | |
42 | fileOut-> cd(); | |
43 | TTree *treeOut = new TTree("TreeR", "Reconstructed Points Container"); | |
44 | ||
45 | Int_t iPlane=0; | |
46 | while (treeIn->GetBranch(Form("Plane_%02d",iPlane))) { | |
47 | // printf("Plane %02d\n",iPlane); | |
48 | Double_t misalignmentPhi = 2.*TMath::Pi()*gRandom->Rndm(); | |
49 | misalignmentX[iPlane] = misalignment*TMath::Cos(misalignmentPhi); | |
50 | misalignmentY[iPlane] = misalignment*TMath::Sin(misalignmentPhi); | |
51 | treeIn ->SetBranchAddress(Form("Plane_%02d",iPlane), &(fRecPointsPerPlaneIn[iPlane])); | |
52 | treeOut->Branch(Form("Plane_%02d",iPlane), &(fRecPointsPerPlaneOut[iPlane])); | |
53 | // treeOut->SetBranchAddress(Form("Plane_%02d",iPlane), &(fRecPointsPerPlaneOut[iPlane])); | |
54 | iPlane++; | |
55 | } | |
56 | ||
57 | iPlane=0; | |
58 | treeIn -> GetEntry(0); | |
59 | while (treeIn->GetBranch(Form("Plane_%02d",iPlane))) { | |
60 | Int_t nClusters = fRecPointsPerPlaneIn[iPlane]->GetEntries(); | |
61 | for (Int_t iCluster=0; iCluster<nClusters; iCluster++) { | |
62 | // printf("Cluster %4d\n",iCluster); | |
63 | AliMFTCluster *newCluster = (AliMFTCluster*) fRecPointsPerPlaneIn[iPlane]->At(iCluster); | |
64 | newCluster->SetClusterEditable(kTRUE); | |
65 | newCluster->SetX(newCluster->GetX()+misalignmentX[iPlane]); | |
66 | newCluster->SetY(newCluster->GetY()+misalignmentY[iPlane]); | |
67 | new ((*fRecPointsPerPlaneOut[iPlane])[fRecPointsPerPlaneOut[iPlane]->GetEntries()]) AliMFTCluster(*newCluster); | |
68 | } | |
69 | iPlane++; | |
70 | } | |
71 | ||
72 | treeOut -> Fill(); | |
73 | fileOut -> mkdir(Form("Event%d",iEv)); | |
74 | fileOut -> cd(Form("Event%d",iEv)); | |
75 | treeOut -> Write(); | |
76 | for (Int_t jPlane=0; jPlane<AliMFTConstants::fNMaxPlanes; jPlane++) { | |
77 | delete fRecPointsPerPlaneIn[jPlane]; | |
78 | delete fRecPointsPerPlaneOut[jPlane]; | |
79 | } | |
80 | ||
81 | iEv++; | |
82 | ||
83 | } | |
84 | ||
85 | fileOut -> Close(); | |
86 | ||
87 | } | |
88 | ||
89 | //==================================================================================================================================================== |