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 #include "AliMUONAlignmentCompareDialog.h"
20 /// \class AliMUONAlignmentCompareDialog
22 /// Widget to select 2 alignments objects from the OCDB (A1,A2) to be compared
24 /// \author Philippe Pillot, Laurent Aphecetche
27 #include "AliCDBManager.h"
28 #include "AliGeomManager.h"
30 #include "AliMUON2DMap.h"
31 #include "AliMUONCalibParamND.h"
32 #include "AliMUONConstants.h"
33 #include "AliMUONGeometryTransformer.h"
34 #include "AliMUONPainterDataRegistry.h"
35 #include "AliMUONTrackerData.h"
36 #include "AliMUONTrackerDataWrapper.h"
37 #include "AliMpConstants.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpDEIterator.h"
40 #include "AliMpDetElement.h"
41 #include "AliMpManuIterator.h"
43 #include "AliMpSegmentation.h"
44 #include "AliMpVPadIterator.h"
45 #include "AliMpVSegmentation.h"
46 #include <TGComboBox.h>
48 #include <TGNumberEntry.h>
49 #include <TGTextEntry.h>
50 #include <TGeoManager.h>
54 ClassImp(AliMUONAlignmentCompareDialog)
60 #define PRECISION 1E-12
62 Double_t Difference(Double_t v1, Double_t v2)
65 return TMath::Abs(d) < PRECISION ? 0.0 : d;
69 //_____________________________________________________________________________
70 AliMUONAlignmentCompareDialog::AliMUONAlignmentCompareDialog(const TGWindow* p, const TGWindow* main, UInt_t w, UInt_t h)
71 : TGTransientFrame(p,main,w,h),
72 fF1(new TGVerticalFrame(this)),
75 fF2(new TGVerticalFrame(this)),
78 fF3(new TGHorizontalFrame(this)),
79 fBasename(new TGTextEntry(fF3)),
80 fButtonFrame(new TGHorizontalFrame(this)),
81 fOK(new TGTextButton(fButtonFrame,"OK")),
82 fCancel(new TGTextButton(fButtonFrame,"Cancel"))
86 SetCleanup(kDeepCleanup);
88 AddInput(fF1,"First alignment",fOCDBPath1,fRun1);
89 AddInput(fF2,"Second alignment",fOCDBPath2,fRun2);
91 fF3->AddFrame(new TGLabel(fF3,"Output basename"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
92 fF3->AddFrame(fBasename,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
94 AddFrame(fF1,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
95 AddFrame(fF2,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
96 AddFrame(fF3,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
98 fButtonFrame->AddFrame(fOK,new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
99 fButtonFrame->AddFrame(fCancel,new TGLayoutHints(kLHintsRight|kLHintsTop,5,5,5,5));
101 AddFrame(fButtonFrame,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
103 fOK->Connect("Clicked()", "AliMUONAlignmentCompareDialog",this,"DoOK()");
104 fCancel->Connect("Clicked()","AliMUONAlignmentCompareDialog",this,"DoCancel()");
107 //_____________________________________________________________________________
108 AliMUONAlignmentCompareDialog::~AliMUONAlignmentCompareDialog()
113 //_____________________________________________________________________________
114 void AliMUONAlignmentCompareDialog::AddInput(TGCompositeFrame* frame, const char* msg,
115 TGTextEntry*& text, TGNumberEntry*& run)
118 TGHorizontalFrame* hf1 = new TGHorizontalFrame(frame);
120 hf1->AddFrame(new TGLabel(hf1,TString(msg) + " ocdb path"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
122 text = new TGTextEntry(hf1,"alien://folder=/alice/data/2012/OCDB");
124 hf1->AddFrame(text,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
126 TGHorizontalFrame* hf2 = new TGHorizontalFrame(frame);
128 hf2->AddFrame(new TGLabel(hf2,TString(msg) + " run number"),new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5));
130 run = new TGNumberEntry(hf2);
132 hf2->AddFrame(run,new TGLayoutHints(kLHintsRight|kLHintsExpandX|kLHintsTop,5,5,5,5));
134 frame->AddFrame(hf1,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
135 frame->AddFrame(hf2,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsTop,5,5,5,5));
138 //______________________________________________________________________________
140 AliMUONAlignmentCompareDialog::DoOK()
144 AliMUONVTrackerData* d = CompareAlignment(fOCDBPath1->GetText(),fRun1->GetNumber(),
145 fOCDBPath2->GetText(),fRun2->GetNumber());
149 TString basename = fBasename->GetText();
151 AliMUONVTrackerDataMaker* dw = new AliMUONTrackerDataWrapper(d);
153 AliMUONPainterDataRegistry::Instance()->Register(dw);
155 TTimer::SingleShot(150,"AliMUONAlignmentCompareDialog",this,"CloseWindow()");
158 //______________________________________________________________________________
160 AliMUONAlignmentCompareDialog::DoCancel()
163 TTimer::SingleShot(150,"AliMUONAlignmentCompareDialog",this,"CloseWindow()");
166 //______________________________________________________________________________
168 AliMUONAlignmentCompareDialog::CompareAlignment(const char* ocdbPathForAlign1, Int_t run1,
169 const char* ocdbPathForAlign2, Int_t run2)
172 AliCDBManager* cdbm = AliCDBManager::Instance();
173 cdbm->SetDefaultStorage("raw://");
175 // get geometry transformers
176 AliMUONGeometryTransformer geoTransformer[2];
178 const char* align[2] = {
187 for (Int_t i = 0; i < 2; i++)
189 cdbm->UnloadFromCache("GRP/Geometry/Data");
190 cdbm->UnloadFromCache("MUON/Align/Data");
191 AliGeomManager::GetGeometry()->UnlockGeometry();
192 AliGeomManager::LoadGeometry();
193 if (!AliGeomManager::GetGeometry()) return 0x0;
194 cdbm->SetSpecificStorage("MUON/Align/Data",align[i]);
195 cdbm->SetRun(runs[i]);
196 AliGeomManager::ApplyAlignObjsFromCDB("MUON");
197 geoTransformer[i].LoadGeometryData();
200 // store for cluster shifts
201 AliMUON2DMap shiftStore(kTRUE);
204 for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
207 AliMpDEIterator nextDE;
209 while (!nextDE.IsDone()) {
211 Int_t deId = nextDE.CurrentDE()->GetId();
214 for (Int_t icath = 0; icath < 2; icath++) {
216 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(deId,AliMp::GetCathodType(icath));
219 AliMpVPadIterator *nextPad = seg->CreateIterator();
221 while (!nextPad->IsDone()) {
223 AliMpPad pad = nextPad->CurrentItem();
224 Int_t manuId = pad.GetManuId();
225 Int_t manuChannel = pad.GetManuChannel();
228 Double_t xl = pad.GetPositionX();
229 Double_t yl = pad.GetPositionY();
232 // position with first alignment
234 geoTransformer[0].Local2Global(deId,xl,yl,zl,x1,y1,z1);
236 // position with second alignment
238 geoTransformer[1].Local2Global(deId,xl,yl,zl,x2,y2,z2);
241 Double_t dx = ::Difference(x2,x1);
242 Double_t dy = ::Difference(y2,y1);
243 Double_t dz = ::Difference(z2,z1);
246 AliMUONVCalibParam* p = static_cast<AliMUONVCalibParam*>(shiftStore.FindObject(deId,manuId));
248 p = new AliMUONCalibParamND(3,AliMpConstants::ManuNofChannels(),deId,manuId,0.);
251 p->SetValueAsDouble(manuChannel,0,dx);
252 p->SetValueAsDouble(manuChannel,1,dy);
253 p->SetValueAsDouble(manuChannel,2,dz);
267 // create tracker data
268 AliMUONTrackerData* data = new AliMUONTrackerData(fBasename->GetText(),fBasename->GetText(),3,kTRUE);
269 data->SetDimensionName(0,"dx"); // max shift in x
270 data->SetDimensionName(1,"dy"); // max shift in y
271 data->SetDimensionName(2,"dz"); // max shift in z
272 data->Add(shiftStore);