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 **************************************************************************/
19 Implementation of MUON Chamber Prototype Class
20 Both read digits from raw data or use the Monte-Carlo.
21 1-Feb-2000 Rachid GUERNANE, IPN Lyon guernane@ipnl.in2p3.fr
25 ////////////////////////////////////////////////
26 // Manager and hits classes for set:PROTO //
27 ////////////////////////////////////////////////
31 #include <TRotMatrix.h>
37 #include <TObjArray.h>
39 #include <TParticle.h>
45 #include <TDirectory.h>
46 #include <TObjectTable.h>
49 #include <AliDetector.h>
51 #include "AliMUONChamber.h"
52 #include "AliMUONproto.h"
53 #include "AliMUONHit.h"
55 #include "AliMUONClusterFinder.h"
57 #include "Riostream.h"
58 #include "AliCallf77.h"
60 //#include "chainalice2.h"
61 #include "AliMUONSegmentationV0.h"
62 //#include "AliMUONSegResV11.h"
65 ClassImp(AliMUONproto)
67 //___________________________________________
68 AliMUONproto::AliMUONproto()
71 AliInfo(" Calling AliMUONproto constructor...");
78 //___________________________________________
79 AliMUONproto::AliMUONproto(const char *name, const char *title)
81 // AliMUON defines everything, but the chamber for NCH=1
84 // z-Positions of Chambers
85 const Float_t zch[1] = {975.};
88 const Float_t dmi[1] = {0.};
91 const Float_t dma[1] = {29.2};
94 // Default Parameters for ALICE2 prototype
97 (*fChambers)[0] = new AliMUONChamber();
98 AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[0];
100 chamber->SetZ(zch[0]);
102 chamber->InitGeo(zch[0]);
103 chamber->SetRInner(dmi[0]/2);
104 chamber->SetROuter(dma[0]/2);
106 for (int i = 0; i <= 99; i++) {
112 #ifdef WE_FORGET_FOR_THE_MOMENT
113 //___________________________________________
114 void AliMUONproto::GetRawDigits(Int_t evnb, Int_t *lptr, Int_t ilen) {
128 AliMUON* MUON = (AliMUON*)gAlice->GetModule("MUON");
129 AliMUONSegmentationV0* seg = (AliMUONSegmentationV0*) Chamber(0).SegmentationModel(1);
134 for (Int_t i = 0; i < 10; i++) {
145 equiplen = lptr[ip++];
147 if (equiplen < 0 ) return;
149 if (itype != (int)(0XCACCA008)) {
151 if (ip < ilen-2) goto nwtype;
156 if ((serial == 190) && (equip == 1)) {
157 for (loop = 0; loop < equiplen; loop++) {
158 nochnl = (lptr[ip] & 0x7ff000 ) >> 12;
159 val = lptr[ip] & 0x3ff;
160 // fill digits from raw data according to cathode connexions
161 if (group[nochnl][2][1]!=0)
162 digits[0] = group[nochnl][2][1] - 12;
163 else if (group[nochnl][1][1]!=0)
164 digits[0] = group[nochnl][1][1] - 12;
166 digits[0] = group[nochnl][0][1] - 12;
167 digits[1] = group[nochnl][0][0];
168 if (digits[0] != seg->Ix(digits[0], digits[1]))
169 printf("Pb pour ix=%d,iy=%d\n", digits[0], digits[1]);
173 if (digits[2] >= fThreshold[nochnl])
174 MUON->AddDigits(ich, tracks, charges, digits);
182 if (ip < ilen-2) goto nwtype;
185 gAlice->TreeD()->Fill();
188 gAlice->TreeD()->Fill();
192 sprintf(hname, "TreeD%d", evnb);
193 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
195 gAlice->TreeD()->Reset();
200 //___________________________________________
201 void AliMUONproto::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
204 ((AliMUONChamber*)(*fChambers)[i])->SetPadSize(isec,p1,p2);
207 //___________________________________________
208 void AliMUONproto::SetChargeSlope(Int_t id, Float_t p1)
211 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
214 //___________________________________________
215 void AliMUONproto::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
218 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSpread(p1,p2);
221 //___________________________________________
222 void AliMUONproto::SetMaxAdc(Int_t id, Float_t p1)
225 ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
228 //___________________________________________
229 void AliMUONproto::CreateGeometry()
231 Int_t *idtmed = fIdtmed->GetArray()-1099;
235 Int_t idGas=idtmed[1100];
237 AliMUONChamber *iChamber;
238 //********************************************************************
239 // Prototype ALICE2 **
240 //********************************************************************
241 iChamber=(AliMUONChamber*) (*fChambers)[0];
245 const Float_t X_POS = 11*.975/2; //half x
246 const Float_t Y_POS = 18*.55/2; //half y
247 const Float_t Z_POS = 0.325;
253 gMC->Gsvolu("C01G", "BOX", idGas, bpar, 3);
254 gMC->Gspos("C01G", 1, "ALIC", -bpar[0], bpar[1], zpos, 0, "ONLY");
257 //___________________________________________
258 void AliMUONproto::CreateMaterials()
260 // *** DEFINITION OF AVAILABLE MUON MATERIALS ***
263 Float_t ag1[3] = { 39.95,12.01,16. };
264 Float_t zg1[3] = { 18.,6.,8. };
265 Float_t wg1[3] = { .8,.0667,.13333 };
266 Float_t dg1 = .001821;
268 Float_t epsil = .001; // Tracking precision,
269 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
271 Int_t ISXFLD = gAlice->Field()->Integ();
272 Float_t SXMGMX = gAlice->Field()->Max();
275 // --- Define the various materials for GEANT ---
276 AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
280 AliMedium(1, "ARG_CO2 ", 22, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepGas,
281 fMaxDestepAlu, epsil, stmin);
283 //AliMedium(1, "AIR_CH_US ", 15, 1, ISXFLD, SXMGMX, tmaxfd, -1., -.3, epsil, stmin);
286 //___________________________________________
287 void AliMUONproto::Init()
289 printf("\n\n\n Start Init for Prototype ALICE2 - CPC chamber type\n\n\n");
292 // Initialize Tracking Chambers
295 ( (AliMUONChamber*) (*fChambers)[0])->Init();
298 // Set the chamber (sensitive region) GEANT identifier
299 ((AliMUONChamber*)(*fChambers)[0])->SetGid(gMC->VolId("C01G"));
301 printf("\n\n\n Finished Init for Prototype ALICE2 - CPC chamber type\n\n\n");
305 //___________________________________________
306 void AliMUONproto::StepManager()
315 Float_t destep, step;
317 static Float_t eloss, eloss2, xhit, yhit, tlength;
318 const Float_t big=1.e10;
321 static Float_t hits[14];
323 TClonesArray &lhits = *fHits;
326 // Set maximum step size for gas
327 // numed=gMC->GetMedium();
329 // Only charged tracks
330 if( !(gMC->TrackCharge()) ) return;
332 // Only gas gap inside chamber
333 // Tag chambers and record hits when track enters
335 id=gMC->CurrentVolID(copy);
337 for (Int_t i=1; i<=kNCH; i++) {
338 if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){
343 if (idvol == -1) return;
345 // Get current particle id (ipart), track position (pos) and momentum (mom)
346 gMC->TrackPosition(pos);
347 gMC->TrackMomentum(mom);
349 ipart = gMC->TrackPid();
350 //Int_t ipart1 = gMC->IdFromPDG(ipart);
351 //printf("ich, ipart %d %d \n",vol[0],ipart1);
354 // momentum loss and steplength in last step
355 destep = gMC->Edep();
356 step = gMC->TrackStep();
359 // record hits when track enters ...
360 if( gMC->IsTrackEntering()) {
361 gMC->SetMaxStep(fMaxStepGas);
362 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
363 Double_t rt = TMath::Sqrt(tc);
364 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
365 Double_t tx=mom[0]/pmom;
366 Double_t ty=mom[1]/pmom;
367 Double_t tz=mom[2]/pmom;
368 Double_t s=((AliMUONChamber*)(*fChambers)[idvol])
371 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
372 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
373 hits[0] = Float_t(ipart); // Geant3 particle type
374 hits[1] = pos[0]+s*tx; // X-position for hit
375 hits[2] = pos[1]+s*ty; // Y-position for hit
376 hits[3] = pos[2]+s*tz; // Z-position for hit
377 hits[4] = theta; // theta angle of incidence
378 hits[5] = phi; // phi angle of incidence
379 hits[8] = (Float_t) fNPadHits; // first padhit
380 hits[9] = -1; // last pad hit
383 hits[10] = mom[3]; // hit momentum P
384 hits[11] = mom[0]; // Px/P
385 hits[12] = mom[1]; // Py/P
386 hits[13] = mom[2]; // Pz/P
389 // phi angle of incidence
395 // Only if not trigger chamber
398 // Initialize hit position (cursor) in the segmentation model
399 ((AliMUONChamber*) (*fChambers)[idvol])
400 ->SigGenInit(pos[0], pos[1], pos[2]);
403 //printf("In the Trigger Chamber #%d\n",idvol-9);
409 // Calculate the charge induced on a pad (disintegration) in case
411 // Mip left chamber ...
412 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
413 gMC->SetMaxStep(big);
417 // Only if not trigger chamber
420 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
425 if (fNPadHits > (Int_t)hits[8]) {
427 hits[9]= (Float_t) fNPadHits;
431 AliMUONHit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
434 // Check additional signal generation conditions
435 // defined by the segmentation
436 // model (boundary crossing conditions)
438 (((AliMUONChamber*) (*fChambers)[idvol])
439 ->SigGenCond(pos[0], pos[1], pos[2]))
441 ((AliMUONChamber*) (*fChambers)[idvol])
442 ->SigGenInit(pos[0], pos[1], pos[2]);
443 // printf("\n-> MakePadHits, reason special %d",ipart);
445 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
451 // nothing special happened, add up energy loss
458 //___________________________________________
459 void AliMUONproto::BuildGeometry()
464 const int kColorMUON = kBlue;
466 Top=gAlice->GetGeometry()->GetNode("alice");
470 float dx, dy, dz, zpos;
472 const Float_t cz[1]={975.};
480 new TBRIK("C_MUON101","Mother volume for Proto.","void",dx*2,dy*2,dz*2);
481 TBRIK* PROTO = new TBRIK("PROT", "Proto. Sens. Region","void",dx,dy,dz);
483 Node = new TNode("MUON101","ChamberNode","C_MUON101",0,0,zpos,"");
484 Node->SetLineColor(kColorMUON);
485 Node->SetVisibility(0);
488 Node = new TNode("MUON201", "Proto. Sens. Region Node", PROTO, -dx, dy, dz);
489 Node->SetLineColor(kColorMUON);
493 //_____________________________________________________________________________
494 void AliMUONproto::FindClusters(Int_t nev, Int_t last_entry)
498 // Loop on chambers and on cathode planes
500 for (Int_t icat = 0; icat < 2; icat++) {
501 gAlice->ResetDigits();
502 gAlice->TreeD()->GetEvent(last_entry+icat);
504 for (Int_t ich = 0; ich < kNTrackingCh; ich++) {
505 AliMUONChamber* iChamber=(AliMUONChamber*) (*fChambers)[ich];
506 TClonesArray *MUONdigits = this->DigitsAddress(ich);
507 if (MUONdigits == 0) continue;
509 // Get ready the current chamber stuff
512 AliMUONResponse* response = iChamber->ResponseModel();
513 AliMUONSegmentation* seg = iChamber->SegmentationModel(icat+1);
514 AliMUONClusterFinder* rec = iChamber->ReconstructionModel();
517 rec->SetSegmentation(seg);
518 rec->SetResponse(response);
519 rec->SetDigits(MUONdigits);
520 rec->SetChamber(ich);
521 rec->FindRawClusters();
525 fRch=RawClustAddress(ich);
531 gAlice->TreeR()->Fill();
537 sprintf(hname,"TreeR%d",nev);
538 gAlice->TreeR()->Write(hname);
539 gAlice->TreeR()->Reset();
542 #ifdef WE_FORGRET_THIS_SHIT
543 //_____________________________________________________________________________
544 void AliMUONproto::SetThreshold()
547 ifstream inputFile("/home/alice/guernane/aliroot/pro/MUON/crped190.dat", ios::in);
549 if (inputFile.fail()) {
550 AliError("Error opening file");
564 inputFile >> Ntrigger;
565 inputFile >> Nchannel;
569 Float_t ped0[Nchannel];
570 Float_t sig0[Nchannel];
571 Float_t ped1[Nchannel];
572 Float_t sig1[Nchannel];
575 for (Int_t i = 0; i < Nchannel-1; i++) {
582 for (Int_t i = 0; i < Nchannel-1; i++) {
583 inputFile >> ichannel;
584 inputFile >> ped0[i];
585 inputFile >> sig0[i];
586 inputFile >> ped1[i];
587 inputFile >> sig1[i];
588 fThreshold[i] = fNsigma*sig1[i];