/[PAMELA software]/calo/flight/CaloPreSampler/src/CaloPreSampler.cpp
ViewVC logotype

Diff of /calo/flight/CaloPreSampler/src/CaloPreSampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mocchiut, Sun Dec 2 19:38:10 2007 UTC revision 1.17 by mocchiut, Wed Mar 10 12:11:11 2010 UTC
# Line 14  CaloPreSampler::CaloPreSampler(){ Line 14  CaloPreSampler::CaloPreSampler(){
14    Clear();    Clear();
15  }  }
16    
17    void CaloPreSampler::SetCaloLevel2Pointer(CaloLevel2 *cl2p){
18      if ( pcalo ) delete pcalo;
19      pcalo = cl2p;
20    }
21    
22  CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){    CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){  
23    //    //
24    L2 = l2p;    L2 = l2p;
# Line 36  CaloPreSampler::CaloPreSampler(PamLevel2 Line 41  CaloPreSampler::CaloPreSampler(PamLevel2
41    sel = true;    sel = true;
42    cont = false;    cont = false;
43    emulate18 = true;    emulate18 = true;
44      usepl18x = false;
45    simulation = false;    simulation = false;
46    withtrk = true;    withtrk = true;
47    rigdefault = 50.;    rigdefault = 50.;
48    nox = false;    nox = false;
49    noy = false;    noy = false;
50      forcecalo = false;
51      forcefitmode = -1;
52      memset(mask,0,2*22*sizeof(Int_t));
53    //    //
54    Clear();    Clear();
55    //    //
# Line 69  CaloPreSampler::CaloPreSampler(PamLevel2 Line 78  CaloPreSampler::CaloPreSampler(PamLevel2
78    //    //
79  }  }
80    
81    CaloTrkVar* CaloPreSampler::GetCaloTrack(Int_t t){
82      this->Process();
83      if ( t < 0 ) return pcalo->GetCaloStoredTrack(t);
84      if ( L2->GetTrack(t) ){
85        return pcalo->GetCaloStoredTrack(L2->GetTrack(t)->GetTrkTrack()->GetSeqNo());
86      };
87      return NULL;
88    }
89    
90  void CaloPreSampler::SetNoWpreSampler(Int_t n){  void CaloPreSampler::SetNoWpreSampler(Int_t n){
91    if ( NC+n < 23 ){    if ( NC+n < 23 ){
92      N = n;      N = n;
# Line 93  void CaloPreSampler::SetNoWcalo(Int_t n) Line 111  void CaloPreSampler::SetNoWcalo(Int_t n)
111    };    };
112  }  }
113    
114    void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){
115      this->SetNoWcalo(0);
116      this->SetNoWpreSampler(0);
117      if ( NoWpreSampler < NoWcalo ){
118            this->SetNoWpreSampler(NoWpreSampler);
119            this->SetNoWcalo(NoWcalo);
120      } else {
121            this->SetNoWcalo(NoWcalo);
122            this->SetNoWpreSampler(NoWpreSampler);
123      };
124    }
125    
126  void CaloPreSampler::Clear(){  void CaloPreSampler::Clear(){
127    //    //
128    pcalo->Clear();    pcalo->Clear();
# Line 136  void CaloPreSampler::Process(){ Line 166  void CaloPreSampler::Process(){
166      return;      return;
167    };    };
168    //    //
169      // Clear structures used to communicate with fortran
170      //
171      event->ClearStructs();//ELENA
172      if ( forcefitmode > 0 ){
173        if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){
174          printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode);
175          forcefitmode = -1;
176        } else {
177          event->clevel2->fmode[0] = forcefitmode;
178          event->clevel2->fmode[1] = forcefitmode;
179        };
180      };
181      //
182    Bool_t newentry = false;    Bool_t newentry = false;
183    //    //
184    if ( L2->IsORB() ){    if ( L2->IsORB() ){
185        if ( debug ) printf(" I am here, we have orbital infos \n");
186      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || sel != ssel ){      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || sel != ssel ){
187        newentry = true;        newentry = true;
188        OBT = L2->GetOrbitalInfo()->OBT;        OBT = L2->GetOrbitalInfo()->OBT;
# Line 197  void CaloPreSampler::Process(){ Line 241  void CaloPreSampler::Process(){
241      //      //
242      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
243      //      //
244        if ( !usepl18x && view==0 && plane==18 ) mip = 0.;
245        //
246      // Mask x or y view if nox and/or noy are true (default false)      // Mask x or y view if nox and/or noy are true (default false)
247      //      //
248        if ( mask[view][plane] ) mip = 0.;
249      if ( nox && view == 0 ) mip = 0.;      if ( nox && view == 0 ) mip = 0.;
250      if ( noy && view == 1 ) mip = 0.;      if ( noy && view == 1 ) mip = 0.;
251      //      //
252        if ( emulate18 && view == 0 && plane == 18 ) mip = 0.;
253        //
254      // Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19      // Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19
255      //                 included so plane < (22 - 2)      //                 included so plane < (22 - 2)
256      //      //
257      if ( sel ){      if ( sel ){
258        if ( plane < (22 - N) ){        if ( plane < (22 - N) ){
259          //          //
260          if ( emulate18 && plane == (18 - N) ) mip = 0.;          if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.;
261          if ( plane >= NC ) mip = 0.;          if ( plane >= NC ) mip = 0.;
262          event->clevel1->estrip[strip][plane][view] = mip;          event->clevel1->estrip[strip][plane][view] = mip;
263          //          //
# Line 220  void CaloPreSampler::Process(){ Line 269  void CaloPreSampler::Process(){
269      if ( cont ){      if ( cont ){
270        if ( plane >= N ){        if ( plane >= N ){
271          //          //
272          if ( emulate18 && plane == (18 + N) ) mip = 0.;          if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.;
273          if ( (plane-N) >= NC ) mip = 0.;          if ( (plane-N) >= NC ) mip = 0.;
274          event->clevel1->estrip[strip][(plane-N)][view] = mip;          event->clevel1->estrip[strip][(plane-N)][view] = mip;
275          //          //
# Line 265  void CaloPreSampler::Process(){ Line 314  void CaloPreSampler::Process(){
314    //    //
315    // use only N W planes    // use only N W planes
316    //    //
317    event->clevel1->npla = 22-N;    //  event->clevel1->npla = 22-N;
318      event->clevel1->npla = NC;
319    //    //
320    S3 = 0;    S3 = 0;
321    S2 = 0;    S2 = 0;
# Line 356  void CaloPreSampler::Process(){ Line 406  void CaloPreSampler::Process(){
406    // conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event    // conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event
407    //    //
408    //  if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){    //  if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){
409    if ( trackanyway && m3 ){    if ( (trackanyway && m3) || forcecalo ){
410      if ( debug ) printf(" Event with a track not fitted by the tracker \n");      if ( debug ) printf(" Event with a track not fitted by the tracker \n");
411      //      //
412      // Disable "track mode" in the fortran routine      // Disable "track mode" in the fortran routine
# Line 488  void CaloPreSampler::Process(){ Line 538  void CaloPreSampler::Process(){
538        if ( debug ) printf(" Selftrigger: problems with event \n");        if ( debug ) printf(" Selftrigger: problems with event \n");
539      };      };
540    };    };
541    //  //   //
542    // Clear structures used to communicate with fortran  //   // Clear structures used to communicate with fortran
543    //  //   //
544    event->ClearStructs();  //   event->ClearStructs();
545    // ELENA: moved @ beginning
546    //    //
547    //    //
548    //    //
# Line 499  void CaloPreSampler::Process(){ Line 550  void CaloPreSampler::Process(){
550    if ( debug ) printf(" exit \n");    if ( debug ) printf(" exit \n");
551    //    //
552  }  }
553    
554    //
555    // Method to add a calorimeter track, evaluated around a tracker track defined by a status vector.
556    // (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection )
557    //
558    //
559    CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){
560    
561        int ntrkentry = pcalo->ntrk();
562        //
563        for (Int_t nt=0; nt < ntrkentry; nt++){  
564            if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){
565                cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl;
566                cout << " --> trktag = "<<trktag<<" already defined "<<endl;
567                return NULL;
568            }
569        }
570        //
571        event->clevel1->good2 = 1; //is a trk track
572        event->clevel1->trkchi2 = 0;
573        event->clevel1->hzn = 0;
574        //
575        // Copy the alpha vector in the input structure
576        //
577        for (Int_t e = 0; e < 5 ; e++){
578            event->clevel1->al_p[e][0] = al[e];
579        };    
580        //
581        // Get tracker related variables for this track
582        //
583        if ( debug ) printf("track %i Call GetTrkVar() \n",trktag);
584        event->GetTrkVar();
585        if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l);
586        //
587        // Save tracker track sequence number
588        //  
589        event->trkseqno = trktag;
590        //
591        // Copy values in the class ca from the structure clevel2
592        //
593        if ( debug ) printf("track %i Call FillTrkVar() \n",trktag);
594        event->FillTrkVar(pcalo,ntrkentry);
595    
596        return pcalo->GetCaloTrkVar(ntrkentry);
597        
598    
599    };//ELENA

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.23