1 #include "AliMFTCluster.h"
3 #include "AliMFTCluster.h"
5 #include "TClonesArray.h"
7 #include "AliMFTConstants.h"
11 TFile *fileIn=0, *fileOut=0;
13 const Int_t labelMCOffset = 1000000;
14 Double_t misalignmentX[AliMFTConstants::fNMaxPlanes] = {0};
15 Double_t misalignmentY[AliMFTConstants::fNMaxPlanes] = {0};
17 //====================================================================================================================================================
19 void AddMisalignmentToClusters(Char_t *nameDir=".",
21 Double_t misalignment = 0.0015) {
23 gRandom -> SetSeed(seed);
25 TClonesArray *fRecPointsPerPlaneIn[AliMFTConstants::fNMaxPlanes] = {0};
26 TClonesArray *fRecPointsPerPlaneOut[AliMFTConstants::fNMaxPlanes] = {0};
28 fileIn = new TFile(Form("%s/MFT.RecPoints.root",nameDir));
29 fileOut = new TFile(Form("%s/MFT.RecPoints.Misaligned.root",nameDir), "recreate");
32 while (fileIn->cd(Form("Event%d",iEv))) {
34 for (Int_t iPlane=0; iPlane<AliMFTConstants::fNMaxPlanes; iPlane++) {
35 fRecPointsPerPlaneIn[iPlane] = new TClonesArray("AliMFTCluster");
36 fRecPointsPerPlaneOut[iPlane] = new TClonesArray("AliMFTCluster");
39 printf("Event %d\n",iEv);
40 TTree *treeIn = (TTree*) gDirectory->Get("TreeR");
41 treeIn -> SetName("TreeR_In");
43 TTree *treeOut = new TTree("TreeR", "Reconstructed Points Container");
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]));
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);
73 fileOut -> mkdir(Form("Event%d",iEv));
74 fileOut -> cd(Form("Event%d",iEv));
76 for (Int_t jPlane=0; jPlane<AliMFTConstants::fNMaxPlanes; jPlane++) {
77 delete fRecPointsPerPlaneIn[jPlane];
78 delete fRecPointsPerPlaneOut[jPlane];
89 //====================================================================================================================================================