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 **************************************************************************/
17 Revision 1.2 2000/06/15 07:58:49 morsch
18 Code from MUON-dev joined
20 Revision 1.1.2.1 2000/04/18 09:11:15 morsch
21 Implementation of MUON Chamber Prototype Class
22 Both read digits from raw data or use the Monte-Carlo.
23 Rachid GUERNANE, IPN Lyon guernane@ipnl.in2p3.fr
28 Implementation of MUON Chamber Prototype Class
29 Both read digits from raw data or use the Monte-Carlo.
30 1-Feb-2000 Rachid GUERNANE, IPN Lyon guernane@ipnl.in2p3.fr
34 ////////////////////////////////////////////////
35 // Manager and hits classes for set:PROTO //
36 ////////////////////////////////////////////////
40 #include <TRotMatrix.h>
46 #include <TObjArray.h>
48 #include <TParticle.h>
54 #include <TDirectory.h>
55 #include <TObjectTable.h>
58 #include <AliDetector.h>
60 #include "AliMUONChamber.h"
61 #include "AliMUONproto.h"
62 #include "AliMUONHit.h"
64 #include "AliMUONClusterFinder.h"
68 #include "AliCallf77.h"
70 //#include "chainalice2.h"
71 #include "AliMUONSegmentationV0.h"
72 //#include "AliMUONSegResV11.h"
74 ClassImp(AliMUONproto)
76 //___________________________________________
77 AliMUONproto::AliMUONproto()
80 cout << "\n Calling AliMUONproto constructor..." << endl;
87 //___________________________________________
88 AliMUONproto::AliMUONproto(const char *name, const char *title)
90 // AliMUON defines everything, but the chamber for NCH=1
93 // z-Positions of Chambers
94 const Float_t zch[1] = {975.};
97 const Float_t dmi[1] = {0.};
100 const Float_t dma[1] = {29.2};
103 // Default Parameters for ALICE2 prototype
106 (*fChambers)[0] = new AliMUONChamber();
107 AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[0];
109 chamber->SetZ(zch[0]);
111 chamber->InitGeo(zch[0]);
112 chamber->SetRInner(dmi[0]/2);
113 chamber->SetROuter(dma[0]/2);
115 for (int i = 0; i <= 99; i++) {
121 #ifdef WE_FORGET_FOR_THE_MOMENT
122 //___________________________________________
123 void AliMUONproto::GetRawDigits(Int_t evnb, Int_t *lptr, Int_t ilen) {
137 AliMUON* MUON = (AliMUON*)gAlice->GetModule("MUON");
138 AliMUONSegmentationV0* seg = (AliMUONSegmentationV0*) Chamber(0).SegmentationModel(1);
143 for (Int_t i = 0; i < 10; i++) {
154 equiplen = lptr[ip++];
156 if (equiplen < 0 ) return;
158 if (itype != (int)(0XCACCA008)) {
160 if (ip < ilen-2) goto nwtype;
165 if ((serial == 190) && (equip == 1)) {
166 for (loop = 0; loop < equiplen; loop++) {
167 nochnl = (lptr[ip] & 0x7ff000 ) >> 12;
168 val = lptr[ip] & 0x3ff;
169 // fill digits from raw data according to cathode connexions
170 if (group[nochnl][2][1]!=0)
171 digits[0] = group[nochnl][2][1] - 12;
172 else if (group[nochnl][1][1]!=0)
173 digits[0] = group[nochnl][1][1] - 12;
175 digits[0] = group[nochnl][0][1] - 12;
176 digits[1] = group[nochnl][0][0];
177 if (digits[0] != seg->Ix(digits[0], digits[1]))
178 printf("Pb pour ix=%d,iy=%d\n", digits[0], digits[1]);
182 if (digits[2] >= fThreshold[nochnl])
183 MUON->AddDigits(ich, tracks, charges, digits);
191 if (ip < ilen-2) goto nwtype;
194 gAlice->TreeD()->Fill();
197 gAlice->TreeD()->Fill();
201 sprintf(hname, "TreeD%d", evnb);
202 gAlice->TreeD()->Write(hname);
204 gAlice->TreeD()->Reset();
209 //___________________________________________
210 void AliMUONproto::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
213 ((AliMUONChamber*)(*fChambers)[i])->SetPadSize(isec,p1,p2);
216 //___________________________________________
217 void AliMUONproto::SetChargeSlope(Int_t id, Float_t p1)
220 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
223 //___________________________________________
224 void AliMUONproto::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
227 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSpread(p1,p2);
230 //___________________________________________
231 void AliMUONproto::SetMaxAdc(Int_t id, Float_t p1)
234 ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
237 //___________________________________________
238 void AliMUONproto::CreateGeometry()
240 Int_t *idtmed = fIdtmed->GetArray()-1099;
244 Int_t idGas=idtmed[1100];
246 AliMUONChamber *iChamber;
247 //********************************************************************
248 // Prototype ALICE2 **
249 //********************************************************************
250 iChamber=(AliMUONChamber*) (*fChambers)[0];
254 const Float_t X_POS = 11*.975/2; //half x
255 const Float_t Y_POS = 18*.55/2; //half y
256 const Float_t Z_POS = 0.325;
262 gMC->Gsvolu("C01G", "BOX", idGas, bpar, 3);
263 gMC->Gspos("C01G", 1, "ALIC", -bpar[0], bpar[1], zpos, 0, "ONLY");
266 //___________________________________________
267 void AliMUONproto::CreateMaterials()
269 // *** DEFINITION OF AVAILABLE MUON MATERIALS ***
272 Float_t ag1[3] = { 39.95,12.01,16. };
273 Float_t zg1[3] = { 18.,6.,8. };
274 Float_t wg1[3] = { .8,.0667,.13333 };
275 Float_t dg1 = .001821;
277 Float_t epsil = .001; // Tracking precision,
278 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
280 Int_t ISXFLD = gAlice->Field()->Integ();
281 Float_t SXMGMX = gAlice->Field()->Max();
284 // --- Define the various materials for GEANT ---
285 AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
289 AliMedium(1, "ARG_CO2 ", 22, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepGas,
290 fMaxDestepAlu, epsil, stmin);
292 //AliMedium(1, "AIR_CH_US ", 15, 1, ISXFLD, SXMGMX, tmaxfd, -1., -.3, epsil, stmin);
295 //___________________________________________
296 void AliMUONproto::Init()
298 printf("\n\n\n Start Init for Prototype ALICE2 - CPC chamber type\n\n\n");
301 // Initialize Tracking Chambers
304 ( (AliMUONChamber*) (*fChambers)[0])->Init();
307 // Set the chamber (sensitive region) GEANT identifier
308 AliMC* gMC = AliMC::GetMC();
309 ((AliMUONChamber*)(*fChambers)[0])->SetGid(gMC->VolId("C01G"));
311 printf("\n\n\n Finished Init for Prototype ALICE2 - CPC chamber type\n\n\n");
315 //___________________________________________
316 void AliMUONproto::StepManager()
325 Float_t destep, step;
327 static Float_t eloss, eloss2, xhit, yhit, tlength;
328 const Float_t big=1.e10;
331 static Float_t hits[14];
333 TClonesArray &lhits = *fHits;
336 // Set maximum step size for gas
337 // numed=gMC->GetMedium();
339 // Only charged tracks
340 if( !(gMC->TrackCharge()) ) return;
342 // Only gas gap inside chamber
343 // Tag chambers and record hits when track enters
345 id=gMC->CurrentVolID(copy);
347 for (Int_t i=1; i<=kNCH; i++) {
348 if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){
353 if (idvol == -1) return;
355 // Get current particle id (ipart), track position (pos) and momentum (mom)
356 gMC->TrackPosition(pos);
357 gMC->TrackMomentum(mom);
359 ipart = gMC->TrackPid();
360 //Int_t ipart1 = gMC->IdFromPDG(ipart);
361 //printf("ich, ipart %d %d \n",vol[0],ipart1);
364 // momentum loss and steplength in last step
365 destep = gMC->Edep();
366 step = gMC->TrackStep();
369 // record hits when track enters ...
370 if( gMC->IsTrackEntering()) {
371 gMC->SetMaxStep(fMaxStepGas);
372 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
373 Double_t rt = TMath::Sqrt(tc);
374 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
375 Double_t tx=mom[0]/pmom;
376 Double_t ty=mom[1]/pmom;
377 Double_t tz=mom[2]/pmom;
378 Double_t s=((AliMUONChamber*)(*fChambers)[idvol])
381 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
382 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
383 hits[0] = Float_t(ipart); // Geant3 particle type
384 hits[1] = pos[0]+s*tx; // X-position for hit
385 hits[2] = pos[1]+s*ty; // Y-position for hit
386 hits[3] = pos[2]+s*tz; // Z-position for hit
387 hits[4] = theta; // theta angle of incidence
388 hits[5] = phi; // phi angle of incidence
389 hits[8] = (Float_t) fNPadHits; // first padhit
390 hits[9] = -1; // last pad hit
393 hits[10] = mom[3]; // hit momentum P
394 hits[11] = mom[0]; // Px/P
395 hits[12] = mom[1]; // Py/P
396 hits[13] = mom[2]; // Pz/P
399 // phi angle of incidence
405 // Only if not trigger chamber
408 // Initialize hit position (cursor) in the segmentation model
409 ((AliMUONChamber*) (*fChambers)[idvol])
410 ->SigGenInit(pos[0], pos[1], pos[2]);
413 //printf("In the Trigger Chamber #%d\n",idvol-9);
419 // Calculate the charge induced on a pad (disintegration) in case
421 // Mip left chamber ...
422 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
423 gMC->SetMaxStep(big);
427 // Only if not trigger chamber
430 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
435 if (fNPadHits > (Int_t)hits[8]) {
437 hits[9]= (Float_t) fNPadHits;
441 AliMUONHit(fIshunt,gAlice->CurrentTrack(),vol,hits);
444 // Check additional signal generation conditions
445 // defined by the segmentation
446 // model (boundary crossing conditions)
448 (((AliMUONChamber*) (*fChambers)[idvol])
449 ->SigGenCond(pos[0], pos[1], pos[2]))
451 ((AliMUONChamber*) (*fChambers)[idvol])
452 ->SigGenInit(pos[0], pos[1], pos[2]);
453 // printf("\n-> MakePadHits, reason special %d",ipart);
455 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
461 // nothing special happened, add up energy loss
468 //___________________________________________
469 void AliMUONproto::BuildGeometry()
474 const int kColorMUON = kBlue;
476 Top=gAlice->GetGeometry()->GetNode("alice");
480 float dx, dy, dz, zpos;
482 const Float_t cz[1]={975.};
490 new TBRIK("C_MUON101","Mother volume for Proto.","void",dx*2,dy*2,dz*2);
491 TBRIK* PROTO = new TBRIK("PROT", "Proto. Sens. Region","void",dx,dy,dz);
493 Node = new TNode("MUON101","ChamberNode","C_MUON101",0,0,zpos,"");
494 Node->SetLineColor(kColorMUON);
495 Node->SetVisibility(0);
498 Node = new TNode("MUON201", "Proto. Sens. Region Node", PROTO, -dx, dy, dz);
499 Node->SetLineColor(kColorMUON);
503 //_____________________________________________________________________________
504 void AliMUONproto::FindClusters(Int_t nev, Int_t last_entry)
508 // Loop on chambers and on cathode planes
510 for (Int_t icat = 0; icat < 2; icat++) {
511 gAlice->ResetDigits();
512 gAlice->TreeD()->GetEvent(last_entry+icat);
514 for (Int_t ich = 0; ich < kNTrackingCh; ich++) {
515 AliMUONChamber* iChamber=(AliMUONChamber*) (*fChambers)[ich];
516 TClonesArray *MUONdigits = this->DigitsAddress(ich);
517 if (MUONdigits == 0) continue;
519 // Get ready the current chamber stuff
522 AliMUONResponse* response = iChamber->ResponseModel();
523 AliMUONSegmentation* seg = iChamber->SegmentationModel(icat+1);
524 AliMUONClusterFinder* rec = iChamber->ReconstructionModel();
527 rec->SetSegmentation(seg);
528 rec->SetResponse(response);
529 rec->SetDigits(MUONdigits);
530 rec->SetChamber(ich);
531 rec->FindRawClusters();
535 fRch=RawClustAddress(ich);
541 gAlice->TreeR()->Fill();
547 sprintf(hname,"TreeR%d",nev);
548 gAlice->TreeR()->Write(hname);
549 gAlice->TreeR()->Reset();
552 #ifdef WE_FORGRET_THIS_SHIT
553 //_____________________________________________________________________________
554 void AliMUONproto::SetThreshold()
557 ifstream inputFile("/home/alice/guernane/aliroot/pro/MUON/crped190.dat", ios::in);
559 if (inputFile.fail()) {
560 cout << "Error opening file" << endl;
574 inputFile >> Ntrigger;
575 inputFile >> Nchannel;
579 Float_t ped0[Nchannel];
580 Float_t sig0[Nchannel];
581 Float_t ped1[Nchannel];
582 Float_t sig1[Nchannel];
585 for (Int_t i = 0; i < Nchannel-1; i++) {
592 for (Int_t i = 0; i < Nchannel-1; i++) {
593 inputFile >> ichannel;
594 inputFile >> ped0[i];
595 inputFile >> sig0[i];
596 inputFile >> ped1[i];
597 inputFile >> sig1[i];
598 fThreshold[i] = fNsigma*sig1[i];