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"
64 ClassImp(AliMUONproto)
66 //___________________________________________
67 AliMUONproto::AliMUONproto()
70 cout << "\n Calling AliMUONproto constructor..." << endl;
77 //___________________________________________
78 AliMUONproto::AliMUONproto(const char *name, const char *title)
80 // AliMUON defines everything, but the chamber for NCH=1
83 // z-Positions of Chambers
84 const Float_t zch[1] = {975.};
87 const Float_t dmi[1] = {0.};
90 const Float_t dma[1] = {29.2};
93 // Default Parameters for ALICE2 prototype
96 (*fChambers)[0] = new AliMUONChamber();
97 AliMUONChamber* chamber = (AliMUONChamber*) (*fChambers)[0];
99 chamber->SetZ(zch[0]);
101 chamber->InitGeo(zch[0]);
102 chamber->SetRInner(dmi[0]/2);
103 chamber->SetROuter(dma[0]/2);
105 for (int i = 0; i <= 99; i++) {
111 #ifdef WE_FORGET_FOR_THE_MOMENT
112 //___________________________________________
113 void AliMUONproto::GetRawDigits(Int_t evnb, Int_t *lptr, Int_t ilen) {
127 AliMUON* MUON = (AliMUON*)gAlice->GetModule("MUON");
128 AliMUONSegmentationV0* seg = (AliMUONSegmentationV0*) Chamber(0).SegmentationModel(1);
133 for (Int_t i = 0; i < 10; i++) {
144 equiplen = lptr[ip++];
146 if (equiplen < 0 ) return;
148 if (itype != (int)(0XCACCA008)) {
150 if (ip < ilen-2) goto nwtype;
155 if ((serial == 190) && (equip == 1)) {
156 for (loop = 0; loop < equiplen; loop++) {
157 nochnl = (lptr[ip] & 0x7ff000 ) >> 12;
158 val = lptr[ip] & 0x3ff;
159 // fill digits from raw data according to cathode connexions
160 if (group[nochnl][2][1]!=0)
161 digits[0] = group[nochnl][2][1] - 12;
162 else if (group[nochnl][1][1]!=0)
163 digits[0] = group[nochnl][1][1] - 12;
165 digits[0] = group[nochnl][0][1] - 12;
166 digits[1] = group[nochnl][0][0];
167 if (digits[0] != seg->Ix(digits[0], digits[1]))
168 printf("Pb pour ix=%d,iy=%d\n", digits[0], digits[1]);
172 if (digits[2] >= fThreshold[nochnl])
173 MUON->AddDigits(ich, tracks, charges, digits);
181 if (ip < ilen-2) goto nwtype;
184 gAlice->TreeD()->Fill();
187 gAlice->TreeD()->Fill();
191 sprintf(hname, "TreeD%d", evnb);
192 gAlice->TreeD()->Write(hname,TObject::kOverwrite);
194 gAlice->TreeD()->Reset();
199 //___________________________________________
200 void AliMUONproto::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
203 ((AliMUONChamber*)(*fChambers)[i])->SetPadSize(isec,p1,p2);
206 //___________________________________________
207 void AliMUONproto::SetChargeSlope(Int_t id, Float_t p1)
210 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSlope(p1);
213 //___________________________________________
214 void AliMUONproto::SetChargeSpread(Int_t id, Float_t p1, Float_t p2)
217 ((AliMUONChamber*) (*fChambers)[i])->SetChargeSpread(p1,p2);
220 //___________________________________________
221 void AliMUONproto::SetMaxAdc(Int_t id, Float_t p1)
224 ((AliMUONChamber*) (*fChambers)[i])->SetMaxAdc(p1);
227 //___________________________________________
228 void AliMUONproto::CreateGeometry()
230 Int_t *idtmed = fIdtmed->GetArray()-1099;
234 Int_t idGas=idtmed[1100];
236 AliMUONChamber *iChamber;
237 //********************************************************************
238 // Prototype ALICE2 **
239 //********************************************************************
240 iChamber=(AliMUONChamber*) (*fChambers)[0];
244 const Float_t X_POS = 11*.975/2; //half x
245 const Float_t Y_POS = 18*.55/2; //half y
246 const Float_t Z_POS = 0.325;
252 gMC->Gsvolu("C01G", "BOX", idGas, bpar, 3);
253 gMC->Gspos("C01G", 1, "ALIC", -bpar[0], bpar[1], zpos, 0, "ONLY");
256 //___________________________________________
257 void AliMUONproto::CreateMaterials()
259 // *** DEFINITION OF AVAILABLE MUON MATERIALS ***
262 Float_t ag1[3] = { 39.95,12.01,16. };
263 Float_t zg1[3] = { 18.,6.,8. };
264 Float_t wg1[3] = { .8,.0667,.13333 };
265 Float_t dg1 = .001821;
267 Float_t epsil = .001; // Tracking precision,
268 Float_t tmaxfd = -20.; // Maximum angle due to field deflection
270 Int_t ISXFLD = gAlice->Field()->Integ();
271 Float_t SXMGMX = gAlice->Field()->Max();
274 // --- Define the various materials for GEANT ---
275 AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 3, wg1);
279 AliMedium(1, "ARG_CO2 ", 22, 1, ISXFLD, SXMGMX, tmaxfd, fMaxStepGas,
280 fMaxDestepAlu, epsil, stmin);
282 //AliMedium(1, "AIR_CH_US ", 15, 1, ISXFLD, SXMGMX, tmaxfd, -1., -.3, epsil, stmin);
285 //___________________________________________
286 void AliMUONproto::Init()
288 printf("\n\n\n Start Init for Prototype ALICE2 - CPC chamber type\n\n\n");
291 // Initialize Tracking Chambers
294 ( (AliMUONChamber*) (*fChambers)[0])->Init();
297 // Set the chamber (sensitive region) GEANT identifier
298 ((AliMUONChamber*)(*fChambers)[0])->SetGid(gMC->VolId("C01G"));
300 printf("\n\n\n Finished Init for Prototype ALICE2 - CPC chamber type\n\n\n");
304 //___________________________________________
305 void AliMUONproto::StepManager()
314 Float_t destep, step;
316 static Float_t eloss, eloss2, xhit, yhit, tlength;
317 const Float_t big=1.e10;
320 static Float_t hits[14];
322 TClonesArray &lhits = *fHits;
325 // Set maximum step size for gas
326 // numed=gMC->GetMedium();
328 // Only charged tracks
329 if( !(gMC->TrackCharge()) ) return;
331 // Only gas gap inside chamber
332 // Tag chambers and record hits when track enters
334 id=gMC->CurrentVolID(copy);
336 for (Int_t i=1; i<=kNCH; i++) {
337 if(id==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()){
342 if (idvol == -1) return;
344 // Get current particle id (ipart), track position (pos) and momentum (mom)
345 gMC->TrackPosition(pos);
346 gMC->TrackMomentum(mom);
348 ipart = gMC->TrackPid();
349 //Int_t ipart1 = gMC->IdFromPDG(ipart);
350 //printf("ich, ipart %d %d \n",vol[0],ipart1);
353 // momentum loss and steplength in last step
354 destep = gMC->Edep();
355 step = gMC->TrackStep();
358 // record hits when track enters ...
359 if( gMC->IsTrackEntering()) {
360 gMC->SetMaxStep(fMaxStepGas);
361 Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
362 Double_t rt = TMath::Sqrt(tc);
363 Double_t pmom = TMath::Sqrt(tc+mom[2]*mom[2]);
364 Double_t tx=mom[0]/pmom;
365 Double_t ty=mom[1]/pmom;
366 Double_t tz=mom[2]/pmom;
367 Double_t s=((AliMUONChamber*)(*fChambers)[idvol])
370 theta = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
371 phi = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
372 hits[0] = Float_t(ipart); // Geant3 particle type
373 hits[1] = pos[0]+s*tx; // X-position for hit
374 hits[2] = pos[1]+s*ty; // Y-position for hit
375 hits[3] = pos[2]+s*tz; // Z-position for hit
376 hits[4] = theta; // theta angle of incidence
377 hits[5] = phi; // phi angle of incidence
378 hits[8] = (Float_t) fNPadHits; // first padhit
379 hits[9] = -1; // last pad hit
382 hits[10] = mom[3]; // hit momentum P
383 hits[11] = mom[0]; // Px/P
384 hits[12] = mom[1]; // Py/P
385 hits[13] = mom[2]; // Pz/P
388 // phi angle of incidence
394 // Only if not trigger chamber
397 // Initialize hit position (cursor) in the segmentation model
398 ((AliMUONChamber*) (*fChambers)[idvol])
399 ->SigGenInit(pos[0], pos[1], pos[2]);
402 //printf("In the Trigger Chamber #%d\n",idvol-9);
408 // Calculate the charge induced on a pad (disintegration) in case
410 // Mip left chamber ...
411 if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
412 gMC->SetMaxStep(big);
416 // Only if not trigger chamber
419 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
424 if (fNPadHits > (Int_t)hits[8]) {
426 hits[9]= (Float_t) fNPadHits;
430 AliMUONHit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
433 // Check additional signal generation conditions
434 // defined by the segmentation
435 // model (boundary crossing conditions)
437 (((AliMUONChamber*) (*fChambers)[idvol])
438 ->SigGenCond(pos[0], pos[1], pos[2]))
440 ((AliMUONChamber*) (*fChambers)[idvol])
441 ->SigGenInit(pos[0], pos[1], pos[2]);
442 // printf("\n-> MakePadHits, reason special %d",ipart);
444 MakePadHits(0.5*(xhit+pos[0]),0.5*(yhit+pos[1]),eloss,0.0,idvol);
450 // nothing special happened, add up energy loss
457 //___________________________________________
458 void AliMUONproto::BuildGeometry()
463 const int kColorMUON = kBlue;
465 Top=gAlice->GetGeometry()->GetNode("alice");
469 float dx, dy, dz, zpos;
471 const Float_t cz[1]={975.};
479 new TBRIK("C_MUON101","Mother volume for Proto.","void",dx*2,dy*2,dz*2);
480 TBRIK* PROTO = new TBRIK("PROT", "Proto. Sens. Region","void",dx,dy,dz);
482 Node = new TNode("MUON101","ChamberNode","C_MUON101",0,0,zpos,"");
483 Node->SetLineColor(kColorMUON);
484 Node->SetVisibility(0);
487 Node = new TNode("MUON201", "Proto. Sens. Region Node", PROTO, -dx, dy, dz);
488 Node->SetLineColor(kColorMUON);
492 //_____________________________________________________________________________
493 void AliMUONproto::FindClusters(Int_t nev, Int_t last_entry)
497 // Loop on chambers and on cathode planes
499 for (Int_t icat = 0; icat < 2; icat++) {
500 gAlice->ResetDigits();
501 gAlice->TreeD()->GetEvent(last_entry+icat);
503 for (Int_t ich = 0; ich < kNTrackingCh; ich++) {
504 AliMUONChamber* iChamber=(AliMUONChamber*) (*fChambers)[ich];
505 TClonesArray *MUONdigits = this->DigitsAddress(ich);
506 if (MUONdigits == 0) continue;
508 // Get ready the current chamber stuff
511 AliMUONResponse* response = iChamber->ResponseModel();
512 AliMUONSegmentation* seg = iChamber->SegmentationModel(icat+1);
513 AliMUONClusterFinder* rec = iChamber->ReconstructionModel();
516 rec->SetSegmentation(seg);
517 rec->SetResponse(response);
518 rec->SetDigits(MUONdigits);
519 rec->SetChamber(ich);
520 rec->FindRawClusters();
524 fRch=RawClustAddress(ich);
530 gAlice->TreeR()->Fill();
536 sprintf(hname,"TreeR%d",nev);
537 gAlice->TreeR()->Write(hname);
538 gAlice->TreeR()->Reset();
541 #ifdef WE_FORGRET_THIS_SHIT
542 //_____________________________________________________________________________
543 void AliMUONproto::SetThreshold()
546 ifstream inputFile("/home/alice/guernane/aliroot/pro/MUON/crped190.dat", ios::in);
548 if (inputFile.fail()) {
549 cout << "Error opening file" << endl;
563 inputFile >> Ntrigger;
564 inputFile >> Nchannel;
568 Float_t ped0[Nchannel];
569 Float_t sig0[Nchannel];
570 Float_t ped1[Nchannel];
571 Float_t sig1[Nchannel];
574 for (Int_t i = 0; i < Nchannel-1; i++) {
581 for (Int_t i = 0; i < Nchannel-1; i++) {
582 inputFile >> ichannel;
583 inputFile >> ped0[i];
584 inputFile >> sig0[i];
585 inputFile >> ped1[i];
586 inputFile >> sig1[i];
587 fThreshold[i] = fNsigma*sig1[i];